Php 店面覆盖自定义注册?

Php 店面覆盖自定义注册?,php,wordpress,woocommerce,storefront,Php,Wordpress,Woocommerce,Storefront,我正在创建一个子主题,使用店面作为父主题。到目前为止,我做得很好,我正在尝试创建一个网站,在那里我可以更改网站样式的基本方面,如背景色、wp admin/customize.php中的自定义文本。 我知道我可以使用添加更多选项,但是店面主题有自己的操作钩子,事实上我已经添加了自己的操作钩子来启用更多选项,见下文 正如您所看到的,问题是它创建了另一个“footer”选项,是否有任何方法在父主题的现有“footer”选项中覆盖或插入自定义选项 这里是我用来插入选项的代码 function foot

我正在创建一个子主题,使用店面作为父主题。到目前为止,我做得很好,我正在尝试创建一个网站,在那里我可以更改网站样式的基本方面,如背景色、wp admin/customize.php中的自定义文本。

我知道我可以使用添加更多选项,但是店面主题有自己的操作钩子,事实上我已经添加了自己的操作钩子来启用更多选项,见下文

正如您所看到的,问题是它创建了另一个“footer”选项,是否有任何方法在父主题的现有“footer”选项中覆盖或插入自定义选项

这里是我用来插入选项的代码

function footer_customize_register( $custom_vars ) {
    $custom_vars ->add_section(
         'layout_section',
                array(
                     'title'       => __( 'Footer', 'pre' ),
                     'capability'  => 'edit_theme_options',
                     'description' => __( 'Allows you to edit your theme layout.', 'pre' ),
                     'priority'    => 25,
                )
    );
    $custom_vars -> add_setting('pre_layout_options[address_text]', array(
         'capability' => 'edit_theme_options',
         'type'       => 'option',
         'default'    => '000 7th St NW',
    ));
    $custom_vars -> add_control('pre_layout_options[address_text]', array(
         'label'   => 'adress',
         'section' => 'layout_section',
         'type'    => 'text',
    ));
    $custom_vars -> add_setting('pre_layout_options[phone_text]', array(
         'capability' => 'edit_theme_options',
         'type'       => 'option',
         'default'    => '01234-567',
    ));
    $custom_vars -> add_control('pre_layout_options[phone_text]', array(
         'label'   => 'ZIP code',
         'section' => 'layout_section',
         'type'    => 'text',
    ));
    $custom_vars -> add_setting('pre_layout_options[VAT]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
        'default'    => '00.000.000/0000-00',
    ));
    $custom_vars -> add_control('pre_layout_options[VAT]', array(
            'label'   => 'VAT number',
            'section' => 'layout_section',
            'type'    => 'text',
    ));
    $custom_vars -> add_setting('pre_layout_options[Location]', array(
            'capability' => 'edit_theme_options',
            'type'       => 'option',
            'default'    => 'Centro',
    ));
    $custom_vars -> add_control('pre_layout_options[Location]', array(
            'label'   => 'Location',
            'section' => 'layout_section',
            'type'    => 'text',
    ));
    
}

add_action('customize_register', 'footer_customize_register');


源代码来自
部分的,您需要添加
店面\页脚
并添加
优先级
,以更改位置。检查下面的代码

function footer_customize_register( $custom_vars ) {

    $custom_vars -> add_setting('pre_layout_options[address_text]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
        'default'    => '000 7th St NW',
    ));
    $custom_vars -> add_control('pre_layout_options[address_text]', array(
        'label'   => 'adress',
        'section' => 'storefront_footer',
        'type'    => 'text',
        'priority' => 50,
    ));
    $custom_vars -> add_setting('pre_layout_options[phone_text]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
        'default'    => '01234-567',
    ));
    $custom_vars -> add_control('pre_layout_options[phone_text]', array(
        'label'   => 'ZIP code',
        'section' => 'storefront_footer',
        'type'    => 'text',
        'priority' => 60,
    ));
    $custom_vars -> add_setting('pre_layout_options[VAT]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
        'default'    => '00.000.000/0000-00',
    ));
    $custom_vars -> add_control('pre_layout_options[VAT]', array(
        'label'   => 'VAT number',
        'section' => 'storefront_footer',
        'type'    => 'text',
        'priority' => 70,
    ));
    $custom_vars -> add_setting('pre_layout_options[Location]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
        'default'    => 'Centro',
    ));
    $custom_vars -> add_control('pre_layout_options[Location]', array(
        'label'   => 'Location',
        'section' => 'storefront_footer',
        'type'    => 'text',
        'priority' => 80,
    ));
    
}

add_action('customize_register', 'footer_customize_register');
测试和工作


请向我们展示您迄今为止所做的尝试。您好@Bhautik,谢谢您的回答,我相信最好的选择是重做问题并插入我用来启用选项的代码。@Bhautik我相信这些函数位于
inc\customizer\class storefront customizer.php
我在研究storefront主题时,在这个文件夹中发现了以
$wp\u customize->add\u control开头的代码块(新的WP_自定义颜色控制($WP_自定义,'storefront_footer_background_Color',数组()
我明天会回来的。我在这里要迟到了。@Bhautik非常感谢您的帮助非常感谢您的支持这工作非常出色,所以基本上如果我想更改其他选项,如页眉选项,我所要做的就是设置优先级?欢迎…页眉使用
'section'=>'storefront\u header',