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 | |
/** | |
* Creates a multipart/form-data body for an image and form fields. | |
* | |
* @param string $file_path The path to the file. | |
* @param string $filename The base filename, if different from the file path. | |
* @param array $fields The form fields. | |
* @return array The boundary ID and the body. | |
*/ |
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 | |
$regex = get_shortcode_regex(); | |
// Find all registered tag names in $content. | |
preg_match_all( "/$regex/", $content, $matches ); | |
if ( ! empty( $matches ) ) { | |
var_dump( $matches[2] ); | |
} |
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 | |
/** | |
* Inserts an item into an array. | |
* | |
* @param array $array The array to insert into. | |
* @param mixed $key The array key to insert the item at, either before or after. | |
* @param mixed $new_key The new array key. | |
* @param mixed $new_item The new item to insert. | |
* @param bool $before Insert before or after? |
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 term list taxonomy --field=term_id | xargs wp term delete taxonomy | |
wp post delete $(wp post list --post_type='page' --format=ids) --force |
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 | |
/** | |
* Determines if any of the supplied vars are empty(). | |
* | |
* @param arra ...$vars List of vars. | |
* @return bool | |
*/ | |
function any_empty( ...$vars ) { | |
foreach ( $vars as $var ) { |
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 pagination counts for a query. | |
* | |
* @param WP_Query $query The query, defaults to global wp_query. | |
* @return array | |
*/ | |
function get_pagination_counts( $query = false ) { | |
global $wp_query; |
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 | |
/** | |
* 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 ) { |
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
[ | |
{ | |
"type": "weekly", | |
"all_day": false, | |
"multi_day": false, | |
"start_date": "2024-03-11", | |
"_start_date_input": "March 11, 2024", | |
"_start_date_obj": "2024-03-11T05:00:00.000Z", | |
"start_time": "08:00:00", | |
"_start_time_input": "8:00 am", |
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
#!/usr/bin/env bash | |
PHP_VERSION=$1 | |
CONF_FOLDER="/usr/local/etc/php/${PHP_VERSION}/" | |
PHP_INI="${CONF_FOLDER}php.ini" | |
cd ${CONF_FOLDER} | |
git clone --depth 1 https://github.com/php-memcached-dev/php-memcached.git | |
cd php-memcached | |
/usr/local/bin/phpize |
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 | |
/** | |
* Sanitize helper function to retrive values from $_GET, $_POST, etc. | |
*/ | |
namespace ProjectName\Sanitizers; | |
/** | |
* Gets a sanitized text field from an array. Defaults to sanitize_text_field(). | |
* |
NewerOlder