PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/custom-post-types/testimonial.php +317 -832 13.3.316.3-a.1 View file →
@@ -4,921 +4,406 @@
4 4 *
5 5 * @package automattic/jetpack
6 6 *
7 7 * @phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
8 - * @phpcs:disable MediaWiki.Usage.NestedFunctions.NestedFunction
9 8 */
10 9
11 10 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
12 11
13 -/**
14 - * Add a Testimonial CPT, and display it with a shortcode
15 - */
16 -class Jetpack_Testimonial {
17 - const CUSTOM_POST_TYPE = 'jetpack-testimonial';
18 - const OPTION_NAME = 'jetpack_testimonial';
19 - const OPTION_READING_SETTING = 'jetpack_testimonial_posts_per_page';
20 -
12 +if ( ! class_exists( 'Jetpack_Testimonial' ) ) {
21 13 /**
22 - * Initialize class.
23 - *
24 - * @return self
14 + * Add a Testimonial CPT, and display it with a shortcode
25 15 */
26 - public static function init() {
27 - static $instance = false;
16 + class Jetpack_Testimonial {
28 17
29 - if ( ! $instance ) {
30 - $instance = new Jetpack_Testimonial();
31 - }
18 + /**
19 + * Store an instance of the new class
20 + *
21 + * @var Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial
22 + */
23 + protected $new_instance;
32 24
33 - return $instance;
34 - }
35 -
36 - /**
37 - * Conditionally hook into WordPress.
38 - *
39 - * Setup user option for enabling CPT.
40 - * If user has CPT enabled, show in admin.
41 - */
42 - public function __construct() {
43 - // Make sure the post types are loaded for imports
44 - add_action( 'import_start', array( $this, 'register_post_types' ) );
45 -
46 - // If called via REST API, we need to register later in lifecycle
47 - add_action( 'restapi_theme_init', array( $this, 'maybe_register_cpt' ) );
48 -
49 - // Add to REST API post type allowed list.
50 - add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_cpt_rest_api_type' ) );
51 -
52 - $this->maybe_register_cpt();
53 - }
54 -
55 - /**
56 - * Registers the custom post types and adds action/filter handlers, but
57 - * only if the site supports it
58 - */
59 - public function maybe_register_cpt() {
60 - // Add an option to enable the CPT
61 - add_action( 'admin_init', array( $this, 'settings_api_init' ) );
62 -
63 - // Check on theme switch if theme supports CPT and setting is disabled
64 - add_action( 'after_switch_theme', array( $this, 'activation_post_type_support' ) );
65 -
66 - $setting = Jetpack_Options::get_option_and_ensure_autoload( self::OPTION_NAME, '0' );
67 -
68 - // Bail early if Testimonial option is not set and the theme doesn't declare support
69 - if ( empty( $setting ) && ! $this->site_supports_custom_post_type() ) {
70 - return;
25 + /**
26 + * Initialize class.
27 + *
28 + * @deprecated 14.2 Moved to Classic Theme Helper package.
29 + */
30 + public static function init() {
31 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
32 + return Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial::init();
71 33 }
72 34
73 - if ( ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) && ! Jetpack::is_module_active( 'custom-content-types' ) ) {
74 - return;
35 + /**
36 + * Conditionally hook into WordPress.
37 + *
38 + * Setup user option for enabling CPT.
39 + * If user has CPT enabled, show in admin.
40 + */
41 + public function __construct() {
42 + $this->new_instance = new Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial();
75 43 }
76 44
77 - // CPT magic
78 - $this->register_post_types();
79 - add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
80 - add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
81 - add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'flush_rules_on_first_testimonial' ) );
82 - add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) );
83 -
84 - // Admin Customization
85 - add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
86 - add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE ), array( $this, 'edit_title_column_label' ) );
87 - add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
88 - if ( ! wp_is_block_theme() ) {
89 - add_action( 'customize_register', array( $this, 'customize_register' ) );
45 + /**
46 + * Forward all method calls to the Jetpack_Testimonial class.
47 + *
48 + * @param string $name The name of the method.
49 + * @param array $arguments The arguments to pass to the method.
50 + *
51 + * @throws Exception If the method is not found.
52 + */
53 + public function __call( $name, $arguments ) {
54 + if ( method_exists( $this->new_instance, $name ) ) {
55 + return call_user_func_array( array( $this->new_instance, $name ), $arguments );
56 + } else {
57 + // Handle cases where the method is not found
58 + throw new Exception( sprintf( 'Undefined method: %s', esc_html( $name ) ) );
59 + }
90 60 }
91 61
92 - // Only add the 'Customize' sub-menu if the theme supports it.
93 - if ( is_admin() && current_theme_supports( self::CUSTOM_POST_TYPE ) && ! empty( self::count_testimonials() ) ) {
94 - add_action( 'admin_menu', array( $this, 'add_customize_page' ) );
62 + /**
63 + * Forward all static method calls to the Jetpack_Testimonial class.
64 + *
65 + * @param string $name The name of the method.
66 + * @param array $arguments The arguments to pass to the method.
67 + *
68 + * @throws Exception If the method is not found.
69 + */
70 + public static function __callStatic( $name, $arguments ) {
71 + if ( method_exists( Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial::class, $name ) ) {
72 + return call_user_func_array( array( Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial::class, $name ), $arguments );
73 + } else {
74 + // Handle cases where the method is not found
75 + throw new Exception( sprintf( 'Undefined static method: %s', esc_html( $name ) ) );
76 + }
95 77 }
96 78
97 - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
98 - // Track all the things
99 - add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) );
100 - add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 );
101 - add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'new_testimonial_stat_bump' ) );
102 -
103 - // Add to Dotcom XML sitemaps
104 - add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
105 - } else {
106 - // Add to Jetpack XML sitemap
107 - add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
79 + /**
80 + * Registers the custom post types and adds action/filter handlers, but
81 + * only if the site supports it.
82 + *
83 + * @deprecated 14.2 Moved to Classic Theme Helper package.
84 + */
85 + public function maybe_register_cpt() {
86 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
87 + $this->new_instance->maybe_register_cpt();
108 88 }
109 89
110 - // Adjust CPT archive and custom taxonomies to obey CPT reading setting
111 - add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ), 20 );
112 - add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) );
113 -
114 - // Register [jetpack_testimonials] always and
115 - // register [testimonials] if [testimonials] isn't already set
116 - add_shortcode( 'jetpack_testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
117 -
118 - if ( ! shortcode_exists( 'testimonials' ) ) {
119 - add_shortcode( 'testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
90 + /**
91 + * Add a checkbox field in 'Settings' > 'Writing'
92 + * for enabling CPT functionality.
93 + *
94 + * @deprecated 14.2 Moved to Classic Theme Helper package.
95 + *
96 + * @return void
97 + */
98 + public function settings_api_init() {
99 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
100 + $this->new_instance->settings_api_init();
120 101 }
121 102
122 - // If CPT was enabled programatically and no CPT items exist when user switches away, disable
123 - if ( $setting && $this->site_supports_custom_post_type() ) {
124 - add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) );
103 + /**
104 + * HTML code to display a checkbox true/false option
105 + * for the CPT setting.
106 + *
107 + * @deprecated 14.2 Moved to Classic Theme Helper package.
108 + *
109 + * @return void
110 + */
111 + public function setting_html() {
112 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
113 + $this->new_instance->setting_html();
125 114 }
126 - }
127 115
128 - /**
129 - * Add a checkbox field in 'Settings' > 'Writing'
130 - * for enabling CPT functionality.
131 - *
132 - * @return void
133 - */
134 - public function settings_api_init() {
135 - add_settings_field(
136 - self::OPTION_NAME,
137 - '<span class="cpt-options">' . __( 'Testimonials', 'jetpack' ) . '</span>',
138 - array( $this, 'setting_html' ),
139 - 'writing',
140 - 'jetpack_cpt_section'
141 - );
142 -
143 - register_setting(
144 - 'writing',
145 - self::OPTION_NAME,
146 - 'intval'
147 - );
148 -
149 - // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering.
150 - if ( $this->site_supports_custom_post_type() ) {
151 - register_setting(
152 - 'writing',
153 - self::OPTION_READING_SETTING,
154 - 'intval'
155 - );
116 + /**
117 + * Add to REST API post type allowed list.
118 + *
119 + * @param array $post_types Array of allowed post types.
120 + * @return array `$post_types` with our type added.
121 + */
122 + public function allow_cpt_rest_api_type( $post_types ) {
123 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
124 + return $this->new_instance->allow_cpt_rest_api_type( $post_types );
156 125 }
157 - }
158 126
159 - /**
160 - * HTML code to display a checkbox true/false option
161 - * for the CPT setting.
162 - *
163 - * @return void
164 - */
165 - public function setting_html() {
166 - if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) : ?>
167 - <p><?php esc_html_e( 'Your theme supports Testimonials', 'jetpack' ); ?></p>
168 - <?php else : ?>
169 - <label for="<?php echo esc_attr( self::OPTION_NAME ); ?>">
170 - <input name="<?php echo esc_attr( self::OPTION_NAME ); ?>" id="<?php echo esc_attr( self::OPTION_NAME ); ?>" <?php echo checked( get_option( self::OPTION_NAME, '0' ), true, false ); ?> type="checkbox" value="1" />
171 - <?php esc_html_e( 'Enable Testimonials for this site.', 'jetpack' ); ?>
172 - <a target="_blank" href="https://en.support.wordpress.com/testimonials/"><?php esc_html_e( 'Learn More', 'jetpack' ); ?></a>
173 - </label>
174 - <?php
175 - endif;
176 -
177 - if ( $this->site_supports_custom_post_type() ) :
178 - printf(
179 - '<p><label for="%1$s">%2$s</label></p>',
180 - esc_attr( self::OPTION_READING_SETTING ),
181 - sprintf(
182 - /* translators: %1$s is replaced with an input field for numbers */
183 - esc_html__( 'Testimonial pages display at most %1$s testimonials', 'jetpack' ),
184 - sprintf(
185 - '<input name="%1$s" id="%1$s" type="number" step="1" min="1" value="%2$s" class="small-text" />',
186 - esc_attr( self::OPTION_READING_SETTING ),
187 - esc_attr( get_option( self::OPTION_READING_SETTING, '10' ) )
188 - )
189 - )
190 - );
191 - endif;
192 - }
193 -
194 - /**
195 - * Should this Custom Post Type be made available?
196 - */
197 - private function site_supports_custom_post_type() {
198 - // If the current theme requests it.
199 - if ( current_theme_supports( self::CUSTOM_POST_TYPE ) || get_option( self::OPTION_NAME, '0' ) ) {
200 - return true;
127 + /**
128 + * Bump Testimonial > New Activation stat
129 + *
130 + * @deprecated 14.2 Moved to Classic Theme Helper package.
131 + */
132 + public function new_activation_stat_bump() {
133 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
134 + $this->new_instance->new_activation_stat_bump();
201 135 }
202 136
203 - // Otherwise, say no unless something wants to filter us to say yes.
204 - /** This action is documented in modules/custom-post-types/nova.php */
205 - return (bool) apply_filters( 'jetpack_enable_cpt', false, self::CUSTOM_POST_TYPE );
206 - }
207 -
208 - /**
209 - * Add to REST API post type allowed list.
210 - *
211 - * @param array $post_types Array of allowed post types.
212 - * @return array `$post_types` with our type added.
213 - */
214 - public function allow_cpt_rest_api_type( $post_types ) {
215 - $post_types[] = self::CUSTOM_POST_TYPE;
216 -
217 - return $post_types;
218 - }
219 -
220 - /**
221 - * Bump Testimonial > New Activation stat
222 - */
223 - public function new_activation_stat_bump() {
224 - /** This action is documented in modules/widgets/social-media-icons.php */
225 - do_action( 'jetpack_bump_stats_extras', 'testimonials', 'new-activation' );
226 - }
227 -
228 - /**
229 - * Bump Testimonial > Option On/Off stats to get total active
230 - *
231 - * @param mixed $old The old option value.
232 - * @param mixed $new The new option value.
233 - */
234 - public function update_option_stat_bump( $old, $new ) {
235 - if ( empty( $old ) && ! empty( $new ) ) {
236 - /** This action is documented in modules/widgets/social-media-icons.php */
237 - do_action( 'jetpack_bump_stats_extras', 'testimonials', 'option-on' );
137 + /**
138 + * Bump Testimonial > Option On/Off stats to get total active
139 + *
140 + * @deprecated 14.2 Moved to Classic Theme Helper package.
141 + *
142 + * @param mixed $old The old option value.
143 + * @param mixed $new The new option value.
144 + */
145 + public function update_option_stat_bump( $old, $new ) {
146 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
147 + $this->new_instance->update_option_stat_bump( $old, $new );
238 148 }
239 149
240 - if ( ! empty( $old ) && empty( $new ) ) {
241 - /** This action is documented in modules/widgets/social-media-icons.php */
242 - do_action( 'jetpack_bump_stats_extras', 'testimonials', 'option-off' );
150 + /**
151 + * Bump Testimonial > Published Testimonials stat when testimonials are published
152 + *
153 + * @deprecated 14.2 Moved to Classic Theme Helper package.
154 + */
155 + public function new_testimonial_stat_bump() {
156 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
157 + $this->new_instance->new_testimonial_stat_bump();
243 158 }
244 - }
245 159
246 - /**
247 - * Bump Testimonial > Published Testimonials stat when testimonials are published
248 - */
249 - public function new_testimonial_stat_bump() {
250 - /** This action is documented in modules/widgets/social-media-icons.php */
251 - do_action( 'jetpack_bump_stats_extras', 'testimonials', 'published-testimonials' );
252 - }
253 -
254 - /**
255 - * Flush permalinks when CPT option is turned on/off
256 - */
257 - public function flush_rules_on_enable() {
258 - flush_rewrite_rules();
259 - }
260 -
261 - /**
262 - * Count published testimonials and flush permalinks when first testimonial is published
263 - */
264 - public function flush_rules_on_first_testimonial() {
265 - $testimonials = get_transient( 'jetpack-testimonial-count-cache' );
266 -
267 - if ( false === $testimonials ) {
268 - flush_rewrite_rules();
269 - $testimonials = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish;
270 -
271 - if ( ! empty( $testimonials ) ) {
272 - set_transient( 'jetpack-testimonial-count-cache', $testimonials, HOUR_IN_SECONDS * 12 );
273 - }
160 + /**
161 + * Flush permalinks when CPT option is turned on/off
162 + *
163 + * @deprecated 14.2 Moved to Classic Theme Helper package.
164 + */
165 + public function flush_rules_on_enable() {
166 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
167 + $this->new_instance->flush_rules_on_enable();
274 168 }
275 - }
276 169
277 - /**
278 - * Flush permalinks when CPT supported theme is activated
279 - */
280 - public function flush_rules_on_switch() {
281 - if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
282 - flush_rewrite_rules();
170 + /**
171 + * Count published testimonials and flush permalinks when first testimonial is published
172 + *
173 + * @deprecated 14.2 Moved to Classic Theme Helper package.
174 + */
175 + public function flush_rules_on_first_testimonial() {
176 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
177 + $this->new_instance->flush_rules_on_first_testimonial();
283 178 }
284 - }
285 179
286 - /**
287 - * On plugin/theme activation, check if current theme supports CPT
288 - */
289 - public static function activation_post_type_support() {
290 - if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
291 - update_option( self::OPTION_NAME, '1' );
180 + /**
181 + * Flush permalinks when CPT supported theme is activated
182 + *
183 + * @deprecated 14.2 Moved to Classic Theme Helper package.
184 + */
185 + public function flush_rules_on_switch() {
186 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
187 + $this->new_instance->flush_rules_on_switch();
292 188 }
293 - }
294 189
295 - /**
296 - * On theme switch, check if CPT item exists and disable if not
297 - */
298 - public function deactivation_post_type_support() {
299 - $portfolios = get_posts(
300 - array(
301 - 'fields' => 'ids',
302 - 'posts_per_page' => 1,
303 - 'post_type' => self::CUSTOM_POST_TYPE,
304 - 'suppress_filters' => false,
305 - )
306 - );
307 -
308 - if ( empty( $portfolios ) ) {
309 - update_option( self::OPTION_NAME, '0' );
190 + /**
191 + * On plugin/theme activation, check if current theme supports CPT
192 + *
193 + * @deprecated 14.2 Moved to Classic Theme Helper package.
194 + */
195 + public static function activation_post_type_support() {
196 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
197 + Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial::activation_post_type_support();
310 198 }
311 - }
312 199
313 - /**
314 - * Register Post Type
315 - */
316 - public function register_post_types() {
317 - if ( post_type_exists( self::CUSTOM_POST_TYPE ) ) {
318 - return;
200 + /**
201 + * On theme switch, check if CPT item exists and disable if not
202 + *
203 + * @deprecated 14.2 Moved to Classic Theme Helper package.
204 + */
205 + public function deactivation_post_type_support() {
206 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
207 + $this->new_instance->deactivation_post_type_support();
319 208 }
320 209
321 - register_post_type(
322 - self::CUSTOM_POST_TYPE,
323 - array(
324 - 'description' => __( 'Customer Testimonials', 'jetpack' ),
325 - 'labels' => array(
326 - 'name' => esc_html__( 'Testimonials', 'jetpack' ),
327 - 'singular_name' => esc_html__( 'Testimonial', 'jetpack' ),
328 - 'menu_name' => esc_html__( 'Testimonials', 'jetpack' ),
329 - 'all_items' => esc_html__( 'All Testimonials', 'jetpack' ),
330 - 'add_new' => esc_html__( 'Add New', 'jetpack' ),
331 - 'add_new_item' => esc_html__( 'Add New Testimonial', 'jetpack' ),
332 - 'edit_item' => esc_html__( 'Edit Testimonial', 'jetpack' ),
333 - 'new_item' => esc_html__( 'New Testimonial', 'jetpack' ),
334 - 'view_item' => esc_html__( 'View Testimonial', 'jetpack' ),
335 - 'search_items' => esc_html__( 'Search Testimonials', 'jetpack' ),
336 - 'not_found' => esc_html__( 'No Testimonials found', 'jetpack' ),
337 - 'not_found_in_trash' => esc_html__( 'No Testimonials found in Trash', 'jetpack' ),
338 - 'filter_items_list' => esc_html__( 'Filter Testimonials list', 'jetpack' ),
339 - 'items_list_navigation' => esc_html__( 'Testimonial list navigation', 'jetpack' ),
340 - 'items_list' => esc_html__( 'Testimonials list', 'jetpack' ),
341 - ),
342 - 'supports' => array(
343 - 'title',
344 - 'editor',
345 - 'thumbnail',
346 - 'page-attributes',
347 - 'revisions',
348 - 'excerpt',
349 - 'newspack_blocks',
350 - ),
351 - 'rewrite' => array(
352 - 'slug' => 'testimonial',
353 - 'with_front' => false,
354 - 'feeds' => false,
355 - 'pages' => true,
356 - ),
357 - 'public' => true,
358 - 'show_ui' => true,
359 - 'menu_position' => 20, // below Pages
360 - 'menu_icon' => 'dashicons-testimonial',
361 - 'capability_type' => 'page',
362 - 'map_meta_cap' => true,
363 - 'has_archive' => true,
364 - 'query_var' => 'testimonial',
365 - 'show_in_rest' => true,
366 - )
367 - );
368 - }
369 -
370 - /**
371 - * Update messages for the Testimonial admin.
372 - *
373 - * @param array $messages Existing post update messages.
374 - * @return array Updated `$messages`.
375 - */
376 - public function updated_messages( $messages ) {
377 - global $post;
378 -
379 - $messages[ self::CUSTOM_POST_TYPE ] = array(
380 - 0 => '', // Unused. Messages start at index 1.
381 - 1 => sprintf(
382 - /* Translators: link to Testimonial item's page. */
383 - __( 'Testimonial updated. <a href="%s">View testimonial</a>', 'jetpack' ),
384 - esc_url( get_permalink( $post->ID ) )
385 - ),
386 - 2 => esc_html__( 'Custom field updated.', 'jetpack' ),
387 - 3 => esc_html__( 'Custom field deleted.', 'jetpack' ),
388 - 4 => esc_html__( 'Testimonial updated.', 'jetpack' ),
389 - 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
390 - ? sprintf(
391 - /* translators: %s: date and time of the revision */
392 - esc_html__( 'Testimonial restored to revision from %s', 'jetpack' ),
393 - wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
394 - )
395 - : false,
396 - 6 => sprintf(
397 - /* Translators: link to Testimonial item's page. */
398 - __( 'Testimonial published. <a href="%s">View testimonial</a>', 'jetpack' ),
399 - esc_url( get_permalink( $post->ID ) )
400 - ),
401 - 7 => esc_html__( 'Testimonial saved.', 'jetpack' ),
402 - 8 => sprintf(
403 - /* Translators: link to Testimonial item's page. */
404 - __( 'Testimonial submitted. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack' ),
405 - esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
406 - ),
407 - 9 => sprintf(
408 - /* Translators: 1: Publishing date and time. 2. Link to testimonial's item page. */
409 - __( 'Testimonial scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview testimonial</a>', 'jetpack' ),
410 - // translators: Publish box date format, see https://php.net/date
411 - date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ),
412 - esc_url( get_permalink( $post->ID ) )
413 - ),
414 - 10 => sprintf(
415 - /* Translators: link to Testimonial item's page. */
416 - __( 'Testimonial draft updated. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack' ),
417 - esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
418 - ),
419 - );
420 -
421 - return $messages;
422 - }
423 -
424 - /**
425 - * Change ‘Enter Title Here’ text for the Testimonial.
426 - *
427 - * @param string $title Placeholder text. Default 'Add title'.
428 - * @return string Replacement title.
429 - */
430 - public function change_default_title( $title ) {
431 - if ( self::CUSTOM_POST_TYPE === get_post_type() ) {
432 - $title = esc_html__( "Enter the customer's name here", 'jetpack' );
210 + /**
211 + * Register Post Type
212 + *
213 + * @deprecated 14.2 Moved to Classic Theme Helper package.
214 + */
215 + public function register_post_types() {
216 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
217 + $this->new_instance->register_post_types();
433 218 }
434 219
435 - return $title;
436 - }
437 -
438 - /**
439 - * Change ‘Title’ column label on all Testimonials page.
440 - *
441 - * @param array $columns An array of column names.
442 - * @return array Updated array.
443 - */
444 - public function edit_title_column_label( $columns ) {
445 - $columns['title'] = esc_html__( 'Customer Name', 'jetpack' );
446 -
447 - return $columns;
448 - }
449 -
450 - /**
451 - * Follow CPT reading setting on CPT archive page
452 - *
453 - * @param WP_Query $query A WP_Query instance.
454 - */
455 - public function query_reading_setting( $query ) {
456 - if ( ! is_admin()
457 - && $query->is_main_query()
458 - && $query->is_post_type_archive( self::CUSTOM_POST_TYPE )
459 - ) {
460 - $query->set( 'posts_per_page', get_option( self::OPTION_READING_SETTING, '10' ) );
220 + /**
221 + * Update messages for the Testimonial admin.
222 + *
223 + * @deprecated 14.2 Moved to Classic Theme Helper package.
224 + *
225 + * @param array $messages Existing post update messages.
226 + * @return array Updated `$messages`.
227 + */
228 + public function updated_messages( $messages ) {
229 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
230 + return $this->new_instance->updated_messages( $messages );
461 231 }
462 - }
463 232
464 - /**
465 - * If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`.
466 - *
467 - * @param array $settings Array of Infinite Scroll settings.
468 - * @return array Updated `$settings`.
469 - */
470 - public function infinite_scroll_click_posts_per_page( $settings ) {
471 - global $wp_query;
472 -
473 - if ( ! is_admin() && true === $settings['click_handle'] && $wp_query->is_post_type_archive( self::CUSTOM_POST_TYPE ) ) {
474 - $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] ); // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
233 + /**
234 + * Change ‘Enter Title Here’ text for the Testimonial.
235 + *
236 + * @deprecated 14.2 Moved to Classic Theme Helper package.
237 + *
238 + * @param string $title Placeholder text. Default 'Add title'.
239 + * @return string Replacement title.
240 + */
241 + public function change_default_title( $title ) {
242 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
243 + return $this->new_instance->change_default_title( $title );
475 244 }
476 245
477 - return $settings;
478 - }
479 -
480 - /**
481 - * Add CPT to Dotcom sitemap
482 - *
483 - * @param array $post_types Array of post types included in sitemap.
484 - * @return array Updated `$post_types`.
485 - */
486 - public function add_to_sitemap( $post_types ) {
487 - $post_types[] = self::CUSTOM_POST_TYPE;
488 -
489 - return $post_types;
490 - }
491 -
492 - /**
493 - * Count the number of published testimonials.
494 - *
495 - * @return int
496 - */
497 - private function count_testimonials() {
498 - $testimonials = get_transient( 'jetpack-testimonial-count-cache' );
499 -
500 - if ( false === $testimonials ) {
501 - $testimonials = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish;
502 -
503 - if ( ! empty( $testimonials ) ) {
504 - set_transient( 'jetpack-testimonial-count-cache', $testimonials, 60 * 60 * 12 );
505 - }
246 + /**
247 + * Change ‘Title’ column label on all Testimonials page.
248 + *
249 + * @deprecated 14.2 Moved to Classic Theme Helper package.
250 + *
251 + * @param array $columns An array of column names.
252 + * @return array Updated array.
253 + */
254 + public function edit_title_column_label( $columns ) {
255 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
256 + return $this->new_instance->edit_title_column_label( $columns );
506 257 }
507 258
508 - return $testimonials;
509 - }
510 -
511 - /**
512 - * Adds a submenu link to the Customizer.
513 - */
514 - public function add_customize_page() {
515 - add_submenu_page(
516 - 'edit.php?post_type=' . self::CUSTOM_POST_TYPE,
517 - esc_html__( 'Customize Testimonials Archive', 'jetpack' ),
518 - esc_html__( 'Customize', 'jetpack' ),
519 - 'edit_theme_options',
520 - add_query_arg(
521 - array(
522 - 'url' => rawurlencode( home_url( '/testimonial/' ) ),
523 - 'autofocus[section]' => 'jetpack_testimonials',
524 - ),
525 - 'customize.php'
526 - )
527 - );
528 - }
529 -
530 - /**
531 - * Adds testimonial section to the Customizer.
532 - *
533 - * @param WP_Customize_Manager $wp_customize Customizer instance.
534 - */
535 - public function customize_register( $wp_customize ) {
536 - jetpack_testimonial_custom_control_classes();
537 -
538 - $wp_customize->add_section(
539 - 'jetpack_testimonials',
540 - array(
541 - 'title' => esc_html__( 'Testimonials', 'jetpack' ),
542 - 'theme_supports' => self::CUSTOM_POST_TYPE,
543 - 'priority' => 130,
544 - )
545 - );
546 -
547 - $wp_customize->add_setting(
548 - 'jetpack_testimonials[page-title]',
549 - array(
550 - 'default' => esc_html__( 'Testimonials', 'jetpack' ),
551 - 'sanitize_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
552 - 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
553 - )
554 - );
555 - $wp_customize->add_control(
556 - 'jetpack_testimonials[page-title]',
557 - array(
558 - 'section' => 'jetpack_testimonials',
559 - 'label' => esc_html__( 'Testimonial Archive Title', 'jetpack' ),
560 - 'type' => 'text',
561 - )
562 - );
563 -
564 - $wp_customize->add_setting(
565 - 'jetpack_testimonials[page-content]',
566 - array(
567 - 'default' => '',
568 - 'sanitize_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
569 - 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
570 - )
571 - );
572 - $wp_customize->add_control(
573 - new Jetpack_Testimonial_Textarea_Control(
574 - $wp_customize,
575 - 'jetpack_testimonials[page-content]',
576 - array(
577 - 'section' => 'jetpack_testimonials',
578 - 'settings' => 'jetpack_testimonials[page-content]',
579 - 'label' => esc_html__( 'Testimonial Archive Content', 'jetpack' ),
580 - )
581 - )
582 - );
583 -
584 - $wp_customize->add_setting(
585 - 'jetpack_testimonials[featured-image]',
586 - array(
587 - 'default' => '',
588 - 'sanitize_callback' => 'attachment_url_to_postid',
589 - 'sanitize_js_callback' => 'attachment_url_to_postid',
590 - 'theme_supports' => 'post-thumbnails',
591 - )
592 - );
593 - $wp_customize->add_control(
594 - new WP_Customize_Image_Control(
595 - $wp_customize,
596 - 'jetpack_testimonials[featured-image]',
597 - array(
598 - 'section' => 'jetpack_testimonials',
599 - 'label' => esc_html__( 'Testimonial Archive Featured Image', 'jetpack' ),
600 - )
601 - )
602 - );
603 -
604 - // The featured image control doesn't display properly in the Customizer unless we coerce
605 - // it back into a URL sooner, since that's what WP_Customize_Upload_Control::to_json() expects
606 - if ( is_admin() ) {
607 - add_filter( 'theme_mod_jetpack_testimonials', array( $this, 'coerce_testimonial_image_to_url' ) );
259 + /**
260 + * Follow CPT reading setting on CPT archive page
261 + *
262 + * @deprecated 14.2 Moved to Classic Theme Helper package.
263 + *
264 + * @param WP_Query $query A WP_Query instance.
265 + */
266 + public function query_reading_setting( $query ) {
267 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
268 + $this->new_instance->query_reading_setting( $query );
608 269 }
609 - }
610 270
611 - /**
612 - * Add Featured image to theme mod if necessary.
613 - *
614 - * @param array $opt The value of the current theme modification.
615 - * @return array Updated `$opt`.
616 - */
617 - public function coerce_testimonial_image_to_url( $opt ) {
618 - if ( ! $opt || ! is_array( $opt ) ) {
619 - return $opt;
271 + /**
272 + * If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`.
273 + *
274 + * @deprecated 14.2 Moved to Classic Theme Helper package.
275 + *
276 + * @param array $settings Array of Infinite Scroll settings.
277 + * @return array Updated `$settings`.
278 + */
279 + public function infinite_scroll_click_posts_per_page( $settings ) {
280 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
281 + return $this->new_instance->infinite_scroll_click_posts_per_page( $settings );
620 282 }
621 - if ( ! isset( $opt['featured-image'] ) || ! is_scalar( $opt['featured-image'] ) ) {
622 - return $opt;
623 - }
624 - $url = wp_get_attachment_url( $opt['featured-image'] );
625 - if ( $url ) {
626 - $opt['featured-image'] = $url;
627 - }
628 - return $opt;
629 - }
630 283
631 - /**
632 - * Our [testimonial] shortcode.
633 - * Prints Testimonial data styled to look good on *any* theme.
634 - *
635 - * @param array $atts Shortcode attributes.
636 - *
637 - * @return string HTML from `self::jetpack_testimonial_shortcode_html()`.
638 - */
639 - public static function jetpack_testimonial_shortcode( $atts ) {
640 - // Default attributes.
641 - $atts = shortcode_atts(
642 - array(
643 - 'display_content' => true, // Can be false, true, or full.
644 - 'image' => true,
645 - 'columns' => 1,
646 - 'showposts' => -1,
647 - 'order' => 'asc',
648 - 'orderby' => 'menu_order,date',
649 - ),
650 - $atts,
651 - 'testimonial'
652 - );
653 -
654 - // A little sanitization.
655 - if (
656 - $atts['display_content']
657 - && 'true' != $atts['display_content'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
658 - && 'full' !== $atts['display_content']
659 - ) {
660 - $atts['display_content'] = false;
284 + /**
285 + * Add CPT to Dotcom sitemap
286 + *
287 + * @deprecated 14.2 Moved to Classic Theme Helper package.
288 + *
289 + * @param array $post_types Array of post types included in sitemap.
290 + * @return array Updated `$post_types`.
291 + */
292 + public function add_to_sitemap( $post_types ) {
293 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
294 + return $this->new_instance->add_to_sitemap( $post_types );
661 295 }
662 296
663 - if ( $atts['image'] && 'true' != $atts['image'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
664 - $atts['image'] = false;
297 + /**
298 + * Adds a submenu link to the Customizer.
299 + *
300 + * @deprecated 14.2 Moved to Classic Theme Helper package.
301 + */
302 + public function add_customize_page() {
303 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
304 + $this->new_instance->add_customize_page();
665 305 }
666 306
667 - $atts['columns'] = absint( $atts['columns'] );
668 -
669 - $atts['showposts'] = (int) $atts['showposts'];
670 -
671 - if ( $atts['order'] ) {
672 - $atts['order'] = urldecode( $atts['order'] );
673 - $atts['order'] = strtoupper( $atts['order'] );
674 - if ( 'DESC' !== $atts['order'] ) {
675 - $atts['order'] = 'ASC';
676 - }
307 + /**
308 + * Adds testimonial section to the Customizer.
309 + *
310 + * @deprecated 14.2 Moved to Classic Theme Helper package.
311 + *
312 + * @param WP_Customize_Manager $wp_customize Customizer instance.
313 + */
314 + public function customize_register( $wp_customize ) {
315 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
316 + $this->new_instance->customize_register( $wp_customize );
677 317 }
678 318
679 - if ( $atts['orderby'] ) {
680 - $atts['orderby'] = urldecode( $atts['orderby'] );
681 - $atts['orderby'] = strtolower( $atts['orderby'] );
682 - $allowed_keys = array( 'author', 'date', 'title', 'menu_order', 'rand' );
683 -
684 - $parsed = array();
685 - foreach ( explode( ',', $atts['orderby'] ) as $orderby ) {
686 - if ( ! in_array( $orderby, $allowed_keys, true ) ) {
687 - continue;
688 - }
689 - $parsed[] = $orderby;
690 - }
691 -
692 - if ( empty( $parsed ) ) {
693 - unset( $atts['orderby'] );
694 - } else {
695 - $atts['orderby'] = implode( ' ', $parsed );
696 - }
319 + /**
320 + * Add Featured image to theme mod if necessary.
321 + *
322 + * @deprecated 14.2 Moved to Classic Theme Helper package.
323 + *
324 + * @param array $opt The value of the current theme modification.
325 + * @return array Updated `$opt`.
326 + */
327 + public function coerce_testimonial_image_to_url( $opt ) {
328 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
329 + return $this->new_instance->coerce_testimonial_image_to_url( $opt );
697 330 }
698 331
699 - // enqueue shortcode styles when shortcode is used
700 - if ( ! wp_style_is( 'jetpack-testimonial-style', 'enqueued' ) ) {
701 - wp_enqueue_style( 'jetpack-testimonial-style', plugins_url( 'css/testimonial-shortcode.css', __FILE__ ), array(), '20140326' );
702 - }
703 -
704 - return self::jetpack_testimonial_shortcode_html( $atts );
705 - }
706 -
707 - /**
708 - * The Testimonial shortcode loop.
709 - *
710 - * @param array $atts Shortcode attributes.
711 - *
712 - * @return string html
713 - */
714 - private static function jetpack_testimonial_shortcode_html( $atts ) {
715 - // Default query arguments
716 - $defaults = array(
717 - 'order' => $atts['order'],
718 - 'orderby' => $atts['orderby'],
719 - 'posts_per_page' => $atts['showposts'],
720 - );
721 -
722 - $args = wp_parse_args( $atts, $defaults );
723 - $args['post_type'] = self::CUSTOM_POST_TYPE; // Force this post type
724 - $query = new WP_Query( $args );
725 -
726 - $testimonial_index_number = 0;
727 -
728 - ob_start();
729 -
730 - // If we have testimonials, create the html
731 - if ( $query->have_posts() ) {
732 -
733 - ?>
734 - <div class="jetpack-testimonial-shortcode column-<?php echo esc_attr( $atts['columns'] ); ?>">
735 - <?php
736 - // Construct the loop...
737 - while ( $query->have_posts() ) {
738 - $query->the_post();
739 - $post_id = get_the_ID();
740 - ?>
741 - <div class="testimonial-entry <?php echo esc_attr( self::get_testimonial_class( $testimonial_index_number, $atts['columns'], has_post_thumbnail( $post_id ) ) ); ?>">
742 - <?php
743 - // The content
744 - if ( false !== $atts['display_content'] ) {
745 - if ( 'full' === $atts['display_content'] ) {
746 - ?>
747 - <div class="testimonial-entry-content"><?php the_content(); ?></div>
748 - <?php
749 - } else {
750 - ?>
751 - <div class="testimonial-entry-content"><?php the_excerpt(); ?></div>
752 - <?php
753 - }
754 - }
755 - ?>
756 - <span class="testimonial-entry-title">&#8213; <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>"><?php the_title(); ?></a></span>
757 - <?php
758 - // Featured image
759 - if ( false !== $atts['image'] ) :
760 - echo self::get_testimonial_thumbnail_link( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
761 - endif;
762 - ?>
763 - </div><!-- close .testimonial-entry -->
764 - <?php
765 - ++$testimonial_index_number;
766 - } // end of while loop
767 -
768 - wp_reset_postdata();
769 - ?>
770 - </div><!-- close .jetpack-testimonial-shortcode -->
771 - <?php
772 - } else {
773 - ?>
774 - <p><em><?php esc_html_e( 'Your Testimonial Archive currently has no entries. You can start creating them on your dashboard.', 'jetpack' ); ?></p></em>
775 - <?php
776 - }
777 - $html = ob_get_clean();
778 -
779 - // Return the HTML block
780 - return $html;
781 - }
782 -
783 - /**
784 - * Individual testimonial class
785 - *
786 - * @param int $testimonial_index_number iterator count the number of columns up starting from 0.
787 - * @param int $columns number of columns to display the content in.
788 - * @param bool $image has a thumbnail or not.
789 - *
790 - * @return string
791 - */
792 - private static function get_testimonial_class( $testimonial_index_number, $columns, $image ) {
793 - $class = array();
794 -
795 - $class[] = 'testimonial-entry-column-' . $columns;
796 -
797 - if ( $columns > 1 ) {
798 - if ( ( $testimonial_index_number % 2 ) === 0 ) {
799 - $class[] = 'testimonial-entry-mobile-first-item-row';
800 - } else {
801 - $class[] = 'testimonial-entry-mobile-last-item-row';
802 - }
803 - }
804 -
805 - // add first and last classes to first and last items in a row
806 - if ( ( $testimonial_index_number % $columns ) === 0 ) {
807 - $class[] = 'testimonial-entry-first-item-row';
808 - } elseif ( ( $testimonial_index_number % $columns ) === ( $columns - 1 ) ) {
809 - $class[] = 'testimonial-entry-last-item-row';
810 - }
811 -
812 - // add class if testimonial has a featured image
813 - if ( false !== $image ) {
814 - $class[] = 'has-testimonial-thumbnail';
815 - }
816 -
817 332 /**
818 - * Filter the class applied to testimonial div in the testimonial
333 + * Our [testimonial] shortcode.
334 + * Prints Testimonial data styled to look good on *any* theme.
819 335 *
820 - * @module custom-content-types
336 + * @deprecated 14.2 Moved to Classic Theme Helper package.
821 337 *
822 - * @since 3.4.0
338 + * @param array $atts Shortcode attributes.
823 339 *
824 - * @param string $class class name of the div.
825 - * @param int $testimonial_index_number iterator count the number of columns up starting from 0.
826 - * @param int $columns number of columns to display the content in.
827 - * @param boolean $image has a thumbnail or not.
340 + * @return string HTML from `self::jetpack_testimonial_shortcode_html()`.
828 341 */
829 - return apply_filters( 'testimonial-entry-post-class', implode( ' ', $class ), $testimonial_index_number, $columns, $image ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
342 + public static function jetpack_testimonial_shortcode( $atts ) {
343 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
344 + return Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial::jetpack_testimonial_shortcode( $atts );
345 + }
830 346 }
831 347
832 348 /**
833 - * Display the featured image if it's available
349 + * Additional Testimonial customizer options.
834 350 *
835 - * @param int $post_id Post ID.
836 - *
837 - * @return string html
351 + * @deprecated 14.2 Moved to Classic Theme Helper package.
838 352 */
839 - private static function get_testimonial_thumbnail_link( $post_id ) {
840 - if ( has_post_thumbnail( $post_id ) ) {
353 + function jetpack_testimonial_custom_control_classes() {
354 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
355 + /**
356 + * Clean the title parameter.
357 + */
358 + class Jetpack_Testimonial_Title_Control extends WP_Customize_Control {
841 359 /**
842 - * Change the thumbnail size for the Testimonial CPT.
360 + * Sanitize content passed to control.
843 361 *
844 - * @module custom-content-types
362 + * @deprecated 14.2 Moved to Classic Theme Helper package.
845 363 *
846 - * @since 3.4.0
847 - *
848 - * @param string|array $var Either a registered size keyword or size array.
364 + * @param string $value Control value.
365 + * @return string Sanitized value.
849 366 */
850 - return '<a class="testimonial-featured-image" href="' . esc_url( get_permalink( $post_id ) ) . '">' . get_the_post_thumbnail( $post_id, apply_filters( 'jetpack_testimonial_thumbnail_size', 'thumbnail' ) ) . '</a>';
851 - }
852 - }
853 -}
854 -
855 -/**
856 - * Additional Testimonial customizer options.
857 - */
858 -function jetpack_testimonial_custom_control_classes() {
859 - /**
860 - * Clean the title parameter.
861 - */
862 - class Jetpack_Testimonial_Title_Control extends WP_Customize_Control {
863 - /**
864 - * Sanitize content passed to control.
865 - *
866 - * @param string $value Control value.
867 - * @return string Sanitized value.
868 - */
869 - public static function sanitize_content( $value ) {
870 - if ( '' != $value ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
871 - $value = trim( convert_chars( wptexturize( $value ) ) );
367 + public static function sanitize_content( $value ) {
368 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
369 + return Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial_Title_Control::sanitize_content( $value );
872 370 }
873 -
874 - return $value;
875 371 }
876 - }
877 372
878 - /**
879 - * Clean textarea content.
880 - */
881 - class Jetpack_Testimonial_Textarea_Control extends WP_Customize_Control {
882 373 /**
883 - * Control type.
884 - *
885 - * @var string
374 + * Clean textarea content.
886 375 */
887 - public $type = 'textarea';
376 + class Jetpack_Testimonial_Textarea_Control extends WP_Customize_Control {
377 + /**
378 + * Control type.
379 + *
380 + * @var string
381 + */
382 + public $type = 'textarea';
888 383
889 - /**
890 - * Render the control's content.
891 - */
892 - public function render_content() {
893 - ?>
894 - <label>
895 - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
896 - <textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
897 - </label>
898 - <?php
899 - }
384 + /**
385 + * Render the control's content.
386 + *
387 + * @deprecated 14.2 Moved to Classic Theme Helper package.
388 + */
389 + public function render_content() {
390 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
391 + $testimonial_textarea_control = new Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial_Textarea_Control( $this->manager, $this->id, $this->args );
392 + $testimonial_textarea_control->render_content();
393 + }
900 394
901 - /**
902 - * Sanitize content passed to control.
903 - *
904 - * @param string $value Control value.
905 - * @return string Sanitized value.
906 - */
907 - public static function sanitize_content( $value ) {
908 - if ( ! empty( $value ) ) {
909 - /** This filter is already documented in core. wp-includes/post-template.php */
910 - $value = apply_filters( 'the_content', $value );
395 + /**
396 + * Sanitize content passed to control.
397 + *
398 + * @deprecated 14.2 Moved to Classic Theme Helper package.
399 + *
400 + * @param string $value Control value.
401 + * @return string Sanitized value.
402 + */
403 + public static function sanitize_content( $value ) {
404 + _deprecated_function( __FUNCTION__, 'jetpack-14.2' );
405 + return Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial_Textarea_Control::sanitize_content( $value );
911 406 }
912 -
913 - $value = preg_replace( '@<div id="jp-post-flair"([^>]+)?>(.+)?</div>@is', '', $value ); // Strip WPCOM and Jetpack post flair if included in content
914 -
915 - return $value;
916 407 }
917 408 }
918 409 }
919 -
920 -add_action( 'init', array( 'Jetpack_Testimonial', 'init' ) );
921 -
922 -// Check on plugin activation if theme supports CPT
923 -register_activation_hook( __FILE__, array( 'Jetpack_Testimonial', 'activation_post_type_support' ) );
924 -add_action( 'jetpack_activate_module_custom-content-types', array( 'Jetpack_Testimonial', 'activation_post_type_support' ) );