Guest User

Untitled

a guest
Feb 8th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: tagDiv speed booster
  4. Plugin URI: http://tagdiv.com
  5. Description: Speed booster for Newspaper theme
  6. Author: tagDiv
  7. Version: 2.1
  8. Author URI: http://tagdiv.com
  9. */
  10.  
  11.  
  12.  
  13. class td_speed_booster {
  14.  
  15. var $load_contact_form_7 = '';
  16. var $load_google_fonts = '';
  17.  
  18. var $styles_for_footer = array();
  19.  
  20. function __construct() {
  21. add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_hook'), 100);
  22. add_action('wp_footer', array($this, 'wp_footer_hook'), 15);
  23. add_action('wp_head', array($this, 'wp_head_hook'), 15);
  24. define('TD_SPEED_BOOSTER' , 'v2.0');
  25. }
  26.  
  27. function enqueue_scripts_hook() {
  28.  
  29.  
  30. //$this->move_js_to_footer('bp-legacy-js');
  31.  
  32.  
  33. if( !is_admin()){
  34. wp_deregister_script('jquery');
  35. wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"), true, '1.10.2', true);
  36. wp_enqueue_script('jquery');
  37. }
  38.  
  39. //move styles
  40. $this->move_style_to_footer('bbp-default-bbpress'); //bpress old
  41. $this->move_style_to_footer('bbp-default'); //bpress
  42.  
  43. $this->move_style_to_footer('contact-form-7');
  44. $this->move_style_to_footer('td-bootstrap');
  45. $this->move_style_to_footer('td-theme');
  46.  
  47. $this->move_style_to_footer('google-font-rest');
  48. $this->move_style_to_footer('woocommerce_frontend_styles');
  49.  
  50.  
  51. //bbpress
  52. //remove_action( 'bbp_head', array($BBP_Default, 'head_scripts') );
  53. }
  54.  
  55.  
  56. function wp_footer_hook() {
  57. foreach ($this->styles_for_footer as $style_id => $style_src) {
  58. echo "<link rel='stylesheet' id='" . $style_id . "-css' href='" . $style_src . "' type='text/css' media='all' />\n";
  59. }
  60. }
  61.  
  62. function wp_head_hook() {
  63. echo '<style>body {visibility:hidden;}</style>';
  64. }
  65.  
  66.  
  67. function move_style_to_footer($style_id) {
  68. global $wp_styles;
  69. if (!empty($wp_styles->registered[$style_id]) and !empty($wp_styles->registered[$style_id]->src)) {
  70. $this->styles_for_footer[$style_id] = $wp_styles->registered[$style_id]->src;
  71. wp_deregister_style($style_id);
  72. }
  73. }
  74.  
  75. function move_js_to_footer($js_id) {
  76. global $wp_scripts;
  77. wp_enqueue_script($js_id, ($wp_scripts->registered[$js_id]->src), '', $wp_scripts->registered[$js_id]->ver, true);
  78. }
  79.  
  80.  
  81.  
  82. }
  83.  
  84.  
  85. new td_speed_booster();
  86.  
  87.  
  88. ?>
Advertisement
Add Comment
Please, Sign In to add comment