This file contains 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
/** | |
* Get information about available image sizes | |
*/ | |
function get_image_sizes($size = '') | |
{ | |
global $_wp_additional_image_sizes; | |
$sizes = array(); | |
$get_intermediate_image_sizes = get_intermediate_image_sizes(); |
This file contains 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() { | |
// Define constructor | |
this.Modal = function() { | |
// Create global element references | |
this.closeButton = null; | |
this.modal = null; | |
this.overlay = null; | |
// Determine proper prefix |
This file contains 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 | |
$article_string = file_get_contents( $url ); | |
$article_string = preg_replace_callback('/<!\[CDATA\[(.*)\]\]>/', 'filter_xml', $article_string); | |
$article_xml = simplexml_load_string($article_string); | |
$namespaces = $article_xml->getNamespaces(true); // get namespaces | |
function filter_xml($matches) { | |
return trim(htmlspecialchars($matches[1])); | |
} | |
// | |
// foreach ($article_xml->channel->item as $item) { |
This file contains 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 translate_woocommerce($translation, $text, $domain) { | |
if ($domain == 'woocommerce') { | |
switch ($text) { | |
case 'SKU': | |
$translation = 'Product Code'; | |
break; | |
case 'SKU:': | |
$translation = 'Product Code:'; | |
break; |
This file contains 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 categories for attachments | |
*/ | |
function add_categories_for_attachments() { | |
register_taxonomy_for_object_type('category', 'attachment'); | |
} | |
add_action('init', 'add_categories_for_attachments'); |
This file contains 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 vehicle registration field to the checkout page | |
*/ | |
add_action( 'woocommerce_after_order_notes', 'car_registration_checkout_field' ); | |
function car_registration_checkout_field( $checkout ) { | |
echo '<div id="car_registration_checkout_field"><h2>' . __('Car Registration') . '</h2>'; | |
This file contains 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 topseller class to product | |
**/ | |
$query = "SELECT ID FROM {$wpdb->posts} p | |
INNER JOIN {$wpdb->postmeta} pm ON ( pm.post_id = p.ID AND pm.meta_key='total_sales' ) | |
WHERE p.post_type = 'product' | |
AND p.post_status = 'publish' | |
ORDER BY pm.meta_value+0 DESC | |
LIMIT 10"; |
This file contains 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
// Name of the file | |
$filename = 'DUMPFILEHERE.sql'; | |
// MySQL host | |
$mysql_host = 'DB_HOST'; | |
// MySQL username | |
$mysql_username = 'DB_USER'; | |
// MySQL password | |
$mysql_password = 'DB_PASSWORD'; | |
// Database name | |
$mysql_database = 'DB_NAME'; |
This file contains 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 get_product_by_sku( $sku ) { | |
global $wpdb; | |
$product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) ); | |
if ( $product_id ) return new WC_Product( $product_id ); | |
return null; | |
} |
NewerOlder