| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/blocksy-companion-pro/framework/features/blocks/ |
Upload File : |
<?php
namespace Blocksy\Editor;
if (! defined('ABSPATH')) {
exit;
}
class Blocks {
private $blocks = [];
public $query = null;
public function __construct() {
// Mount at `after_setup_theme` to make sure the theme is loaded
add_action(
'after_setup_theme',
[$this, 'mount'],
50
);
}
public function mount() {
add_action('enqueue_block_editor_assets', function () {
if (! function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(BLOCKSY__FILE__);
$deps = [
'wp-blocks',
'wp-editor',
'wp-core-data',
'wp-element',
'wp-block-editor',
'wp-server-side-render',
];
global $wp_customize;
if ($wp_customize) {
$deps[] = 'ct-customizer-controls';
} else {
$deps[] = 'ct-options-scripts';
}
$theme = blocksy_get_wp_parent_theme();
wp_register_style(
'blocksy-theme-blocks-editor-styles',
get_template_directory_uri() . '/static/bundle/theme-blocks-editor-styles.min.css',
[],
$theme->get('Version')
);
wp_enqueue_script(
'blocksy/gutenberg-blocks',
BLOCKSY_URL . '/static/bundle/blocks/blocks.js',
$deps,
$data['Version'],
false
);
});
$blocks = [
'about-me',
'contact-info',
'quote',
'socials',
'search',
'share-box'
];
foreach ($blocks as $block) {
$this->blocks[$block] = new \Blocksy\Editor\GutenbergBlock(
$block,
[
'static' => false,
]
);
}
add_action('wp_ajax_blocksy_get_dynamic_block_view', function () {
if (
! current_user_can('edit_posts')
||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
! isset($_POST['block'])
||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
! isset($_POST['attributes'])
) {
wp_send_json_error();
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$block_name = sanitize_key($_POST['block']);
if (! isset($this->blocks[$block_name])) {
wp_send_json_error();
}
$gutenberg_block = $this->blocks[$block_name];
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$attributes = json_decode(wp_unslash($_POST['attributes']), true);
if (! is_array($attributes)) {
$attributes = [];
}
wp_send_json_success([
'content' => $gutenberg_block->render($attributes),
]);
});
$this->init_blocks();
}
public function init_blocks() {
// Root Block
new \Blocksy\Editor\Blocks\BlockWrapper();
new \Blocksy\Editor\Blocks\BreadCrumbs();
$this->query = new \Blocksy\Editor\Blocks\Query();
new \Blocksy\Editor\Blocks\TaxQuery();
new \Blocksy\Editor\Blocks\DynamicData();
}
}