javascript, jQuery

SquareSpace Scroll + YouTube PopUP

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() { 
    
    $('a[href*="https://www.youtube.com/watch?"]').each(function() {
  $(this).attr('data-fancybox','');
 });
      
   $('a[href*="https://youtu.be/"]').each(function() {
  $(this).attr('data-fancybox','');
 });    
	
	
	});
</script>

<script>
$(document).ready(function(){
  // Add smooth scrolling to all links
  $("a").on('click', function(event) {

    // Make sure this.hash has a value before overriding default behavior
    if (this.hash !== "") {
      // Prevent default anchor click behavior
      event.preventDefault();

      // Store hash
      var hash = this.hash;

      // Using jQuery's animate() method to add smooth page scroll
      // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
      $('html, body').animate({
        scrollTop: $(hash).offset().top
      }, 800, function(){
   
        // Add hash (#) to URL when done scrolling (default click behavior)
        window.location.hash = hash;
      });
    } // End if
  });
});
</script>

Aggiungendo il codice in tutte le pagine non ci sono problemi

il clic si attiva su ID dell’elemento sia un <p> o un <div>

 

Senza categoria

SquareSpace Scroll

va inserito dentro la pagina specifica

<script src="https://code.jquery.com/jquery-2.1.3.min.js">
</script><script type="text/javascript">
$(function() {$('a[href*=#]:not([href=#])').click(function() {if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {var target = $(this.hash);target = target.length ? target : $('[name=' + this.hash.slice(1) +']');if (target.length) {$('html,body').animate({scrollTop: target.offset().top}, 1000);return false;}}});});
</script>

si aggiunge un nuovo blocco di codice

<a name="special"></a>

 

PHP, WordPress

Plugin Cart Flatsome

file woocommerce-cart-add-ons.php

cercare la linea <ul class=”products sfn-cart-addons”>

<ul class="products sfn-cart-addons row large-columns-4 medium-columns-3 small-columns-1 row-small">

 

AGGIUNGI AL FILE woocommerce-cart-add-ons.php (riga 71 circa)

//checkout page
add_action('woocommerce_after_checkout_form', array($this, 'cart_display_addons'), 20);

 

javascript

mobile da javascript

<script>
jQuery( document ).ready(function($) {      
    var isMobile = window.matchMedia("only screen and (max-width: 760px)").matches;

    if (isMobile) {
        //Conditional script here

    } 
 });

</script>

 

Senza categoria

Youtube embed

<div class="rwd-video">
    <iframe src="//www.youtube.com/embed/ID-VIDEO?rel=0" allowfullscreen="" frameborder="0" height="360" width="640">
    </iframe>
</div>
.rwd-video {
    height: 0;
    overflow: hidden;
    padding-bottom: 56.25%;
    padding-top: 30px;
    position: relative;
}
.rwd-video iframe,
.rwd-video object,
.rwd-video embed {
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
}

Bisogna mantenere la proporzione di 56,25% che è il rapporto di 16/9  (9/16 = 0,5625)

Per calcolare ampiezze differenti: altezza*0,5625: 640*0,5625 = 360 e manterrà l’aspect ratio

WordPress

Cercare utilizzo Coupon WooCommerce

Questo snipet di codice consente di ricercare un codice coupon nelle tabelle giuste e di estrapolare l’indirizzo email di chi lo ha utilizzato

SELECT meta_value as EMAIL_CLIENTE from wpdx_postmeta WHERE 
meta_key = '_billing_email'
AND
post_id IN (
SELECT order_id FROM wpdx_woocommerce_order_items WHERE order_item_name = 'domini30anni'
);

VERSIONE POTENTE – Cerca da una certa data in poi o in un range di date

SELECT meta_value as EMAIL_CLIENTE from wpdx_postmeta WHERE 
meta_key = '_billing_email'
AND
post_id IN (
SELECT post_id as ID from wpdx_postmeta WHERE 
meta_key = '_completed_date' AND meta_value >= '2019-03-05'
AND
meta_key = '_completed_date' AND meta_value <= '2019-03-30'
AND
post_id IN (
SELECT order_id FROM wpdx_woocommerce_order_items WHERE order_item_name = 'domini30anni'
));

 

PHP

Fix Bridge – Velocità caricamento

  1. guarda bridgeshoot.com/shop / per prima cosa sistema i permessi con il file chmod

Create this files in your child theme: custom_js.js, custom_css.css, default_dynamic.js, style_dynamic.css. style_dynamic_responsive.css

3. View your site’s viewsource, open and copy custom_js.php, custom_css.php, default_dynamic.php, style_dynamic.php and style_dynamic_responsive.php content to it’s correspnding files created in child theme

4. Last step is to paste this code to your child theme’s functions.php file:

function qode_styles_child() {
    wp_deregister_style('style_dynamic');
    wp_register_style('style_dynamic', get_stylesheet_directory_uri() . '/style_dynamic.css');
    wp_enqueue_style('style_dynamic');

    wp_deregister_style('style_dynamic_responsive');
    wp_register_style('style_dynamic_responsive', get_stylesheet_directory_uri() .'/style_dynamic_responsive.css');
    wp_enqueue_style('style_dynamic_responsive');

    wp_deregister_style('custom_css');
    wp_register_style('custom_css', get_stylesheet_directory_uri() . '/custom_css.css');
    wp_enqueue_style('custom_css');
}

function qode_scripts_child() {
    wp_deregister_script('default_dynamic');
    wp_register_script('default_dynamic', get_stylesheet_directory_uri() . '/default_dynamic.js');
    wp_enqueue_style('default_dynamic', array(),false,true);

    wp_deregister_script('custom_js');
    wp_register_script('custom_js', get_stylesheet_directory_uri() . '/custom_js.js');
    wp_enqueue_style('custom_js', array(),false,true);
}

add_action( 'wp_enqueue_scripts', 'qode_styles_child', 11);
add_action( 'wp_enqueue_scripts', 'qode_scripts_child', 11);