PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
5.1.1 5.1.0 5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 All 240 releases
ultimate-post / includes / notice / types / class-content-notice.php

class-content-notice.php in Post Grid Gutenberg Blocks – PostX 5.1.1, at includes/notice/types/class-content-notice.php

68 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Text and button notice.
4 *
5 * @package ULTP\Notice
6 */
7
8 namespace ULTP\Includes\Notice;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Standard admin notice: icon, a heading with an offer line, and an upgrade button.
14 */
15 class Content_Notice extends Abstract_Campaign_Notice {
16
17 /**
18 * Template views/content.php.
19 */
20 const VIEW = 'content';
21
22 /**
23 * Content notice settings.
24 *
25 * @return array
26 */
27 protected function get_defaults() {
28 return array_merge(
29 parent::get_defaults(),
30 array(
31 'utm_key' => 'content_notice',
32 'content_heading' => '',
33 'content_subheading' => '', // May contain one %s, replaced by `discount_content` in bold.
34 'discount_content' => '',
35 'border_color' => '#0322ff',
36 'icon' => '',
37 'is_discount_logo' => false, // true: square discount logo and outline button.
38 'button_text' => __( 'Upgrade Now!', 'ultimate-post' ),
39 'background_color' => '', // Button colour when is_discount_logo is false.
40 )
41 );
42 }
43
44 /**
45 * The offer line with `discount_content` in bold in place of its %s.
46 *
47 * The line is usually translated, and on PHP 8 a stray % or an extra placeholder in a
48 * translation makes sprintf() throw. Fall back to a plain replacement instead.
49 *
50 * @return string Safe HTML.
51 */
52 public function get_subheading_html() {
53 $format = wp_kses_post( (string) $this->get( 'content_subheading' ) );
54 $discount = '<strong>' . esc_html( $this->get( 'discount_content' ) ) . '</strong>';
55
56 try {
57 $html = sprintf( $format, $discount );
58 } catch ( \Throwable $e ) {
59 $html = false;
60 }
61
62 if ( false === $html ) { // PHP 7.4 returns false instead of throwing.
63 $html = str_replace( array( '%1$s', '%s' ), $discount, $format );
64 }
65 return $html;
66 }
67 }
68