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 | |
| /* | |
| Plugin Name: Listing Content Item | |
| Plugin URI: | |
| Description: | |
| Author: | |
| Version: 1.0 | |
| Author URI: | |
| */ |
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 VAT and SSN fields in billing address display | |
| add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_ssn_formatted_billing_address', 10, 2 ); | |
| function custom_add_vat_ssn_formatted_billing_address( $fields, $order ) { | |
| $fields['vat'] = $order->billing_vat; | |
| $fields['ssn'] = $order->billing_ssn; | |
| return $fields; | |
| } | |
| add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 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
| <?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 |
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 | |
| /** | |
| * 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 | |
| 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 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 | |
| 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
| 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
| 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){ |