【问题标题】:Elementor icons control icon not showingElementor 图标控件图标未显示
【发布时间】:2022-01-25 08:49:02
【问题描述】:

我的 elementor 图标控件图标未显示。当我第一次将小部件拖放到 elementor 编辑部分时,它(图标未显示)不起作用,但是当我更改图标时,它显示正常。有什么问题?我该如何解决这个问题?

<?php
  namespace MeetTheTeam\Widgets;

  use Elementor\Widget_Base;
  use Elementor\Controls_Manager;

  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

  class MTTTest extends Widget_Base {
    public function get_name() {
      return 'team-mtt-widgetdd';
    }
    public function get_title() {
      return __( 'Team Sectionsdd', 'meet_the_team' );
    }
    public function get_icon() {
      return 'eicon-image-rollover';
    }
    public function get_categories() {
      return [ 'meet-the-team' ];
    }
    public function get_script_depends() {
      return [ 'meet_the_teamd' ];
    }
    
    protected function _register_controls() {
      $this->start_controls_section(
        'section_icond',
        [
          'label' => __( 'Icon', 'text-domain' ),
        ]
      );
      
      $repeater = new \Elementor\Repeater();
      
      $repeater->add_control(
        'mtt_social_icon_three_sk',
        [
          'label' => esc_html__( 'Icon', 'meet_the_team' ),
          'type' => \Elementor\Controls_Manager::ICONS,
          'default' => [
            'value' => 'fab fa-linkedin',
            'library' => 'solid',
          ],
        ]
      );

      $this->add_control(
        'mtt_boxfgfg',
        [
          'label' => esc_html__( 'Meet The Team', 'meet_the_team' ),
          'type' => \Elementor\Controls_Manager::REPEATER,
          'fields' => $repeater->get_controls(),
          'default' => [
            [
              'mtt_box_title' => esc_html__( 'Title #1', 'meet_the_team' ),
            ],
            [
              'mtt_box_title' => esc_html__( 'Title #2', 'meet_the_team' ),
            ],
          ],
          'title_field' => `{{{ mtt_box_title }}}`,
        ]
      );

      $this->end_controls_section();
    }

    protected function render() {
      $settings = $this->get_settings_for_display();
      if ( $settings['mtt_boxfgfg'] ) {
        foreach (  $settings['mtt_boxfgfg'] as $item ) {
        ?>
        <div class="test_icon"><i class="<?php echo esc_html($item['mtt_social_icon_three_sk']['value']); ?>"></i></div>
        <?php
      }
    }
  }

    protected function _content_template() {
      ?>
      <# if ( settings.mtt_boxfgfg.length ) { #>
        <# _.each( settings.mtt_boxfgfg, function( item ) { #>
          <div class="test_icon"><i class="{{{item['mtt_social_icon_three_sk']['value']}}}"></i></div>
        <# }); #>
      <# } #>
    <?php
    }
  }

【问题讨论】:

    标签: javascript php wordpress elementor wordpress-plugin-creation


    【解决方案1】:

    也许你没有用 fab fa-linkedin 加载字体真棒脚本,试试 fa fa-linkedin

    【讨论】:

    • fa fa-linkedin 也无法正常工作
    • 尝试在页面中使用 firefox 检查元素,并查看您希望在该图标上出现的类
    • 第一次课程没有显示,但是当我编辑图标时,课程正在显示
    • 在您的代码中有 2 个图标,1 个转义 1 个没有,都转义 &lt;i class="&lt;?php echo esc_html($item['mtt_social_icon_three_sk']['value']); ?&gt;"&gt;&lt;/i&gt; 而不是 &lt;i class="{{{item['mtt_social_icon_three_sk']['value']}}}"&gt;&lt;/i&gt;
    • 知道了。非常感谢。
    猜你喜欢
    • 2021-11-18
    • 1970-01-01
    • 2013-09-29
    • 2019-06-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多