#Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
#Enable repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
This file contains hidden or 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 | |
/** | |
* login_with_email filter to the authenticate filter hook, to fetch a username based on entered email | |
* @param obj $user | |
* @param string $username [description] | |
* @param string $password [description] | |
* @return boolean | |
*/ | |
add_filter('authenticate', 'login_with_email', 20, 3); |
This file contains hidden or 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
Show hidden characters
/* | |
Replace default osx keymap, or just add this to Preferences -> Key Bindings -> User | |
*/ | |
[ | |
{ "keys": ["ctrl+q"], "command": "exit" }, | |
{ "keys": ["ctrl+shift+n"], "command": "new_window" }, | |
{ "keys": ["ctrl+shift+w"], "command": "close_window" }, | |
{ "keys": ["ctrl+o"], "command": "prompt_open_file" }, | |
{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" }, |
This file contains hidden or 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
SELECT p.ID, p.post_type, p.post_status, m.* FROM wp_posts p LEFT JOIN | |
( SELECT | |
post_id, | |
GROUP_CONCAT(if(meta_key = 'campaign_description', meta_value, NULL)) AS 'description', | |
GROUP_CONCAT(if(meta_key = 'campaign_start', meta_value, NULL)) AS 'start', | |
GROUP_CONCAT(if(meta_key = 'campaign_end', meta_value, NULL)) AS 'end', | |
GROUP_CONCAT(if(meta_key = 'campaign_priority', meta_value, NULL)) AS 'priority' | |
FROM wp_postmeta | |
GROUP BY post_id ) m | |
ON m.post_id = p.ID |
This file contains hidden or 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 | |
/** | |
* Repeatable Custom Fields in a Metabox | |
* Author: Helen Hou-Sandi | |
* | |
* From a bespoke system, so currently not modular - will fix soon | |
* Note that this particular metadata is saved as one multidimensional array (serialized) | |
*/ | |
function hhs_get_sample_options() { |
This file contains hidden or 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 | |
/** | |
* getMostPriority() | |
* Utility function for getting random values with weighting. | |
* Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50) | |
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%. | |
* The return value is the array key, A, B, or C in this case. Note that the values assigned | |
* do not have to be percentages. The values are simply relative to each other. If one value | |
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66% | |
* chance of being selected. Also note that weights should be integers. |
This file contains hidden or 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 from a single line string | |
$output = "Likening ‘not-critical’ with"; | |
$output = preg_replace('/[^(\x20-\x7F)]*/','', $output); | |
echo $output; | |
//Remove from a multi-line string | |
$output = "Likening ‘not-critical’ with \n Likening ‘not-critical’ with \r Likening ‘not-critical’ with. ' ! -."; | |
$output = preg_replace('/[^(\x20-\x7F)\x0A\x0D]*/','', $output); | |
echo $output; |
This file contains hidden or 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 | |
function custom_do_settings_sections($page) { | |
global $wp_settings_sections, $wp_settings_fields; | |
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) | |
return; | |
foreach( (array) $wp_settings_sections[$page] as $section ) { | |
echo "<h3>{$section['title']}</h3>\n"; | |
call_user_func($section['callback'], $section); |
This file contains hidden or 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 | |
/** | |
* Get the Featured image URL of a post | |
* @global object $post | |
* @param string $size | |
* @return string | |
*/ | |
function funkmo_get_post_thumbnail_url($post_id='') { | |
$image_url = ''; | |
This file contains hidden or 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 little class records how long it takes each WordPress action or filter | |
* to execute which gives a good indicator of what hooks are being slow. | |
* You can then debug those hooks to see what hooked functions are causing problems. | |
* | |
* This class does NOT time the core WordPress code that is being run between hooks. | |
* You could use similar code to this that doesn't have an end processor to do that. | |
* |