问题描述
我正尝试使用 wp_is_mobile 功能-https://developer.wordpress.org/reference/functions/wp_is_mobile/
为移动设备禁用Navgoco Menu插件的CSS和JS文件。<?PHP if ( wp_is_mobile() ) : ?>
/* display and echo mobile specific stuff here */
<?PHP else : ?>
/* display and echo desktop stuff here */
<?PHP endif; ?>
function scripts_styles() {
$options = get_option( 'navgoco_settings' );
wp_register_script ( 'navgocojs',plugins_url( '/js/jquery.navgoco.js',__FILE__ ),array( 'jquery' ),'0.2.1',false );
wp_register_script ( 'navgococookie',plugins_url( '/js/jquery.cookie.min.js','1.4.1',false );
wp_register_style ( 'navgococss',plugins_url( '/css/navgoco.css','','all' );
wp_register_script ( 'navgoco-init',plugins_url( '/js/navgoco-init.js',array( 'navgocojs' ),'1.0.0',false );
// Add new plugin options defaults here,set them to blank,this will avoid PHP notices of undefined,if new options are introduced to the plugin and are not saved or udated then the setting will be defined.
$options_default = array(
'ng_menu_save' => '','ng_menu_disable_style' => '','ng_menu_selection' => '','ng_menu_accordion' => '','ng_menu_html_carat' => '','ng_slide_easing' => '','ng_slide_duration' => '',);
$options = wp_parse_args( $options,$options_default );
wp_enqueue_script( 'navgocojs' );
if( (bool) $options['ng_menu_save'] == true ) {
wp_enqueue_script( 'navgococookie' );
}
if( (bool) $options['ng_menu_disable_style'] == false ) {
wp_enqueue_style( 'navgococss' );
wp_enqueue_style( 'fontawesome' );
}
$data = array (
'ng_navgo' => array(
'ng_menu_selection' => esc_html($options['ng_menu_selection']),'ng_menu_accordion' => (bool)$options['ng_menu_accordion'],'ng_menu_html_carat' => $options['ng_menu_html_carat'],'ng_slide_easing' => esc_html($options['ng_slide_easing']),'ng_slide_duration' => (int)$options['ng_slide_duration'],'ng_menu_save' => (bool)$options['ng_menu_save'],),);
//add filter
$data = apply_filters( 'ng_navgoco_navgocoVars',$data );
// Pass PHP variables to jQuery script
wp_localize_script( 'navgoco-init','navgocoVars',$data );
wp_enqueue_script( 'navgoco-init' );
}
是否可以在此处实现wp_is_mobile?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)