小编Mat*_*hew的帖子

Wordpress 定制器自定义控件传输 postMessage 不起作用

我正在构建一个WordPress主题并且需要在定制器controls中添加自定义,输入字段显示但是当我更改输入的值时没有任何反应。

这是我的代码。

class WP_Customize_Custom_Control extends WP_Customize_Control {
  public $type = 'custom_control';

  function render_content(){
  }
  public function content_template() {
    ?>
    <input type="text" id="custom_control" name="custom_control" />
    <?php
  }
}

function company_customize_register( $wp_customize ){
  $wp_customize->register_control_type( 'WP_Customize_Custom_Control' );
  $wp_customize->add_setting('custom_smthing', array( 'default' => get_theme_mod( "custom_smthing" ), 'transport' =>'postMessage' ) );
  $wp_customize->add_control(new WP_Customize_Custom_Control($wp_customize,'custom_smthing',
    array(
      'label'      => __( 'Custom Control', 'company' ),
      'section'    => 'body_backgrounds',
      'settings'   => 'custom_smthing',
     )
   )
  );
}
add_action( 'customize_register', 'company_customize_register' );
Run Code Online (Sandbox Code Playgroud)

而js是

( function( $ ) {
  console.log("test1"); …
Run Code Online (Sandbox Code Playgroud)

javascript php wordpress jquery wordpress-theming

7
推荐指数
1
解决办法
650
查看次数

标签 统计

javascript ×1

jquery ×1

php ×1

wordpress ×1

wordpress-theming ×1