Why does my custom plugin only function correctly once per page?

The reason your code only applies to the first table, is because you are only selecting the first input with var number = document.querySelector(‘.nutrition-table__number’); You need to loop over all your tables, and add an event listener to each. Here is an example of how this could work. The plugin pattern is from https://vanillajstoolkit.com/boilerplates/revealing-module-pattern/ /*! … Read more

Changing the pointing of assets from old server to new server

Usually scripts and styles are loaded with wp_enqueue_script or wp_enqueue_style in the theme’s functions.php. That’s the most common scenario. This function takes an $src parameter which is the absolute URL to the resource, and the best practice is to use get_stylesheet_directory_uri to retrieve the URL to the folder containing the script. This way, if the … Read more

How to generate expiring URL of the page?

This plugin fits most of the requirements that you need: https://wordpress.org/plugins/public-post-preview/ It allows you to share a preview of the page to anyone with the link. You can modify the expiry time with a filter. add_filter( ‘ppp_nonce_life’, ‘my_nonce_life’ ); function my_nonce_life() { return 60 * 60 * 24 * 1; // 1 day }

Apply only the css in my style.css file

You can’t, not without isolating the insides of the block. This means you would need to use an iframe or build a web component. This will require significant effort, and also carry lots of downsides and new problems. Instead, investigate CSS specificity as fundamentally it’s a CSS problem not a WordPress problem. Note that by … Read more

show wc_add notices on particular page in woo commerce custom plugin development

I solve this problem below is code. add_action( ‘woocommerce_init’, array( $this, ‘afwo_add_notices’ ) ); public function afwo_add_notices() { if ( isset( $_POST[‘whatsapp_cart_nonce_field’] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[‘whatsapp_cart_nonce_field’] ) ), ‘whatsapp_cart_field’ ) ) { echo ”; } if ( empty( WC()->session->get( ‘WhatsApp_cart’ ) ) ) { return; } if ( isset( $_GET[‘index_to_remove’] ) ) { … Read more