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 | |
add_filter( 'deprecated_constructor_trigger_error', '__return_false' ); | |
add_filter( 'deprecated_function_trigger_error', '__return_false' ); | |
add_filter( 'deprecated_file_trigger_error', '__return_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
// Create a new post | |
var post = new wp.api.models.Posts({ title:'new test' } ); | |
post.save(); | |
// Get a collection of the post's categories | |
var postCategories = post.getCategories(); | |
// The new post has an single Category: Uncategorized | |
postCategories.at( 0 ).get('name'); | |
// response -> "Uncategorized" |
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
jQuery( document ).on( 'click', 'div.attachment-preview', function( e ) { | |
console.log( 'Image clicked', e ); | |
// Do ajax stuff here... | |
} ); |
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
var callbackFunction = function( e ) { | |
console.log( 'Image clicked', e ); | |
// Do ajax stuff here... | |
}; | |
wp.media.view.Attachment.prototype.on( 'click', callbackFunction ); | |
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
$host = parse_url( strtolower( site_url() ) , PHP_URL_HOST ); | |
if ( strpos( $host, 'domain.com' ) ) { | |
$site_matches = true; | |
} |
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 use_floor_for_human_time_diff( $since, $diff, $from, $to ) { | |
if ( empty( $to ) ) { | |
$to = time(); | |
} | |
$diff = (int) abs( $to - $from ); | |
if ( $diff < HOUR_IN_SECONDS ) { | |
$mins = floor( $diff / MINUTE_IN_SECONDS ); |
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
In some environments it’s necessary to hop through 1 or even 2 | |
gateways to reach the hosts. | |
In order to make this a little easier and also allow easy scp file | |
transfers here is a little guide for setting up ssh access. | |
Add the following to your ~/.ssh/config file | |
Host * | |
TCPKeepAlive yes |
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
For reference, here's how I'm doing it now: | |
``` | |
add_filter( 'oembed_request_post_id', function( $post_id, $url ) { | |
if( is_my_gallery_page() ) { | |
add_filter( 'post_embed_url', function( $embed_url ) use ($url) { | |
remove_filter( current_filter(), __FUNCTION__ ); | |
$url = explode("?",$url); | |
$embed_url = $embed_url."?".$url[1]; | |
return $embed_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
/** | |
* A filter dropdown for month/dates. | |
*/ | |
wp.media.view.CategoryFilter = wp.media.view.AttachmentFilters.extend({ | |
id: 'media-attachment-date-filters', | |
createFilters: function() { | |
var filters = {}; | |
var categories = ['one', 'two', 'three']; | |
_.each( categories || {}, function( value, index ) { | |
filters[ index ] = { |
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 10 posts in the quick draft list. | |
wp.hooks.addFilter( | |
'dashboard_recent_drafts_fetch_args', | |
function( $args ) { | |
$args['per_page'] = 10; | |
return $args; | |
} | |
); |