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('json_api_encode', 'json_api_encode_acf'); | |
| function json_api_encode_acf($response) | |
| { | |
| if (isset($response['posts'])) { | |
| foreach ($response['posts'] as $post) { | |
| json_api_add_acf($post); // Add specs to each post | |
| } | |
| } |
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_action( 'admin_menu', 'remove_menus' ); | |
| function remove_menus() { | |
| global $menu; | |
| global $submenu; | |
| // echo '<pre>'; | |
| // print_r($menu); |
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.ajax({ | |
| url: '/wp-admin/admin-ajax.php', | |
| type: 'GET',//POST, JSON, XML | |
| dataType: 'html', | |
| data: ({ | |
| action: 'MY_AJAX_FUNCTION', | |
| state: state, | |
| }), | |
| success: function(data){ | |
| if (data){ |
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(function($) { | |
| $('form[data-async]').live('submit', function(event) { | |
| var $form = $(this); | |
| var $target = $($form.attr('data-target')); | |
| $.ajax({ | |
| type: $form.attr('method'), | |
| url: $form.attr('action'), | |
| data: $form.serialize(), |
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 MyJS { | |
| public function __construct() { | |
| add_action( 'wp_enqueue_scripts', array( &$this, 'addScripts' ) ); | |
| } | |
| public function addScripts() { | |
| // jQuery |
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 save percent next to sale item prices. | |
| add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 ); | |
| function woocommerce_custom_sales_price( $price, $product ) { | |
| $percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 ); | |
| return $price . sprintf( __(' Save %s', 'woocommerce' ), $percentage . '%' ); | |
| } | |
| ?> |
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 | |
| global $wpdb; | |
| // Insert the original post | |
| $original = wp_insert_post($array, true); | |
| // Insert the translated post | |
| $translated = wp_insert_post($array, true); | |
| // Make some updates to both translations |
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 the custom attribute "Special Promotion" to a product. | |
| */ | |
| add_filter( 'dfrpswc_product_attributes', 'mycode_add_promo_attribute', 20, 5 ); | |
| function mycode_add_promo_attribute( $attributes, $post, $product, $set, $action ) { | |
| if ( isset( $product['promo'] ) ) { | |
| $attr = 'Special Promotion'; | |
| if ( !isset( $attributes[sanitize_title( $attr )] ) ) { |
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 color attribute. | |
| * | |
| * The attribute "Color" with a slug of "color" must already exist here: | |
| * WordPress Admin Area > Products > Attributes. | |
| */ | |
| add_filter( 'dfrpswc_filter_attribute_value', 'mycode_add_color_attribute', 20, 6 ); | |
| function mycode_add_color_attribute( $value, $attribute, $post, $product, $set, $action ) { |
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 | |
| /** | |
| * Setup admin bar item which opens URL in a thickbox window | |
| * | |
| * @param WP_Admin_Bar $wp_admin_bar | |
| */ | |
| function admin_bar_menu_modal_window( $wp_admin_bar ) | |
| { | |
| // add "tools" node |