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