Как добавить ссылку на шорткод значка в теме Wordpress - PullRequest
0 голосов
/ 24 октября 2019

Я довольно новичок в Wordpress и PHP. Я приобрел тему и использую несколько шорткодов-тизеров на своей домашней странице. Тем не менее, я хотел бы, чтобы, когда я нажимал на значок, его перенаправляли на другую часть сайта. Как мне это сделать?

Пока что я отредактировал wp-content/themes/dotdigital/framework-customizations/extensions/shortcodes/shortcodes/teaser/options.php и добавил следующий фрагмент кода, который я взял из другого шорткода с такой функциональностью:

    'link'        => array(
        'label' => esc_html__( 'Button Link', 'dotdigital' ),
        'desc'  => esc_html__( 'Where should your button link to', 'dotdigital' ),
        'type'  => 'text',
        'value' => '#'
    ),
    'target'      => array(
        'type'         => 'switch',
        'label'        => esc_html__( 'Open Link in New Window', 'dotdigital' ),
        'desc'         => esc_html__( 'Select here if you want to open the linked page in a new window', 'dotdigital' ),
        'right-choice' => array(
            'value' => '_blank',
            'label' => esc_html__( 'Yes', 'dotdigital' ),
        ),
        'left-choice'  => array(
            'value' => '_self',
            'label' => esc_html__( 'No', 'dotdigital' ),
        ),
    ),

Это сработало довольнокрасиво, и теперь у меня есть возможность добавить ссылку при создании / редактировании иконки-тизера из интерфейса администратора WP. Тем не менее, это все еще не работает. Я понимаю, что я должен также редактировать view.php. На данный момент это выглядит так:

<?php if ( ! defined( 'FW' ) ) {
    die( 'Forbidden' );
}
/**
 * @var array $atts
 */

$teaser_type   = isset( $atts['teaser_types']['teaser_type'] ) ? $atts['teaser_types']['teaser_type'] : false;
$teaser_image  = isset( $atts['teaser_types'][ $teaser_type ]['teaser_image'] ) ? $atts['teaser_types'][ $teaser_type ]['teaser_image'] : false;
$icon          = isset( $atts['teaser_types'][ $teaser_type ]['icon'] ) ? $atts['teaser_types'][ $teaser_type ]['icon'] : false;
$icon_size     = isset( $atts['teaser_types'][ $teaser_type ]['icon_size'] ) ? $atts['teaser_types'][ $teaser_type ]['icon_size'] : 'size_small';
$icon_style    = isset( $atts['teaser_types'][ $teaser_type ]['icon_style'] ) ? $atts['teaser_types'][ $teaser_type ]['icon_style'] : false;
$icon_color    = isset( $atts['teaser_types'][ $teaser_type ]['icon_color'] ) ? $atts['teaser_types'][ $teaser_type ]['icon_color'] : false;
$teaser_center = isset( $atts['teaser_types'][ $teaser_type ]['teaser_center'] ) ? $atts['teaser_types'][ $teaser_type ]['teaser_center'] : false;

//common teaser properties for all teaser types
$title        = $atts['title'];
$teaser_style = $atts['teaser_style'];
$title_tag    = $atts['title_tag'];
$content      = $atts['content'];

//available teaser layouts:
//icon_left
//icon_right
//image_top
//image_left
//image_right
//icon_top - default

switch ( $teaser_type ) :
...

А затем в коде подробно рассматриваются различные типы тизер-иконок, которые я могу использовать.

Мой вопрос: что мне добавить сюда и где, чтобы ссылка работала при нажатии на изображение?

...