Changeset 1835998
- Timestamp:
- 03/08/2018 07:32:39 AM (8 years ago)
- Location:
- mcw-pwa/trunk
- Files:
-
- 1 added
- 5 edited
-
MCW_PWA.php (modified) (4 diffs)
-
includes/MCW_PWA_Assets.php (modified) (2 diffs)
-
includes/MCW_PWA_Module.php (modified) (2 diffs)
-
includes/MCW_PWA_Service_Worker.php (modified) (1 diff)
-
includes/MCW_PWA_Settings.php (modified) (2 diffs)
-
php.ini (added)
Legend:
- Unmodified
- Added
- Removed
-
mcw-pwa/trunk/MCW_PWA.php
r1800312 r1835998 4 4 Plugin URI: https://github.com/tyohan/mcw-pwa 5 5 Description: WordPress plugin to optimize loading performance with minimum configuration using PWA approach 6 Version: 0.1. 16 Version: 0.1.2 7 7 Author: Yohan Totting 8 8 Author URI: https://tyohan.me … … 36 36 37 37 require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Service_Worker.php'); 38 require_once(MCW_PWA_DIR.'/includes/performance/MCW_PWA_Performance.php'); 38 39 require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Settings.php'); 39 40 require_once(MCW_PWA_DIR.'/includes/MCW_PWA_LazyLoad.php'); 40 41 require_once(MCW_PWA_DIR.'includes/MCW_PWA_Assets.php'); 41 42 require_once(MCW_PWA_DIR.'includes/MCW_PWA_Add_Homescreen.php'); 42 43 43 44 MCW_PWA_Settings::instance(); … … 45 46 MCW_PWA_LazyLoad::instance(); 46 47 MCW_PWA_Assets::instance(); 48 //MCW_PWA_Add_Homescreen::instance(); 49 MCW_PWA_Performance::instance(); 47 50 48 51 register_deactivation_hook( __FILE__, array(MCW_PWA_Service_Worker::instance(),'flushRewriteRules' )); … … 53 56 delete_option('mcw_enable_service_workers'); 54 57 delete_option('mcw_enable_lazy_load'); 58 delete_option('mcw_enable_performance'); 55 59 } 56 60 -
mcw-pwa/trunk/includes/MCW_PWA_Assets.php
r1800308 r1835998 29 29 add_filter( 'style_loader_src', array($this,'removeVersion'), 9999,1 ); 30 30 // Remove WP Version From Scripts 31 add_filter( 'script_loader_src', array($this,'removeVersion'), 9999,1 ); 31 add_filter( 'script_loader_src', array($this,'removeVersion'), 9999,1 ); 32 33 $this->disableEmojis(); 32 34 } 33 35 } … … 93 95 return $tag; 94 96 } 97 98 public function disableEmojis() { 99 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 100 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 101 remove_action( 'embed_head', 'print_emoji_detection_script', 7 ); 102 103 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 104 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 105 106 remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 107 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 108 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 109 110 add_filter( 'tiny_mce_plugins', array( $this, 'disableEmojiTinymce' ) ); 111 add_filter( 'wp_resource_hints', array( $this, 'disableEmojisRemoveDNSPrefetch' ), 10, 2 ); 112 } 113 114 /** 115 * Filter function used to remove the tinymce emoji plugin. 116 * 117 * @param array $plugins 118 * @return array Difference betwen the two arrays 119 */ 120 public function disableEmojiTinymce( $plugins ) { 121 if ( is_array( $plugins ) ) { 122 return array_diff( $plugins, array( 'wpemoji' ) ); 123 } else { 124 return array(); 125 } 126 } 127 128 /** 129 * Remove emoji CDN hostname from DNS prefetching hints. 130 * 131 * @param array $urls URLs to print for resource hints. 132 * @param string $relation_type The relation type the URLs are printed for. 133 * @return array Difference betwen the two arrays. 134 */ 135 public function disableEmojisRemoveDNSPrefetch( $urls, $relation_type ) { 136 if ( 'dns-prefetch' == $relation_type ) { 137 /** This filter is documented in wp-includes/formatting.php */ 138 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' ); 139 140 $urls = array_diff( $urls, array( $emoji_svg_url ) ); 141 } 142 143 return $urls; 144 } 95 145 } -
mcw-pwa/trunk/includes/MCW_PWA_Module.php
r1800325 r1835998 18 18 } 19 19 20 protected function settingsApiInit(){ 21 22 } 23 24 protected function initScript(){ 25 //won't do anything unless overide 26 27 } 28 20 29 public function settingCallback() { 21 30 … … 31 40 return (int) get_option( $this->getKey(), 1 )===1; 32 41 } 42 43 public static function debug($msg){ 44 echo '<script>console.log('.$msg.');</script>'; 45 } 33 46 } -
mcw-pwa/trunk/includes/MCW_PWA_Service_Worker.php
r1800308 r1835998 20 20 parent::__construct(); 21 21 if($this->isEnable()){ 22 add_action( 'init', array( self::$__instance, 'registerRewriteRule' ) );22 add_action( 'init', array( $this, 'registerRewriteRule' ) ); 23 23 add_action( 'template_redirect', array( $this, 'renderSW' ), 2 ); 24 24 add_filter( 'query_vars', array( $this, 'registerQueryVar' ) ); -
mcw-pwa/trunk/includes/MCW_PWA_Settings.php
r1800325 r1835998 1 1 <?php 2 define( 'MCW_SETTING_URL', 'mcw_setting_page' ); 2 3 require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Service_Worker.php'); 3 4 require_once(MCW_PWA_DIR.'/includes/MCW_PWA_LazyLoad.php'); … … 75 76 76 77 } 78 79 if( isset( $_GET[ 'tab' ] ) ) { 80 $active_tab = $_GET[ 'tab' ]; 81 } // end if 77 82 ?> 78 83 <div class="wrap"> 79 84 <h1>Minimum Configuration WordPress PWA Settings</h1> 85 80 86 <?php 81 87 // show error/update messages 82 88 settings_errors( 'mcw_messages' ); 83 89 ?> 90 <h2 class="nav-tab-wrapper"> 91 <?php echo '<a href="?page='.MCW_SETTING_URL.'&tab=enable_options" class="nav-tab '.($active_tab == "enable_options" ? "nav-tab-active" : "").'">Enable Features</a>';?> 92 <?php echo '<a href="?page='.MCW_SETTING_URL.'&tab=manifest_options" class="nav-tab '.($active_tab == "manifest_options" ? "nav-tab-active" : "").'">Web Manifest</a>';?> 93 </h2> 94 84 95 <form method="post" action="options.php"> 85 96 <?php 86 // This prints out all hidden setting fields 87 settings_fields( MCW_PWA_OPTION); 88 do_settings_sections( MCW_PWA_SETTING_PAGE ); 97 if( $active_tab == 'enable_options' ) { 98 // This prints out all hidden setting fields 99 settings_fields( MCW_PWA_OPTION); 100 do_settings_sections( MCW_PWA_SETTING_PAGE ); 101 } else { 102 // This print out manifest settings 103 104 } // end if/else 105 89 106 submit_button(); 90 107 ?>
Note: See TracChangeset
for help on using the changeset viewer.