有些主题在编辑器中具有带有HTML项目的高级按钮,如下所示:
他们是怎么做到的?我试图查看函数内部。Zerif Lite的php(一个在定制程序中也使用HTML的主题),我找不到任何东西。HTML inside Customizer
1 个回复
SO网友:Self Designs
我已经看了一下你提到的主题的内部。下面的代码(在zerif\\u customizer.js文件中)似乎就是创建这个按钮的原因。
jQuery(\'.preview-notice\').append(\'<a class="zerif-upgrade-to-pro-button" href="http://themeisle.com/themes/zerif-pro-one-page-wordpress-theme/" class="button" target="_blank">{pro}</a>\'.replace(\'{pro}\',zerifLiteCustomizerObject.pro));
这可以在主题js文件中找到。然后,他们将此文件连接到函数中的定制器上。使用此代码的php文件function zerif_registers() {
wp_enqueue_script( \'zerif_customizer_script\', get_template_directory_uri() . \'/js/zerif_customizer.js\', array("jquery"), \'20120206\', true );
wp_localize_script( \'zerif_customizer_script\', \'zerifLiteCustomizerObject\', array(
\'documentation\' => __( \'View Documentation\', \'zerif-lite\' ),
\'pro\' => __(\'View PRO version\',\'zerif-lite\')
) );
}
add_action( \'customize_controls_enqueue_scripts\', \'zerif_registers\' );
希望这能让你有所收获。