Git Product home page Git Product logo

Comments (4)

benlk avatar benlk commented on August 25, 2024

The following things must be ensured:

  • every Pym instance on the page is initialized

Here are the solutions that I can think of:

string matching and global variables and filters to put the pymsrc script tag at the start of the_content()

  1. Add a filter to the_content that checks for the presence of the string 'pym', and if it is there, sets a global "maybe" variable to true
  2. In the pym renderer, if it is called, if the tag doesn't have its own pymsrc, set a global definitely variable to true. If pymsrc is set, then instead output the pymsrc's tag
  3. In a filter running on the_content that runs at a very late priority, like 100, if $maybe and $definitely, prepend the_content with a script tag that registers the appropriate pymsrc.

Enqueue the new pym.Parent in the footer

  1. Everytime we would output a <script>var pym_1 = new pym.Parent('pym_1', 'https://f.benlk.com/graphics/heartbeat-abortion-bills/child.html', {})</script> , instead of outputting it then, add it to the footer with a generated callback function that has the correct variables inserted into its call.

This doesn't move the location of the pymsrc tag starting Pym, but it also does not prevent addressing #33 by enqueuing the pymsrc tag in the wp_footer as long as the function outputting that tag is enqueued at a higher priority.

from pym-shortcode.

benlk avatar benlk commented on August 25, 2024

I asked in #wordpress on freenode IRC, and received feedback to the effect that the best place to put those script tags is in <head> or at the end of <body> with wp_footer.

from pym-shortcode.

benlk avatar benlk commented on August 25, 2024

My worry is that someone using this plugin is going to be using WordPress in a way that powers a non-main-website content presentation, and their content presentation is going to render the_content() as HTML with scripts and stuff, but without any of the dependency-satisfying code from wp_footer.

from pym-shortcode.

benlk avatar benlk commented on August 25, 2024

Feedback in #wordpress on newsnerdery.org Slack from several people also recommends wp_footer.

from pym-shortcode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.