GithubHelp home page GithubHelp logo

Comments (5)

renestalder avatar renestalder commented on June 10, 2024

Okay, it works in comments, but not somewhere else. Wanted behaviour?

from gulp-wp-theme.

xarem avatar xarem commented on June 10, 2024

It works in markup files (in comments and in the code) but it looks like it works only for the first replacement in every file.

Example:

src:

wp_enqueue_style('made_fonts', get_template_directory_uri() . '/fonts.css', [], '{PKG_VERSION}');
wp_enqueue_style('made_style', get_stylesheet_uri(), [], '{PKG_VERSION}');
wp_enqueue_script('made_scripts', get_template_directory_uri() . '/app.js', [], '{PKG_VERSION}', true);

dist:

wp_enqueue_style('made_fonts', get_template_directory_uri() . '/fonts.css', [], '0.0.0');
wp_enqueue_style('made_style', get_stylesheet_uri(), [], '{PKG_VERSION}');
wp_enqueue_script('made_scripts', get_template_directory_uri() . '/app.js', [], '{PKG_VERSION}', true);

from gulp-wp-theme.

renestalder avatar renestalder commented on June 10, 2024

This might only work if you remove the comment in the head of the default template. I've already tested to set a variable at start, after the first replacement which is the comment.

How about reading the package.json in PHP separately and setting a global variable for use in markup files? I'm bothered that there is a performance drop in compilation if the replace script of gulp would have to replace all instances of all markup files.

from gulp-wp-theme.

xarem avatar xarem commented on June 10, 2024

By default, we add the current version to the theme's style.css (https://github.com/whatwedo/gulp-wp-theme/blob/master/src/resources/stylus/style.styl#L6)

Therefore, you can use a WordPress internal function to get the current theme version:

https://codex.wordpress.org/Function_Reference/wp_get_theme#Display_the_Current_Theme.27s_Version

But anyway this bug should be fixed

from gulp-wp-theme.

renestalder avatar renestalder commented on June 10, 2024

Uhh.... didn't know about that.

Solves the problem entirely and IMHO should be used instead of replaces in markup.
https://codex.wordpress.org/Function_Reference/wp_get_theme

from gulp-wp-theme.

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.