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.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / theme-tools / featured-content.php
jetpack / modules / theme-tools Last commit date
compat 1 month ago content-options 2 weeks ago js 5 years ago responsive-videos 1 year ago site-logo 7 months ago social-menu 1 month ago content-options.php 7 months ago featured-content.php 7 months ago responsive-videos.php 7 months ago site-breadcrumbs.php 1 year ago site-logo.php 7 months ago social-links.php 7 months ago social-menu.php 7 months ago
featured-content.php
365 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Theme Tools: functions for Featured Content enhancements.
4 *
5 * @package automattic/jetpack
6 */
7 use Automattic\Jetpack\Status\Host;
8
9 if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
10
11 /**
12 * Featured Content.
13 *
14 * This module will allow users to define a subset of posts to be displayed in a
15 * theme-designated featured content area.
16 *
17 * This feature will only be activated for themes that declare that they support
18 * it. This can be done by adding code similar to the following during the
19 * "after_setup_theme" action:
20 *
21 * add_theme_support( 'featured-content', array(
22 * 'filter' => 'mytheme_get_featured_content',
23 * 'max_posts' => 20,
24 * 'post_types' => array( 'post', 'page' ),
25 * ) );
26 *
27 * For maximum compatibility with different methods of posting users will
28 * designate a featured post tag to associate posts with. Since this tag now has
29 * special meaning beyond that of a normal tags, users will have the ability to
30 * hide it from the front-end of their site.
31 *
32 * @deprecated 13.6 Moved to Classic Theme Helper package.
33 */
34 class Featured_Content {
35 /**
36 * The maximum number of posts that a Featured Content area can contain. We
37 * define a default value here but themes can override this by defining a
38 * "max_posts" entry in the second parameter passed in the call to
39 * add_theme_support( 'featured-content' ).
40 *
41 * @deprecated 13.6 Moved to Classic Theme Helper package.
42 * @see Featured_Content::init()
43 * @var int
44 */
45 public static $max_posts = 15;
46
47 /**
48 * The registered post types supported by Featured Content. Themes can add
49 * Featured Content support for registered post types by defining a
50 * 'post_types' argument (string|array) in the call to
51 * add_theme_support( 'featured-content' ).
52 *
53 * @deprecated 13.6 Moved to Classic Theme Helper package.
54 * @see Featured_Content::init()
55 * @var array
56 */
57 public static $post_types = array( 'post' );
58
59 /**
60 * The tag that is used to mark featured content. Users can define
61 * a custom tag name that will be stored in this variable.
62 *
63 * @deprecated 13.6 Moved to Classic Theme Helper package.
64 * @see Featured_Content::hide_featured_term
65 * @var string
66 */
67 public static $tag;
68
69 /**
70 * Instantiate.
71 *
72 * All custom functionality will be hooked into the "init" action.
73 *
74 * @deprecated 13.6 Moved to Classic Theme Helper package.
75 */
76 public static function setup() {
77 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content::setup' );
78 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup();
79 }
80
81 /**
82 * Conditionally hook into WordPress.
83 *
84 * Themes must declare that they support this module by adding
85 * add_theme_support( 'featured-content' ); during after_setup_theme.
86 *
87 * If no theme support is found there is no need to hook into WordPress. We'll
88 * just return early instead.
89 *
90 * @deprecated 13.6 Moved to Classic Theme Helper package.
91 *
92 * @uses Featured_Content::$max_posts
93 */
94 public static function init() {
95 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\init' );
96 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::init();
97 }
98
99 /**
100 * Hide "featured" tag from the front-end.
101 *
102 * Has to run on wp_loaded so that the preview filters of the customizer
103 * have a chance to alter the value.
104 *
105 * @deprecated 13.6 Moved to Classic Theme Helper package.
106 */
107 public static function wp_loaded() {
108 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\wp_loaded' );
109 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::wp_loaded();
110 }
111
112 /**
113 * Get featured posts
114 *
115 * This method is not intended to be called directly. Theme developers should
116 * place a filter directly in their theme and then pass its name as a value of
117 * the "filter" key in the array passed as the $args parameter during the call
118 * to: add_theme_support( 'featured-content', $args ).
119 *
120 * @deprecated 13.6 Moved to Classic Theme Helper package.
121 * @uses Featured_Content::get_featured_post_ids()
122 *
123 * @return array
124 */
125 public static function get_featured_posts() {
126 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_featured_posts' );
127 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_featured_posts();
128 }
129
130 /**
131 * Get featured post IDs
132 *
133 * This function will return the an array containing the post IDs of all
134 * featured posts.
135 *
136 * Sets the "featured_content_ids" transient.
137 *
138 * @deprecated 13.6 Moved to Classic Theme Helper package.
139 * @return array Array of post IDs.
140 */
141 public static function get_featured_post_ids() {
142 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_featured_post_ids' );
143 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_featured_post_ids();
144 }
145
146 /**
147 * Delete Transient.
148 *
149 * Hooks in the "save_post" action.
150 *
151 * @deprecated 13.6 Moved to Classic Theme Helper package.
152 * @see Featured_Content::validate_settings().
153 */
154 public static function delete_transient() {
155 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\delete_transient' );
156 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::delete_transient();
157 }
158
159 /**
160 * Flush the Post Tag relationships cache.
161 *
162 * Hooks in the "update_option_featured-content" action.
163 *
164 * @deprecated 13.6 Moved to Classic Theme Helper package.
165 * @param array $prev Previous option data.
166 * @param array $opts New option data.
167 */
168 public static function flush_post_tag_cache( $prev, $opts ) {
169 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\flush_post_tag_cache' );
170 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::flush_post_tag_cache( $prev, $opts );
171 }
172
173 /**
174 * Exclude featured posts from the blog query when the blog is the front-page,
175 * and user has not checked the "Also display tagged posts outside the Featured Content area" checkbox.
176 *
177 * Filter the home page posts, and remove any featured post ID's from it.
178 * Hooked onto the 'pre_get_posts' action, this changes the parameters of the
179 * query before it gets any posts.
180 *
181 * @deprecated 13.6 Moved to Classic Theme Helper package.
182 * @uses Featured_Content::get_featured_post_ids();
183 * @uses Featured_Content::get_setting();
184 * @param WP_Query $query WP_Query object.
185 * @return WP_Query Possibly modified WP_Query
186 */
187 public static function pre_get_posts( $query ) {
188 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\pre_get_posts' );
189
190 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::pre_get_posts( $query );
191 }
192
193 /**
194 * Reset tag option when the saved tag is deleted.
195 *
196 * It's important to mention that the transient needs to be deleted, too.
197 * While it may not be obvious by looking at the function alone, the transient
198 * is deleted by Featured_Content::validate_settings().
199 *
200 * Hooks in the "delete_post_tag" action.
201 *
202 * @deprecated 13.6 Moved to Classic Theme Helper package.
203 * @see Featured_Content::validate_settings().
204 *
205 * @param int $tag_id The term_id of the tag that has been deleted.
206 * @return void
207 */
208 public static function delete_post_tag( $tag_id ) {
209 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\delete_post_tag' );
210 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::delete_post_tag( $tag_id );
211 }
212
213 /**
214 * Hide featured tag from displaying when global terms are queried from
215 * the front-end.
216 *
217 * Hooks into the "get_terms" filter.
218 *
219 * @deprecated 13.6 Moved to Classic Theme Helper package.
220 * @uses Featured_Content::get_setting()
221 *
222 * @param array $terms A list of term objects. This is the return value of get_terms().
223 * @param array $taxonomies An array of taxonomy slugs.
224 * @param array $args Array of get_terms() arguments.
225 * @return array $terms
226 */
227 public static function hide_featured_term( $terms, $taxonomies, $args ) {
228 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\hide_featured_term' );
229
230 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::hide_featured_term( $terms, $taxonomies, $args );
231 }
232
233 /**
234 * Hide featured tag from displaying when terms associated with a post object
235 * are queried from the front-end.
236 *
237 * Hooks into the "get_the_terms" filter.
238 *
239 * @deprecated 13.6 Moved to Classic Theme Helper package.
240 * @uses Featured_Content::get_setting()
241 *
242 * @param \WP_Term[]|\WP_Error $terms A list of term objects. This is the return value of get_the_terms().
243 * @param int $id The ID field for the post object that terms are associated with.
244 * @param string $taxonomy The slug of the taxonomy.
245 * @return \WP_Term[]|\WP_Error $terms
246 */
247 public static function hide_the_featured_term( $terms, $id, $taxonomy ) {
248 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\hide_the_featured_term' );
249
250 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::hide_the_featured_term( $terms, $id, $taxonomy );
251 }
252
253 /**
254 * Register custom setting on the Settings -> Reading screen.
255 *
256 * @deprecated 13.6 Moved to Classic Theme Helper package.
257 * @uses Featured_Content::render_form()
258 * @uses Featured_Content::validate_settings()
259 *
260 * @return void
261 */
262 public static function register_setting() {
263 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\register_setting' );
264 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::register_setting();
265 }
266
267 /**
268 * Add settings to the Customizer.
269 *
270 * @deprecated 13.6 Moved to Classic Theme Helper package.
271 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
272 */
273 public static function customize_register( $wp_customize ) {
274 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\customize_register' );
275 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::customize_register( $wp_customize );
276 }
277
278 /**
279 * Enqueue the tag suggestion script.
280 *
281 * @deprecated 13.6 Moved to Classic Theme Helper package.
282 */
283 public static function enqueue_scripts() {
284 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\enqueue_scripts' );
285 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::enqueue_scripts();
286 }
287
288 /**
289 * Renders all form fields on the Settings -> Reading screen.
290 *
291 * @deprecated 13.6 Moved to Classic Theme Helper package.
292 */
293 public static function render_form() {
294 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\render_form' );
295 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::render_form();
296 }
297
298 /**
299 * Get settings
300 *
301 * Get all settings recognized by this module. This function will return all
302 * settings whether or not they have been stored in the database yet. This
303 * ensures that all keys are available at all times.
304 *
305 * In the event that you only require one setting, you may pass its name as the
306 * first parameter to the function and only that value will be returned.
307 *
308 * @deprecated 13.6 Moved to Classic Theme Helper package.
309 * @param string $key The key of a recognized setting.
310 * @return mixed Array of all settings by default. A single value if passed as first parameter.
311 */
312 public static function get_setting( $key = 'all' ) {
313 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_setting' );
314 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_setting( $key );
315 }
316
317 /**
318 * Validate settings
319 *
320 * Make sure that all user supplied content is in an expected format before
321 * saving to the database. This function will also delete the transient set in
322 * Featured_Content::get_featured_content().
323 *
324 * @deprecated 13.6 Moved to Classic Theme Helper package.
325 * @uses Featured_Content::delete_transient()
326 *
327 * @param array $input Array of settings input.
328 * @return array $output
329 */
330 public static function validate_settings( $input ) {
331 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\validate_settings' );
332 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::validate_settings( $input );
333 }
334
335 /**
336 * Removes the quantity setting from the options array.
337 *
338 * @deprecated 13.6 Moved to Classic Theme Helper package.
339 * @return void
340 */
341 public static function switch_theme() {
342 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\switch_theme' );
343 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::switch_theme();
344 }
345
346 /**
347 * Update Featured Content term data as necessary when a shared term is split.
348 *
349 * @deprecated 13.6 Moved to Classic Theme Helper package.
350 * @param int $old_term_id ID of the formerly shared term.
351 * @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
352 * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
353 * @param string $taxonomy Taxonomy for the split term.
354 */
355 public static function jetpack_update_featured_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
356 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\jetpack_update_featured_content_for_split_terms' );
357 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::jetpack_update_featured_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy );
358 }
359 }
360
361 if ( ! ( new Host() )->is_wpcom_platform() ) {
362 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup();
363 }
364 }
365