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 filter__acf_update_value( $value, $post_id, $field ) { | |
$post_type = get_post_type( $post_id ); | |
$meta = wp_get_attachment_metadata($value); | |
if ( intval( $meta['width'] ) < 300 || intval( $meta['height'] ) < 300 ) { | |
$value = null; | |
do_action( 'simple_admin_notice', "Selected image (.../{$meta['file']}) was less than 300 x 300. Please select a different image.", 'error' ); | |
} |
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).ready(function ($) { | |
$('.link').off("click").on("click", function (e) { | |
// add your click handling here | |
e.stopPropagation(); | |
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
<?php | |
function helper__dynamic_sidebar_params__title_class ( $instance, $widget, $args ) { | |
if ( isset( $instance['title'] ) ) { | |
$new_class = implode( '_', array( 'widget', $widget->id_base, sanitize_title( $instance['title'] ) ) ) . " "; | |
$args['before_widget'] = str_replace( 'class="', 'class="' . $new_class, $args['before_widget'] ); | |
// For lack of a proper filter, let's just do this ourselves - will have to keep up to date with WP, though. | |
$was_cache_addition_suspended = wp_suspend_cache_addition(); | |
if ( $widget->is_preview() && ! $was_cache_addition_suspended ) { | |
wp_suspend_cache_addition( 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 time_the_hooks( $hook = null ) { | |
static $time = array( 0, '', array() ); | |
if ( in_array( $hook, array('gettext') ) ) { return; } | |
ob_clean(); | |
// if ( microtime(true) - $time[0] > 0.0001 ) { | |
if ( 'get_' === $time[1] ) { | |
echo (int) ( ( microtime( true ) - $time[0] ) * 100000 ); |
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 | |
/** | |
* Send a template for handling notifications that other plugins can hook into. | |
*/ | |
add_action( 'customize_controls_print_footer_scripts', function () { | |
?> | |
<script type="text/html" id="tmpl-customize-unified-notifications"> | |
<ul> | |
<# _.each( data.notifications, function( notification ) { #> | |
<li class="notice notice-{{ notification.type || 'info' }} {{ data.altNotice ? 'notice-alt' : '' }}" data-code="{{ notification.code }}" data-type="{{ notification.type }}"> |
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
/** | |
* Get a list of posts that use an attachment. | |
* | |
* @param integer $attachment_id Attachment post id. | |
* | |
* @return string | |
*/ | |
function get_attachment_usages( $attachment_id ) { | |
$posts = []; | |
$statuses = []; |
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
/** | |
* Get a list of posts that use an attachment that have been published or other status. | |
* | |
* @param integer $attachment_id Attachment post id. | |
* @param array $statuses Array of statuses to check for. | |
* | |
* @return string | |
*/ | |
function get_attachment_usages( $attachment_id, $statuses = array( 'publish' ) ) { | |
$post_ids = []; |
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
//wp.media.view.Modal.prototype: open, ready | |
( function ($) { | |
var $attachments = $('.attachments').children(), | |
blocked = [ 1, 2, 12, 4593 ]; | |
wp.media.events.on( 'open', function( arguments ) { | |
alert('event fired') | |
}); |
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 | |
class Meta_Reset { | |
function __construct() { | |
add_action( 'parse_request', [ $this, 'parse_request' ] ); | |
} | |
/** | |
* Usage: mydomain.com/?meta_reset=1 | |
*/ | |
function parse_request() { |