Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Redux更新wordpress blogname和blogdescription_Php_Wordpress_Redux Framework - Fatal编程技术网

Php 使用Redux更新wordpress blogname和blogdescription

Php 使用Redux更新wordpress blogname和blogdescription,php,wordpress,redux-framework,Php,Wordpress,Redux Framework,是否可以通过Redux框架更新wordpress blogname和blogdescription array( 'id' => 'blogdescription', 'type' => 'text', 'title' => 'Blog Description', 'default' => '', ), 你可以使用这个函数 update_选项('blogname','newvalue') update_

是否可以通过Redux框架更新wordpress blogname和blogdescription

array(
    'id'        => 'blogdescription',
    'type'      => 'text',
    'title'     => 'Blog Description',
    'default'   => '',
),
你可以使用这个函数

update_选项('blogname','newvalue')

update_选项('blogdescription','newvalue')

与管理员挂钩

add_action('admin_init', 'update_my_site_blog_info');
function update_my_site_blog_info() {
    $old  = get_option('blogdescription');
    $new = 'New Site Title';
    if ( $old  !== $new ) {
        update_option( 'blogdescription', $new  );
    }
}
编辑:

我想这样比较好

add_filter('redux/options/[your_opt_name]/compiler', 'update_my_site_blog_info');
function update_my_site_blog_info() {
    $new = 'New Site Title';
    update_option( 'blogdescription', $new  );
}
然后您的字段需要启用编译器

array(
    'id'        => 'blogdescription',
    'type'      => 'text',
    'title'     => 'Blog Description',
    'default'   => '',
    'compiler'  => true,
),

谢谢你的帮助,我是这样做的

add_action('init', 'update_my_site_blog_info');
    function update_my_site_blog_info()
    {
        global $opt_keyname;
        $check = array('blogdescription', 'blogname');
        foreach($check as $key)
        {
            if ( get_option($key)  != $opt_keyname[$key] )
            {
                update_option( $key, $opt_keyname[$key] );
            }
        }
    }


Redux::setSection( $opt_name,
        array(
            'title'     => 'Basic Settings',
            'id'        => 'basic_settings',
            'fields'    => array(
                array(
                    'id'        => 'blogname',
                    'type'      => 'text',
                    'title'     => 'Blog Title',
                    'default'   => get_option( 'blogname' )
                ),
                array(
                    'id'        => 'blogdescription',
                    'type'      => 'text',
                    'title'     => 'Blog Description',
                    'default'   => get_option( 'blogdescription' )
                ),
            )
        )
    );