Skip to content

Instantly share code, notes, and snippets.

@WerdsWords
WerdsWords / autocomplete_users_for_site_admins.php
Last active December 20, 2015 14:39
#28: autocomplete_users_for_site_admins
<?php
/**
* Enable user auto-complete for non-super admins who have the promote_users cap.
*
* @see wp_ajax_autocomplete_user()
*
* @param bool $yesno Whether to allow non-super admins to use user autocomplete. Defaults to false.
*
* @return bool Whether to allow it.
*/
@WerdsWords
WerdsWords / heartbeat_nopriv_send.php
Created August 3, 2013 22:05
#27: heartbeat_nopriv_send
<?php
// There is no example yet.
@WerdsWords
WerdsWords / heartbeat_nopriv_received.php
Last active December 20, 2015 14:39
#26: heartbeat_nopriv_received
<?php
/**
* Example 'Marco, Polo' Heartbeat nopriv data received filter.
*
* Based on an original Gist by Jason Coleman (https://gist.github.com/strangerstudios/5888123)
*
* @see wp_ajax_nopriv_heartbeat()
*
* @param array|object $response The response object.
* @param array $data An array of $_POST data.
@WerdsWords
WerdsWords / the_modified_date.php
Created July 27, 2013 17:40
#25: the_modified_date
<?php
/**
* Modifed date emphasis
*
* @param string $modified_date The modified date output.
* @param string $date The date format. Defaults to 'date_format' option value.
* @param string $before What to output before the date.
* @param string $after What to output after the date.
*
* @return string The modified modified date (heh)
@WerdsWords
WerdsWords / login_messages.php
Created July 27, 2013 17:15
#24: login_messages
<?php
/**
* AP style-ize 'e-mail' in login messages
*
* @param string $messages The login message(s).
*
* @return string The filtered login message(s).
*/
function wpdocs_login_messages( $messages ) {
$messages = str_replace( 'e-mail', 'email', $messages );
@WerdsWords
WerdsWords / wp_sprintf_l.php
Last active December 20, 2015 07:19
#23: wp_sprintf_l
<?php
/**
* Remove use of Oxford/serial comma at the end of taxonomy lists
*
* @param array $separators The array of defaul list item separators.
*
* @return array The filtered list of list separators.
*/
function wpdocs_no_oxford_comma( $separators ) {
// Replaces __( ', and ' )
@WerdsWords
WerdsWords / http_response_timeout.php
Created July 26, 2013 18:38
#22: http_response_timeout
<?php
/**
* Extend http timeout duration to 30 seconds
*
* @param int $timeout The timeout duration in seconds. Default is 5.
*
* @return int The filtered timeout duration in seconds.
*/
function wpdocs_extend_http_response_timeout( $timeout ) {
return 30; // seconds
@WerdsWords
WerdsWords / xmlrpc_default_taxonomy_fields.php
Created July 26, 2013 18:01
#21: xmlrpc_default_taxonomy_fields
<?php
/**
* Only retrieve cap and object_type in taxonomy XML-RPC getters
*
* @see wp.getTaxonomy(), wp.getTaxonomies()
*
* @param array $fields An array of taxonomy fields.
* @param string $method The XML-RPC method name.
*
* @return array The filtered array of fields.
@WerdsWords
WerdsWords / map_meta_cap.php
Created July 26, 2013 17:33
#20: map_meta_cap
<?php
/**
* Only allow super admins to upload files
*
* @see map_meta_cap()
*
* @param array $caps Primitive capabilities assigned to meta caps.
* @param string $cap Meta capability.
* @param int $user_id The current user id.
* @param array $args An array of arguments, sometimes empty.
@WerdsWords
WerdsWords / delete_{$meta_type}_metadata.php
Created July 25, 2013 04:58
#19: delete_{$meta_type}_metadata
<?php
/**
* Keep posts' featured images
*
* @see delete_metadata()
*
* @param bool $bool Default is null, anything else short-circuits delete_metadata().
* @param int $object_id The post, user, or comment object id.
* @param string $meta_key The meta key to delete.
* @param string $meta_value The meta value to delete.