PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 13.6.2
Jetpack – WP Security, Backup, Speed, & Growth v13.6.2
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 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7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3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.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 2 years ago content-options 2 years ago js 6 years ago responsive-videos 3 years ago site-logo 2 years ago social-menu 2 years ago content-options.php 2 years ago devicepx.php 2 years ago featured-content.php 2 years ago infinite-scroll.php 4 years ago random-redirect.php 2 years ago responsive-videos.php 2 years ago site-breadcrumbs.php 3 years ago site-logo.php 2 years ago social-links.php 2 years ago social-menu.php 4 years ago
featured-content.php
362 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
8 if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
9
10 /**
11 * Featured Content.
12 *
13 * This module will allow users to define a subset of posts to be displayed in a
14 * theme-designated featured content area.
15 *
16 * This feature will only be activated for themes that declare that they support
17 * it. This can be done by adding code similar to the following during the
18 * "after_setup_theme" action:
19 *
20 * add_theme_support( 'featured-content', array(
21 * 'filter' => 'mytheme_get_featured_content',
22 * 'max_posts' => 20,
23 * 'post_types' => array( 'post', 'page' ),
24 * ) );
25 *
26 * For maximum compatibility with different methods of posting users will
27 * designate a featured post tag to associate posts with. Since this tag now has
28 * special meaning beyond that of a normal tags, users will have the ability to
29 * hide it from the front-end of their site.
30 *
31 * @deprecated 13.6 Moved to Classic Theme Helper package.
32 */
33 class Featured_Content {
34 /**
35 * The maximum number of posts that a Featured Content area can contain. We
36 * define a default value here but themes can override this by defining a
37 * "max_posts" entry in the second parameter passed in the call to
38 * add_theme_support( 'featured-content' ).
39 *
40 * @deprecated 13.6 Moved to Classic Theme Helper package.
41 * @see Featured_Content::init()
42 * @var int
43 */
44 public static $max_posts = 15;
45
46 /**
47 * The registered post types supported by Featured Content. Themes can add
48 * Featured Content support for registered post types by defining a
49 * 'post_types' argument (string|array) in the call to
50 * add_theme_support( 'featured-content' ).
51 *
52 * @deprecated 13.6 Moved to Classic Theme Helper package.
53 * @see Featured_Content::init()
54 * @var array
55 */
56 public static $post_types = array( 'post' );
57
58 /**
59 * The tag that is used to mark featured content. Users can define
60 * a custom tag name that will be stored in this variable.
61 *
62 * @deprecated 13.6 Moved to Classic Theme Helper package.
63 * @see Featured_Content::hide_featured_term
64 * @var string
65 */
66 public static $tag;
67
68 /**
69 * Instantiate.
70 *
71 * All custom functionality will be hooked into the "init" action.
72 *
73 * @deprecated 13.6 Moved to Classic Theme Helper package.
74 */
75 public static function setup() {
76 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content::setup' );
77 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup();
78 }
79
80 /**
81 * Conditionally hook into WordPress.
82 *
83 * Themes must declare that they support this module by adding
84 * add_theme_support( 'featured-content' ); during after_setup_theme.
85 *
86 * If no theme support is found there is no need to hook into WordPress. We'll
87 * just return early instead.
88 *
89 * @deprecated 13.6 Moved to Classic Theme Helper package.
90 *
91 * @uses Featured_Content::$max_posts
92 */
93 public static function init() {
94 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\init' );
95 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::init();
96 }
97
98 /**
99 * Hide "featured" tag from the front-end.
100 *
101 * Has to run on wp_loaded so that the preview filters of the customizer
102 * have a chance to alter the value.
103 *
104 * @deprecated 13.6 Moved to Classic Theme Helper package.
105 */
106 public static function wp_loaded() {
107 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\wp_loaded' );
108 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::wp_loaded();
109 }
110
111 /**
112 * Get featured posts
113 *
114 * This method is not intended to be called directly. Theme developers should
115 * place a filter directly in their theme and then pass its name as a value of
116 * the "filter" key in the array passed as the $args parameter during the call
117 * to: add_theme_support( 'featured-content', $args ).
118 *
119 * @deprecated 13.6 Moved to Classic Theme Helper package.
120 * @uses Featured_Content::get_featured_post_ids()
121 *
122 * @return array
123 */
124 public static function get_featured_posts() {
125 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_featured_posts' );
126 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_featured_posts();
127 }
128
129 /**
130 * Get featured post IDs
131 *
132 * This function will return the an array containing the post IDs of all
133 * featured posts.
134 *
135 * Sets the "featured_content_ids" transient.
136 *
137 * @deprecated 13.6 Moved to Classic Theme Helper package.
138 * @return array Array of post IDs.
139 */
140 public static function get_featured_post_ids() {
141 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_featured_post_ids' );
142 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_featured_post_ids();
143 }
144
145 /**
146 * Delete Transient.
147 *
148 * Hooks in the "save_post" action.
149 *
150 * @deprecated 13.6 Moved to Classic Theme Helper package.
151 * @see Featured_Content::validate_settings().
152 */
153 public static function delete_transient() {
154 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\delete_transient' );
155 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::delete_transient();
156 }
157
158 /**
159 * Flush the Post Tag relationships cache.
160 *
161 * Hooks in the "update_option_featured-content" action.
162 *
163 * @deprecated 13.6 Moved to Classic Theme Helper package.
164 * @param array $prev Previous option data.
165 * @param array $opts New option data.
166 */
167 public static function flush_post_tag_cache( $prev, $opts ) {
168 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\flush_post_tag_cache' );
169 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::flush_post_tag_cache( $prev, $opts );
170 }
171
172 /**
173 * Exclude featured posts from the blog query when the blog is the front-page,
174 * and user has not checked the "Also display tagged posts outside the Featured Content area" checkbox.
175 *
176 * Filter the home page posts, and remove any featured post ID's from it.
177 * Hooked onto the 'pre_get_posts' action, this changes the parameters of the
178 * query before it gets any posts.
179 *
180 * @deprecated 13.6 Moved to Classic Theme Helper package.
181 * @uses Featured_Content::get_featured_post_ids();
182 * @uses Featured_Content::get_setting();
183 * @param WP_Query $query WP_Query object.
184 * @return WP_Query Possibly modified WP_Query
185 */
186 public static function pre_get_posts( $query ) {
187 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\pre_get_posts' );
188
189 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::pre_get_posts( $query );
190 }
191
192 /**
193 * Reset tag option when the saved tag is deleted.
194 *
195 * It's important to mention that the transient needs to be deleted, too.
196 * While it may not be obvious by looking at the function alone, the transient
197 * is deleted by Featured_Content::validate_settings().
198 *
199 * Hooks in the "delete_post_tag" action.
200 *
201 * @deprecated 13.6 Moved to Classic Theme Helper package.
202 * @see Featured_Content::validate_settings().
203 *
204 * @param int $tag_id The term_id of the tag that has been deleted.
205 * @return void
206 */
207 public static function delete_post_tag( $tag_id ) {
208 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\delete_post_tag' );
209 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::delete_post_tag( $tag_id );
210 }
211
212 /**
213 * Hide featured tag from displaying when global terms are queried from
214 * the front-end.
215 *
216 * Hooks into the "get_terms" filter.
217 *
218 * @deprecated 13.6 Moved to Classic Theme Helper package.
219 * @uses Featured_Content::get_setting()
220 *
221 * @param array $terms A list of term objects. This is the return value of get_terms().
222 * @param array $taxonomies An array of taxonomy slugs.
223 * @param array $args Array of get_terms() arguments.
224 * @return array $terms
225 */
226 public static function hide_featured_term( $terms, $taxonomies, $args ) {
227 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\hide_featured_term' );
228
229 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::hide_featured_term( $terms, $taxonomies, $args );
230 }
231
232 /**
233 * Hide featured tag from displaying when terms associated with a post object
234 * are queried from the front-end.
235 *
236 * Hooks into the "get_the_terms" filter.
237 *
238 * @deprecated 13.6 Moved to Classic Theme Helper package.
239 * @uses Featured_Content::get_setting()
240 *
241 * @param array $terms A list of term objects. This is the return value of get_the_terms().
242 * @param int $id The ID field for the post object that terms are associated with.
243 * @param array $taxonomy An array of taxonomy slugs.
244 * @return array $terms
245 */
246 public static function hide_the_featured_term( $terms, $id, $taxonomy ) {
247 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\hide_the_featured_term' );
248
249 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::hide_the_featured_term( $terms, $id, $taxonomy );
250 }
251
252 /**
253 * Register custom setting on the Settings -> Reading screen.
254 *
255 * @deprecated 13.6 Moved to Classic Theme Helper package.
256 * @uses Featured_Content::render_form()
257 * @uses Featured_Content::validate_settings()
258 *
259 * @return void
260 */
261 public static function register_setting() {
262 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\register_setting' );
263 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::register_setting();
264 }
265
266 /**
267 * Add settings to the Customizer.
268 *
269 * @deprecated 13.6 Moved to Classic Theme Helper package.
270 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
271 */
272 public static function customize_register( $wp_customize ) {
273 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\customize_register' );
274 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::customize_register( $wp_customize );
275 }
276
277 /**
278 * Enqueue the tag suggestion script.
279 *
280 * @deprecated 13.6 Moved to Classic Theme Helper package.
281 */
282 public static function enqueue_scripts() {
283 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\enqueue_scripts' );
284 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::enqueue_scripts();
285 }
286
287 /**
288 * Renders all form fields on the Settings -> Reading screen.
289 *
290 * @deprecated 13.6 Moved to Classic Theme Helper package.
291 */
292 public static function render_form() {
293 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\render_form' );
294 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::render_form();
295 }
296
297 /**
298 * Get settings
299 *
300 * Get all settings recognized by this module. This function will return all
301 * settings whether or not they have been stored in the database yet. This
302 * ensures that all keys are available at all times.
303 *
304 * In the event that you only require one setting, you may pass its name as the
305 * first parameter to the function and only that value will be returned.
306 *
307 * @deprecated 13.6 Moved to Classic Theme Helper package.
308 * @param string $key The key of a recognized setting.
309 * @return mixed Array of all settings by default. A single value if passed as first parameter.
310 */
311 public static function get_setting( $key = 'all' ) {
312 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\get_setting' );
313 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::get_setting( $key );
314 }
315
316 /**
317 * Validate settings
318 *
319 * Make sure that all user supplied content is in an expected format before
320 * saving to the database. This function will also delete the transient set in
321 * Featured_Content::get_featured_content().
322 *
323 * @deprecated 13.6 Moved to Classic Theme Helper package.
324 * @uses Featured_Content::delete_transient()
325 *
326 * @param array $input Array of settings input.
327 * @return array $output
328 */
329 public static function validate_settings( $input ) {
330 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\validate_settings' );
331 return Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::validate_settings( $input );
332 }
333
334 /**
335 * Removes the quantity setting from the options array.
336 *
337 * @deprecated 13.6 Moved to Classic Theme Helper package.
338 * @return void
339 */
340 public static function switch_theme() {
341 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\switch_theme' );
342 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::switch_theme();
343 }
344
345 /**
346 * Update Featured Content term data as necessary when a shared term is split.
347 *
348 * @deprecated 13.6 Moved to Classic Theme Helper package.
349 * @param int $old_term_id ID of the formerly shared term.
350 * @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
351 * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
352 * @param string $taxonomy Taxonomy for the split term.
353 */
354 public static function jetpack_update_featured_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
355 _deprecated_function( __METHOD__, 'jetpack-13.6', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Featured_Content\\jetpack_update_featured_content_for_split_terms' );
356 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::jetpack_update_featured_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy );
357 }
358 }
359
360 Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup();
361 }
362