Woocommerce section name?

时间:2019-01-20 作者:Sumon Hasan

enter image description here

自定义程序节的名称是什么?我想在customizer woocommerce部分下添加一个字段选项。或者如何在woocommerce选项下添加字段?有人能帮我吗?

1 个回复
最合适的回答,由SO网友:Andrea Somovigo 整理而成

WOO customizer设置位于“woocommerce”定制器面板下(自WP 4.0以来已添加该面板)

add_action(\'customize_register\',"SE_add_options_t_woo_customizer");

function SE_add_options_t_woo_customizer($wp_customize ){
  $wp_customize->add_section( "my_new_section" , 
    array(
      \'title\' => "My new section",
      \'priority\' => 20,
      \'panel\' => \'woocommerce\', // here is where you grab the woocommerce panel to add settings and controls to
      ) 
    );
  $wp_customize->add_setting(\'my_new_setting\',
     array(
        \'default\'              => \'no\',
        \'type\'                 => \'option\',
        \'capability\'           => \'manage_woocommerce\',
        \'sanitize_callback\'    => \'wc_bool_to_string\',
        \'sanitize_js_callback\' => \'wc_string_to_bool\',
    )
  );
  $wp_customize->add_control(\'my_new_control\',
    array(
        \'label\'       => __( \'Control\', \'woocommerce\' ),
        \'description\' => __( \'This is my new control\', \'woocommerce\' ),
        \'section\'     => \'my_new_section\',
        \'settings\'    => \'my_new_setting\',
        \'type\'        => \'checkbox\',
    )
);

}

相关推荐