TplMng

// This code is part of the template, $tplData[‘hasShellZip’] is provided through TplMng $hasShellZip = $tplData[‘hasShellZip’]; if ($hasShellZip) { esc_html_e(‘The “Shell Zip” mode allows…’, ‘duplicator-pro’); ?>Continue reading

HTML inside PHP

// ❌ The output of this function is not readable public function displayHtml() { //some logic here echo ‘ ‘; echo ‘‘; echo ‘‘; echo __(‘Some text’, ‘duplicator-pro’); echo ‘ ‘; } // ❌ This function needs to escape large…Continue reading

Escaping data with wp_kses

// ❌ Don’t use html tags in escaping functions like esc_html, esc_attr and their localized equivalents // Expected output: This part of the text is bold and this part underlined. esc_html_e( ‘This part of the text is bold and this…Continue reading

Basic WP escaping functions

// ❌ Don’t use _e(), __(), _x() etc. to output data // ✅ Use the escaped versions instead esc_html_e(), esc_html__(), esc_html_x() etc. // ❌ Don’t echo any HTML attributes without escapingContinue reading

Observe the Target Node Mutations (DOM)

// Options for the observer (which mutations to observe) const config = { attributes: true, childList: true, characterData: true, subtree: true, }; // Callback function to execute when mutations are observed const callback = (mutationList, observer) => { for (const…Continue reading

After Checkout Event In WooCommerce

add_action( ‘woocommerce_thankyou’, ‘pe_wc_checkout_script’, 10, 1); function pe_wc_checkout_script($order_id) { $cart_campaign_name = ‘Enter cart abandonment campaign name’; do_action(‘pe_wpcode_wc_checkout_script’, $order_id, $cart_campaign_name); }Continue reading

On Add to Cart Event in WooCommerce

add_action( ‘woocommerce_add_to_cart’, ‘pe_wc_cart_script’, 10, 6); add_action( ‘wp_enqueue_scripts’, ‘pe_wc_cart_ajax_script’ ); function pe_wc_cart_script( $cart_item_key, $product_id, …$rest_params ) { $browse_campaign_name = ‘Enter browse abandonment campaign name’; $cart_campaign_name = ‘Enter cart abandonment campaign name’; do_action(‘pe_wpcode_wc_cart_script’, $product_id, $browse_campaign_name, $cart_campaign_name); } function pe_wc_cart_ajax_script() { $browse_campaign_name =…Continue reading

On Browsing WooCommerce Products

add_action( ‘woocommerce_after_single_product’, ‘pe_wc_browse_script’ ); function pe_wc_browse_script() { $browse_campaign_name = ‘Enter browse abandonment campaign name’; do_action(‘pe_wpcode_wc_browse_script’, $browse_campaign_name ); }Continue reading