vendredi 3 juin 2016

Wordpress: How to load javascript in plugin when only the hostname exists

I have a series of plugins that only load their respective javascript files, based on a page name, as follows:

function getnames_scripts() {
  global $post;
  if ( in_array( $post->post_name, array( 'somepage', 'anotherpage') ) ){
    wp_enqueue_script(
      'getnames-script',
      plugin_dir_url(__FILE__) . "assets/getnames.js",
      array('jquery'),
      '1.0',
      true
    );
  }

How can I check to load the javascript when only the hostname is present, i.e. 192.0.0.50, instead of 192.0.0.50/somepage/?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire