Changeset 2028901
- Timestamp:
- 02/12/2019 03:24:01 AM (7 years ago)
- Location:
- better-resource-hints
- Files:
-
- 42 added
- 18 edited
-
tags/1.1.3 (added)
-
tags/1.1.3/better-resource-hints.php (added)
-
tags/1.1.3/composer.json (added)
-
tags/1.1.3/index.php (added)
-
tags/1.1.3/readme.txt (added)
-
tags/1.1.3/src (added)
-
tags/1.1.3/src/Filters.php (added)
-
tags/1.1.3/src/Preconnector.php (added)
-
tags/1.1.3/src/Prefetcher.php (added)
-
tags/1.1.3/src/Preloader.php (added)
-
tags/1.1.3/src/Settings.php (added)
-
tags/1.1.3/src/Utilities.php (added)
-
tags/1.1.3/src/assets (added)
-
tags/1.1.3/src/assets/css (added)
-
tags/1.1.3/src/assets/css/style.css (added)
-
tags/1.1.3/src/assets/img (added)
-
tags/1.1.3/src/assets/img/envelope.svg (added)
-
tags/1.1.3/src/assets/img/github.svg (added)
-
tags/1.1.3/src/assets/img/twitter.svg (added)
-
tags/1.1.3/src/assets/img/wordpress.svg (added)
-
tags/1.1.3/src/assets/js (added)
-
tags/1.1.3/src/assets/js/preload.min.js (added)
-
tags/1.1.3/src/assets/js/scripts.js (added)
-
tags/1.1.3/src/assets/js/scripts.min.js (added)
-
tags/1.1.3/src/assets/scss (added)
-
tags/1.1.3/src/assets/scss/FeedbackList.scss (added)
-
tags/1.1.3/src/assets/scss/PromoBar.scss (added)
-
tags/1.1.3/src/assets/scss/Tabs.scss (added)
-
tags/1.1.3/src/assets/scss/_variables.scss (added)
-
tags/1.1.3/src/assets/scss/style.scss (added)
-
tags/1.1.3/src/inc (added)
-
tags/1.1.3/src/inc/index.php (added)
-
tags/1.1.3/src/inc/preconnect-assets.php (added)
-
tags/1.1.3/src/inc/preconnect-server-push.php (added)
-
tags/1.1.3/src/inc/prefetched-scripts.php (added)
-
tags/1.1.3/src/inc/prefetched-server-push.php (added)
-
tags/1.1.3/src/inc/prefetched-styles.php (added)
-
tags/1.1.3/src/inc/preloaded-scripts.php (added)
-
tags/1.1.3/src/inc/preloaded-server-push.php (added)
-
tags/1.1.3/src/inc/preloaded-styles.php (added)
-
tags/1.1.3/src/inc/promo.php (added)
-
tags/1.1.3/src/index.php (added)
-
trunk/better-resource-hints.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Filters.php (modified) (1 diff)
-
trunk/src/Preconnector.php (modified) (1 diff)
-
trunk/src/Prefetcher.php (modified) (1 diff)
-
trunk/src/Preloader.php (modified) (1 diff)
-
trunk/src/Settings.php (modified) (7 diffs)
-
trunk/src/Utilities.php (modified) (1 diff)
-
trunk/src/assets/js/preload.min.js (modified) (1 diff)
-
trunk/src/inc/preconnect-assets.php (modified) (1 diff)
-
trunk/src/inc/preconnect-server-push.php (modified) (1 diff)
-
trunk/src/inc/prefetched-scripts.php (modified) (2 diffs)
-
trunk/src/inc/prefetched-server-push.php (modified) (1 diff)
-
trunk/src/inc/prefetched-styles.php (modified) (2 diffs)
-
trunk/src/inc/preloaded-scripts.php (modified) (2 diffs)
-
trunk/src/inc/preloaded-server-push.php (modified) (1 diff)
-
trunk/src/inc/preloaded-styles.php (modified) (2 diffs)
-
trunk/src/inc/promo.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
better-resource-hints/trunk/better-resource-hints.php
r1885229 r2028901 3 3 * Plugin Name: Better Resource Hints 4 4 * Description: Easy preloading, prefetching, HTTP/2 server pushing, and more for your CSS and JavaScript. 5 * Version: 1.1. 25 * Version: 1.1.3 6 6 * Author: Alex MacArthur 7 7 * Author URI: http://macarthur.me … … 21 21 require_once 'src/Utilities.php'; 22 22 23 if ( !defined( 'WPINC' )) {24 die;23 if (!defined('WPINC')) { 24 die; 25 25 } 26 26 27 class App { 27 define('BETTER_RESOURCE_HINTS_OPTIONS_PREFIX', 'better_resource_hints'); 28 define('BETTER_RESOURCE_HINTS_ADMIN_SETTINGS_PAGE_SLUG', 'better_resource_hints'); 28 29 29 private static $instance; 30 class App 31 { 30 32 31 protected static $plugin_data = null; 32 protected static $options_prefix = 'better_resource_hints'; 33 protected static $admin_settings_page_slug = 'better_resource_hints'; 34 protected static $copy = array( 35 'public' => 'Better Resource Hints' 36 ); 33 /** 34 * Initialize the plugin. 35 * 36 * @return object App Instance of class. 37 */ 38 public static function go() 39 { 40 $GLOBALS[ __CLASS__ ] = new self; 41 return $GLOBALS[ __CLASS__ ]; 42 } 37 43 38 public static function init() { 39 if(!isset(self::$instance) && !(self::$instance instanceof App)) { 40 self::$instance = new App; 41 } 42 } 44 /** 45 * Retrive array of plugin data. 46 * 47 * @return array 48 */ 49 public static function getPluginData() 50 { 51 return get_plugin_data(__FILE__); 52 } 43 53 44 public function __construct() { 45 self::$plugin_data = get_plugin_data(__DIR__ . '/better-resource-hints.php'); 54 public function __construct() 55 { 56 new Filters; 57 new Settings; 58 new Preloader; 59 new Prefetcher; 60 new Preconnector; 46 61 47 new Filters; 48 new Settings; 49 new Preloader; 50 new Prefetcher; 51 new Preconnector; 62 add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts' )); 63 } 52 64 53 add_action( 'admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts' )); 54 } 55 56 /** 65 /** 57 66 * Enqueue necessary admin scripts & styles. 58 67 * 59 68 * @return void 60 69 */ 61 public function enqueue_styles_and_scripts() { 62 wp_enqueue_style( 'better-resource-hints', plugin_dir_url( __FILE__ ) . 'src/assets/css/style.css', array(), self::$plugin_data['Version']); 63 wp_enqueue_script( 'better-resource-hints', plugin_dir_url( __FILE__ ) . 'src/assets/js/scripts.min.js', array(), self::$plugin_data['Version'], true); 64 } 65 70 public function enqueue_styles_and_scripts() 71 { 72 $plugin_data = self::getPluginData(); 73 wp_enqueue_style('better-resource-hints', plugin_dir_url(__FILE__) . 'src/assets/css/style.css', [], $plugin_data['Version']); 74 wp_enqueue_script('better-resource-hints', plugin_dir_url(__FILE__) . 'src/assets/js/scripts.min.js', [], $plugin_data['Version'], true); 75 } 66 76 } 67 77 68 App:: init();78 App::go(); -
better-resource-hints/trunk/readme.txt
r1885229 r2028901 4 4 Donate link: paypal.me/alexmacarthur 5 5 Tags: performance, resource hints, prefetch, preload, server push, HTTP/2 6 Requires PHP: 5.6 6 7 Requires at least: 4.0 7 Tested up to: 4.9.68 Stable tag: 1.1. 28 Tested up to: 5.0.3 9 Stable tag: 1.1.3 9 10 License: GPLv2 or later 10 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 147 148 * Fix typos in documentation. 148 149 150 = 1.1.3 = 151 * Add fallback for cases when no assets are registered. 152 * Clean up plugin code structure. 153 * Switch from yarn to npm for JS package management. 154 * Update preload polyfill for CSS preloading. 155 * More intelligently load preload polyfill. 156 149 157 == Feedback == 150 158 -
better-resource-hints/trunk/src/Filters.php
r1872104 r2028901 3 3 namespace BetterResourceHints; 4 4 5 class Filters extends App { 5 class Filters 6 { 7 public function __construct() 8 { 9 add_filter('style_loader_tag', array($this, 'add_id_to_style_tags'), 10, 4); 10 add_filter('script_loader_tag', array($this, 'add_id_to_script_tags'), 10, 3); 11 } 6 12 7 public function __construct() { 8 add_filter('style_loader_tag', array($this, 'add_id_to_style_tags'), 10, 4); 9 add_filter('script_loader_tag', array($this, 'add_id_to_script_tags'), 10, 3);10 }13 public function add_id_to_style_tags($html, $handle, $href, $media) 14 { 15 return str_replace('<link ', '<link data-handle="' . $handle . '" ', $html); 16 } 11 17 12 public function add_id_to_style_tags($html, $handle, $href, $media) { 13 return str_replace('<link ', '<link data-handle="' . $handle . '" ', $html); 14 } 15 16 public function add_id_to_script_tags($tag, $handle, $src) { 17 return str_replace('<script ', '<script data-handle="' . $handle . '" ', $tag); 18 } 18 public function add_id_to_script_tags($tag, $handle, $src) 19 { 20 return str_replace('<script ', '<script data-handle="' . $handle . '" ', $tag); 21 } 19 22 } -
better-resource-hints/trunk/src/Preconnector.php
r1885229 r2028901 3 3 namespace BetterResourceHints; 4 4 5 class Preconnector extends App { 5 class Preconnector 6 { 7 private $hostsToPreconnect = array(); 6 8 7 private $hostsToPreconnect = array(); 9 public function __construct() 10 { 11 add_filter('wp_resource_hints', array($this, 'preconnect_hosts'), 11, 2); 12 } 8 13 9 public function __construct() { 10 add_filter('wp_resource_hints', array($this, 'preconnect_hosts'), 11, 2); 11 } 14 /** 15 * If enabled, generate a preconnect tag for each asset that's dns-prefetched. 16 * 17 * @param array $urls 18 * @param string $type 19 * @return array 20 */ 21 public function preconnect_hosts($urls, $type) 22 { 23 if (Utilities::get_option('preconnect_hosts_option') === 'no_assets') { 24 return $urls; 25 } 12 26 13 /** 14 * If enabled, generate a preconnect tag for each asset that's dns-prefetched. 15 * 16 * @param array $urls 17 * @param string $type 18 * @return array 19 */ 20 public function preconnect_hosts($urls, $type) { 21 if(Utilities::get_option('preconnect_hosts_option') === 'no_assets') return $urls; 27 foreach ($urls as $url) { 28 if (Utilities::get_option("preconnect_hosts_enable_server_push")) { 29 Utilities::construct_server_push_headers('preconnect', $url, null, false); 30 } 22 31 23 foreach($urls as $url) { 32 if (gettype($url) !== 'string') { 33 continue; 34 } 24 35 25 if(Utilities::get_option("preconnect_hosts_enable_server_push")) { 26 Utilities::construct_server_push_headers('preconnect', $url, null, false); 27 } 36 $parsedURL = wp_parse_url($url); 37 unset($parsedURL["scheme"]); 28 38 29 if(gettype($url) !== 'string') continue; 39 $reconstructedURL = isset($parsedURL['host']) 40 ? '//' . $parsedURL['host'] 41 : '//' . join("", $parsedURL); 30 42 31 $parsedURL = wp_parse_url($url);32 unset($parsedURL["scheme"]); 43 echo apply_filters('better_resource_hints_preconnect_tag', "<link rel='preconnect' href='{$reconstructedURL}'/>\n", $reconstructedURL); 44 } 33 45 34 $reconstructedURL = isset($parsedURL['host']) 35 ? '//' . $parsedURL['host'] 36 : '//' . join("", $parsedURL); 37 38 echo apply_filters('better_resource_hints_preconnect_tag', "<link rel='preconnect' href='{$reconstructedURL}'/>\n", $reconstructedURL); 39 } 40 41 return $urls; 42 } 46 return $urls; 47 } 43 48 } -
better-resource-hints/trunk/src/Prefetcher.php
r1885229 r2028901 3 3 namespace BetterResourceHints; 4 4 5 class Prefetcher extends App { 5 class Prefetcher 6 { 7 public function __construct() 8 { 9 add_action('wp_head', array($this, 'prefetch_javascript'), 1); 10 add_action('wp_head', array($this, 'prefetch_styles'), 1); 11 } 6 12 7 public function __construct() {8 add_action('wp_head', array($this, 'prefetch_javascript'), 1); 9 add_action('wp_head', array($this, 'prefetch_styles'), 1);10 }13 public function prefetch_javascript() 14 { 15 $this->generate_prefetch_markup('scripts'); 16 } 11 17 12 public function prefetch_javascript() { 13 $this->generate_prefetch_markup('scripts'); 14 } 18 public function prefetch_styles() 19 { 20 $this->generate_prefetch_markup('styles'); 21 } 15 22 16 public function prefetch_styles() { 17 $this->generate_prefetch_markup('styles'); 18 } 23 /** 24 * Only allow users to prefetch by specific handle, 25 * because we don't want to prefetch all admin scripts 26 * if that option is selected. 27 * 28 * @param string $type 29 * @return void 30 */ 31 private function generate_prefetch_markup($type = 'scripts') 32 { 33 global ${'wp_' . $type}; 34 $singularType = substr_replace($type, "", -1); 35 $handlesToPrefetch = []; 19 36 20 /** 21 * Only allow users to prefetch by specific handle, 22 * because we don't want to prefetch all admin scripts 23 * if that option is selected. 24 * 25 * @param string $type 26 * @return void 27 */ 28 private function generate_prefetch_markup($type = 'scripts') { 37 $noSpaces = Utilities::strip_spaces(Utilities::get_option('prefetch_'. $type. '_handles')); 38 $specificHandlesToPrefetch = explode(',', $noSpaces ?: ''); 29 39 30 global ${'wp_' . $type}; 31 $singularType = substr_replace($type, "", -1); 32 $handlesToPrefetch = []; 40 //-- @todo In the future, check if user would like to preload $specificHandlesToPrefetch's dependencies as well. 41 // foreach($specificHandlesToPrefetch as $handle) { 42 // $specificHandlesToPrefetch = array_merge($specificHandlesToPrefetch, Utilities::collect_all_deps($handle)); 43 // } 33 44 34 $noSpaces = Utilities::strip_spaces(Utilities::get_option('prefetch_'. $type. '_handles')); 35 $specificHandlesToPrefetch = explode(',', $noSpaces ?: ''); 45 //-- Loop through and print preload tags. 46 foreach (array_unique($specificHandlesToPrefetch) as $handle) { 47 $resource = isset(${'wp_' . $type}->registered[$handle]) 48 ? ${'wp_' . $type}->registered[$handle] 49 : false; 36 50 37 //-- @todo In the future, check if user would like to preload $specificHandlesToPrefetch's dependencies as well. 38 // foreach($specificHandlesToPrefetch as $handle) { 39 // $specificHandlesToPrefetch = array_merge($specificHandlesToPrefetch, Utilities::collect_all_deps($handle)); 40 // } 51 if ($resource === false) { 52 continue; 53 } 54 if (empty($resource->src)) { 55 continue; 56 } 41 57 42 //-- Loop through and print preload tags. 43 foreach(array_unique($specificHandlesToPrefetch) as $handle) { 44 $resource = isset(${'wp_' . $type}->registered[$handle]) 45 ? ${'wp_' . $type}->registered[$handle] 46 : false; 58 $methodToCheckIfAssetIsEnqueued = 'wp_' . $singularType . '_is'; 59 if ($methodToCheckIfAssetIsEnqueued($handle)) { 60 continue; 61 } 47 62 48 if($resource === false) continue; 49 if(empty($resource->src)) continue; 63 $source = $resource->src . ($resource->ver ? "?ver={$resource->ver}" : ""); 50 64 51 $methodToCheckIfAssetIsEnqueued = 'wp_' . $singularType . '_is'; 52 if($methodToCheckIfAssetIsEnqueued($handle)) continue; 65 if (Utilities::get_option("prefetch_assets_enable_server_push")) { 66 Utilities::construct_server_push_headers('prefetch', $source); 67 } 53 68 54 $source = $resource->src . ($resource->ver ? "?ver={$resource->ver}" : ""); 55 56 if(Utilities::get_option("prefetch_assets_enable_server_push")) { 57 Utilities::construct_server_push_headers('prefetch', $source); 58 } 59 60 echo apply_filters('better_resource_hints_prefetch_tag', "<link rel='prefetch' href='{$source}'/>\n", $handle, $type); 61 } 62 } 69 echo apply_filters('better_resource_hints_prefetch_tag', "<link rel='prefetch' href='{$source}'/>\n", $handle, $type); 70 } 71 } 63 72 } -
better-resource-hints/trunk/src/Preloader.php
r1885229 r2028901 3 3 namespace BetterResourceHints; 4 4 5 class Preloader extends App { 5 class Preloader 6 { 7 public function __construct() 8 { 9 add_action('wp_enqueue_scripts', array($this, 'enqueue_load_css_js')); 10 add_action('wp_head', array($this, 'preload_javascript'), 1); 11 add_action('wp_head', array($this, 'preload_css'), 1); 12 add_filter('better_resource_hints_preload_tag', array($this, 'change_rel_type'), 10, 3); 13 add_filter('better_resource_hints_should_preload', array($this, 'default_script_preloading'), 10, 4); 14 } 6 15 7 public function __construct() { 8 add_action('wp_enqueue_scripts', array($this, 'enqueue_load_css_js')); 9 add_action('wp_head', array($this, 'preload_javascript'), 1); 10 add_action('wp_head', array($this, 'preload_css'), 1); 11 add_filter('better_resource_hints_preload_tag', array($this, 'change_rel_type'), 10, 3); 12 add_filter('better_resource_hints_should_preload', array($this, 'default_script_preloading'), 10, 4); 13 } 16 /** 17 * If no option is set (like, it's a fresh install), preload footer scripts by default. 18 * 19 * @param boolean $should 20 * @param object $resource 21 * @param string $type 22 * @param mixed $option 23 * 24 * @return void 25 */ 26 public function default_script_preloading($should, $resource, $type, $option) 27 { 28 if ( 29 !$option && 30 $type === 'scripts' && 31 (isset($resource->extra['group']) && $resource->extra['group'] === 1) 32 ) { 33 return true; 34 } 14 35 15 /** 16 * If no option is set (like, it's a fresh install), preload footer scripts by default. 17 * 18 * @param boolean $should 19 * @param object $resource 20 * @param string $type 21 * @param mixed $option 22 * 23 * @return void 24 */ 25 public function default_script_preloading($should, $resource, $type, $option) { 26 if( 27 !$option && 28 $type === 'scripts' && 29 (isset($resource->extra['group']) && $resource->extra['group'] === 1) 30 ) { 31 return true; 32 } 36 return $should; 37 } 33 38 34 return $should; 35 } 39 public function preload_css() 40 { 41 $this->generate_preload_markup('styles'); 42 } 36 43 37 public function preload_css() { 38 $this->generate_preload_markup('styles'); 39 } 44 public function preload_javascript() 45 { 46 $this->generate_preload_markup('scripts'); 47 } 40 48 41 public function preload_javascript() { 42 $this->generate_preload_markup('scripts'); 43 } 49 public function enqueue_load_css_js() 50 { 51 $preloadOption = Utilities::get_option('preload_styles_option'); 44 52 45 public function enqueue_load_css_js() { 46 wp_enqueue_script( 'loadcss', plugin_dir_url( __FILE__ ) . 'assets/js/preload.min.js', array(), null); 47 } 53 if ($preloadOption !== 'no_styles') { 54 wp_enqueue_script('loadcss', plugin_dir_url(__FILE__) . 'assets/js/preload.min.js', array(), null); 55 } 56 } 48 57 49 /** 50 * If we're generating preload tags for CSS, change them to stylesheets and remove from queue. 51 * 52 * @param string $tag HTML tag 53 * @param string $handle 54 * @param string $type 55 * @return void 56 */ 57 public function change_rel_type($tag, $handle, $type) { 58 /** 59 * If we're generating preload tags for CSS, change them to stylesheets and remove from queue. 60 * 61 * @param string $tag HTML tag 62 * @param string $handle 63 * @param string $type 64 * @return void 65 */ 66 public function change_rel_type($tag, $handle, $type) 67 { 68 if ($type === 'styles') { 69 global ${'wp_' . $type}; 70 $queue = ${'wp_' . $type}->queue; 71 unset(${'wp_' . $type}->queue[array_search($handle, $queue)]); 58 72 59 if($type === 'styles') { 60 global ${'wp_' . $type}; 61 $queue = ${'wp_' . $type}->queue; 62 unset(${'wp_' . $type}->queue[array_search($handle, $queue)]); 73 return str_replace('as=', 'onload="this.onload=null;this.rel=\'stylesheet\'" as=', $tag); 74 } 63 75 64 return str_replace('as=', 'onload="this.rel=\'stylesheet\'" as=', $tag);65 }76 return $tag; 77 } 66 78 67 return $tag; 68 } 79 private function generate_preload_markup($type = 'scripts') 80 { 81 global ${'wp_' . $type}; 82 $handlesToPreload = []; 69 83 70 private function generate_preload_markup($type = 'scripts') { 71 global ${'wp_' . $type};72 $handlesToPreload = [];84 $preloadOption = Utilities::get_option('preload_'. $type . '_option'); 85 $noSpaces = Utilities::strip_spaces(Utilities::get_option('preload_'. $type. '_handles')); 86 $specificHandlesToPreload = explode(',', $noSpaces ?: ''); 73 87 74 $preloadOption = Utilities::get_option('preload_'. $type . '_option'); 75 $noSpaces = Utilities::strip_spaces(Utilities::get_option('preload_'. $type. '_handles')); 76 $specificHandlesToPreload = explode(',', $noSpaces ?: ''); 88 //-- @todo In the future, check if user would like to preload $specificHandlesToPreload's dependencies as well. 89 // foreach($specificHandlesToPreload as $handle) { 90 // $specificHandlesToPreload = array_merge($specificHandlesToPreload, Utilities::collect_all_deps($handle)); 91 // } 77 92 78 //-- @todo In the future, check if user would like to preload $specificHandlesToPreload's dependencies as well. 79 // foreach($specificHandlesToPreload as $handle) { 80 // $specificHandlesToPreload = array_merge($specificHandlesToPreload, Utilities::collect_all_deps($handle)); 81 // } 93 //-- Gather all enqueued scripts and dependencies. 94 foreach (${'wp_' . $type}->queue as $handle) { 95 $handlesToPreload[] = $handle; 96 $handlesToPreload = array_merge($handlesToPreload, Utilities::collect_all_deps($handle, $type)); 97 } 82 98 83 //-- Gather all enqueued scripts and dependencies. 84 foreach(${'wp_' . $type}->queue as $handle) { 85 $handlesToPreload[] = $handle; 86 $handlesToPreload = array_merge($handlesToPreload, Utilities::collect_all_deps($handle, $type)); 87 } 99 //-- Loop through and print preload tags. 100 foreach (array_unique($handlesToPreload) as $handle) { 101 $resource = ${'wp_' . $type}->registered[$handle]; 88 102 89 //-- Loop through and print preload tags. 90 foreach(array_unique($handlesToPreload) as $handle) { 91 $resource = ${'wp_' . $type}->registered[$handle]; 103 if (empty($resource->src)) { 104 continue; 105 } 92 106 93 if(empty($resource->src)) continue; 107 if ( 108 //-- Only footer scripts! 109 $preloadOption === ('footer_' . $type) && isset($resource->extra['group']) && $resource->extra['group'] === 1 94 110 95 if( 96 //-- Only footer scripts! 97 $preloadOption === ('footer_' . $type) && isset($resource->extra['group']) && $resource->extra['group'] === 1 111 //-- All scripts! 112 || $preloadOption === ('all_' . $type) 98 113 99 //-- All scripts!100 || $preloadOption === ('all_' . $type)114 //-- Only scripts specified! 115 || $preloadOption === ('choose_' . $type) && in_array($handle, $specificHandlesToPreload) 101 116 102 //-- Only scripts specified! 103 || $preloadOption === ('choose_' . $type) && in_array($handle, $specificHandlesToPreload) 117 //-- Allow this to be manually enabled. 118 || apply_filters('better_resource_hints_should_preload', false, $resource, $type, $preloadOption) 119 ) { 120 $singular = substr_replace($type, "", -1); 121 $source = $resource->src . ($resource->ver ? "?ver={$resource->ver}" : ""); 104 122 105 //-- Allow this to be manually enabled. 106 || apply_filters('better_resource_hints_should_preload', false, $resource, $type, $preloadOption) 107 ) { 108 $singular = substr_replace($type, "", -1); 109 $source = $resource->src . ($resource->ver ? "?ver={$resource->ver}" : ""); 123 if (Utilities::get_option("preload_assets_enable_server_push")) { 124 Utilities::construct_server_push_headers('preload', $source, $singular); 125 } 110 126 111 if(Utilities::get_option("preload_assets_enable_server_push")) { 112 Utilities::construct_server_push_headers('preload', $source, $singular); 113 } 114 115 echo apply_filters('better_resource_hints_preload_tag', "<link rel='preload' href='{$source}' as='{$singular}'/>\n", $handle, $type); 116 } 117 } 118 } 127 echo apply_filters('better_resource_hints_preload_tag', "<link rel='preload' href='{$source}' as='{$singular}'/>\n", $handle, $type); 128 } 129 } 130 } 119 131 } -
better-resource-hints/trunk/src/Settings.php
r1873759 r2028901 6 6 require_once 'Utilities.php'; 7 7 8 class Settings extends App { 8 class Settings 9 { 10 public $options; 11 public $github_url = ''; 12 public $wordpress_url = ''; 13 public $twitter_url = ''; 14 public $website_url = 'http://macarthur.me/#contact'; 9 15 10 public $options; 11 public $github_url = ''; 12 public $wordpress_url = ''; 13 public $twitter_url = ''; 14 public $website_url = 'http://macarthur.me/#contact'; 16 /** 17 * Add actions, set up stuffs. 18 */ 19 public function __construct() 20 { 21 $this->options = Utilities::get_options(); 22 add_action('admin_init', array($this, 'register_main_setting')); 23 add_action('admin_init', array($this, 'register_settings')); 24 add_action('admin_menu', array($this, 'better_resource_hints_settings_page')); 25 add_action('wp_logout', array($this, 'reset_active_tab')); 26 } 15 27 16 /** 17 * Add actions, set up stuffs. 18 */ 19 public function __construct() { 20 $this->options = Utilities::get_options(); 21 add_action( 'admin_init', array($this, 'register_main_setting')); 22 add_action( 'admin_init', array($this, 'register_settings')); 23 add_action( 'admin_menu', array($this, 'better_resource_hints_settings_page')); 24 add_action( 'wp_logout', array($this, 'reset_active_tab')); 25 } 28 public function reset_active_tab() 29 { 30 $options = get_option(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX); 31 unset($options['last-active-tab']); 32 update_option(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX, $options); 33 } 26 34 27 public function reset_active_tab() { 28 $options = get_option(self::$options_prefix); 29 unset($options['last-active-tab']); 30 update_option(self::$options_prefix, $options); 31 } 35 /** 36 * Add submenu page for settings. 37 * 38 * @return void 39 */ 40 public function better_resource_hints_settings_page() 41 { 42 add_submenu_page('options-general.php', 'Better Resource Hints Settings', 'Better Resource Hints', 'edit_posts', BETTER_RESOURCE_HINTS_OPTIONS_PREFIX, array($this, 'settings_page_callback')); 43 } 32 44 33 /** 34 * Add submenu page for settings. 35 * 36 * @return void 37 */ 38 public function better_resource_hints_settings_page() { 39 add_submenu_page('options-general.php', self::$copy['public'] . ' Settings', self::$copy['public'], 'edit_posts', self::$options_prefix, array($this, 'settings_page_callback')); 40 } 41 42 /** 43 * Generate markup for settings page. 44 * 45 * @return void 46 */ 47 public function settings_page_callback() { 48 ?> 45 /** 46 * Generate markup for settings page. 47 * 48 * @return void 49 */ 50 public function settings_page_callback() 51 { 52 ?> 49 53 <div id="BRCSettingsPage" class="wrap"> 50 <h1> <?php echo self::$copy['public']; ?>Settings</h1>54 <h1>Better Resource Hints Settings</h1> 51 55 52 56 <div id="poststuff"> … … 56 60 <?php wp_nonce_field('update-options'); ?> 57 61 <?php 58 settings_fields( self::$options_prefix . '_settings' ); 59 do_settings_sections( self::$admin_settings_page_slug ); 60 submit_button(); 61 ?> 62 settings_fields(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX . '_settings'); 63 do_settings_sections(BETTER_RESOURCE_HINTS_ADMIN_SETTINGS_PAGE_SLUG); 64 submit_button(); ?> 62 65 </form> 63 66 </div> … … 71 74 72 75 <?php 73 }76 } 74 77 75 /** 76 * Register the main setting for storing settings. 77 * 78 * @return void 79 */ 80 public function register_main_setting() { 81 register_setting( self::$options_prefix . '_settings', self::$options_prefix); 82 } 78 /** 79 * Register the main setting for storing settings. 80 * 81 * @return void 82 */ 83 public function register_main_setting() 84 { 85 register_setting(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX . '_settings', BETTER_RESOURCE_HINTS_OPTIONS_PREFIX); 86 } 83 87 84 /** 85 * Register Default fallback and force settings. 86 * 87 * @return void 88 */ 89 public function register_settings () { 90 add_settings_section( self::$options_prefix . '_tabs', '', array( $this, 'cb_tabs' ), self::$admin_settings_page_slug ); 91 } 88 /** 89 * Register Default fallback and force settings. 90 * 91 * @return void 92 */ 93 public function register_settings() 94 { 95 add_settings_section(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX . '_tabs', '', array( $this, 'cb_tabs' ), BETTER_RESOURCE_HINTS_ADMIN_SETTINGS_PAGE_SLUG); 96 } 92 97 93 /**94 * Outputs field markup.95 *96 * @return void97 */98 public function cb_tabs() {99 $lastActiveTab = Utilities::get_option("last-active-tab"); 100 $lastActiveTab = $lastActiveTab ?: 'preload';101 ?>98 /** 99 * Outputs field markup. 100 * 101 * @return void 102 */ 103 public function cb_tabs() 104 { 105 $lastActiveTab = Utilities::get_option("last-active-tab"); 106 $lastActiveTab = $lastActiveTab ?: 'preload'; ?> 102 107 103 108 <div class="TabHolder"> … … 107 112 <div class="Tab-content"> 108 113 <?php 109 echo "<p>Preloading an asset instructs the browser to download it immediately at a high priorty. All of this happens in the background, so page load isn't blocked while these resources are being downloaded, improving metrics like overall page load time and time to interactive. It's best to preload assets that are definitely needed, but discovered late on the page.</p>"; 110 include plugin_dir_path(__FILE__) . 'inc/preloaded-scripts.php'; 111 include plugin_dir_path(__FILE__) . 'inc/preloaded-styles.php'; 112 include plugin_dir_path(__FILE__) . 'inc/preloaded-server-push.php'; 113 ?> 114 echo "<p>Preloading an asset instructs the browser to download it immediately at a high priorty. All of this happens in the background, so page load isn't blocked while these resources are being downloaded, improving metrics like overall page load time and time to interactive. It's best to preload assets that are definitely needed, but discovered late on the page.</p>"; 115 include plugin_dir_path(__FILE__) . 'inc/preloaded-scripts.php'; 116 include plugin_dir_path(__FILE__) . 'inc/preloaded-styles.php'; 117 include plugin_dir_path(__FILE__) . 'inc/preloaded-server-push.php'; ?> 114 118 </div> 115 119 </div> … … 120 124 <div class="Tab-content"> 121 125 <?php 122 echo "<p>Prefetching an asset instructs the browser to download it in the background as a low priority, so that you can cache it for future use on other pages. Because of this, you should only prefetch assets that AREN'T needed on the current page, but on pages the user is likely to visit in the future.</p>"; 123 include plugin_dir_path(__FILE__) . 'inc/prefetched-scripts.php'; 124 include plugin_dir_path(__FILE__) . 'inc/prefetched-styles.php'; 125 include plugin_dir_path(__FILE__) . 'inc/prefetched-server-push.php'; 126 ?> 126 echo "<p>Prefetching an asset instructs the browser to download it in the background as a low priority, so that you can cache it for future use on other pages. Because of this, you should only prefetch assets that AREN'T needed on the current page, but on pages the user is likely to visit in the future.</p>"; 127 include plugin_dir_path(__FILE__) . 'inc/prefetched-scripts.php'; 128 include plugin_dir_path(__FILE__) . 'inc/prefetched-styles.php'; 129 include plugin_dir_path(__FILE__) . 'inc/prefetched-server-push.php'; ?> 127 130 </div> 128 131 </div> … … 133 136 <div class="Tab-content"> 134 137 <?php 135 echo "<p>Preconnect hints perform DNS lookups, TLS negotiations, TCP handshakes before any HTTP requests are made, reducing latency. It's a beefier version of the dns-prefetch hint, but is less widely supported.</p>"; 136 echo "<p>By default, WordPress enables dns-prefetch for all externally hosted assets. Enabling this option will add a preconnect hint to each asset that is DNS prefetched.</p>"; 137 include plugin_dir_path(__FILE__) . 'inc/preconnect-assets.php'; 138 include plugin_dir_path(__FILE__) . 'inc/preconnect-server-push.php'; 139 ?> 138 echo "<p>Preconnect hints perform DNS lookups, TLS negotiations, TCP handshakes before any HTTP requests are made, reducing latency. It's a beefier version of the dns-prefetch hint, but is less widely supported.</p>"; 139 echo "<p>By default, WordPress enables dns-prefetch for all externally hosted assets. Enabling this option will add a preconnect hint to each asset that is DNS prefetched.</p>"; 140 include plugin_dir_path(__FILE__) . 'inc/preconnect-assets.php'; 141 include plugin_dir_path(__FILE__) . 'inc/preconnect-server-push.php'; ?> 140 142 </div> 141 143 </div> … … 143 145 </div> 144 146 <?php 145 }147 } 146 148 } -
better-resource-hints/trunk/src/Utilities.php
r1873759 r2028901 3 3 namespace BetterResourceHints; 4 4 5 class Utilities extends App { 6 7 public static function strip_spaces($string) { 8 return trim(preg_replace('/\s+/', '', $string)); 9 } 10 11 /** 12 * Send a 'Link' header. 13 * 14 * @param string $rel Type of header you'd like to push (prefetch, preload, etc.). 15 * @param string $src Source of the asset to be pushed. 16 * @param string $type Type of the asset to be pushed. 17 * @return void 18 */ 19 public static function construct_server_push_headers($rel, $src, $type = null, $forceSameHost = true) { 20 21 if(headers_sent()) return; 22 if(strpos($src, site_url()) === false && $forceSameHost) return; 23 24 $header = sprintf( 25 'Link: <%s>; rel=%s; ', 26 esc_url( parse_url($src, PHP_URL_PATH) ), 27 $rel 28 ); 29 30 if($type) { 31 $header .= 'as=' . $type; 32 } 33 34 header(apply_filters(self::$options_prefix . '_header', $header, $rel, $src, $type), false); 35 } 36 37 /** 38 * Gets serialized settings in options table. 39 * 40 * @return array 41 */ 42 public static function get_options() { 43 return get_option(self::$options_prefix); 44 } 45 46 /** 47 * Pass a handle get array of all of it's dependencies, recursively. 48 * 49 * @param string $handle 50 * @param string $type 51 * @return array 52 */ 53 public static function collect_all_deps($handle, $type = 'scripts') { 54 global ${'wp_' . $type}; 55 $handles = []; 56 57 foreach(${'wp_' . $type}->registered[$handle]->deps as $dep) { 58 $handles[] = $dep; 59 $handles = array_merge($handles, self::collect_all_deps($dep, $type)); 60 } 61 62 return array_unique($handles); 63 } 64 65 /** 66 * Gets specific option value. 67 * 68 * @param string $key Option key 69 * @return string 70 */ 71 public static function get_option($key) { 72 if(isset(self::get_options()[$key])) { 73 return self::get_options()[$key]; 5 class Utilities 6 { 7 public static function strip_spaces($string) 8 { 9 return trim(preg_replace('/\s+/', '', $string)); 74 10 } 75 11 76 return false; 77 } 12 /** 13 * Send a 'Link' header. 14 * 15 * @param string $rel Type of header you'd like to push (prefetch, preload, etc.). 16 * @param string $src Source of the asset to be pushed. 17 * @param string $type Type of the asset to be pushed. 18 * @return void 19 */ 20 public static function construct_server_push_headers($rel, $src, $type = null, $forceSameHost = true) 21 { 22 if (headers_sent()) { 23 return; 24 } 25 if (strpos($src, site_url()) === false && $forceSameHost) { 26 return; 27 } 78 28 79 /** 80 * Gets full name of particular field, with prefix appended. 81 * 82 * @param string $name Name of field 83 * @return string 84 */ 85 public static function get_field_name($name) { 86 return self::$options_prefix . '[' . $name . ']'; 87 } 29 $header = sprintf( 30 'Link: <%s>; rel=%s; ', 31 esc_url(parse_url($src, PHP_URL_PATH)), 32 $rel 33 ); 34 35 if ($type) { 36 $header .= 'as=' . $type; 37 } 38 39 header(apply_filters(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX . '_header', $header, $rel, $src, $type), false); 40 } 41 42 /** 43 * Gets serialized settings in options table. 44 * 45 * @return array 46 */ 47 public static function get_options() 48 { 49 return get_option(BETTER_RESOURCE_HINTS_OPTIONS_PREFIX); 50 } 51 52 /** 53 * Pass a handle get array of all of it's dependencies, recursively. 54 * 55 * @param string $handle 56 * @param string $type 57 * @return array 58 */ 59 public static function collect_all_deps($handle, $type = 'scripts') 60 { 61 global ${'wp_' . $type}; 62 $assets = ${'wp_' . $type}; 63 $handles = []; 64 65 $registeredScripts = isset($assets->registered) ? $assets->registered : null; 66 67 //-- We have no registered scripts. Get outta here. 68 if (empty($registeredScripts)) { 69 return $handles; 70 } 71 72 foreach ($assets->registered[$handle]->deps as $dep) { 73 $handles[] = $dep; 74 $handles = array_merge($handles, self::collect_all_deps($dep, $type)); 75 } 76 77 return array_unique($handles); 78 } 79 80 /** 81 * Gets specific option value. 82 * 83 * @param string $key Option key 84 * @return string 85 */ 86 public static function get_option($key) 87 { 88 if (isset(self::get_options()[$key])) { 89 return self::get_options()[$key]; 90 } 91 92 return false; 93 } 94 95 /** 96 * Gets full name of particular field, with prefix appended. 97 * 98 * @param string $name Name of field 99 * @return string 100 */ 101 public static function get_field_name($name) 102 { 103 return BETTER_RESOURCE_HINTS_OPTIONS_PREFIX . '[' . $name . ']'; 104 } 88 105 } -
better-resource-hints/trunk/src/assets/js/preload.min.js
r1872104 r2028901 1 (function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='/',b(b.s=3)})([,,,function(a,b,c){a.exports=c(4)},function(a,b,c){(function(a){(function(a){'use strict';a.loadCSS||(a.loadCSS=function(){});var c=loadCSS.relpreload={};if(c.support=function(){var b;try{b=a.document.createElement('link').relList.supports('preload')}catch(a){b=!1}return function(){return b}}(),c.bindMediaToggle=function(a){function b(){a.media=c}var c=a.media||'all';a.addEventListener?a.addEventListener('load',b):a.attachEvent&&a.attachEvent('onload',b),setTimeout(function(){a.rel='stylesheet',a.media='only x'}),setTimeout(b,3e3)},c.poly=function(){if(!c.support())for(var b,d=a.document.getElementsByTagName('link'),e=0;e<d.length;e++)b=d[e],'preload'!==b.rel||'style'!==b.getAttribute('as')||b.getAttribute('data-loadcss')||(b.setAttribute('data-loadcss',!0),c.bindMediaToggle(b))},!c.support()){c.poly();var d=a.setInterval(c.poly,500);a.addEventListener?a.addEventListener('load',function(){c.poly(),a.clearInterval(d)}):a.attachEvent&&a.attachEvent('onload',function(){c.poly(),a.clearInterval(d)})}b.loadCSS=loadCSS})('undefined'==typeof a?this:a)}).call(b,c(5))},function(a){var b=function(){return this}();try{b=b||Function('return this')()||(1,eval)('this')}catch(a){'object'==typeof window&&(b=window)}a.exports=b}]);1 !function(n){"use strict";n.loadCSS||(n.loadCSS=function(){});var o=loadCSS.relpreload={};if(o.support=function(){var e;try{e=n.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),o.bindMediaToggle=function(t){var e=t.media||"all";function a(){t.addEventListener?t.removeEventListener("load",a):t.attachEvent&&t.detachEvent("onload",a),t.setAttribute("onload",null),t.media=e}t.addEventListener?t.addEventListener("load",a):t.attachEvent&&t.attachEvent("onload",a),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(a,3e3)},o.poly=function(){if(!o.support())for(var t=n.document.getElementsByTagName("link"),e=0;e<t.length;e++){var a=t[e];"preload"!==a.rel||"style"!==a.getAttribute("as")||a.getAttribute("data-loadcss")||(a.setAttribute("data-loadcss",!0),o.bindMediaToggle(a))}},!o.support()){o.poly();var t=n.setInterval(o.poly,500);n.addEventListener?n.addEventListener("load",function(){o.poly(),n.clearInterval(t)}):n.attachEvent&&n.attachEvent("onload",function(){o.poly(),n.clearInterval(t)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:n.loadCSS=loadCSS}("undefined"!=typeof global?global:this); -
better-resource-hints/trunk/src/inc/preconnect-assets.php
r1873759 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("preconnect_hosts_option"); 4 $value = !$value ? 'external_assets' : $value; 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("preconnect_hosts_option"); 5 $value = !$value ? 'external_assets' : $value; 5 6 ?> 6 7 -
better-resource-hints/trunk/src/inc/preconnect-server-push.php
r1873759 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("preconnect_hosts_enable_server_push"); 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("preconnect_hosts_enable_server_push"); 4 5 ?> 5 6 -
better-resource-hints/trunk/src/inc/prefetched-scripts.php
r1872104 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("prefetch_scripts_option"); 4 $valueHandles = Utilities::get_option("prefetch_scripts_handles"); 5 $value = !$value ? 'no_scripts' : $value; 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("prefetch_scripts_option"); 5 $valueHandles = Utilities::get_option("prefetch_scripts_handles"); 6 $value = !$value ? 'no_scripts' : $value; 6 7 ?> 7 8 … … 38 39 <div class="InputBlock-row"> 39 40 <textarea 40 <?php if($value !== 'choose_scripts'){ echo 'style="display: none;"'; }; ?> 41 <?php if ($value !== 'choose_scripts') { 42 echo 'style="display: none;"'; 43 }; ?> 41 44 name="<?php echo Utilities::get_field_name("prefetch_scripts_handles"); ?>"><?php echo $valueHandles; ?></textarea> 42 45 </div> -
better-resource-hints/trunk/src/inc/prefetched-server-push.php
r1872104 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("prefetch_assets_enable_server_push"); 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("prefetch_assets_enable_server_push"); 4 5 ?> 5 6 -
better-resource-hints/trunk/src/inc/prefetched-styles.php
r1872104 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("prefetch_styles_option"); 4 $valueHandles = Utilities::get_option("prefetch_styles_handles"); 5 $value = !$value ? 'no_styles' : $value; 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("prefetch_styles_option"); 5 $valueHandles = Utilities::get_option("prefetch_styles_handles"); 6 $value = !$value ? 'no_styles' : $value; 6 7 ?> 7 8 … … 38 39 <div class="InputBlock-row"> 39 40 <textarea 40 <?php if($value !== 'choose_styles'){ echo 'style="display: none;"'; }; ?> 41 <?php if ($value !== 'choose_styles') { 42 echo 'style="display: none;"'; 43 }; ?> 41 44 name="<?php echo Utilities::get_field_name("prefetch_styles_handles"); ?>"><?php echo $valueHandles; ?></textarea> 42 45 </div> -
better-resource-hints/trunk/src/inc/preloaded-scripts.php
r1872104 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("preload_scripts_option"); 4 $valueHandles = Utilities::get_option("preload_scripts_handles"); 5 $value = !$value ? 'footer_scripts' : $value; 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("preload_scripts_option"); 5 $valueHandles = Utilities::get_option("preload_scripts_handles"); 6 $value = !$value ? 'footer_scripts' : $value; 6 7 ?> 7 8 … … 66 67 <div class="InputBlock-row"> 67 68 <textarea 68 <?php if($value !== 'choose_scripts'){ echo 'style="display: none;"'; }; ?> 69 <?php if ($value !== 'choose_scripts') { 70 echo 'style="display: none;"'; 71 }; ?> 69 72 name="<?php echo Utilities::get_field_name("preload_scripts_handles"); ?>"><?php echo $valueHandles; ?></textarea> 70 73 </div> -
better-resource-hints/trunk/src/inc/preloaded-server-push.php
r1881680 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("preload_assets_enable_server_push"); 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("preload_assets_enable_server_push"); 4 5 ?> 5 6 -
better-resource-hints/trunk/src/inc/preloaded-styles.php
r1872104 r2028901 1 1 <?php 2 use BetterResourceHints\Utilities; 3 $value = Utilities::get_option("preload_styles_option"); 4 $valueHandles = Utilities::get_option("preload_styles_handles"); 5 $value = !$value ? 'no_styles' : $value; 2 use BetterResourceHints\Utilities; 3 4 $value = Utilities::get_option("preload_styles_option"); 5 $valueHandles = Utilities::get_option("preload_styles_handles"); 6 $value = !$value ? 'no_styles' : $value; 6 7 ?> 7 8 … … 52 53 <div class="InputBlock-row"> 53 54 <textarea 54 <?php if($value !== 'choose_styles'){ echo 'style="display: none;"'; }; ?> 55 <?php if ($value !== 'choose_styles') { 56 echo 'style="display: none;"'; 57 }; ?> 55 58 name="<?php echo Utilities::get_field_name("preload_styles_handles"); ?>"><?php echo $valueHandles; ?></textarea> 56 59 </div> -
better-resource-hints/trunk/src/inc/promo.php
r1881680 r2028901 1 1 <?php 2 namespace BetterResourceHints; 3 use BetterResourceHints\App; 4 ?> 2 namespace BetterResourceHints; 3 4 use BetterResourceHints\App; 5 6 ?> 5 7 6 8 <div class="PromoBar"> 7 9 8 <h2 class="PromoBar-title">Has <em> <?php echo App::$copy['public']; ?></em> been useful? Share the news!</h2>10 <h2 class="PromoBar-title">Has <em>Better Resource Hints</em> been useful? Share the news!</h2> 9 11 10 12 <ul class="FeedbackList"> 11 13 <li class="FeedbackList-item FeedbackItem"> 12 14 <a class="FeedbackItem-link FeedbackItem-link--github" href="https://github.com/alexmacarthur/wp-better-resource-hints" target="_blank"> 13 <?php echo file_get_contents(plugin_dir_path( __FILE__) . '../assets/img/github.svg'); ?>15 <?php echo file_get_contents(plugin_dir_path(__FILE__) . '../assets/img/github.svg'); ?> 14 16 </a> 15 17 <span class="FeedbackItem-text"><p><a href="https://github.com/alexmacarthur/wp-better-resource-hints">Star</a> it.</p></span> … … 17 19 <li class="FeedbackList-item FeedbackItem"> 18 20 <a class="FeedbackItem-link" href="https://wordpress.org/plugins/better-resource-hints/?rate=5#new-post" target="_blank"> 19 <?php echo file_get_contents(plugin_dir_path( __FILE__) . '../assets/img/wordpress.svg'); ?>21 <?php echo file_get_contents(plugin_dir_path(__FILE__) . '../assets/img/wordpress.svg'); ?> 20 22 </a> 21 23 <span class="FeedbackItem-text"><p><a href="https://wordpress.org/plugins/better-resource-hints/?rate=5#new-post">Review</a> it.</p></span> … … 23 25 <li class="FeedbackList-item FeedbackItem"> 24 26 <a class="FeedbackItem-link" href="https://twitter.com/home?status=I've%20seen%20some%20serious%20performance%20improvements%20after%20installing%20%40amacarthur's%20Better%20Resource%20Hints%20plugin%20for%20%23WordPress!%20https%3A//wordpress.org/plugins/better-resource-hints/" target="_blank"> 25 <?php echo file_get_contents(plugin_dir_path( __FILE__) . '../assets/img/twitter.svg'); ?>27 <?php echo file_get_contents(plugin_dir_path(__FILE__) . '../assets/img/twitter.svg'); ?> 26 28 </a> 27 29 <span class="FeedbackItem-text"><p><a href="https://twitter.com/home?status=I've%20seen%20some%20serious%20performance%20improvements%20after%20installing%20%40amacarthur's%20Better%20Resource%20Hints%20plugin%20for%20%23WordPress!%20https%3A//wordpress.org/plugins/better-resource-hints/">Tweet</a> about it.</p></span> … … 29 31 <li class="FeedbackList-item FeedbackItem"> 30 32 <a class="FeedbackItem-link FeedbackItem-link--mail" href="https://macarthur.me/contact" target="_blank"> 31 <?php echo file_get_contents(plugin_dir_path( __FILE__) . '../assets/img/envelope.svg'); ?>33 <?php echo file_get_contents(plugin_dir_path(__FILE__) . '../assets/img/envelope.svg'); ?> 32 34 </a> 33 35 <span class="FeedbackItem-text"><p><a href="https://macarthur.me/contact">Email</a> me.</p></span>
Note: See TracChangeset
for help on using the changeset viewer.