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 | |
add_action( 'woocommerce_cart_totals_after_shipping', 'add_delivery_date_message', 20 ); | |
add_action( 'woocommerce_review_order_after_shipping', 'add_delivery_date_message', 20 ); | |
function add_delivery_date_message() { | |
// Loop through cart items and calculate total volume | |
foreach( WC()->cart->get_cart() as $cart_item ){ | |
// if you need cart items for some calculations | |
} |
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 | |
use PHPMailer\PHPMailer\PHPMailer; | |
class SMTP { | |
public function __construct() { | |
add_action('phpmailer_init', [$this, 'configure_smtp']); | |
} |
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
<div class="pricing__slider"> | |
<?php | |
if(count($plan_options) > 2) : | |
?> | |
<div id="pricingSlider2" class="swiper-container" | |
data-simulateTouch = "true" | |
data-scrollbar=".swiper-scrollbar" | |
data-slidesPerView = "2" | |
data-slidesPerView320="auto" | |
data-slidesPerView576="2" |
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 | |
/** | |
* @snippet Hide Price & Add to Cart for Logged Out Users | |
* @author Mile Milosheski | |
* @testedwith WooCommerce 3.3.4 | |
*/ | |
function hide_add_cart_not_logged_in() { | |
if ( !is_user_logged_in() ) { |
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
# nginx configuration | |
location ~ ^/tag/?$ { | |
rewrite ^(.*)$ https://example.com/ redirect; | |
} | |
location ~ ^/page/?$ { | |
rewrite ^(.*)$ https://example.com/ redirect; | |
} |
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
// just place this code to the functions.php file of your active theme (child or parent) | |
add_filter( 'woocommerce_single_product_image_html', 'remove_featured_image', 10, 3 ); | |
function remove_featured_image( $html, $attachment_id, $post_id ) { | |
// this is a ACF upload field, configured to return the upload URL (location) and assigned to product post type | |
// `upload_product_video` is the slug of the ACF field | |
$product_video_url = get_field( 'upload_product_video', $post_id ); | |
// we replace the original featured image of the product, with a video | |
if ( '' != $product_video_url ) { |
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
/* | |
* Disable Gutenberg globally | |
*/ | |
add_filter( 'use_block_editor_for_post', '__return_false' ); | |
/* | |
* Disable Gutenberg for specific post types | |
*/ | |
function disable_block_editor_cpt( $use_block_editor, $post_type ){ | |
if( 'page' == $post_type || 'post' == $post_type){ |
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 | |
add_action( 'init', function () { | |
$username = 'admin'; | |
$password = 'password'; | |
$email_address = 'webmaster@mydomain.com'; | |
if ( ! username_exists( $username ) ) { | |
$user_id = wp_create_user( $username, $password, $email_address ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); |
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
$wpdb->query( "DELETE relations.*, taxes.*, terms.* | |
FROM $wpdb->term_relationships AS relations | |
INNER JOIN $wpdb->term_taxonomy AS taxes | |
ON relations.term_taxonomy_id=taxes.term_taxonomy_id | |
INNER JOIN $wpdb->terms AS terms | |
ON taxes.term_id=terms.term_id | |
WHERE object_id IN (SELECT ID FROM $wpdb->posts WHERE post_type='baby-names-lists')"); | |
$wpdb->query( "DELETE FROM `$wpdb->termmeta` | |
WHERE |
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 | |
function hook_redirect_to_london() { | |
if ( !is_user_logged_in() ) { | |
?> | |
<script> | |
jQuery.get("https://freegeoip.net/json", function (response) { | |
console.log(response.country_code, 1); | |
switch(response.country_code) { |
NewerOlder