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 | |
| // Get headers for 100 unique random domains with get_headers() and cURL to determine which is faster. | |
| /* | |
| TL;DR -> cURL is significantly faster. | |
| get_headers (GET) vs cURL: | |
| Execution time : 139.95884609222 seconds | |
| Execution time : 65.998840093613 seconds |
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
| //Woocommerce Checkout JS events | |
| $( document.body ).trigger( 'init_checkout' ); | |
| $( document.body ).trigger( 'payment_method_selected' ); | |
| $( document.body ).trigger( 'update_checkout' ); | |
| $( document.body ).trigger( 'updated_checkout' ); | |
| $( document.body ).trigger( 'checkout_error' ); | |
| //Woocommerce cart page JS events | |
| $( document.body ).trigger( 'wc_cart_emptied' ); | |
| $( document.body ).trigger( 'update_checkout' ); |
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 | |
| /** | |
| * Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty | |
| */ | |
| add_action ('woocommerce_add_to_cart', 'lenura_empty_cart_before_add', 0); | |
| function lenura_empty_cart_before_add() { | |
| global $woocommerce; | |
| // Get 'product_id' and 'quantity' for the current woocommerce_add_to_cart operation |
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
| { | |
| "require": { | |
| "phpoffice/phpspreadsheet": "^1.18", | |
| "mpdf/mpdf": "^8.0" | |
| } | |
| } |
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 | |
| //.... load wordpress stuff etc | |
| if(!is_user_logged_in()) { | |
| wp_redirect( wp_login_url($_SERVER['SCRIPT_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
| { "name": "resize_and_watermark_images", "version": "1.0.0", "description": "", "main": "resize.js", "author": "Anton Semenov", "license": "", "dependencies": { "sharp": "^0.29.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 | |
| // Display the custom checkbow field in checkout | |
| add_action( 'woocommerce_review_order_before_order_total', 'fee_installment_checkbox_field', 20 ); | |
| function fee_installment_checkbox_field(){ | |
| echo '<tr class="packing-select"><th>'; | |
| woocommerce_form_field( 'installment_fee', array( | |
| 'type' => 'checkbox', | |
| 'class' => array('installment-fee form-row-wide'), | |
| 'label' => __('Montaža v 14 dneh (predpripravljen prostor) - 170€'), |
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 | |
| $args = array( | |
| 'post_type' => array( 'product' ), | |
| 'meta_key' => 'total_sales', | |
| 'orderby' => 'meta_value_num', | |
| 'order' => 'desc', | |
| 'posts_per_page' => 5 | |
| ); | |
| $popular_products = new WP_Query( $args ); |
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
| //Using wp cli | |
| wp wc tool run clear_sessions --user=1 | |
| Useful related commands: https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Overview#command-1 | |
| wp wc tool run delete_orphaned_variations --user=1 | |
| wp wc tool run clear_expired_transients --user=1 | |
| wp wc tool run clear_transients --user=1 | |
| --user=1 is an admin user with ID=1 in my case |
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 | |
| /* | |
| * THE FILTER | |
| * | |
| */ | |
| function custom_responsive_image_sizes($sizes, $img_name, $attachment_id) { | |
| $sizes = wp_get_attachment_image_sizes($attachment_id, 'original'); | |
| $meta = wp_get_attachment_metadata($attachment_id); | |
| $width = $meta['width']; |