Plugin Directory

Changeset 1835998


Ignore:
Timestamp:
03/08/2018 07:32:39 AM (8 years ago)
Author:
tyohan
Message:

update with combine assets

Location:
mcw-pwa/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • mcw-pwa/trunk/MCW_PWA.php

    r1800312 r1835998  
    44Plugin URI:   https://github.com/tyohan/mcw-pwa
    55Description:  WordPress plugin to optimize loading performance with minimum configuration using PWA approach
    6 Version:      0.1.1
     6Version:      0.1.2
    77Author:       Yohan Totting
    88Author URI:   https://tyohan.me
     
    3636
    3737require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Service_Worker.php');
     38require_once(MCW_PWA_DIR.'/includes/performance/MCW_PWA_Performance.php');
    3839require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Settings.php');
    3940require_once(MCW_PWA_DIR.'/includes/MCW_PWA_LazyLoad.php');
    4041require_once(MCW_PWA_DIR.'includes/MCW_PWA_Assets.php');
    41    
     42require_once(MCW_PWA_DIR.'includes/MCW_PWA_Add_Homescreen.php');
    4243
    4344MCW_PWA_Settings::instance();
     
    4546MCW_PWA_LazyLoad::instance();
    4647MCW_PWA_Assets::instance();
     48//MCW_PWA_Add_Homescreen::instance();
     49MCW_PWA_Performance::instance();
    4750
    4851register_deactivation_hook( __FILE__, array(MCW_PWA_Service_Worker::instance(),'flushRewriteRules' ));
     
    5356    delete_option('mcw_enable_service_workers');
    5457    delete_option('mcw_enable_lazy_load');
     58    delete_option('mcw_enable_performance');
    5559}
    5660
  • mcw-pwa/trunk/includes/MCW_PWA_Assets.php

    r1800308 r1835998  
    2929            add_filter( 'style_loader_src', array($this,'removeVersion'), 9999,1 );
    3030            // 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();
    3234        }
    3335    }
     
    9395        return $tag;
    9496    }
     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    }
    95145}
  • mcw-pwa/trunk/includes/MCW_PWA_Module.php

    r1800325 r1835998  
    1818    }
    1919
     20    protected function settingsApiInit(){
     21
     22    }
     23   
     24    protected function initScript(){
     25        //won't do anything unless overide
     26
     27    }
     28
    2029    public function settingCallback() {
    2130       
     
    3140        return (int) get_option( $this->getKey(), 1 )===1;
    3241    }
     42
     43    public static function debug($msg){
     44        echo '<script>console.log('.$msg.');</script>';
     45    }
    3346}
  • mcw-pwa/trunk/includes/MCW_PWA_Service_Worker.php

    r1800308 r1835998  
    2020        parent::__construct();
    2121        if($this->isEnable()){
    22             add_action( 'init', array( self::$__instance, 'registerRewriteRule' ) );
     22            add_action( 'init', array( $this, 'registerRewriteRule' ) );
    2323            add_action( 'template_redirect', array( $this, 'renderSW' ), 2 );
    2424            add_filter( 'query_vars', array( $this, 'registerQueryVar' ) );
  • mcw-pwa/trunk/includes/MCW_PWA_Settings.php

    r1800325 r1835998  
    11<?php
     2define( 'MCW_SETTING_URL', 'mcw_setting_page' );
    23require_once(MCW_PWA_DIR.'/includes/MCW_PWA_Service_Worker.php');
    34require_once(MCW_PWA_DIR.'/includes/MCW_PWA_LazyLoad.php');
     
    7576           
    7677        }
     78       
     79        if( isset( $_GET[ 'tab' ] ) ) {
     80            $active_tab = $_GET[ 'tab' ];
     81        } // end if
    7782        ?>
    7883        <div class="wrap">
    7984            <h1>Minimum Configuration WordPress PWA Settings</h1>
     85           
    8086            <?php
    8187                // show error/update messages
    8288                settings_errors( 'mcw_messages' );
    8389            ?>
     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
    8495            <form method="post" action="options.php">
    8596            <?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               
    89106                submit_button();
    90107            ?>
Note: See TracChangeset for help on using the changeset viewer.