Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / Filtro JSON-LD di Rank Math per Categorie di Prodotto WooCommerce.md
Last active January 15, 2025 10:37
Filtro JSON-LD di Rank Math per Categorie di Prodotto WooCommerce

Filtro JSON-LD di Rank Math per Categorie di Prodotto WooCommerce

Questo filtro personalizzato aggiunge dati strutturati JSON-LD alle pagine delle categorie di prodotto in WooCommerce, migliorando la visibilità SEO e la ricchezza dei risultati nei motori di ricerca. Il filtro genera dati strutturati per i prodotti pubblicati e disponibili nella categoria corrente.

Funzionalità

  • Verifica che la pagina corrente sia una categoria di prodotto valida.
  • Recupera prodotti pubblicati e in stock, ordinati alfabeticamente.
  • Genera dati JSON-LD secondo lo standard Schema.org, includendo dettagli come nome, URL, descrizione, immagine e prezzi.
  • Supporta prodotti semplici e variabili, gestendo prezzi multipli per variazioni.
@FrancoStino
FrancoStino / Add TinyMCE Editor to WooCommerce Product Categories Description Field.md
Created January 11, 2025 12:17
Add TinyMCE Editor to Custom Taxonomy Categories Description Field

Add TinyMCE Editor to WooCommerce Product Categories Description Field

This snippet adds the TinyMCE editor to the description field of WooCommerce product categories in the WordPress admin panel. It ensures the wp_editor is loaded and applies TinyMCE to the description field for editing product categories.

Code

add_action( 'admin_enqueue_scripts', 'enqueue_editor_scripts' );
function enqueue_editor_scripts()
{
@FrancoStino
FrancoStino / WordPress ACF Image and YouTube URL Uploads via REST API.md
Last active November 26, 2024 16:54
Processes image URLs and YouTube iframe embeds from ACF fields during WordPress page creation via the REST API. It downloads, saves, and attaches images to the media library while extracting and storing YouTube URLs.

WordPress ACF Image and YouTube URL Uploads via REST API

Preview:
// Funzione per caricare l'immagine e ottenere l'ID dell'allegato
function uploadImageAndGetID( $img_url, $post_id, $name )
{
 // Carica i file necessari per la gestione degli allegati
 if ( !function_exists( 'wp_generate_attachment_metadata' ) )
 {
  require_once( ABSPATH . 'wp-admin/includes/image.php' );
@FrancoStino
FrancoStino / Simple Basic Authentication Plugin for WordPress REST API.md
Created November 26, 2024 16:41
This code snippet adds a simple Basic Authentication plugin for WordPress REST API. It checks if the username or password are valid, and then authenticates it using wp_authenticate(). If there is an error during authentication, it sets the current user ID to

WordPress Basic Authentication for REST API

Preview:
/*
Plugin Name: Basic Authentication for REST API
Plugin URI: https://example.com
Description: A simple Basic Authentication plugin for WordPress REST API.
Version: 1.0
Author: Il tuo nome
Author URI: https://example.com
@FrancoStino
FrancoStino / Woo Discount Rules v2 - Get discount details against product .md
Created November 26, 2024 12:16
This code, implemented as a WordPress action hook, retrieves and displays discount details for a WooCommerce product using the Advanced Discount Rules plugin. It fetches discount information, iterates through available discount rules, and outputs details like rule ID, start and end dates, and discount specifics.

Woo Discount Rules v2 - Get discount details against product

Preview:
add_action( 'wp_footer', function ()
{
    /** 
     * Get the discount details of given product with custom price
     * @param $price float/integer
     * @param $product object (Product object Example: wc_get_product($product_id))
     * @param $quantity int
@FrancoStino
FrancoStino / JetBrains trial reset.md
Created November 13, 2024 16:57 — forked from h3ssan/JetBrains trial reset.md
Reset all JetBrains products trial in Linux

In some cases, only these lines will work

for product in IntelliJIdea WebStorm DataGrip PhpStorm CLion PyCharm GoLand RubyMine; do
    rm -rf ~/.config/$product*/eval 2> /dev/null
    rm -rf ~/.config/JetBrains/$product*/eval 2> /dev/null
done

But if not, try these

@FrancoStino
FrancoStino / Add InCI Meta Box to Post.md
Created November 7, 2024 16:26
This code snippet adds an INCI meta box to a post. It retrieves the product and content, sets up settings for this document URL using Tinymce's editor class with specific parameters such as quicktags, textarea rows, media buttons, and wp_editor functions

Add InCI Meta Box to Post

Preview:
public function add_INCI_meta_box( $post )
    {
        $product  = wc_get_product( $post->ID );
        $content  = $product->get_meta( '_INCI_specs' );
        $settings = array(
            'tinymce'       => array(
                'setup' => 'function (ed) {
@FrancoStino
FrancoStino / Remove the branch locally and in the remote repository in one operation.md
Created September 2, 2024 09:39
This code snippet updates the "nome-branch" branch in a Git repository and deletes it from its origin.

Remove the branch locally and in the remote repository in one operation

Preview:
git branch -D nome-branch && git push origin --delete nome-branch
Associated Context
Type Code Snippet ( .sh )
Associated Tags Git branching Git push origin Nome-branch management Command line interface Node js frameworks Version control Data processing Remote repository creation Repository deletion
💡 Smart Description This code snippet updates the "nome-branch" branch in a Git repository and deletes it from its origin.
@FrancoStino
FrancoStino / Calculate Volumetric Weight Shipping - Woocommerce.md
Created August 14, 2024 09:39
A PHP function to calculate and set volumetric weight for shipping packages in WooCommerce based on product dimensions.

Calculate Volumetric Weight Shipping - Woocommerce

Preview:
<?php 

add_filter('woocommerce_cart_shipping_packages', 'calculate_volumetric_weight_shipping');

function calculate_volumetric_weight_shipping($packages) {
    $conversion_factor = 200; // Il fattore di conversione: 200 kg per m³
   
@FrancoStino
FrancoStino / git-export.md
Created July 29, 2024 14:19 — forked from vanquang9387/git-export.md
git: export diff files between 2 branches/commits

We can get list of changed files between 2 branches/commits by

$ tar --ignore-failed-read -vczf archive.tgz $(git diff --name-only --diff-filter=ACMRT master develop)

Let's see important part:

  1. git diff master develop:
    Get differences between master and develop branches.