From d86d3b33a945a67527c87be6bf185bcf4c210ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BB=B5=E7=BE=8A?= <76205031+dmygzs@users.noreply.github.com> Date: Sun, 23 Mar 2025 17:34:27 +0800 Subject: [PATCH 1/2] Add files via upload --- index.php | 148 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/index.php b/index.php index b6a88de..31ed316 100644 --- a/index.php +++ b/index.php @@ -1,72 +1,76 @@ -)/i', $post->post_content, $matches); - }, false ); - if ( !$found_block ) { - return; - } - } - } - - $_min = WP_DEBUG === true?'':'.min'; - - wp_register_style( 'enlighterjs', IOTHEME_BLOCK_URL . '/assets/css/enlighterjs'.$_min.'.css', array(), IOTHEME_BLOCK_VERSION ); - wp_register_script( 'enlighterjs', IOTHEME_BLOCK_URL . '/assets/js/enlighterjs'.$_min.'.js', array('jquery'), IOTHEME_BLOCK_VERSION, true ); - - if(is_single()){ - wp_enqueue_style('enlighterjs'); - wp_enqueue_script('enlighterjs'); - - wp_localize_script('enlighterjs', 'io_code_settings', array( - 'pre_c' => '© '.get_bloginfo('name'), - )); - } -} -add_action('wp_enqueue_scripts', 'io_code_add_enlighter_assets' ); - -/** - * 为编辑器添加全局变量 - * @return void - */ -function io_code_plugin_mce_config(){ - echo ''; -} -add_action('admin_print_scripts', 'io_code_plugin_mce_config');//wp_enqueue_editor | wp_head +)/i', $post->post_content, $matches); + }, false ); + if ( !$found_block ) { + return; + } + } else { + return; + } + } + } + + $_min = WP_DEBUG === true?'':'.min'; + + wp_register_style( 'enlighterjs', IOTHEME_BLOCK_URL . '/assets/css/enlighterjs'.$_min.'.css', array(), IOTHEME_BLOCK_VERSION ); + wp_register_script( 'enlighterjs', IOTHEME_BLOCK_URL . '/assets/js/enlighterjs'.$_min.'.js', array('jquery'), IOTHEME_BLOCK_VERSION, true ); + + if(is_single()){ + wp_enqueue_style('enlighterjs'); + wp_enqueue_script('enlighterjs'); + + wp_localize_script('enlighterjs', 'io_code_settings', array( + 'pre_c' => '© '.get_bloginfo('name'), + )); + } +} +add_action('wp_enqueue_scripts', 'io_code_add_enlighter_assets' ); + +/** + * 为编辑器添加全局变量 + * @return void + */ +function io_code_plugin_mce_config(){ + echo ''; +} +add_action('admin_print_scripts', 'io_code_plugin_mce_config');//wp_enqueue_editor | wp_head From 573e9c93be90ae4581a5a420389de30f8cc1b5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BB=B5=E7=BE=8A?= <76205031+dmygzs@users.noreply.github.com> Date: Sun, 23 Mar 2025 17:36:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=20array=5Freduc?= =?UTF-8?q?e()=20=E5=87=BD=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了 array_reduce() 函数使用时可能引发的警告问题。原代码中,$posts 变量可能为 null 或未定义,直接将其传递给 array_reduce() 会导致 PHP 抛出警告信息。为了增强代码的健壮性,添加了对 $posts 的检查逻辑,确保其已设置且为数组后再执行 array_reduce() 操作。