HEX
Server: nginx/1.28.0
System: Linux yisu-68a5f20334161 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 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/q.autos58.cn/wp-content/themes/kong20/inc/options/metabox-options.php
<?php if (!defined('ABSPATH')) {die;} // Cannot access directly.

$prefix_post_opts_seo = 'seo-postmeta-box';
//自定义文章SEO信息
    CSF::createMetabox($prefix_post_opts_seo, array(
        'title'     => '自定义文章SEO信息',
        'post_type' => array('post','page'),
        'data_type' => 'unserialize',
    ));
    CSF::createSection($prefix_post_opts_seo, array(
        'fields' => array(

            array(
                'id'      => 'post_titie_s',
                'type'    => 'switcher',
                'title'   => 'SEO标题',
                'label'   => '不设置则自动根据WP规则显示',
                'default' => false,
            ),
            array(
                'id'         => 'post_titie',
                'type'       => 'text',
                'title'      => 'SEO标题',
                'subtitle'   => '',
                'dependency' => array('post_titie_s', '==', 'true'),
            ),
            array(
                'id'      => 'post_keywords_s',
                'type'    => 'switcher',
                'title'   => 'SEO关键词',
                'label'   => '不设置则自动抓取当前文章设置的标签',
                'default' => false,
            ),
            array(
                'id'         => 'keywords',
                'type'       => 'text',
                'title'      => '关键词',
                'subtitle'   => '关键词用英文逗号,隔开',
                'dependency' => array('post_keywords_s', '==', 'true'),
            ),
            array(
                'id'      => 'post_description_s',
                'type'    => 'switcher',
                'title'   => 'SEO描述',
                'label'   => '不设置则自动根据摘要获取',
                'default' => false,
            ),
            array(
                'id'         => 'description',
                'type'       => 'textarea',
                'title'      => '描述内容',
                'subtitle'   => '字数控制到80-150最佳',
                'dependency' => array('post_description_s', '==', 'true'),
            ),

            

        ),
    ));
//文章扩展产品多图


//获取一个随机数
function hua_get_mt_rand_view($args = array())
{
    $defaults = array(
        'max' => 500,
        'min' => 20,
    );
    
    $args = wp_parse_args($args, $defaults);
    $min = (int)$args['min'];
    $max = (int)$args['max'];
    
    if ($min > $max) {
        throw new InvalidArgumentException('最小值不能大于最大值');
    }
    
    return mt_rand($min, $max);
}  
function hua_get_mt_rand_number($args = array())
{
    $defaults = array(
        'max' => 30,
        'min' => 10,
    );
    
    $args = wp_parse_args($args, $defaults);
    $min = (int)$args['min'];
    $max = (int)$args['max'];
    
    if ($min > $max) {
        throw new InvalidArgumentException('最小值不能大于最大值');
    }
    
    return mt_rand($min, $max);
}  
CSF::createMetabox('posts_mainb', array(
    'title'     => '文章扩展',
    'post_type' => 'post',
    'data_type' => 'unserialize',
    'context' => 'side',
));
CSF::createSection('posts_mainb', array(
    'fields' => array(
        
        array(
            'id'    => 'views',
            'type'  => 'number',
            'title' => '阅读量',
            'default' => hua_get_mt_rand_view(_hua('post_default_mate', '', 'views')),
            'validate' => 'csf_validate_numeric',
        ),
        /*
        array(
            'id'    => 'hua_thumbup',
            'type'  => 'number',
            'title' => '点赞数',
            'default' => hua_get_mt_rand_number(_hua('post_default_mate', '', 'hua_thumbup')),
            'validate' => 'csf_validate_numeric',
        ),*/
        
       
    )
));
// prefix_page_opts
$prefix_page_opts = '_hua_page_options';

CSF::createMetabox($prefix_page_opts, array(
    'title'     => '封面图',
    'post_type' => 'page',
    'data_type' => 'unserialize',
    'priority'  => 'high',
));

CSF::createSection($prefix_page_opts, array(
    'fields' => array(
        array(
            'id' => 'categoty-img',
            'desc' => 'page单页封面图,建议尺寸为1920x350。',
            'default' => $imagepath . 'cat-banner.jpg',
            'preview' => true,
            'library' => 'image', 
            'type' => 'upload'
        ),

    ),
));