文章目录
本文最后更新于 2023-09-11,已超过 365 天未更新,内容可能已失效。

新增功能-在wp外观-菜单添加菜单时,可以自定义图标,直观方便,无需手动添加html的fa图标代码 直接可视化选择添加

 

[tip_success]本次更新对于喜欢美化的来说确实方便了,可以直接选择喜欢的图标。遗憾的是还是不能定义颜色,以及旋转。好了话不多说,直接教程。

本次需要修改的两个文件ripro\inc\class\walker.class.php;  ripro\inc\codestar-framework\options\nav-menu-options.php[/tip_success]

第一步

添加font图标颜色和旋转的控制。 ripro\inc\codestar-framework\options\nav-menu-options.php

<?php if ( ! defined( 'ABSPATH' )  ) { die; } // Cannot access directly.

$prefix = '_ripro_menu_options';
CSF::createNavMenuOptions( $prefix, array(
  'data_type' => 'unserialize'
) );
CSF::createSection( $prefix, array(
  'fields' => array(
    array(
        'id'      => 'menu_icon',
        'type'    => 'icon',
        'title'   => '菜单图标',
    ),
    array(
      'id'    => 'is_catmenu',
      'type'  => 'switcher',
      'title' => '高级菜单',
      'desc' => '鼠标滑过展示分类下文章-仅在分类菜单中有效,开启后可以显示最新10篇文章',
    ),
  )
) );

 

替换为:

[rihide]

<?php if ( ! defined( 'ABSPATH' )  ) { die; } // Cannot access directly.

$prefix = '_ripro_menu_options';
CSF::createNavMenuOptions( $prefix, array(
  'data_type' => 'unserialize'
) );
CSF::createSection( $prefix, array(
  'fields' => array(
    array(
        'id'      => 'menu_icon',
        'type'    => 'icon',
        'title'   => '菜单图标',
    ),
    array(
      'id'    => 'is_catmenu',
      'type'  => 'switcher',
      'title' => '高级菜单',
      'desc' => '鼠标滑过展示分类下文章-仅在分类菜单中有效,开启后可以显示最新10篇文章',
    ),
    array(
        'id'      => 'nav_color',
        'type'    => 'color',
        'title'   => '图标颜色',
        'desc'      => '选择颜色',
        'default' => '#2c63ff',
    ),
    array(
      'id'    => 'is_fa_spin',
      'type'  => 'switcher',
      'title' => '图标旋转',
      'desc' => '是否开启图标旋转',
    ),
  )
) );

[/rihide]

第二步:

添加菜单输入的文件ripro\inc\class\walker.class.php  77-80行

$menu_icon = get_post_meta( $item->ID, 'menu_icon', true );
        if( ! empty( $menu_icon ) ) {
            $item->title = '<span><i class="'. $menu_icon .'"></i> ' . $item->title .'</span>';
        }

 

 

替换为:

[rihide]

$menu_icon = get_post_meta( $item->ID, 'menu_icon', true );
        $nav_color = get_post_meta( $item->ID, 'nav_color',true);
        $is_fa_spin= get_post_meta( $item->ID, 'is_fa_spin',true);
        if( ! empty( $menu_icon ) ) {
            if($is_fa_spin){
            $item->title = '<span><i class="'. $menu_icon .' fa-spin " style="color:'.$nav_color.'"></i> ' . $item->title .'</span>';
        }else{
            $item->title = '<span><i class="'. $menu_icon .'" style="color:'.$nav_color.'"></i> ' . $item->title .'</span>';
        }
        }

[/rihide]

最后效果:

ripro7.3主题美化教程-WordPress菜单添加font图标

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/3372.html
本文作者:子佩·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (2)

  • 子佩 幸运儿 · 参与过抽奖活动创始成员 · 站点上线 30 天内注册+1

    这次准备在首页待几天!

    4 年前
  • 子佩 幸运儿 · 参与过抽奖活动创始成员 · 站点上线 30 天内注册+1

    看的我热血沸腾,转身踢开旁边的牛自己犁了三十亩地

    4 年前
/