Enqueue Script and Style to website head from a plugin


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if ( !is_admin() ) {
  2. add_action('wp_print_styles', 'wpe_styles');
  3. add_action('init','wpe_scripts');
  4. function wpe_styles() {
  5. $wpe_css_Url = WP_PLUGIN_URL . '/wp-estate/wp-estate.css';
  6. $wpe_css_File = WP_PLUGIN_DIR . '/wp-estate/wp-estate.css';
  7. if ( file_exists($wpe_css_File) ) {
  8. wp_register_style('wpe_styles', $wpe_css_Url);
  9. wp_enqueue_style( 'wpe_styles');
  10. }
  11. }
  12. function wpe_scripts() {
  13. $wpe_scripts_Url = WP_PLUGIN_URL . '/wp-estate/wp-estate.js';
  14. $wpe_scripts_File = WP_PLUGIN_DIR . '/wp-estate/wp-estate.js';
  15. if ( file_exists($wpe_scripts_File) ) {
  16. wp_register_script('wpe_scripts',$wpe_scripts_Url, array('jquery'),'' );
  17. wp_enqueue_script('wpe_scripts');
  18. }
  19. }
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.