Changeset 27120
- Timestamp:
- 02/07/2014 05:38:08 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php
r27118 r27120 87 87 add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 ); 88 88 add_action( 'admin_init', array( __CLASS__, 'register_setting' ) ); 89 add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) ); 89 90 add_action( 'save_post', array( __CLASS__, 'delete_transient' ) ); 90 91 add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) ); … … 169 170 // Query for featured posts. 170 171 $featured = get_posts( array( 171 'numberposts' => $settings['quantity'],172 'numberposts' => self::$max_posts, 172 173 'tax_query' => array( 173 174 array( … … 204 205 public static function get_sticky_posts() { 205 206 $settings = self::get_setting(); 206 return array_slice( get_option( 'sticky_posts', array() ), 0, $settings['quantity']);207 return array_slice( get_option( 'sticky_posts', array() ), 0, self::$max_posts ); 207 208 } 208 209 … … 475 476 $defaults = array( 476 477 'hide-tag' => 1, 477 'quantity' => 6,478 478 'tag-id' => 0, 479 479 'tag-name' => 'featured', … … 482 482 $options = wp_parse_args( $saved, $defaults ); 483 483 $options = array_intersect_key( $options, $defaults ); 484 $options['quantity'] = self::sanitize_quantity( $options['quantity'] );485 484 486 485 if ( 'all' != $key ) { … … 526 525 } 527 526 528 if ( isset( $input['quantity'] ) ) {529 $output['quantity'] = self::sanitize_quantity( $input['quantity'] );530 }531 532 527 $output['hide-tag'] = isset( $input['hide-tag'] ) && $input['hide-tag'] ? 1 : 0; 533 528 … … 537 532 return $output; 538 533 } 539 540 /**541 * Sanitize quantity of featured posts.542 *543 * @static544 * @access public545 * @since Twenty Fourteen 1.0546 *547 * @param int $input The value to sanitize.548 * @return int A number between 1 and FeaturedContent::$max_posts.549 */550 public static function sanitize_quantity( $input ) {551 $quantity = absint( $input );552 553 if ( $quantity > self::$max_posts ) {554 $quantity = self::$max_posts;555 } else if ( 1 > $quantity ) {556 $quantity = 1;557 }558 559 return $quantity;560 }561 562 534 } // Featured_Content 563 535
Note: See TracChangeset
for help on using the changeset viewer.