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-view.php
629 lines
| 1 | <?php |
| 2 | /** |
| 3 | * View class. |
| 4 | * |
| 5 | * @since 2.3.0 |
| 6 | */ |
| 7 | |
| 8 | // Exit if accessed directly |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | if ( ! class_exists( 'Strong_View' ) ) : |
| 14 | |
| 15 | class Strong_View { |
| 16 | |
| 17 | /** |
| 18 | * The view settings. |
| 19 | * |
| 20 | * @var array |
| 21 | */ |
| 22 | public $atts; |
| 23 | |
| 24 | /** |
| 25 | * The query. |
| 26 | */ |
| 27 | public $query; |
| 28 | |
| 29 | /** |
| 30 | * The template file. |
| 31 | */ |
| 32 | public $template_file; |
| 33 | |
| 34 | /** |
| 35 | * The view output. |
| 36 | * |
| 37 | * @var string |
| 38 | */ |
| 39 | public $html; |
| 40 | |
| 41 | /** |
| 42 | * The plugin version. |
| 43 | * |
| 44 | * @var string |
| 45 | */ |
| 46 | public $plugin_version; |
| 47 | |
| 48 | /** |
| 49 | * The stylesheet handle. For adding inline style. |
| 50 | * |
| 51 | * @since 2.31.8 |
| 52 | * @var string |
| 53 | */ |
| 54 | public $stylesheet; |
| 55 | |
| 56 | /** |
| 57 | * Strong_View constructor. |
| 58 | * |
| 59 | * @param array $atts |
| 60 | */ |
| 61 | public function __construct( $atts = array() ) { |
| 62 | $this->atts = apply_filters( 'wpmtst_view_atts', $atts ); |
| 63 | $this->plugin_version = get_option( 'wpmtst_plugin_version' ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Return a specific view attribute. |
| 68 | * |
| 69 | * @param $att |
| 70 | * @since 2.33.0 |
| 71 | * |
| 72 | * @return mixed|null |
| 73 | */ |
| 74 | public function get_att( $att ) { |
| 75 | return isset( $this->atts[ $att ] ) ? $this->atts[ $att ] : null; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Return our rendered template. |
| 80 | * |
| 81 | * @return string |
| 82 | */ |
| 83 | public function output() { |
| 84 | return $this->html; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Warning message of view not found. |
| 89 | * |
| 90 | * @return string |
| 91 | */ |
| 92 | public function nothing_found() { |
| 93 | ob_start(); |
| 94 | ?> |
| 95 | <p style="color: #CD0000;"> |
| 96 | <?php esc_html_e( 'No testimonials found. Check your view settings.', 'strong-testimonials' ); ?><br> |
| 97 | <span style="color: #777; font-size: 0.9em;"><?php esc_html_e( '(Only administrators see this message.)', 'strong-testimonials' ); ?></span> |
| 98 | </p> |
| 99 | <?php |
| 100 | |
| 101 | return apply_filters( 'wpmtst_message_nothing_found', ob_get_clean() ); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Warning message shown when the configured template doesn't exist |
| 106 | * and the front end has silently fallen back to the default template. |
| 107 | * |
| 108 | * @param string $template_key The requested (unresolved) template key. |
| 109 | * |
| 110 | * @since 3.3.2 |
| 111 | * @return string |
| 112 | */ |
| 113 | public function template_not_found_notice( $template_key ) { |
| 114 | if ( ! $template_key || ! current_user_can( 'strong_testimonials_views' ) ) { |
| 115 | return ''; |
| 116 | } |
| 117 | |
| 118 | if ( in_array( $template_key, WPMST()->templates->get_template_keys(), true ) ) { |
| 119 | return ''; |
| 120 | } |
| 121 | |
| 122 | ob_start(); |
| 123 | ?> |
| 124 | <p style="color: #CD0000;"> |
| 125 | <?php |
| 126 | printf( |
| 127 | /* translators: %s: template name */ |
| 128 | esc_html__( 'Template "%s" not found. The default template is used instead.', 'strong-testimonials' ), |
| 129 | esc_html( $template_key ) |
| 130 | ); |
| 131 | ?> |
| 132 | <br> |
| 133 | <span style="color: #777; font-size: 0.9em;"><?php esc_html_e( '(Only administrators see this message.)', 'strong-testimonials' ); ?></span> |
| 134 | </p> |
| 135 | <?php |
| 136 | |
| 137 | return apply_filters( 'wpmtst_message_template_not_found', ob_get_clean(), $template_key, $this ); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Process the view. |
| 142 | * |
| 143 | * Used by main class to load the scripts and styles for this View. |
| 144 | */ |
| 145 | public function process() {} |
| 146 | |
| 147 | /** |
| 148 | * Build the view. |
| 149 | */ |
| 150 | public function build() {} |
| 151 | |
| 152 | /** |
| 153 | * Add content filters. |
| 154 | */ |
| 155 | public function add_content_filters() { |
| 156 | |
| 157 | if ( 'truncated' === $this->get_att( 'content' ) ) { |
| 158 | |
| 159 | // automatic excerpt |
| 160 | |
| 161 | $this->excerpt_filters(); |
| 162 | |
| 163 | $this->hybrid_content(); |
| 164 | |
| 165 | add_filter( 'wpmtst_get_the_excerpt', 'wpmtst_bypass_excerpt', 1 ); |
| 166 | |
| 167 | if ( $this->get_att( 'more_post_ellipsis' ) ) { |
| 168 | add_filter( 'wpmtst_use_ellipsis', '__return_true' ); |
| 169 | } |
| 170 | } elseif ( 'excerpt' === $this->get_att( 'content' ) ) { |
| 171 | |
| 172 | // manual excerpt (if no excerpt then use automatic excerpt) |
| 173 | |
| 174 | $this->excerpt_filters(); |
| 175 | |
| 176 | $this->hybrid_content(); |
| 177 | |
| 178 | if ( $this->get_att( 'more_full_post' ) ) { |
| 179 | add_filter( 'wpmtst_get_the_excerpt', array( $this, 'manual_excerpt_more' ), 20 ); |
| 180 | } |
| 181 | |
| 182 | if ( $this->get_att( 'more_post_ellipsis' ) ) { |
| 183 | add_filter( 'wpmtst_use_ellipsis', array( $this, 'has_no_excerpt' ) ); |
| 184 | } else { |
| 185 | add_filter( 'wpmtst_use_ellipsis', '__return_false' ); |
| 186 | } |
| 187 | } else { |
| 188 | |
| 189 | // full content |
| 190 | add_filter( 'wpmtst_get_the_content', 'wpmtst_the_content_filtered' ); |
| 191 | |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Add excerpt filters. |
| 197 | * |
| 198 | * @since 2.33.0 |
| 199 | */ |
| 200 | public function excerpt_filters() { |
| 201 | add_filter( 'wpmtst_get_the_content', 'wpmtst_the_excerpt_filtered' ); |
| 202 | add_filter( 'wpmtst_get_the_excerpt', 'wpmtst_trim_excerpt' ); |
| 203 | |
| 204 | if ( ! $this->get_att( 'use_default_length' ) ) { |
| 205 | add_filter( 'excerpt_length', array( $this, 'excerpt_length' ), 999 ); |
| 206 | } |
| 207 | |
| 208 | if ( ! $this->get_att( 'use_default_more' ) ) { |
| 209 | add_filter( 'excerpt_more', array( $this, 'excerpt_more' ), 99999 ); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Add hybrid content filters. |
| 215 | * |
| 216 | * @since 2.33.0 |
| 217 | */ |
| 218 | public function hybrid_content() { |
| 219 | if ( $this->get_att( 'more_post_in_place' ) ) { |
| 220 | add_filter( 'wpmtst_is_hybrid_content', '__return_true' ); |
| 221 | } else { |
| 222 | add_filter( 'wpmtst_read_more_post_link', 'wpmtst_prepend_ellipsis' ); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Remove content filters. |
| 228 | * |
| 229 | * @since 2.33.0 |
| 230 | */ |
| 231 | public function remove_content_filters() { |
| 232 | remove_filter( 'wpmtst_get_the_content', 'wpmtst_the_content_filtered' ); |
| 233 | remove_filter( 'wpmtst_get_the_content', 'wpmtst_the_excerpt_filtered' ); |
| 234 | |
| 235 | remove_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
| 236 | remove_filter( 'excerpt_more', array( $this, 'excerpt_more' ) ); |
| 237 | remove_filter( 'wpmtst_read_more_post_link', 'wpmtst_prepend_ellipsis' ); |
| 238 | |
| 239 | remove_filter( 'wpmtst_get_the_excerpt', 'wpmtst_bypass_excerpt', 1 ); |
| 240 | remove_filter( 'wpmtst_get_the_excerpt', 'wpmtst_hybrid_excerpt' ); |
| 241 | remove_filter( 'wpmtst_get_the_excerpt', 'wpmtst_trim_excerpt' ); |
| 242 | remove_filter( 'wpmtst_get_the_excerpt', array( $this, 'manual_excerpt_more' ), 20 ); |
| 243 | |
| 244 | remove_filter( 'wpmtst_is_hybrid_content', '__return_true' ); |
| 245 | remove_filter( 'wpmtst_use_ellipsis', '__return_true' ); |
| 246 | remove_filter( 'wpmtst_use_ellipsis', array( $this, 'has_no_excerpt' ) ); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Return true if post has no manual excerpt. |
| 251 | * |
| 252 | * @since 2.33.0 |
| 253 | * |
| 254 | * @return bool |
| 255 | */ |
| 256 | public function has_no_excerpt() { |
| 257 | return ! has_excerpt(); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Set custom excerpt length. |
| 262 | * |
| 263 | * @param $words |
| 264 | * @since 2.33.0 |
| 265 | * |
| 266 | * @return mixed|null |
| 267 | */ |
| 268 | public function excerpt_length( $words ) { |
| 269 | $excerpt_length = $this->get_att( 'excerpt_length' ); |
| 270 | |
| 271 | return $excerpt_length ? $excerpt_length : $words; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * The read-more link, maybe prepended with an ellipsis. |
| 276 | * |
| 277 | * @param $more |
| 278 | * @since 2.33.0 |
| 279 | * |
| 280 | * @return string |
| 281 | */ |
| 282 | public function excerpt_more( $more ) { |
| 283 | return wpmtst_get_excerpt_more_link(); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Maybe add read-more to manual excerpt. |
| 288 | * |
| 289 | * @since 2.26.0 |
| 290 | * @param $excerpt |
| 291 | * |
| 292 | * @return string |
| 293 | */ |
| 294 | public function manual_excerpt_more( $excerpt ) { |
| 295 | if ( has_excerpt() ) { |
| 296 | $excerpt .= apply_filters( 'excerpt_more', ' […]' ); |
| 297 | } |
| 298 | |
| 299 | return $excerpt; |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Build our query based on view attributes. |
| 304 | */ |
| 305 | public function build_query() {} |
| 306 | |
| 307 | /** |
| 308 | * Build class list based on view attributes. |
| 309 | * |
| 310 | * This must happen after the query. |
| 311 | */ |
| 312 | public function build_classes() {} |
| 313 | |
| 314 | /** |
| 315 | * Load template's extra stylesheets. |
| 316 | * |
| 317 | * @since 2.11.12 |
| 318 | * @since 2.16.0 In Strong_View class. |
| 319 | */ |
| 320 | public function load_extra_stylesheets() { |
| 321 | $styles = WPMST()->templates->get_template_config( $this->atts, 'styles', false ); |
| 322 | if ( $styles ) { |
| 323 | $styles_array = explode( ',', str_replace( ' ', '', $styles ) ); |
| 324 | foreach ( $styles_array as $handle ) { |
| 325 | WPMST()->render->add_style( $handle ); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Load template's script and/or dependencies. |
| 332 | * |
| 333 | * @since 1.25.0 |
| 334 | * @since 2.16.0 In Strong_View class. |
| 335 | */ |
| 336 | public function load_dependent_scripts() { |
| 337 | // Scripts that are already registered. |
| 338 | $deps = WPMST()->templates->get_template_config( $this->atts, 'scripts', false ); |
| 339 | $deps_array = $deps ? explode( ',', str_replace( ' ', '', $deps ) ) : array(); |
| 340 | |
| 341 | // A single script included in directory. |
| 342 | $script = WPMST()->templates->get_template_config( $this->atts, 'script', false ); |
| 343 | |
| 344 | if ( $script ) { |
| 345 | $handle = 'testimonials-' . $this->get_att( 'template' ); |
| 346 | wp_register_script( $handle, $script, $deps_array ); |
| 347 | WPMST()->render->add_script( $handle ); |
| 348 | } else { |
| 349 | foreach ( $deps_array as $handle ) { |
| 350 | WPMST()->render->add_script( $handle ); |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Find a template's associated stylesheet. |
| 357 | * |
| 358 | * @since 1.23.0 |
| 359 | * @since 2.16.0 In Strong_View class. |
| 360 | * |
| 361 | * @param bool $enqueue True = enqueue the stylesheet, @since 2.3 |
| 362 | * |
| 363 | * @return bool|string |
| 364 | */ |
| 365 | public function find_stylesheet( $enqueue = true ) { |
| 366 | // In case of deactivated widgets still referencing deleted Views |
| 367 | if ( ! $this->get_att( 'template' ) ) { |
| 368 | return false; |
| 369 | } |
| 370 | |
| 371 | $stylesheet = WPMST()->templates->get_template_attr( $this->atts, 'stylesheet', true ); |
| 372 | if ( $stylesheet ) { |
| 373 | $handle = 'testimonials-' . str_replace( ':', '-', $this->get_att( 'template' ) ); |
| 374 | $this->set_stylesheet( $handle ); |
| 375 | wp_register_style( $handle, $stylesheet, array(), $this->plugin_version ); |
| 376 | if ( $enqueue ) { |
| 377 | WPMST()->render->add_style( $handle ); |
| 378 | } else { |
| 379 | return $handle; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | return false; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Assemble list of CSS classes. |
| 388 | * |
| 389 | * @since 2.11.0 |
| 390 | * @since 2.30.0 Adding template option classes. |
| 391 | * |
| 392 | * @return array |
| 393 | */ |
| 394 | public function get_template_css_class() { |
| 395 | $template_name = isset( $this->atts['template'] ) ? $this->atts['template'] : ''; |
| 396 | $template_settings = $this->get_att( 'template_settings' ); |
| 397 | |
| 398 | $template_object = WPMST()->templates->get_template_by_name( $template_name ); |
| 399 | |
| 400 | // If the configured template doesn't exist, fall back to default for CSS class. |
| 401 | if ( ! $template_object ) { |
| 402 | $template_name = apply_filters( 'wpmtst_default_template', 'default', $this->atts ); |
| 403 | $template_object = WPMST()->templates->get_template_by_name( $template_name ); |
| 404 | } |
| 405 | |
| 406 | // Maintain back-compat with template format version 1.0. |
| 407 | $class = str_replace( ':content', '', $template_name ); |
| 408 | $class = str_replace( ':', '-', $class ); |
| 409 | $class = str_replace( '-form-form', '-form', $class ); |
| 410 | $class = $class . ' wpmtst-' . $class; |
| 411 | $class_list = array( $class ); |
| 412 | |
| 413 | if ( isset( $template_object['config']['options'] ) && is_array( ( $template_object['config']['options'] ) ) ) { |
| 414 | |
| 415 | foreach ( $template_object['config']['options'] as $option ) { |
| 416 | |
| 417 | if ( ! isset( $option->values ) ) { |
| 418 | continue; |
| 419 | } |
| 420 | |
| 421 | if ( isset( $template_settings[ $template_name ][ $option->name ] ) ) { |
| 422 | |
| 423 | foreach ( $option->values as $value ) { |
| 424 | if ( $value->value === $template_settings[ $template_name ][ $option->name ] ) { |
| 425 | if ( isset( $value->class_name ) ) { |
| 426 | $class_list[] = $value->class_name; |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | return array_filter( $class_list ); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Print our custom style. |
| 439 | * |
| 440 | * @since 2.22.0 |
| 441 | */ |
| 442 | public function add_custom_style() { |
| 443 | $this->custom_background(); |
| 444 | $this->custom_font_color(); |
| 445 | |
| 446 | /** |
| 447 | * Hook to add more inline style. |
| 448 | * |
| 449 | * @since 2.22.0 |
| 450 | */ |
| 451 | do_action( 'wpmtst_view_custom_style', $this ); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Is this a form view? |
| 456 | * |
| 457 | * @since 2.30.0 |
| 458 | * |
| 459 | * @return bool |
| 460 | */ |
| 461 | public function is_form() { |
| 462 | return ( 'form' === $this->get_att( 'mode' ) ); |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Build CSS for custom font color. |
| 467 | * |
| 468 | * @since 2.30.0 |
| 469 | */ |
| 470 | public function custom_font_color() { |
| 471 | $font_color = $this->get_att( 'font-color' ); |
| 472 | if ( ! isset( $font_color['type'] ) || 'custom' !== $font_color['type'] ) { |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | $c1 = isset( $font_color['color'] ) ? $font_color['color'] : ''; |
| 477 | $css = ''; |
| 478 | if ( $c1 ) { |
| 479 | $view_el = ".strong-view-id-{$this->get_att( 'view' )}"; |
| 480 | $handle = $this->get_stylesheet(); |
| 481 | |
| 482 | if ( $this->is_form() ) { |
| 483 | $css .= "$view_el .strong-form-inner { color: $c1; }"; |
| 484 | } else { |
| 485 | $css .= "$view_el .wpmtst-testimonial-heading," . |
| 486 | "$view_el .wpmtst-testimonial-content p," . |
| 487 | "$view_el .wpmtst-testimonial-content span," . |
| 488 | "$view_el .wpmtst-testimonial-content a.readmore," . |
| 489 | "$view_el .wpmtst-testimonial-content div.readmore-content," . |
| 490 | "$view_el .wpmtst-testimonial-content div.readmore-excerpt," . |
| 491 | "$view_el .wpmtst-testimonial-inner .wpmtst-testimonial-field," . |
| 492 | "$view_el .wpmtst-testimonial-inner .wpmtst-testimonial-field a," . |
| 493 | "$view_el .wpmtst-testimonial-client div," . |
| 494 | "$view_el .wpmtst-testimonial-client a { color: $c1; }"; |
| 495 | } |
| 496 | if ( wp_style_is( $handle, 'done' ) ) { |
| 497 | echo '<style type="text/css" id="wpmtst-view-custom-style">' . $css . '</style>'; |
| 498 | } else { |
| 499 | wp_add_inline_style( $handle, $css ); |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * Build CSS for custom background. |
| 506 | */ |
| 507 | public function custom_background() { |
| 508 | |
| 509 | $background = $this->get_att( 'background' ); |
| 510 | if ( ! isset( $background['type'] ) ) { |
| 511 | return; |
| 512 | } |
| 513 | |
| 514 | $handle = $this->get_stylesheet(); |
| 515 | $c1 = ''; |
| 516 | $c2 = ''; |
| 517 | |
| 518 | switch ( $background['type'] ) { |
| 519 | case 'preset': |
| 520 | if ( '' === $background['preset'] ) { |
| 521 | break; |
| 522 | } |
| 523 | $preset = wpmtst_get_background_presets( $background['preset'] ); |
| 524 | $c1 = $preset['color']; |
| 525 | if ( isset( $preset['color2'] ) ) { |
| 526 | $c2 = $preset['color2']; |
| 527 | } |
| 528 | break; |
| 529 | case 'gradient': |
| 530 | $c1 = $background['gradient1']; |
| 531 | $c2 = $background['gradient2']; |
| 532 | break; |
| 533 | case 'single': |
| 534 | $c1 = $background['color']; |
| 535 | break; |
| 536 | default: |
| 537 | } |
| 538 | |
| 539 | // Special handling for Divi Builder |
| 540 | $prefix = ''; |
| 541 | $css = ''; |
| 542 | if ( $this->get_att( 'divi_builder' ) && wpmtst_divi_builder_active() ) { |
| 543 | $prefix = '#et_builder_outer_content '; |
| 544 | } |
| 545 | |
| 546 | $view_el = "$prefix.strong-view-id-{$this->get_att( 'view' )}"; |
| 547 | |
| 548 | // Includes special handling for Bold template. |
| 549 | if ( $c1 && $c2 ) { |
| 550 | |
| 551 | $gradient = self::gradient_rules( $c1, $c2 ); |
| 552 | |
| 553 | if ( $this->is_form() ) { |
| 554 | |
| 555 | $css = "$view_el .strong-form-inner { $gradient }"; |
| 556 | } else { |
| 557 | |
| 558 | $css = "$view_el .wpmtst-testimonial-inner { $gradient }"; |
| 559 | |
| 560 | if ( 'bold' === WPMST()->atts( 'template' ) ) { |
| 561 | $css .= "$view_el .readmore-page { background: $c2 }"; |
| 562 | } |
| 563 | } |
| 564 | } elseif ( $c1 ) { |
| 565 | if ( $this->is_form() ) { |
| 566 | $css = "{$view_el} .strong-form-inner { background: {$c1}; }"; |
| 567 | } else { |
| 568 | |
| 569 | $css = "$view_el .wpmtst-testimonial-inner { background: $c1; }"; |
| 570 | |
| 571 | if ( 'bold' === WPMST()->atts( 'template' ) ) { |
| 572 | $css .= "$view_el .readmore-page { background: $c1 }"; |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | if ( wp_style_is( $handle, 'done' ) ) { |
| 578 | echo '<style type="text/css" id="wpmtst-custom-style">' . $css . '</style>'; |
| 579 | } else { |
| 580 | wp_add_inline_style( $handle, $css ); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Print gradient rules. |
| 586 | * |
| 587 | * @param $c1 |
| 588 | * @param $c2 |
| 589 | * |
| 590 | * @return string |
| 591 | */ |
| 592 | public function gradient_rules( $c1, $c2 ) { |
| 593 | return "background: {$c1}; |
| 594 | background: -moz-linear-gradient(top, {$c1} 0%, {$c2} 100%); |
| 595 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, {$c1}), color-stop(100%, {$c2})); |
| 596 | background: -webkit-linear-gradient(top, {$c1} 0%, {$c2} 100%); |
| 597 | background: -o-linear-gradient(top, {$c1} 0%, {$c2} 100%); |
| 598 | background: -ms-linear-gradient(top, {$c1} 0%, {$c2} 100%); |
| 599 | background: linear-gradient(to bottom, {$c1} 0%, {$c2} 100%); |
| 600 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='{$c1}', endColorstr='{$c2}', GradientType=0);"; |
| 601 | } |
| 602 | |
| 603 | /** |
| 604 | * Stars |
| 605 | * |
| 606 | * @since 2.16.0 In Strong_View class. |
| 607 | */ |
| 608 | public function has_stars() { |
| 609 | if ( $this->get_att( 'client_section' ) ) { |
| 610 | foreach ( $this->get_att( 'client_section' ) as $field ) { |
| 611 | if ( 'rating' === $field['type'] ) { |
| 612 | WPMST()->render->add_style( 'wpmtst-rating-display' ); |
| 613 | break; |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | public function set_stylesheet( $handle = '' ) { |
| 620 | $this->stylesheet = $handle; |
| 621 | } |
| 622 | |
| 623 | public function get_stylesheet() { |
| 624 | return $this->stylesheet; |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | endif; |
| 629 |