Let's create one million posts to see the performance of a Wordpress site.
The purpose of this document is to find out what is the underlying data that gets modified in a wordpress database when a post with an image are created.
| <?php | |
| /** | |
| * Plugin Name: Cotizador de Regalos | |
| * Description: Plugin para cotizar regalos personalizados. | |
| * Version: 1.0 | |
| */ | |
| // ✅ Configurar ACF para guardar y cargar campos desde la carpeta del plugin | |
| add_filter('acf/settings/save_json', function () { | |
| return plugin_dir_path(__FILE__) . 'acf-json'; | |
| }); | 
| <?php | |
| add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) { | |
| if ( is_user_logged_in() && is_shop() && $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
| $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"><div class="ct-cart-actions">'; | |
| $html .= woocommerce_quantity_input( array(), $product, false ); | |
| $html .= '<button type="submit" class="single_add_to_cart_button button alt" name="add-to-cart" value="' . $product->get_id() . '">' . esc_html( $product->add_to_cart_text() ) . '</button>'; | |
| $html .= '</div></form>'; | |
| } | |
| return $html; | |
| }, 10, 2 ); | 
| <?php | |
| // Add this to Content Blocks > Hook > No Condition or Location | |
| // Call it through Customizer > Product Archives > Card Options > Enable Content Block Element > Select the Hook name in drop down | |
| if ( is_product() || is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { | |
| global $product; | |
| if ( ! $product->is_sold_individually() && 'variable' != $product->product_type && $product->is_purchasable() && $product->is_in_stock() ) { | |
| echo '<div class="dhn-atc-wrap">'; | |
| woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) ); | |
| echo '<a href="' . esc_url( $product->add_to_cart_url() ) . '" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="' . esc_attr( $product->get_id() ) . '" aria-label="' . esc_attr( sprintf( __( 'Add to cart: %s', 'woocommerce' ), $product->get_name() ) ) . '" aria-describedby="" rel="nofollow">' . esc_html( $p | 
| <?php | |
| add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) { | |
| if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
| $class = implode( ' ', array_filter( array( | |
| 'button', | |
| 'product_type_' . $product->get_type(), | |
| $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', | |
| $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', | |
| ) ) ); | 
| /* | |
| * Adding extra field on New product popup/without popup form | |
| */ | |
| add_action( 'dokan_new_product_after_product_tags','new_product_field',10 ); | |
| function new_product_field(){ ?> | |
| <div class="dokan-form-group"> | 
| <?php | |
| /** | |
| * Put this into your functions.php of your child-theme or custom plugin | |
| * you can create the role with wp-cli by running `wp shell` and running the command: | |
| * add_role('merchant','Merchant',array('read' => true, 'delete_posts' => false) ); | |
| */ | |
| /** | |
| * Step #1: create the field used to store the new sale_price for product_variation and for products | |
| */ | 
| <?php | |
| /* | |
| Plugin Name: Custom Birthday Plugin | |
| Plugin URI: | |
| Description: Plugin que crea una tabla de cumpleaños en la base de datos. | |
| Version: | |
| Author: | |
| Author URI: | |
| License: | |
| License URI: | 
| <?php | |
| /** | |
| * Update Post Title from an ACF field value on post save. | |
| * | |
| * Triggers on save, edit or update of published posts. | |
| * Works in "Quick Edit", but not bulk edit. | |
| */ | |
| function sync_acf_post_title($post_id, $post, $update) { | |
| $acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here | 
| <?php | |
| $sku = 'ITEM001'; | |
| $qty = 1; | |
| // Get product_id from SKU — returns null if not found | |
| $product_id = wc_get_product_id_by_sku( $sku ); | |
| // Process if product found | |
| if ( $product_id != null ) { |