HEX
Server: nginx/1.24.0
System: Linux iZm5eic9piryinoecjybjoZ 3.10.0-1160.114.2.el7.x86_64 #1 SMP Wed Mar 20 15:54:52 UTC 2024 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: 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
Upload Files
File: /www/wwwroot/h3.iyingtaos.cn/wp-content/themes/three-picture/functions.php
<?php 
register_nav_menus(array(
    'primary'=>'主菜单'
));
function my_custom_sidebar() {
    register_sidebar(
        array (
            'name' => '测试侧边栏',//侧边栏名称
            'id' => 'test-side-bar',//侧边栏ID
            'description' => '这里是侧边栏的描述',//侧边栏描述
            'before_widget' => '<div class="widget-content aaa">',//侧边栏前面的代码
            'after_widget' => "</div>",//侧边栏后面的代码
            'before_title' => '<h3 class="widget-title">',//侧边栏标题的前面的代码
            'after_title' => '</h3>',//侧边栏标题的后面的代码
        )
    );
    
	//可同时注册多个小工具
	register_sidebar(
        array (
            'name' => '测试侧边栏2',//侧边栏名称
            'id' => 'test-side-bar2',//侧边栏ID
            'description' => '这里是侧边栏的描述',//侧边栏描述
            'before_widget' => '<div class="widget-content2">',//侧边栏前面的代码
            'after_widget' => "</div>",//侧边栏后面的代码
            'before_title' => '<h3 class="widget-title2">',//侧边栏标题的前面的代码
            'after_title' => '</h3>',//侧边栏标题的后面的代码
        )
    );
}
add_action( 'widgets_init', 'my_custom_sidebar' );
function my_theme_setup() {
    add_theme_support('post-thumbnails');
}
add_action('after_setup_theme', 'my_theme_setup');

if (class_exists('MultiPostThumbnails')) {  
    // 第一个额外缩略图  
    new MultiPostThumbnails(array(  
        'label' => '第二个特色图片', // 缩略图的标签  
        'id' => 'two-image', // 缩略图的唯一标识符  
        'post_type' => 'post' // 指定缩略图应用于文章  
    ));  

    // 第二个额外缩略图  
    new MultiPostThumbnails(array(  
        'label' => '第三个特色图片',  
        'id' => 'three-image',  
        'post_type' => 'post'  
    ));  

    // 如果需要为页面或其他自定义类型设置缩略图,可以复制上述代码并修改'post_type'  
}
function custom_image_sizes() {
    add_image_size('custom-size', 300, 200, true); // 这里的宽高值是示例,按实际需要调整
}
add_action('after_setup_theme', 'custom_image_sizes');



// function my_theme_enqueue_scripts() {
    // 注册 jQuery
//     wp_enqueue_script('jquery');

//     // 注册自定义脚本
//     wp_enqueue_script('my-custom-script', get_template_directory_uri() . '/js/my-custom-script.js', array('jquery'), null, true);

//     // 本地化脚本
//     $data = array(
//         'ajax_url' => admin_url('admin-ajax.php')
//     );
//     wp_localize_script('my-custom-script', 'my_ajax_object', $data);
// }
// add_action('wp_enqueue_scripts', 'my_theme_enqueue_scripts');

function my_handle_infinite_scroll() {

    $paged = intval($_POST['page']);
    $query_args = array(
        'post_type' => 'post',
        'paged' => $paged,
        'posts_per_page' => 15,//每次加载的数量
    );
    $category_id = isset($_POST['category_id']) ? intval($_POST['category_id']) : '';
    $fenlei = isset($_POST['fenlei']) ? $_POST['fenlei']: '';
//     $current_category = get_queried_object();
    if ($category_id) {
    $query_args['cat'] = $category_id; // 使用当前分类的ID
    }
    $query = new WP_Query($query_args);
    if ($query->have_posts()) {
        ob_start(); // 开始输出缓冲区
        while ($query->have_posts()) {
        $query->the_post();
        set_query_var('fenlei', $fenlei);
        get_template_part('templates/lists'); // 加载你的 lists 模板
        }
        $content = ob_get_clean(); // 获取内容并清空缓冲区
        wp_send_json_success(array('content' => $content));
    } else {
        wp_send_json_error('没有更多文章');
    }
    wp_die(); // 结束 AJAX 处理
}

// AJAX 处理函数
add_action('wp_ajax_nopriv_infinite_scroll', 'my_handle_infinite_scroll');
add_action('wp_ajax_infinite_scroll', 'my_handle_infinite_scroll');

function mce_page_break($mce_buttons) {   
$pos = array_search('wp_more', $mce_buttons, true);   
if ($pos !== false) {   
$buttons = array_slice($mce_buttons, 0, $pos + 1); $buttons[] = 'wp_page';   
$mce_buttons = array_merge($buttons, array_slice($mce_buttons, $pos + 1)); }   
return $mce_buttons; }    
add_filter('mce_buttons', 'mce_page_break');
add_filter('https_ssl_verify', '__return_false');
add_filter('https_ssl_verify', '__return_false');