All Projects → mindkomm → theme-lib-mix

mindkomm / theme-lib-mix

Licence: MIT License
A Laravel Mix function for WordPress themes.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to theme-lib-mix

air
A hyper-minimal WordPress starter theme for developers built with Tailwind CSS.
Stars: ✭ 45 (+36.36%)
Mutual labels:  wordpress-theme, theme-development
sage-laravel-mix
🌟 Sage 9 with laravel mix & vuejs
Stars: ✭ 31 (-6.06%)
Mutual labels:  wordpress-theme, laravel-mix
FAU-Einrichtungen
WordPress-Theme für zentrale Einrichtungen der Friedrich-Alexander-Universität Erlangen-Nürnberg
Stars: ✭ 15 (-54.55%)
Mutual labels:  wordpress-theme
WordPress-UIkit-Starter-Theme
A WordPress starter theme for developers using the frontend framework UIkit
Stars: ✭ 55 (+66.67%)
Mutual labels:  wordpress-theme
blade-generate
Forces generation of Blade template cache files for Sage9.
Stars: ✭ 64 (+93.94%)
Mutual labels:  wordpress-theme
bootstrap-basic
Bootstrap 3 css framework theme for wordpress. For theme developer can start build their theme very fast. To download for use with your project, please go to wordpress.org themes page in the link.
Stars: ✭ 22 (-33.33%)
Mutual labels:  wordpress-theme
envoyer-npm-deployment
Compile assets that depend on node packages using Laravel Envoyer deployment hooks
Stars: ✭ 43 (+30.3%)
Mutual labels:  laravel-mix
wp-spa-boilerplate
A JavaScript single page WordPress theme boilerplate using Vue.js and the WordPress REST API.
Stars: ✭ 13 (-60.61%)
Mutual labels:  wordpress-theme
wp-theme-zentile
Zentile is a lightweight magazine theme inspired by Yandex.Zen
Stars: ✭ 27 (-18.18%)
Mutual labels:  wordpress-theme
gridd
Flexible grid-based WordPress theme
Stars: ✭ 38 (+15.15%)
Mutual labels:  wordpress-theme
mediawiki twentyten
The TwentyTen theme for WordPress ported to a MediaWiki skin.
Stars: ✭ 14 (-57.58%)
Mutual labels:  wordpress-theme
primer-child-escapade
Escapade is a Primer child theme with a unique sidebar navigation.
Stars: ✭ 15 (-54.55%)
Mutual labels:  wordpress-theme
starter-kit-theme
WordPress starter theme with a modern development stack for launching projects faster and easily
Stars: ✭ 25 (-24.24%)
Mutual labels:  wordpress-theme
react-theme
Production ready Wordpress theme built with React, Redux, Redux-Thunk, Intl, React Router v4, etc... and packaged by Webpack 2. Enjoy!
Stars: ✭ 14 (-57.58%)
Mutual labels:  wordpress-theme
primer-child-stout
Stout is a GoDaddy Primer child theme with a bold vibe.
Stars: ✭ 13 (-60.61%)
Mutual labels:  wordpress-theme
Tint-Pro
WordPress高级扩展主题Tinection Two/Tint
Stars: ✭ 42 (+27.27%)
Mutual labels:  wordpress-theme
win10exp
WordPress win10exp主题
Stars: ✭ 25 (-24.24%)
Mutual labels:  wordpress-theme
craft-boilerplate
Starter project for Craft CMS & Tailwind CSS Sites
Stars: ✭ 18 (-45.45%)
Mutual labels:  laravel-mix
untheme
A blank WordPress theme for developers.
Stars: ✭ 82 (+148.48%)
Mutual labels:  wordpress-theme
brunch-wordpress-theme
WordPress Starter Theme That Uses Brunch, Bower, And Bootstrap
Stars: ✭ 15 (-54.55%)
Mutual labels:  wordpress-theme

Mix

A Laravel Mix function for WordPress themes.

The mix() function is useful if you want to enable cache busting for your theme asset files (CSS, JavaScript, images, icon sprites). Laravel Mix allows you to create a mix-manifest.json file, which might look like this:

{
    "/css/styles.css": "/css/styles.css?id=6ed48b0b831e80bd7549",
    "/js/scripts.js": "/js/scripts.js?id=1bdd07b944e933aa88aa",
}

The ID parameter is a hash of the file contents that changes every time that you make a change to a file. The mix(), mix_child() and mix_any() functions provided in this package allow you to use these hashed URLs for enqueueing your assets in your WordPress theme.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-mix

Usage

The mix() function assumes that you have a mix-manifest.json (generated by the version function of Laravel Mix) in the build folder of your theme.

add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style(
        'styles',
        mix( 'build/css/styles.css' )
    );
} );

If the mix function can’t find your asset file in the manifest file, it will return the asset URL through get_theme_file_uri as a fallback.

Functions

Name Return Type Summary/Returns
mix() string Gets the path to a versioned Mix file in a theme.

Returns: The versioned file URL.
mix_child() string Gets the path to a versioned Mix file in a child theme.

Returns: The versioned file URL.
mix_any() string Gets the path to a versioned Mix file outside of your theme folders.

Returns: The versioned file URL.

mix()

Gets the path to a versioned Mix file in a theme.

Use this function if you want to load theme dependencies. This function will cache the contents of the manifest files for you.

  • If you want to use mix in a child theme, use mix_child().
  • If you want to use mix outside of your theme folder, you can use mix_any().

since 1.0.0

mix( string $path, array $args = [] )

Returns: string The versioned file URL.

Name Type Description
$path string The relative path to the file.
$args array Optional. An array of arguments for the function.
  • (bool) $is_child – Whether to check the child directory first. Default false.
  • (string) $manifest_directory – Custom relative path to manifest directory. Default build.
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style(
        'styles',
        mix( 'build/css/styles.css' )
    );
} );

mix_child()

Gets the path to a versioned Mix file in a child theme.

Similar to mix(), but tries to load a file from the child theme first.

since 1.2.0

mix_child( string $path, array $args = [] )

add_action( 'wp_enqueue_scripts', function() {
	wp_enqueue_style(
		'theme-styles-child',
		mix_child( 'build/css/styles-child.css' ),
		[],
		null
	);
} );

mix_any()

Gets the path to a versioned Mix file outside of your theme folders.

The difference to the mix() function is that for this function, you need to provide the absolute paths to the file and the manifest directory. The benefit is that it’s more versatile and that you can use it for functionality that might not live in a theme, but in a plugin, vendor packages or in a symlinked package.

since 1.1.0

mix_any( string $path, string $manifest_directory, string $manifest_name = mix-manifest.json )

Returns: string The versioned file URL.

Name Type Description
$path string The full path to the file.
$manifest_directory string The full path to the manifest directory.
$manifest_name string Optional. The name of the manifest file in $manifest_directory. Default mix-manifest.json.

Support

This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].