[Plugin: PodPress] load scripts only when needed
-
Hi,
I′m developing a website with ober 500 Pages- one of them uses PodPress but the scripts are in wp_head so it slows down the whole page.
Does anyone knows what to do to include the scripts only on a specific page?
I think it′s the main-file called podpress.php starting from line 328, but I don’t know enough about Plugin-Development to change the values on my own.
Original-Code:
/* stuff that goes in the HTML header */ if ( TRUE == version_compare($wp_version, '2.7', '>=') ) { if (FALSE === is_admin()) { add_action('wp_print_scripts', 'podpress_print_frontend_js'); add_action('wp_print_styles', 'podpress_print_frontend_css'); } add_action('wp_head', 'podPress_print_feed_links_to_header'); } else { add_action('wp_head', 'podPress_wp_head'); } add_action('wp_footer', 'podPress_wp_footer'); add_action('switch_theme', 'podPress_switch_theme');
or later in line 494:
function podpress_print_frontend_js() { wp_register_script( 'podpress_frontend_script', PODPRESS_URL.'/js/podpress.js' ); wp_enqueue_script( 'podpress_frontend_script' ); // ntm: this way of loading a localized JS scripts is probably not very elegant but it works in WP version older than 2.3 // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used. require_once(PODPRESS_DIR.'/podpress_js_i18n.php'); podpress_print_localized_frontend_js_vars(); podpress_print_js_vars(); } // for WP 2.7+ function podpress_print_frontend_css() { if (file_exists(get_template_directory().'/podpress.css')) { wp_register_style( 'podpress_frontend_styles', get_template_directory_uri().'/podpress.css' ); } else { wp_register_style( 'podpress_frontend_styles', PODPRESS_URL.'/podpress.css' ); } wp_enqueue_style( 'podpress_frontend_styles' ); } // for WP version < 2.7 function podPress_wp_head() { // frontend header echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/podpress.js"></script>'."\n"; // ntm: this way of loading a localized Js scripts is probably not very elegant but it works in WP version older than 2.3 // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used. require_once(PODPRESS_DIR.'/podpress_js_i18n.php'); podpress_print_localized_frontend_js_vars(); podpress_print_js_vars(); if (file_exists(get_template_directory().'/podpress.css')) { echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/podpress.css" type="text/css" />'."\n"; } else { echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/podpress.css" type="text/css" />'."\n"; } podPress_print_feed_links_to_header(); }
Can anyone help? Thanks a lot!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[Plugin: PodPress] load scripts only when needed’ is closed to new replies.