Plugin Directory


Ignore:
Timestamp:
12/10/2018 09:23:37 PM (7 years ago)
Author:
futtta
Message:

why not update asyncjs for my birthday?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • async-javascript/trunk/asyncjsBackendClass.php

    r1863184 r1991235  
    1818        define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
    1919        define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
    20         define( 'AJ_VERSION', '3.18.04.23' );
     20        define( 'AJ_VERSION', '2.18.12.10' );
    2121        define( 'AJ_UA', 'Async JavaScript/' . AJ_VERSION . ' (+https://autoptimize.com/)' );
     22        add_filter( 'plugin_action_links_'.plugin_basename( 'async-javascript/async-javascript.php' ), array( $this, 'setmeta' ), 10, 2 );
    2223        add_action( 'plugins_loaded', array( $this, 'aj_admin_init' ) );
    2324        add_action( 'admin_init', array( $this, 'aj_disable_pro' ) );
     
    6566     */
    6667    public static function aj_uninstall() {
    67         $optionsToRemove = array('aj_async','aj_autoptimize_enabled','aj_autoptimize_method','aj_defer','aj_enabled','aj_exclusions','aj_gtmetrix_api_key','aj_gtmetrix_results','aj_gtmetrix_server','aj_gtmetrix_username','aj_jquery','aj_method','aj_plugin_exclusions','aj_theme_exclusions','aj_version');
     68        $optionsToRemove = array('aj_async','aj_autoptimize_enabled','aj_autoptimize_method','aj_defer','aj_enabled','aj_enabled_logged','aj_enabled_shop','aj_exclusions','aj_gtmetrix_api_key','aj_gtmetrix_results','aj_gtmetrix_server','aj_gtmetrix_username','aj_jquery','aj_method','aj_plugin_exclusions','aj_theme_exclusions','aj_version');
    6869        if ( !is_multisite() ) {
    6970            foreach ($delete_options as $del_opt) { delete_option( $del_opt ); }
     
    134135        // check if upgrading from early release so settings can be transferred
    135136        $aj_version = get_option( 'aj_version', '' );
    136         if ( $aj_version == '' || $aj_version < '2017.04.25' ) {
    137             $aj_enabled = get_option( 'aj_enabled', 0 );
    138             $aj_method = get_option( 'aj_method', 'async' );
    139             $aj_jquery = ( get_option( 'aj_jquery', 'async' ) == 'same' ) ? $aj_method : get_option( 'aj_jquery', 'async' );
    140             $aj_async = get_option( 'aj_async', '' );
    141             $aj_defer = get_option( 'aj_defer', '' );
    142             $aj_exclusions = get_option( 'aj_exclusions', '' );
    143             $aj_plugin_exclusions = ( is_array( get_option( 'aj_plugin_exclusions', array() ) ) && !is_null( get_option( 'aj_plugin_exclusions', array() ) ) ? get_option( 'aj_plugin_exclusions', array() ) : explode( ',', get_option( 'aj_plugin_exclusions', '' ) ) );
    144             $aj_theme_exclusions = ( is_array( get_option( 'aj_theme_exclusions', array() ) ) && !is_null( get_option( 'aj_theme_exclusions', array() ) ) ? get_option( 'aj_theme_exclusions', array() ) : explode( ',', get_option( 'aj_theme_exclusions', '' ) ) );
    145             $aj_autoptimize_enabled = get_option( 'aj_autoptimize_enabled', 0 );
    146             $aj_autoptimize_method = get_option( 'aj_autoptimize_method', 'async' );
    147             update_option( 'aj_enabled', $aj_enabled );
    148             update_option( 'aj_method', $aj_method );
    149             update_option( 'aj_jquery', $aj_jquery );
    150             update_option( 'aj_async', $aj_async );
    151             update_option( 'aj_defer', $aj_defer );
    152             update_option( 'aj_exclusions', $aj_exclusions );
    153             update_option( 'aj_plugin_exclusions', $aj_plugin_exclusions );
    154             update_option( 'aj_theme_exclusions', $aj_theme_exclusions );
    155             update_option( 'aj_autoptimize_enabled', $aj_autoptimize_enabled );
    156             update_option( 'aj_autoptimize_method', $aj_autoptimize_method );
     137        if ( $aj_version == '' ) {
     138            // set default values
     139            update_option( 'aj_enabled', 0 );
     140            update_option( 'aj_method', 'async' );
     141            update_option( 'aj_enabled_logged', 0 );
     142            update_option( 'aj_enabled_shop', 0 );
     143            update_option( 'aj_jquery', 'exclude' );
     144            update_option( 'aj_async', '' );
     145            update_option( 'aj_defer', '' );
     146            update_option( 'aj_exclusions', '' );
     147            update_option( 'aj_plugin_exclusions', '' );
     148            update_option( 'aj_theme_exclusions', '' );
     149            update_option( 'aj_autoptimize_enabled', 0 );
     150            update_option( 'aj_autoptimize_method', 'async' );
     151        } else if ( $aj_version < '2.18.12.10' || $aj_version == '3.18.04.23' ) {
     152            // upgrade from 2.18.06.13, enable aj for logged users & checkout/ cart to ensure non-regression
     153            update_option( 'aj_enabled_logged', 1 );
     154            update_option( 'aj_enabled_shop', 1 );
    157155        }
    158156
     
    348346        require_once('asyncjsAllAjax.php');
    349347    }
     348
     349    /*
     350     * setmeta function as in Autoptimize to add settings link on plugin overview page
     351     */
     352    public function setmeta($links, $file = null)
     353    {
     354        // Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/.
     355        // Do it only once - saves time.
     356        static $plugin;
     357        if ( empty( $plugin ) ) {
     358            $plugin = plugin_basename( AJ_PLUGIN_DIR . 'async-javascript.php' );
     359        }
     360
     361        // If it's us, add the link.
     362        if ( $file === $plugin ) {
     363            $newlink = array( sprintf( '<a href="options-general.php?page=async-javascript">%s</a>', __( 'Settings' ) ) );
     364            $links = array_merge( $newlink, $links );
     365        }
     366
     367        return $links;
     368    }
    350369}
Note: See TracChangeset for help on using the changeset viewer.