Skip to content

Instantly share code, notes, and snippets.

/**
* @returns {wp.media.view.AttachmentCompat} Returns itself to allow chaining
*/
render: function() {
var compat = this.model.get('compat');
if ( ! compat || ! compat.item ) {
return;
}
this.$el.empty().append(this.$el);
this.views.detach();
@LinzardMac
LinzardMac / gist:b6f52af6bbe35f7bd347
Created August 12, 2015 20:07
Test JS for trac ticket "Custom fields in media modal javascript events are unbound after ajax save method"
jQuery(document).on('click', '.colorButton', function(event) {
var input = jQuery('input');
input.css('background-color' , 'red');
});
@LinzardMac
LinzardMac / gist:81d2360c227ebc325325
Created August 12, 2015 20:06
Test Case for Trac Ticket "Custom fields in media modal javascript events are unbound after ajax save method"
// Enqueue other custom javascript
function enqueue_custom_js(){
//Adds your custom script
wp_enqueue_script('jquery');
wp_register_script('jsbind', get_template_directory_uri() . '/js/javascriptbind.js' , array('jquery'), '1', true );
wp_enqueue_script( 'jsbind');
}
add_action('admin_enqueue_scripts','enqueue_custom_js');
@LinzardMac
LinzardMac / gist:dee0488120d436e5b43b
Created August 10, 2015 21:33
Replicate multiple-input-value bug in media modal
/*
*In plugin file or functions.php add the following code to create new form fields in your media modal
*/
function multiple_input_field( $form_fields, $post ) {
$foo = get_post_meta( $post->ID, 'foo', true );
$form_fields['foo'] = array(
'label' => 'Is Foo',
'input' => 'html',
'html' =>
wp.media.view.AttachmentCompat.prototype.events['change {all selectors found in the if statement below}'] = 'save';
if ( .name.length > 2 && '[]' == .name.substr( pair.name.length - 2 ) ) {
var pairName = .name.substr( 0, .name.length - 2 );
if ( pairName in data ) {
data[ pairName ] += ',' + .value;
} else {
data[ pairName ] = .value;
}
function getUsers(){
header("Access-Control-Allow-Origin: *");
$term = $_GET['search'];
// var_dump($_GET);
$args = array(
'search' => '*'.esc_attr( $term ).'*',
'fields' => array('first_name', 'last_name', 'ID', 'display_name'),
'meta_query' => array(
'relation' => 'OR',
array(
final class myClass {
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof myClass ) ) {
self::$instance = new myClass;
self::$instance->setup_constants();
}
array(
'label' => 'Location',
'desc' => '',
'id' => $prefix.'location',
'type' => 'loc_group',
'options' => array(
'location'=> array(
'options' => array(
'state' => array(
.message[type=system] { color: #080; }
.message[type=error] { color: #f00; font-weight: bold; }
.message[type=reply] { color: #088; }
.message[type=error_reply] { color: #f00; }
.message[type=dcc_send_send] { color: #088; }
.message[type=dcc_send_receive] { color: #00c; }
.message[type=privmsg] {}
.message[type=notice] { color: #888; }
.message[type=action] { color: #080; }
.message[type=join] { color: #080; }
@LinzardMac
LinzardMac / gist:d4bcdef8a0e0371af52a
Created April 14, 2015 23:35
How to add query variables to WP URL
// create your variable, add your "key" called event_event, and define what the value should be
//for front end
$edit_post = add_query_arg( 'edit_event', $user_post->ID, site_url('/edit-events/') );
//for admin
$edit_post = add_query_arg( 'edit_event', $user_post->ID, admin_url('admin.php?page=example') );
// then simply do this for your link
<a href="<?php echo $edit_post; ?>" title="edit event"><?php echo $user_post->post_title; ?></a>