View get_wordpress_image_sizes.php
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(); |
View modal.js
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 |
View parse.php
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) { |
View translate_woocommerce.php
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; |
View media-taxonomies.php
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'); |
View Add custom field to woocommerce checkout.
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>'; | |
View Add css class to top selling products
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"; |
View Import an sql dump file with PHP
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'; |
View How to Find Product by SKU in WooCommerce
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