generate_selectlist_query(); } // TODO This might best be handled as block textarea or shortcode inner content. // CONSIDER renaming this to inner_content to replace the built in. $fields = [ 'general' => [ 'main' => [ 'id' => [ 'type' => 'postselect', 'post_type' => 'pum_cta', 'label' => __( 'Which type of CTA would you like to use?', 'popup-maker' ), // 'options' => array_merge( // [ // [ // 'value' => '', // 'label' => __( 'Select a Call to Action', 'popup-maker' ), // ], // ], // $ctas // ), 'std' => '', 'priority' => 0, ], 'link_target' => [ 'type' => 'radio', 'label' => __( 'Open in a new tab?', 'popup-maker' ), 'options' => [ '_self' => __( 'No', 'popup-maker' ), '_blank' => __( 'Yes', 'popup-maker' ), ], 'std' => '_self', 'priority' => 0.1, ], 'text' => [ 'type' => 'text', 'label' => __( 'Enter text for your call to action.', 'popup-maker' ), 'std' => __( 'Learn more', 'popup-maker' ), 'priority' => 0.2, ], ], ], 'appearance' => [ 'main' => [ 'style' => [ 'type' => 'radio', 'label' => __( 'Choose a style.', 'popup-maker' ), 'options' => [ 'fill' => __( 'Fill', 'default' ), 'outline' => __( 'Outline', 'default' ), 'text-only' => __( 'Text Only', 'popup-maker' ), ], 'std' => 'fill', 'priority' => 1.1, ], 'align' => [ 'type' => 'select', 'label' => __( 'Alignment', 'popup-maker' ), 'options' => [ 'left' => __( 'Left', 'popup-maker' ), 'center' => __( 'Center', 'popup-maker' ), 'right' => __( 'Right', 'popup-maker' ), 'full' => __( 'Full', 'popup-maker' ), ], 'priority' => 1.2, ], 'extra_link_classes' => [ 'type' => 'text', 'label' => __( 'Additional CSS classes.', 'popup-maker' ), 'std' => '', 'priority' => 1.3, ], ], ], 'extra' => [ 'main' => [], ], ]; return $fields; } /** * Shortcode handler. * * This calls our chosen CTA's render method. * * @param array $atts Shortcode attributes. * @param string $content Shortcode content. * * @return string */ public function handler( $atts, $content = null ) { $atts = $this->shortcode_atts( $atts ); $cta_id = $atts['id']; $target = $atts['link_target']; $text = ! empty( $atts['text'] ) ? $atts['text'] : $content; $style = $atts['style']; $align = $atts['align']; $cta = \PopupMaker\get_cta_by_id( $cta_id ); if ( ! $cta ) { return 'Missing Call To Action'; } $type = $cta->get_setting( 'type', 'link' ); $uuid = $cta->get_uuid(); // Get the current popup id. $popup_id = pum_get_popup_id(); $url = $cta->generate_url('', [ 'pid' => $popup_id ? $popup_id : null, ]); $wrapper_classes = [ 'pum-cta-wrapper', 'align' . $align, 'is-style-' . $style, 'text-only' === $atts['style'] ? 'pum-cta--button' : null, ]; $cta_content = sprintf( "%s", esc_url_raw( $url ), esc_attr( $atts['extra_link_classes'] ), esc_attr( $target ), esc_attr( $type ), esc_html( $text ) ); ob_start(); ?>
[ 'href' => true, 'class' => true, 'target' => true, 'rel' => true, 'data-cta-type' => true, ], ] ); ?>