Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Why do you do_action wp_enqueue_scripts? #154

Open
HashimotoEffata opened this issue Aug 31, 2023 · 1 comment
Open

Why do you do_action wp_enqueue_scripts? #154

HashimotoEffata opened this issue Aug 31, 2023 · 1 comment

Comments

@HashimotoEffata
Copy link

HashimotoEffata commented Aug 31, 2023

Issue

The do_action code reads the wpcf7 script to be dequeued.

table-of-contents-plus/class-toc-plus.php:250
do_action( 'wp_enqueue_scripts' );

Steps to reproduce

Twenty Twenty-One: 1.9

Table of Contents Plus: 2302
Contact Form 7: 5.8

  1. Add the following code to functions.php.
// A
add_action('wpcf7_enqueue_scripts', function() {
	wp_dequeue_script('contact-form-7');
});
// B
add_filter('wpcf7_load_js', '__return_false');
  1. Create a new post consisting of [toc] and 4 h2s.
  2. On the published post open the developer-tool and in the Network tab filter for "contact-form-7" and make sure the contact-form-7 script is read.
  3. Update options by removing "Show text" and "Hide text" in Heading text in Admin Page->Settings->TOC+.
  4. If you check the Network tab of developer-tool again, the contact-form-7 script is not being read.
    This is very strange.

Method B is the method introduced officially.
https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/

If I comment out either the A or B code, it will work.

Why do you do do_action wp_enqueue_scripts on line 250 of table-of-contents-plus/class-toc-plus.php?

@zedzedzed
Copy link
Owner

Apologies for the late reply.

It was done in this manner to reseed the javascript function with overrides provided when using the toc shortcode. I've redone the logic so that it shouldn't affect what you're doing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants