Created
February 4, 2017 19:38
-
-
Save badcrocodile/aede719461fb373be7945849ca9f8eb0 to your computer and use it in GitHub Desktop.
One way to add_action ooo style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace IngredientManager; | |
/** | |
* Usage: In calling script: | |
* $enqueue_scripts = new EnqueueScript | |
*/ | |
class EnqueueScript | |
{ | |
public function __construct() | |
{ | |
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); | |
} | |
/** | |
* Enqueue scripts & styles | |
* | |
* @return bool | |
*/ | |
public function enqueue_scripts() | |
{ | |
// *_version updates version # whenever file is updated to help with caching issues | |
$js_version = date("ymd-Gis", filemtime(plugin_dir_path(dirname(__FILE__)) . 'Resources/js/scripts.js')); | |
$css_version = date("ymd-Gis", filemtime(plugin_dir_path(dirname(__FILE__)) . 'Resources/css/styles.css')); | |
wp_enqueue_script('scripts', plugin_dir_url(dirname(__FILE__)) . 'Resources/js/scripts.js', array('jquery'), $js_version); | |
wp_enqueue_style('styles', plugin_dir_url(dirname(__FILE__)) . 'Resources/css/styles.css', false, $css_version); | |
wp_enqueue_script('font-awesome', 'https://use.fontawesome.com/206ac00799.js'); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment