This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->_add_action( 'current_screen', 'maybe_hide_meta_boxes' ); | |
/** | |
* Hides various meta boxes if they have not already been hidden. | |
* Users can still unhide the meta box and it will not be hidden in | |
* the future. | |
* | |
* @param WP_Screen $screen The current screen object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gets all of the descendant/child post IDs for a parent post ID. | |
* | |
* @param int $parent_post_id The parent post ID. | |
* @return array | |
*/ | |
function get_all_descendants( $parent_post_id ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
/** | |
* Generate a term list/report. | |
* | |
* ## OPTIONS | |
* | |
* <taxonomy> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove an anonymous object filter. | |
* | |
* @param string $tag Hook name. | |
* @param string $class Class name | |
* @param string $method Method name | |
* @return void | |
*/ | |
function remove_anonymous_object_filter( $tag, $class, $method ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* wp_parse_args() with support for multi-level arrays. | |
* | |
* @param array &$a Arrays to be parsed | |
* @param array $b Defaults for the arrays. | |
* @return array | |
*/ | |
function multi_level_wp_parse_args( &$a, $b ) { | |
// https://mekshq.com/recursive-wp-parse-args-wordpress-function/ | |
// Similar to wp_parse_args() just a bit extended to work with multidimensional arrays :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Formats a timestamp into a date and time based on WordPress settings. | |
* | |
* @param int $timestamp The timestamp. | |
* @param string $format Optional date time format. | |
* @return string | |
*/ | |
function timestamp_to_date_time( $timestamp, $format = false ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Quickly provide a namespaced way to get functions. | |
* | |
* @param string $function Name of function in namespace. | |
* @return string | |
*/ | |
function n( $function ) { | |
return __NAMESPACE__ . "\\$function"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Runs WP_Query and gets all results using pagination. | |
* | |
* @param array $query_args List of WP_Query args. | |
* @return array | |
*/ | |
function get_paginated_query_results( $query_args ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Outputs a list of sanitized CSS class names. | |
* | |
* @param array|string $classes List of class names (array or string with | |
* class names separated by spaces or commas). | |
* @param bool $echo Echo the list of class names (defaults to true). | |
* @return void|array | |
*/ | |
function output_css_classes( $classes, $echo = true ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns a random cache time, defaults to between 11 and 12 hours. | |
* | |
* @param integer $min Min time in seconds. | |
* @param integer $max Max time in seconds. | |
* @return integer | |
*/ | |
function get_cache_time( $min = HOUR_IN_SECONDS * 11, $max = HOUR_IN_SECONDS * 12 ) { |