= 0 ) { $sticky = array_slice( $sticky, 0, $num_stickies ); } $args = array ( 'ignore_sticky_posts' => 1, 'order_by' => 'date', 'order' => 'DESC', 'post__in' => $sticky, 'posts_per_page' => $num_stickies, ); return new \WP_Query( $args ); } /** * Retrives the value of a setting previously saved to the database * typically through the use of the metabox mb_ctl components or * through the use of custom fields. * @param string $slug The unique key of the value to be retrieved * @param mixed $default If no value is found in the database, return this value instead * @return string The desired value */ static function get_opt( $slug, $default = null ) { // Get the global post and cascade. global $post; return self::get_opt_explicit( $post, $slug, $default ); } /** * Retrives the value of a setting previously saved to the database * typically through the use of the metabox mb_ctl components or * through the use of custom fields. * @param object $post The post with the option to be retrieved * @param string $slug The unique key of the value to be retrieved * @param mixed $default If no value is found in the database, return this value instead * @return string The desired value */ static function get_opt_explicit( $post, $slug, $default = null ) { // Ensure that we are on a post/page that has postmeta if ( empty( $post ) ) return $default; // Retrieve the value from the database. $value = get_post_meta( $post->ID, $slug, true ); // If no value was found and a default was provided, use the default. if ( ( $value == '' ) && ( $default != null ) ) { $value = $default; } // Return the ultimate value. return $value; } /** * Evidently, 'get_template_part' does not return an indicator that the * template actually loaded. So, this function tests if the file exists * so it has something to return to the client and loads the template if * the desired template is found. * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. * @return boolean Whether or not the template was found/loaded */ static function get_template_part( $slug, $name = null ) { // Put together a list of templates to look through, just like // the original function - one with the name and one without. $templates = array(); $name = (string)$name; if ( !empty( $name ) ) $templates[] = $slug.'-'.$name.'.php'; $templates[] = $slug.'.php'; // See if the template really exists. $found = locate_template( $templates, false ); // Try loading the template no matter what - use the regular WP // function because it sets up a hook call too. get_template_part( $slug, $name ); // And return the info (the reason for this function) to the client. return $found; } /* PRIVATE */ /** * Only use this class as a utility.. */ private function __construct() { // Intentionally blank.. } } ?>