summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:14:18 -0500
committerAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:14:18 -0500
commitc00d17bd8b26b20be39ada518d07bb5a07478b29 (patch)
treeacd2e2e9f27dd228d918fce844077a22a7acdf33 /themes/twentyfourteen/inc/featured-content.php
parentUpdate jetpack 6.3.2 (diff)
downloadblogs-gentoo-c00d17bd8b26b20be39ada518d07bb5a07478b29.tar.gz
blogs-gentoo-c00d17bd8b26b20be39ada518d07bb5a07478b29.tar.bz2
blogs-gentoo-c00d17bd8b26b20be39ada518d07bb5a07478b29.zip
Update twentyfourteen 2.4
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'themes/twentyfourteen/inc/featured-content.php')
-rw-r--r--themes/twentyfourteen/inc/featured-content.php161
1 files changed, 90 insertions, 71 deletions
diff --git a/themes/twentyfourteen/inc/featured-content.php b/themes/twentyfourteen/inc/featured-content.php
index 808a8a74..ffeb993d 100644
--- a/themes/twentyfourteen/inc/featured-content.php
+++ b/themes/twentyfourteen/inc/featured-content.php
@@ -23,6 +23,8 @@ class Featured_Content {
*
* @since Twenty Fourteen 1.0
*
+ * @static
+ * @access public
* @var int
*/
public static $max_posts = 15;
@@ -32,6 +34,8 @@ class Featured_Content {
*
* All custom functionality will be hooked into the "init" action.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function setup() {
@@ -47,6 +51,8 @@ class Featured_Content {
* If no theme support is found there is no need to hook into WordPress.
* We'll just return early instead.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function init() {
@@ -77,15 +83,15 @@ class Featured_Content {
self::$max_posts = absint( $theme_support[0]['max_posts'] );
}
- add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
- add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 );
- add_action( 'admin_init', array( __CLASS__, 'register_setting' ) );
- add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) );
- add_action( 'save_post', array( __CLASS__, 'delete_transient' ) );
- add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) );
- add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
- add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
- add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) );
+ add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
+ add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 );
+ add_action( 'admin_init', array( __CLASS__, 'register_setting' ) );
+ add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) );
+ add_action( 'save_post', array( __CLASS__, 'delete_transient' ) );
+ add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) );
+ add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
+ add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
+ add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) );
}
/**
@@ -94,11 +100,13 @@ class Featured_Content {
* Has to run on wp_loaded so that the preview filters of the Customizer
* have a chance to alter the value.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function wp_loaded() {
if ( self::get_setting( 'hide-tag' ) ) {
- add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 );
+ add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 );
add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 );
}
}
@@ -106,6 +114,8 @@ class Featured_Content {
/**
* Get featured posts.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @return array Array of featured posts.
@@ -118,12 +128,10 @@ class Featured_Content {
return array();
}
- $featured_posts = get_posts(
- array(
- 'include' => $post_ids,
- 'posts_per_page' => count( $post_ids ),
- )
- );
+ $featured_posts = get_posts( array(
+ 'include' => $post_ids,
+ 'posts_per_page' => count( $post_ids ),
+ ) );
return $featured_posts;
}
@@ -136,6 +144,8 @@ class Featured_Content {
*
* Sets the "featured_content_ids" transient.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @return array Array of post IDs.
@@ -150,20 +160,18 @@ class Featured_Content {
if ( $term ) {
// Query for featured posts.
- $featured_ids = get_posts(
- array(
- 'fields' => 'ids',
- 'numberposts' => self::$max_posts,
- 'suppress_filters' => false,
- 'tax_query' => array(
- array(
- 'field' => 'term_id',
- 'taxonomy' => 'post_tag',
- 'terms' => $term->term_id,
- ),
+ $featured_ids = get_posts( array(
+ 'fields' => 'ids',
+ 'numberposts' => self::$max_posts,
+ 'suppress_filters' => false,
+ 'tax_query' => array(
+ array(
+ 'field' => 'term_id',
+ 'taxonomy' => 'post_tag',
+ 'terms' => $term->term_id,
),
- )
- );
+ ),
+ ) );
}
// Get sticky posts if no Featured Content exists.
@@ -181,6 +189,8 @@ class Featured_Content {
/**
* Return an array with IDs of posts maked as sticky.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @return array Array of sticky posts.
@@ -196,6 +206,8 @@ class Featured_Content {
*
* @see Featured_Content::validate_settings().
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function delete_transient() {
@@ -209,6 +221,8 @@ class Featured_Content {
* Hooked onto the 'pre_get_posts' action, this changes the parameters of
* the query before it gets any posts.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param WP_Query $query WP_Query object.
@@ -255,6 +269,8 @@ class Featured_Content {
*
* @see Featured_Content::validate_settings().
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param int $tag_id The term_id of the tag that has been deleted.
@@ -267,7 +283,7 @@ class Featured_Content {
}
$settings['tag-id'] = 0;
- $settings = self::validate_settings( $settings );
+ $settings = self::validate_settings( $settings );
update_option( 'featured-content', $settings );
}
@@ -276,6 +292,8 @@ class Featured_Content {
*
* Hooks into the "get_terms" filter.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param array $terms List of term objects. This is the return value of get_terms().
@@ -322,6 +340,8 @@ class Featured_Content {
*
* Hooks into the "get_the_terms" filter.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param array $terms A list of term objects. This is the return value of get_the_terms().
@@ -361,6 +381,8 @@ class Featured_Content {
/**
* Register custom setting on the Settings -> Reading screen.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function register_setting() {
@@ -370,61 +392,54 @@ class Featured_Content {
/**
* Add settings to the Customizer.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
*/
public static function customize_register( $wp_customize ) {
- $wp_customize->add_section(
- 'featured_content', array(
- 'title' => __( 'Featured Content', 'twentyfourteen' ),
- 'description' => sprintf(
- __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
- esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
- admin_url( 'edit.php?show_sticky=1' )
- ),
- 'priority' => 130,
- 'theme_supports' => 'featured-content',
- )
- );
+ $wp_customize->add_section( 'featured_content', array(
+ 'title' => __( 'Featured Content', 'twentyfourteen' ),
+ 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
+ esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
+ admin_url( 'edit.php?show_sticky=1' )
+ ),
+ 'priority' => 130,
+ 'theme_supports' => 'featured-content',
+ ) );
// Add Featured Content settings.
- $wp_customize->add_setting(
- 'featured-content[tag-name]', array(
- 'default' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
- 'type' => 'option',
- 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
- )
- );
- $wp_customize->add_setting(
- 'featured-content[hide-tag]', array(
- 'default' => true,
- 'type' => 'option',
- 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
- )
- );
+ $wp_customize->add_setting( 'featured-content[tag-name]', array(
+ 'default' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
+ 'type' => 'option',
+ 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
+ ) );
+ $wp_customize->add_setting( 'featured-content[hide-tag]', array(
+ 'default' => true,
+ 'type' => 'option',
+ 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
+ ) );
// Add Featured Content controls.
- $wp_customize->add_control(
- 'featured-content[tag-name]', array(
- 'label' => __( 'Tag Name', 'twentyfourteen' ),
- 'section' => 'featured_content',
- 'priority' => 20,
- )
- );
- $wp_customize->add_control(
- 'featured-content[hide-tag]', array(
- 'label' => __( 'Don&rsquo;t display tag on front end.', 'twentyfourteen' ),
- 'section' => 'featured_content',
- 'type' => 'checkbox',
- 'priority' => 30,
- )
- );
+ $wp_customize->add_control( 'featured-content[tag-name]', array(
+ 'label' => __( 'Tag Name', 'twentyfourteen' ),
+ 'section' => 'featured_content',
+ 'priority' => 20,
+ ) );
+ $wp_customize->add_control( 'featured-content[hide-tag]', array(
+ 'label' => __( 'Don&rsquo;t display tag on front end.', 'twentyfourteen' ),
+ 'section' => 'featured_content',
+ 'type' => 'checkbox',
+ 'priority' => 30,
+ ) );
}
/**
* Enqueue the tag suggestion script.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*/
public static function enqueue_scripts() {
@@ -443,6 +458,8 @@ class Featured_Content {
* its name as the first parameter to the function and only that
* value will be returned.
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param string $key The key of a recognized setting.
@@ -474,6 +491,8 @@ class Featured_Content {
* format before saving to the database. This function will also
* delete the transient set in Featured_Content::get_featured_content().
*
+ * @static
+ * @access public
* @since Twenty Fourteen 1.0
*
* @param array $input Array of settings input.