Jump to content


These Forums Are Now Read-Only


For TubePress support, please post a question here or open a support ticket and we will be glad to assist.


Photo

Specify Which Pages Tubepress Assets Load On


Best Answer eric, 30 May 2014 - 12:43 AM

Hi ddover,
 
Thanks for the good question. As Brandon indicated, TubePress doesn't offer out-of-the-box support for selective page loading in WordPress environments. While it's certainly possible to selectively load plugins, we're not aware of any non-programmatic way to do this easily. That said, it seems like you are pretty comfortable with PHP and the WordPress API, so here are some tips:
 
In TubePress 3.1.x and below, here is where TubePress enqueues its script and CSS file. You can ignore the $wordPressFunctionWrapper-> noise as that is simply there for unit testing. e.g. 

$wordPressFunctionWrapper->wp_enqueue_script()

is the same as

wp_enqueue_script()

So you could easily add some logic at line 56 to only run on certain pages. e.g.

...
if (!is_page('my videos')) {
    return;
}
$wordPressFunctionWrapper->wp_register_script('tubepress', $jsUrl);
$wordPressFunctionWrapper->wp_register_style('tubepress', $cssUrl);
...

Does that answer your question?

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 ddover

ddover

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 24 May 2014 - 04:16 PM

Hi there,

 

I am running TubePress Pro 3.1.1 on Wordpress 3.9.1.

 

Currently TubePress's assets (tubepress.css and tubepress.js) load on every page on my site. This is unnecessary, as the plugin is only utilized on a few pages.

 

How do I prevent the assets from loading on certain pages?

 

Better yet, how do whitelist which pages the assets should load on?



#2 brandon

brandon

    Advanced Member

  • TubePress Staff
  • 1989 posts

Posted 27 May 2014 - 08:22 PM

Hello ddover,

 

Due to the way that wordpress works, it is not possible to prevent TubePress from loading on certain pages, while loading on others.  Please note that the js and css files are very tiny and most likely do not impact the load time of your site.

 

Thanks!


Want a faster, more personalized support experience? Open a ticket with us! We will be gradually phasing out forum-based support in favor of a proper ticketing system. Please help us help you!


#3 ddover

ddover

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 28 May 2014 - 07:55 PM

Hi there,

 

"Due to the way that wordpress works, it is not possible to prevent TubePress from loading on certain pages, while loading on others."

 

With all due respect, that is clearly not the case: See http://codex.wordpre...ference/is_page and http://codex.wordpress.org/Function_Reference/is_single

 

Note that these functions allow for parameters which allow you to specify IDs and Titles and Slugs to identify specific pages and posts.

 

 

Would you mind running my question by one of your developers?



#4 brandon

brandon

    Advanced Member

  • TubePress Staff
  • 1989 posts

Posted 28 May 2014 - 09:56 PM

Hi ddover,

 

I've asked a developer to look at your post.

 

Thanks


Want a faster, more personalized support experience? Open a ticket with us! We will be gradually phasing out forum-based support in favor of a proper ticketing system. Please help us help you!


#5 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 30 May 2014 - 12:43 AM   Best Answer

Hi ddover,
 
Thanks for the good question. As Brandon indicated, TubePress doesn't offer out-of-the-box support for selective page loading in WordPress environments. While it's certainly possible to selectively load plugins, we're not aware of any non-programmatic way to do this easily. That said, it seems like you are pretty comfortable with PHP and the WordPress API, so here are some tips:
 
In TubePress 3.1.x and below, here is where TubePress enqueues its script and CSS file. You can ignore the $wordPressFunctionWrapper-> noise as that is simply there for unit testing. e.g. 

$wordPressFunctionWrapper->wp_enqueue_script()

is the same as

wp_enqueue_script()

So you could easily add some logic at line 56 to only run on certain pages. e.g.

...
if (!is_page('my videos')) {
    return;
}
$wordPressFunctionWrapper->wp_register_script('tubepress', $jsUrl);
$wordPressFunctionWrapper->wp_register_style('tubepress', $cssUrl);
...

Does that answer your question?



#6 ddover

ddover

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 31 May 2014 - 05:08 PM

Thanks Eric,

 

That is the information I am looking for! You rock, thanks!