Home › Forums › WordPress › Enqueue Scripts and Styles › Enqueue Scripts in a Class
- This topic has 0 replies, 1 voice, and was last updated 8 years, 3 months ago by Layer7web.
Viewing 0 reply threads
-
AuthorPosts
-
-
August 15, 2016 at 10:16 pm #2396
Layer7webKeymasterPHP12345678910111213141516<?phpif ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directlyif ( ! class_exists( 'ExampleClass' ) ) {class ExampleClass {public function __construct() {add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_and_css' ) );}public function enqueue_scripts_and_css(){wp_register_script( 'handle_of_script', 'path/to/script/example.js' );wp_enqueue_script( 'handle_of_script' );}}}- This topic was modified 8 years, 3 months ago by Layer7web.
-
-
AuthorPosts
Viewing 0 reply threads
You must be logged in to reply to this topic.
Comments are closed.