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
| function facet_availability_logic( $return, $params ) { | |
| // get facet in question | |
| $facet = $params['facet']; | |
| // assign values to $selected_values var | |
| $selected_values = $params['selected_values']; | |
| // if the facet's NAME is 'date' | |
| // (this can be changed to the name of your facet you want to override) | |
| if ( 'dates' == $facet['name'] ) { | |
| // assign variables to first (start date) and second (end date) queries passed |
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
| /* | |
| * Test case #1 | |
| */ | |
| add_filter( 'the_title', 'my_add_custom_content' ); | |
| function my_add_custom_content( $title) { | |
| if ( is_singular( 'events' ) ): | |
| $postID = get_the_ID(); | |
| $html = '<a href="#" class="goingLink setGoing" id="'.$postID.'" data-value="'. $postID .'">I\'m Going</a><div id="fb-root"></div>'; |
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
| function my_debug_tests( $data, $post, $context ) { | |
| var_dump($data); | |
| var_dump($post); | |
| var_dump($context); | |
| add_filter( 'json_prepare_post', 'my_debug_test', 10, 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
| 'meta_query' => array( | |
| array( | |
| 'key' => 'tagged_users', | |
| 'value' => 's:1:"2";', | |
| 'compare' => 'IN', | |
| ), | |
| Actual DB record: | |
| a:1:{i:0;s:1:"2";} |
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
| add_filter( 'the_content', 'prefix_insert_post_ads' ); | |
| function prefix_insert_post_ads( $content ) { | |
| if ( 'post' == get_post_type() && is_single() && ! is_admin() ) { | |
| return prefix_insert_after_paragraph( 6, 1, $content ); | |
| } | |
| } |
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
| $db = @mysql_connect('server', 'username', 'password'); | |
| if (!$db) echo "connection failed"; | |
| else echo "connection succeeded"; |
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
| foreach($users as $user) { | |
| $tagged_user_photos = get_user_meta($user, 'tagged_photos', false); | |
| var_dump($tagged_user_photos); | |
| $tagged_user_photos[] = $post_id; | |
| update_user_meta( $user, 'tagged_photos', $tagged_user_photos); | |
| } |
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
| _.each( this.$el.serializeArray(), function( pair ) { | |
| /* | |
| * Feature Added: returns js array object for multiple value inputs | |
| * This is the reason we had to override the default save function | |
| * function originates in media-views.js line 2295 | |
| */ | |
| // if the pair.name is greater than 2 chars and [] is the last two chars | |
| if ( pair.name.length > 2 && '[]' == pair.name.substr( pair.name.length - 2 ) ) { |
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($){ | |
| wp.media.view.AttachmentCompat.prototype.save = function( event ) { | |
| var data = {}; | |
| if ( event ) { | |
| event.preventDefault(); | |
| } | |
| _.each( this.$el.serializeArray(), function( pair ) { |
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
| /* backbone functions for views */ | |
| render: function() { | |
| var compat = this.model.get('compat'); | |
| if ( ! compat || ! compat.item ) { | |
| return; | |
| } | |
| this.views.detach(); | |
| this.$el.html( compat.item ); | |
| this.views.render(); |