View get-term-ids.php
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 the term IDs for the term names. Creates the terms if they do not exist. | |
* | |
* @param string $term_names The term name (or names separated with pipes). | |
* @param string $taxonomy The taxonomy. | |
* @return array | |
*/ | |
function get_term_ids( $term_names, $taxonomy ) { |
View slow-db-queries.php
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 | |
global $wpdb; | |
$wpdb->queries = []; | |
// Run some slow code here. | |
if ( ! empty( $wpdb->queries ) ) { |
View cli-add-new-term.txt
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 post list --taxonomy_name=existing-term-slug --format=ids | xargs -0 -d ' ' -I % wp post term add % taxonomy_name new-term-slug |
View add-term-to-post.php
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 | |
$term = 'Some Term Name' | |
$taxonomy = 'some-taxonomy'; | |
if ( function_exists( '\wpcom_vip_term_exists' ) ) { | |
$term_data = \wpcom_vip_term_exists( $term, $taxonomy ); | |
} else { | |
$term_data = term_exists( $term, $taxonomy ); // phpcs:ignore | |
} |
View hide-meta-boxes.php
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. |
View get-all-descendants.php
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 ) { |
View term-report-cli.php
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> |
View remove-anonymous-object-filter.php
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 ) { |
View multi-level-wp-parse-args.php
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 :) |
NewerOlder