brew install memcached libmemcached zlib pkg-config
pecl install memcached
<?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. | |
*/ |
<?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] ); | |
} |
<?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? |
wp term list taxonomy --field=term_id | xargs wp term delete taxonomy | |
wp post delete $(wp post list --post_type='page' --format=ids) --force |
<?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 ) { |
<?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; |
<?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 ) { |
[ | |
{ | |
"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", |
#!/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 |