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 |
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 | |
/* | |
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
<?php | |
/* | |
Description: Adds a taxonomy filter in the admin list page for a custom post type. | |
Written for: http://wordpress.stackexchange.com/posts/582/ | |
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins | |
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps... | |
*/ | |
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list'); | |
function add_businesses_column_to_listing_list( $posts_columns ) { | |
if (!isset($posts_columns['author'])) { |
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 | |
// define location of Parse PHP SDK, e.g. location in "Parse" folder | |
// Defaults to ./Parse/ folder. Add trailing slash | |
define( 'PARSE_SDK_DIR', './Parse/' ); | |
// include Parse SDK autoloader | |
require_once( 'autoload.php' ); | |
// Add the "use" declarations where you'll be using the classes | |
use Parse\ParseClient; |