Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created June 18, 2021 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szepeviktor/064f79f8788b0cae59df6e4eb5df5c93 to your computer and use it in GitHub Desktop.
Save szepeviktor/064f79f8788b0cae59df6e4eb5df5c93 to your computer and use it in GitHub Desktop.
Informative constants for WordPress wp_enqueue_script() and wp_enqueue_style()
<?php
namespace WordPress\Enqueue;
// wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false )
const DEPS_EMPTY = [];
const VER_CORE = false;
const VER_EMPTY = null;
const IN_HEADER = false;
const IN_FOOTER = true;
// wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' )
const MEDIA_ALL = 'all';
const MEDIA_PRINT = 'print';
const MEDIA_SCREEN = 'screen';
@szepeviktor
Copy link
Author

Usage

wp_enqueue_script(
	'main',
	'//cdn.example.com/main.js',
	WordPress\Enqueue\DEPS_EMPTY,
	WordPress\Enqueue\VER_EMPTY,
	WordPress\Enqueue\IN_FOOTER
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment