elementor
1 year ago
logs
1 month ago
strong-testimonials-beaver-block
1 year ago
submodules
8 months ago
class-strong-gutemberg.php
1 year ago
class-strong-log.php
1 year ago
class-strong-mail.php
1 year ago
class-strong-testimonials-average-shortcode.php
1 year ago
class-strong-testimonials-count-shortcode.php
1 year ago
class-strong-testimonials-defaults.php
1 month ago
class-strong-testimonials-form.php
1 month ago
class-strong-testimonials-order.php
1 year ago
class-strong-testimonials-privacy.php
1 year ago
class-strong-testimonials-render.php
1 month ago
class-strong-testimonials-templates.php
1 year ago
class-strong-testimonials-view-shortcode.php
1 week ago
class-strong-testimonials-view-widget.php
1 year ago
class-strong-view-display.php
1 day ago
class-strong-view-form.php
1 day ago
class-strong-view-slideshow.php
1 day ago
class-strong-view.php
1 day ago
class-walker-strong-category-checklist-front.php
1 year ago
deprecated.php
1 year ago
filters.php
1 month ago
functions-activation.php
1 month ago
functions-content.php
11 months ago
functions-image.php
5 months ago
functions-rating.php
1 year ago
functions-template-form.php
1 week ago
functions-template.php
4 months ago
functions-views.php
1 year ago
functions.php
1 month ago
l10n-polylang.php
1 year ago
l10n-wpml.php
1 year ago
post-types.php
1 week ago
retro.php
1 year ago
scripts.php
1 month ago
class-strong-testimonials-view-shortcode.php
146 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Strong_Testimonials_View_Shortcode |
| 4 | * |
| 5 | * @since 2.28.0 |
| 6 | */ |
| 7 | |
| 8 | class Strong_Testimonials_View_Shortcode { |
| 9 | |
| 10 | /** |
| 11 | * @var string |
| 12 | */ |
| 13 | public $shortcode = 'testimonial_view'; |
| 14 | |
| 15 | public function __construct() { |
| 16 | add_shortcode( $this->shortcode, array( $this, 'testimonial_view_shortcode' ) ); |
| 17 | add_filter( 'shortcode_atts_' . $this->shortcode, array( $this, 'testimonial_view_filter' ), 10, 3 ); |
| 18 | |
| 19 | add_filter( 'widget_text', 'do_shortcode' ); |
| 20 | add_filter( 'no_texturize_shortcodes', array( $this, 'no_texturize_shortcodes' ) ); |
| 21 | |
| 22 | add_filter( 'strong_view_html', array( $this, 'remove_whitespace' ) ); |
| 23 | add_filter( 'strong_view_form_html', array( $this, 'remove_whitespace' ) ); |
| 24 | } |
| 25 | |
| 26 | public function get_shortcode() { |
| 27 | return $this->shortcode; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Our primary shortcode. |
| 32 | * |
| 33 | * @param $atts |
| 34 | * @param null $content |
| 35 | * |
| 36 | * @return mixed|string |
| 37 | */ |
| 38 | public function testimonial_view_shortcode( $atts, $content = null ) { |
| 39 | $out = shortcode_atts( // phpcs:ignore sanitized in render_view |
| 40 | array(), |
| 41 | $atts, |
| 42 | $this->shortcode |
| 43 | ); |
| 44 | |
| 45 | return $this->render_view( $out ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Shortcode attribute filter |
| 50 | * |
| 51 | * @since 1.21.0 |
| 52 | * |
| 53 | * @param array $out The output array of shortcode attributes. |
| 54 | * @param array $pairs The supported attributes and their defaults. |
| 55 | * @param array $atts The user defined shortcode attributes. |
| 56 | * |
| 57 | * @return array |
| 58 | */ |
| 59 | public function testimonial_view_filter( $out, $pairs, $atts ) { |
| 60 | return WPMST()->render->parse_view( $out, $pairs, $atts ); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Render the View. |
| 65 | * |
| 66 | * @param $out |
| 67 | * |
| 68 | * @return mixed|string |
| 69 | */ |
| 70 | public function render_view( $out ) { |
| 71 | // Did we find this view? |
| 72 | if ( isset( $out['view_not_found'] ) && $out['view_not_found'] ) { |
| 73 | if ( current_user_can( 'strong_testimonials_views' ) ) { |
| 74 | ob_start(); |
| 75 | ?> |
| 76 | <p style="color: #CD0000;"> |
| 77 | <?php |
| 78 | // translators: %s is the placeholder for the testimonial view name or identifier. |
| 79 | printf( esc_html__( 'Testimonial view %s not found.', 'strong-testimonials' ), esc_attr( $out['view'] ) ); |
| 80 | ?> |
| 81 | <br> |
| 82 | <span style="color: #777; font-size: 0.9em;"><?php esc_html_e( '(Only administrators see this message.)', 'strong-testimonials' ); ?></span> |
| 83 | </p> |
| 84 | <?php |
| 85 | return ob_get_clean(); |
| 86 | } |
| 87 | return ''; |
| 88 | } |
| 89 | |
| 90 | switch ( $out['mode'] ) { |
| 91 | case 'form': |
| 92 | $view = new Strong_View_Form( $out ); |
| 93 | if ( isset( $_GET['success'] ) && isset( $_GET['formid'] ) && (int) $out['form_id'] === (int) $_GET['formid'] ) { |
| 94 | $view->success(); |
| 95 | } else { |
| 96 | $view->build(); |
| 97 | } |
| 98 | break; |
| 99 | case 'slideshow': |
| 100 | $view = new Strong_View_Slideshow( $out ); |
| 101 | $view->build(); |
| 102 | break; |
| 103 | default: |
| 104 | $view = new Strong_View_Display( $out ); |
| 105 | $view->build(); |
| 106 | } |
| 107 | |
| 108 | return $view->output(); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Remove whitespace between tags. Helps prevent double wpautop in plugins |
| 113 | * like Posts For Pages and Custom Content Shortcode. |
| 114 | * |
| 115 | * @param $html |
| 116 | * |
| 117 | * @since 2.3 |
| 118 | * |
| 119 | * @return mixed |
| 120 | */ |
| 121 | public function remove_whitespace( $html ) { |
| 122 | $options = get_option( 'wpmtst_options' ); |
| 123 | $saved_value = isset( $options['remove_whitespace'] ) ? (bool) $options['remove_whitespace'] : true; |
| 124 | if ( apply_filters( 'wpmtst_remove_whitespace_enabled', $saved_value ) ) { |
| 125 | return wpmtst_strip_whitespace( $html ); |
| 126 | } |
| 127 | |
| 128 | return $html; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Do not texturize shortcode. |
| 133 | * |
| 134 | * @since 1.11.5 |
| 135 | * |
| 136 | * @param $shortcodes |
| 137 | * |
| 138 | * @return array |
| 139 | */ |
| 140 | public function no_texturize_shortcodes( $shortcodes ) { |
| 141 | $shortcodes[] = $this->shortcode; |
| 142 | |
| 143 | return $shortcodes; |
| 144 | } |
| 145 | } |
| 146 |