| Server IP : 116.153.78.57 / Your IP : 43.159.78.123 Web Server : nginx/1.28.0 System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 User : www ( 1001) 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 MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/functions/ |
Upload File : |
<?php
/*
* @Author: iowen
* @Author URI: https://www.iowen.cn/
* @Date: 2023-04-02 22:08:22
* @LastEditors: iowen
* @LastEditTime: 2024-09-07 14:18:00
* @FilePath: /onenav/inc/functions/io-admin.php
* @Description:
*/
/**
* 添加古腾堡区块内容
* @return void
*/
function io_theme_block() {
$depends = array( 'wp-blocks', 'wp-element', 'wp-components' );
if ( wp_script_is( 'wp-edit-widgets' ) ) {
$depends[] = 'wp-edit-widgets';
} else {
$depends[] = 'wp-edit-post';
}
wp_register_script(
'io_block',
get_template_directory_uri() . '/assets/js/gutenberg-edit.js',
$depends,
IO_VERSION
);
wp_register_style(
'io_block',
get_template_directory_uri() . '/assets/css/gutenberg-edit.css',
array( 'wp-edit-blocks' ),
IO_VERSION
);
register_block_type( 'io/block', array(
'editor_script' => 'io_block',
'editor_style' => 'io_block',
) );
}
if (function_exists('register_block_type')) {
add_action('init', 'io_theme_block');
$wp_version = get_bloginfo('version', 'display');
if (version_compare('5.7.9', $wp_version) == -1) {
add_filter('block_categories_all', function ($categories, $post) {
return io_add_block_categories($categories, $post);
}, 10, 2);
} else {
add_filter('block_categories', function ($categories, $post) {
return io_add_block_categories($categories, $post);
}, 10, 2);
}
}
function io_add_block_categories($categories, $post){
$is_one = false;
foreach ($categories as $value) {
if($value['slug'] == 'io_block_cat'){
$is_one = true;
break;
}
}
if($is_one){
return $categories;
}
return array_merge(
array(
array(
'slug' => 'io_block_cat',
'title' => 'IO 模块',
),
),
$categories
);
}