Quick Post Widget
Inclusion of files everywhere (8 posts)

  1. silvanasono
    Posted 4 years ago #

    thanks for this plugin, it is very good.
    I have the following problem and, as i am not so experienced in building plugins, i could not solve it.
    I want this post widget being only in a page. I expected that everything should have been loaded in that page, instead all the js, css files are loaded in any page of the site and in some cases this create conflict with some configuration, beyond the fact that the website load so many files all together everytime, even when not necessary.
    If you have an idea how to adjust this problem it will be great, otherwise i would need to uninstall this plugin.

    Thank you very mcuh


  2. Diogo15
    Posted 4 years ago #

    If you want to contribute with the plugin development, and you have experience with wp,php,js, you can make it to work like this:
    otherwise, you can use wordpress function IS_PAGE(), before every request http://codex.wordpress.org/Function_Reference/is_page

    I added a new condition: IS_HOME():

    if (!is_admin() && !is_home() ) {
    	wp_enqueue_style('jquery-ui-style', $qpw_plugin_url . 'css/jquery-ui.css');
    	wp_enqueue_script('tinymce', get_bloginfo('wpurl') . '/wp-includes/js/tinymce/tiny_mce.js');
    	wp_enqueue_script('tinybrowser', $qpw_plugin_url . 'mce/tinybrowser/tb_tinymce.js.php');
    	wp_enqueue_script('datepicker', $qpw_plugin_url . 'js/ui.datepicker.min.js', array('jquery'));
    	wp_enqueue_script('datepicker-' . $qpw_locale, $qpw_plugin_url . 'js/ui.datepicker-' . $qpw_locale . '.js', array('datepicker'));
    	wp_enqueue_script('slider', $qpw_plugin_url . 'js/ui.slider.js', array('jquery','jquery-ui-dialog'));
    	wp_enqueue_script('timepicker', $qpw_plugin_url . 'js/jquery-ui-timepicker-addon.js', array('slider'));
    	wp_enqueue_script('quick-post-script', $qpw_plugin_url . 'js/qpw.js', array('jquery','jquery-ui-dialog'));
    	wp_enqueue_script('qpw_locale_' . $qpw_locale, $qpw_plugin_url . 'mce/langs/' . $qpw_locale . '.js');
    	if(!isset($_SESSION)) { @session_start(); }
    	$_SESSION['qpw_locale'] = $qpw_locale;
    	} else {
    		wp_enqueue_script('quick-post-script', $qpw_plugin_url . 'js/qpw_admin.js');
  3. silvanasono
    Posted 4 years ago #

    Well, it is exactly how i have done, i put !is_home and it did not work, because it did not load the functions at all. Anyway i will try again as you suggested, it might be that i had missed something...

  4. Diogo15
    Posted 4 years ago #

    If you want the plugin just work in home page, you must to write:

    if (!is_admin() && is_home() )

    Without the ! ...

  5. 3dolab
    Posted 4 years ago #

    I tried any possible conditional tags, including is_front_page() or is_singular(), only to realize that it would never work, since the 'init' hook is too early for them.

    Scripts and styles should be moved in another function outside qpw_init and then added as action to the 'wp' or 'wp_print_scripts' hook.


  6. silvanasono
    Posted 4 years ago #

    This is the point.
    My belief, that i will check as sooc as i can, is that init is an initialization of a class that occurs once, when the class is loaded the first time, that is when the website is loaded the first time. This is why you in that section you cannot choose any page for loading the scripts.
    So I believe.

  7. Diogo15
    Posted 4 years ago #

    You were right, i found a solution:

    function your_function(){
     if ( is_page('YOUR_PAGE') ) {
      // load scripts.
  8. silvanasono
    Posted 4 years ago #

    Thanks, I will try it soon

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic