settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http ); } // Adds the Autoptimize Toolbar to the Admin bar. // (we load outside the is_admin check so it's also displayed on the frontend toolbar). $toolbar = new autoptimizeToolbar(); } /** * Instantiates aoconfig. * * @return autoptimizeConfig */ static public function instance() { // Only one instance. if ( null === self::$instance ) { self::$instance = new autoptimizeConfig(); } return self::$instance; } public function show_network_message() { ?>

ao_admin_tabs(); ?>

ao_admin_tabs(); ?>
  • />
    ' . __( '(deprecated)', 'autoptimize' ) . ''; ?>
  • />
    ' . __( '(deprecated)', 'autoptimize' ) . ''; ?>
  • />
  • 0 ) { $details = ', ~' . $ao_cache_size . ' total'; } // translators: Kilobytes + timestamp shown. printf( __( '%1$s files, totalling %2$s (calculated at %3$s)', 'autoptimize' ), $ao_stat_arr[0], $ao_cache_size, date( 'H:i e', $ao_stat_arr[2] ) ); } ?>
  • get( 'autoptimize_css_aggregate' ) && ! $conf->get( 'autoptimize_js_aggregate' ) ) { $_min_excl_class = 'hidden'; } ?>

%s', __( 'Settings' ) ); array_unshift( $links, $settings_link ); } else { // 2.8 and higher. // If it's us, add the link. if ( $file === $plugin ) { $newlink = array( sprintf( '%s', __( 'Settings' ) ) ); $links = array_merge( $links, $newlink ); } } return $links; } /** * Provides the default options. * * @return array */ public static function get_defaults() { static $config = array( 'autoptimize_html' => 0, 'autoptimize_html_keepcomments' => 0, 'autoptimize_enable_site_config' => 1, 'autoptimize_js' => 0, 'autoptimize_js_aggregate' => 1, 'autoptimize_js_defer_not_aggregate' => 0, 'autoptimize_js_exclude' => 'wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js, js/jquery/jquery.min.js', 'autoptimize_js_trycatch' => 0, 'autoptimize_js_justhead' => 0, 'autoptimize_js_include_inline' => 0, 'autoptimize_js_forcehead' => 0, 'autoptimize_css' => 0, 'autoptimize_css_aggregate' => 1, 'autoptimize_css_exclude' => 'admin-bar.min.css, dashicons.min.css, wp-content/cache/, wp-content/uploads/', 'autoptimize_css_justhead' => 0, 'autoptimize_css_include_inline' => 1, 'autoptimize_css_defer' => 0, 'autoptimize_css_defer_inline' => '', 'autoptimize_css_inline' => 0, 'autoptimize_css_datauris' => 0, 'autoptimize_cdn_url' => '', 'autoptimize_cache_nogzip' => 1, 'autoptimize_optimize_logged' => 1, 'autoptimize_optimize_checkout' => 0, 'autoptimize_minify_excluded' => 1, 'autoptimize_cache_fallback' => 1, ); return $config; } /** * Returns default option values for autoptimizeExtra. * * @return array */ public static function get_ao_extra_default_options() { $defaults = array( 'autoptimize_extra_checkbox_field_1' => '0', 'autoptimize_extra_checkbox_field_0' => '0', 'autoptimize_extra_radio_field_4' => '1', 'autoptimize_extra_text_field_2' => '', 'autoptimize_extra_text_field_3' => '', 'autoptimize_extra_text_field_7' => '', ); return $defaults; } /** * Returns default option values for autoptimizeExtra. * * @return array */ public static function get_ao_imgopt_default_options() { $defaults = array( 'autoptimize_imgopt_checkbox_field_1' => '0', // imgopt off. 'autoptimize_imgopt_select_field_2' => '2', // quality glossy. 'autoptimize_imgopt_checkbox_field_3' => '0', // lazy load off. 'autoptimize_imgopt_checkbox_field_4' => '0', // webp off (might be removed). 'autoptimize_imgopt_text_field_5' => '', // lazy load exclusions empty. 'autoptimize_imgopt_text_field_6' => '', // optimization exclusions empty. 'autoptimize_imgopt_number_field_7' => '0', // lazy load from nth image (0 = lazyload all). ); return $defaults; } /** * Returns preload JS onload handler. * * @param string $media media attribute value the JS to use. * * @return string */ public static function get_ao_css_preload_onload( $media = 'all' ) { $preload_onload = apply_filters( 'autoptimize_filter_css_preload_onload', "this.onload=null;this.media='" . $media . "';" ); return $preload_onload; } public function get( $key ) { if ( ! is_array( $this->config ) ) { // Default config. $config = self::get_defaults(); // Override with user settings. foreach ( array_keys( $config ) as $name ) { $conf = autoptimizeOptionWrapper::get_option( $name ); if ( false !== $conf ) { // It was set before! $config[ $name ] = $conf; } } // Save for next call. $this->config = apply_filters( 'autoptimize_filter_get_config', $config ); } if ( isset( $this->config[ $key ] ) ) { return $this->config[ $key ]; } return false; } private function get_futtta_feeds( $url ) { if ( $this->settings_screen_do_remote_http ) { $rss = fetch_feed( $url ); $maxitems = 0; if ( ! is_wp_error( $rss ) ) { $maxitems = $rss->get_item_quantity( 7 ); $rss_items = $rss->get_items( 0, $maxitems ); } ?> __( 'JS, CSS & HTML', 'autoptimize' ) ) ); $tab_content = ''; $tabs_count = count( $tabs ); if ( $tabs_count > 1 ) { if ( isset( $_GET['page'] ) ) { $current_id = $_GET['page']; } else { $current_id = 'autoptimize'; } $tab_content .= ''; } else { $tab_content = '
'; } return $tab_content; } /** * Returns true if in admin (and not in admin-ajax.php!) * * @return bool */ public static function is_admin_and_not_ajax() { return ( is_admin() && ! self::doing_ajax() ); } /** * Returns true if doing ajax. * * @return bool */ protected static function doing_ajax() { if ( function_exists( 'wp_doing_ajax' ) ) { return wp_doing_ajax(); } return ( defined( 'DOING_AJAX' ) && DOING_AJAX ); } /** * Returns true menu or tab is to be shown. * * @return bool */ public static function should_show_menu_tabs() { if ( ! is_multisite() || is_network_admin() || 'on' === autoptimizeOptionWrapper::get_option( 'autoptimize_enable_site_config' ) ) { return true; } else { return false; } } }