Repository: norcross/airplane-mode
Branch: main
Commit: ba64ab53cf26
Files: 12
Total size: 69.0 KB
Directory structure:
gitextract_qj6t8kvq/
├── .gitattributes
├── .gitignore
├── CHANGES.md
├── LICENSE
├── README.md
├── airplane-mode.php
├── composer.json
├── inc/
│ └── wp-cli.php
├── languages/
│ ├── default.mo
│ └── default.po
├── lib/
│ └── css/
│ └── airplane-mode.css
└── readme.txt
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
.gitattributes export-ignore
.gitignore export-ignore
composer.json export-ignore
================================================
FILE: .gitignore
================================================
.htaccess
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
*.log
wp-content/cache/
wp-content/backups/
sitemap.xml.gz
wp-config.php
================================================
FILE: CHANGES.md
================================================
#### Version 0.2.8 - 2024/12/02
* Confirming `get_plugin_data` or `is_plugin_active` is checked properly. props @swissspidy
#### Version 0.2.7 - 2024/11/12
* Replacing dull monotone avatars with color ones. props @akirk
#### Version 0.2.6 - 2022/10/13
* Remove usage of 'jetpack_development_mode' that's been deprecated. props @crstauf
* Gracefully handle empty values for script and stylesheet URLs. props @johnbillion
#### Version 0.2.5 - 2019/11/15
* Remove usage of method that's been deprecated in WordPress trunk. props @johnbillion
#### Version 0.2.4 - 2017/12/13
* Added localhost bypass for loading CSS and JS files when hot reloading. props @shadyvb
* Added additional hook removals for new automated updates and language packs.
* Removed outdated `create_function` call for PHP 7.2 compatibility. props @geminorum
* General cleanup
#### Version 0.2.3 - 2017/03/05
* Adding option to force transient purge
* Adding `clean` action to WP-CLI functions
#### Version 0.2.2 - 2016/12/07
* Adding WP-CLI support. props @markjaquith
#### Version 0.2.1 - 2016/10/19
* Fix settings page language drowdown when used offline. props @onnimonni
#### Version 0.2.0 - 2016/08/26
* modify CSS loading for front-end, removed loading for login page. props @barryceelen
* fixed WP.org theme API call request to avoid `WP_Error` return. props @onnimonni
#### Version 0.1.9 - 2016/07/25
* prevent BuddyPress from falling back to Gravatar. props @johnbillion
#### Version 0.1.8 - 2016/07/12
* allow `JETPACK_DEV_DEBUG` constant to take priority over filter. props @kopepasah
* added additional CSS for upcoming 4.6. change to upload tab.
#### Version 0.1.7 - 2016/05/18
* allow local HTTP calls with optional filter. props @johnbillion
* add back index.php link to main dashboard menu item
* bumped minimum WP version requirement to 4.4
#### Version 0.1.6 - 2016/04/25
* minor tweak to include CSS for new icon font
#### Version 0.1.5 - 2016/04/24
* adding custom icon font for display and removing label. props @barryceelen
#### Version 0.1.4 - 2016/02/26
* better setup for blocked external assets. props @johnbillion
#### Version 0.1.3 - 2016/02/22
* modified CSS rules to fix media bulk actions bar from disappearing
* moved `airplane_mode_status_change` action to run before redirect, and now includes the status being run.
#### Version 0.1.2 - 2016/01/09
* added back HTTP count when inactive
* removed HTTP count completely when Query Monitor is active
#### Version 0.1.1 - 2016/01/06
* fixed incorrect nonce check that was breaking toggle
* changed CSS and JS checks to include all themes and plugins as well as core
#### Version 0.1.0 - 2015/12/30
* added `airplane_mode_purge_transients` filter to bypass transient purge
#### Version 0.0.9 - 2015/12/07
* changed from colored circle to actual airplane icon for usability
* fixed dashboard link icon for multisite
* changed to exclude all external stylesheets, not just Open Sans
* added language files for translateable goodness
* general cleanup for WP coding standards
#### Version 0.0.8 - 2015/05/18
* added `class_exists` as now included in DesktopServer and collisions could result
* fixed `if ( ! defined ...` for `AIRMDE_BASE` constant
* add `.gitattributes` to remove certain files from updates
#### Version 0.0.7 - 2015/04/21
* fixed some CSS from hiding plugins page bar
* moved changelog to it's own file
* added `composer.json`
* added contributors to readme
* clarified license (MIT)
#### Version 0.0.6 - 2015/04/02
* version bump for GitHub updater
#### Version 0.0.5 - 2015/04/02
* fixed bug in update logic that was preventing checks when disabled (but activated). props @johnbillion
#### Version 0.0.3 - 2015/01/23
* added `airplane_mode_status_change` hook for functions to fire on status change
* purge update related transients on disable
* added WordPress formatted readme file
#### Version 0.0.2 - 2015/01/21
* added GitHub Updater support
* fixed update capabilities when status is disabled
#### Version 0.0.1 - 2014/06/01
* lots of stuff. I wasn't keeping a changelog. I apologize.
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 Norcross
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
Airplane Mode
========================
## Contributors
* [Andrew Norcross](https://github.com/norcross)
* [John Blackbourn](https://github.com/johnbillion)
* [Andy Fragen](https://github.com/afragen)
* [Viktor Szépe](https://github.com/szepeviktor)
* [Chris Christoff](https://github.com/chriscct7)
* [Mark Jaquith](https://github.com/markjaquith)
## About
Control loading of external files when developing locally. WP loads certain external files (fonts, Gravatar, etc.) and makes external HTTP calls. This isn't usually an issue, unless you're working in an evironment without a web connection. This plugin removes/unhooks those actions to reduce load time and avoid errors due to missing files.
## Current Actions
* removes external JS and CSS files from loading
* replaces all instances of Gravatar with a local image to remove external call
* removes all HTTP requests
* disables all WP update checks for core, languages, themes, and plugins
* includes toggle in admin bar for quick enable / disable
## Changelog
See [CHANGES.md](CHANGES.md).
## Notes
If you need offline activation, see [this script](https://gist.github.com/solepixel/e1d03f4dcd1b9e86552b3cc6937325bf) written by [Brian DiChiara](https://github.com/solepixel)
## Roadmap
* fine tune HTTP request removal
* find other calls from core
* add other requests from popular plugins
#### [Pull requests](https://github.com/norcross/airplane-mode/pulls) are very much welcome and encouraged.
================================================
FILE: airplane-mode.php
================================================
<?php
/**
* Plugin Name: Airplane Mode
* Plugin URI: https://github.com/norcross/airplane-mode
* Description: Control loading of external files when developing locally.
* Author: Andrew Norcross
* Author URI: https://andrewnorcross.com/
* Version: 0.2.8
* Text Domain: airplane-mode
* Requires WP: 4.4
* Domain Path: languages
* GitHub Plugin URI: https://github.com/norcross/airplane-mode
* @package airplane-mode
*/
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Andrew Norcross
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Set our base if not already defined.
if ( ! defined( 'AIRMDE_BASE' ) ) {
define( 'AIRMDE_BASE', plugin_basename( __FILE__ ) );
}
// Set our directory if not already defined.
if ( ! defined( 'AIRMDE_DIR' ) ) {
define( 'AIRMDE_DIR', plugin_dir_path( __FILE__ ) );
}
// Set our version if not already defined.
if ( ! defined( 'AIRMDE_VER' ) ) {
define( 'AIRMDE_VER', '0.2.8' );
}
// Load our WP-CLI helper if that is defined and available.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once dirname( __FILE__ ) . '/inc/wp-cli.php';
}
// Ensure the class has not already been loaded.
if ( ! class_exists( 'Airplane_Mode_Core' ) ) {
/**
* Call our class.
*/
class Airplane_Mode_Core {
/**
* Static property to hold our singleton instance.
*
* @var $instance
*/
static $instance = false;
/**
* Set a var for the number of HTTP requests.
*
* @var $http_count
*/
private $http_count = 0;
/**
* This is our constructor. There are many like it, but this one is mine.
*/
private function __construct() {
add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
add_action( 'style_loader_src', array( $this, 'block_style_load' ), 100 );
add_action( 'script_loader_src', array( $this, 'block_script_load' ), 100 );
add_action( 'admin_init', array( $this, 'remove_update_crons' ) );
add_action( 'admin_init', array( $this, 'remove_schedule_hook' ) );
add_filter( 'embed_oembed_html', array( $this, 'block_oembed_html' ), 1, 4 );
add_filter( 'get_avatar', array( $this, 'replace_gravatar' ), 1, 5 );
add_filter( 'map_meta_cap', array( $this, 'prevent_auto_updates' ), 10, 2 );
add_filter( 'default_avatar_select', array( $this, 'default_avatar' ) );
// Kill all the http requests.
add_filter( 'pre_http_request', array( $this, 'disable_http_reqs' ), 10, 3 );
// Check for our query string and handle accordingly.
add_action( 'init', array( $this, 'toggle_check' ) );
// Check for status change and purge transients as needed.
add_action( 'airplane_mode_status_change', array( $this, 'purge_transients' ) );
// Add our counter action.
add_action( 'airplane_mode_http_args', array( $this, 'count_http_requests' ), 0, 0 );
// CSS loader and top toggle.
add_action( 'admin_bar_menu', array( $this, 'admin_bar_toggle' ), 9999 );
add_action( 'wp_enqueue_scripts', array( $this, 'toggle_css' ), 9999 );
add_action( 'admin_enqueue_scripts', array( $this, 'toggle_css' ), 9999 );
// Body class on each location for the display.
add_filter( 'body_class', array( $this, 'body_class' ) );
add_filter( 'login_body_class', array( $this, 'body_class' ) );
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
// Remove bulk action for updating themes/plugins.
add_filter( 'bulk_actions-plugins', array( $this, 'remove_bulk_actions' ) );
add_filter( 'bulk_actions-themes', array( $this, 'remove_bulk_actions' ) );
add_filter( 'bulk_actions-plugins-network', array( $this, 'remove_bulk_actions' ) );
add_filter( 'bulk_actions-themes-network', array( $this, 'remove_bulk_actions' ) );
// Admin UI items.
add_action( 'admin_menu', array( $this, 'admin_menu_items' ), 9999 );
add_action( 'network_admin_menu', array( $this, 'ms_admin_menu_items' ), 9999 );
add_filter( 'install_plugins_tabs', array( $this, 'plugin_add_tabs' ) );
// Theme update API for different calls.
add_filter( 'themes_api', array( $this, 'bypass_theme_api_call' ), 10, 3 );
add_filter( 'themes_api_result', array( $this, 'bypass_theme_api_result' ), 10, 3 );
// Time based transient checks.
add_filter( 'pre_site_transient_update_themes', array( $this, 'last_checked_themes' ) );
add_filter( 'pre_site_transient_update_plugins', array( $this, 'last_checked_plugins' ) );
add_filter( 'pre_site_transient_update_core', array( $this, 'last_checked_core' ) );
add_filter( 'site_transient_update_themes', array( $this, 'remove_update_array' ) );
add_filter( 'site_transient_update_plugins', array( $this, 'remove_update_array' ) );
// Disable fetching languages from online
add_filter( 'site_transient_available_translations', array( $this, 'available_translations' ), 9999, 1 );
// Use our own filters for scripts and stylesheets to allow local.
add_filter( 'airplane_mode_parse_style', array( $this, 'bypass_asset_block' ), 10, 2 );
add_filter( 'airplane_mode_parse_script', array( $this, 'bypass_asset_block' ), 10, 2 );
// Our activation / deactivation triggers.
register_activation_hook( __FILE__, array( $this, 'create_setting' ) );
register_deactivation_hook( __FILE__, array( $this, 'remove_setting' ) );
// All our various filter checks.
if ( $this->enabled() ) {
// Allows locally defined JETPACK_DEV_DEBUG constant to override filter.
if ( ! defined( 'JETPACK_DEV_DEBUG' ) ) {
if ( ! function_exists( 'get_plugin_data' ) || ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if ( is_plugin_active( 'jetpack/jetpack.php' ) ) {
$jetpack_plugin = get_plugin_data( trailingslashit( WP_PLUGIN_DIR ) . 'jetpack/jetpack.php' );
if ( version_compare( '8.8.0', $jetpack_plugin['Version'], '<=' ) ) {
// Keep jetpack 8.8.0+ from attempting external requests.
add_filter( 'jetpack_offline_mode', '__return_true', 9999 );
} else {
// Keep jetpack <8.8.0 from attempting external requests.
add_filter( 'jetpack_development_mode', '__return_true', 9999 );
}
}
}
// Prevent BuddyPress from falling back to Gravatar avatars.
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
// Disable automatic updater updates.
add_filter( 'automatic_updater_disabled', '__return_true' );
// Tell WordPress we are on a version control system to add additional blocks.
add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' );
// Disable translation updates.
add_filter( 'auto_update_translation', '__return_false' );
// Disable minor core updates.
add_filter( 'allow_minor_auto_core_updates', '__return_false' );
// Disable major core updates.
add_filter( 'allow_major_auto_core_updates', '__return_false' );
// Disable dev core updates.
add_filter( 'allow_dev_auto_core_updates', '__return_false' );
// Disable overall core updates.
add_filter( 'auto_update_core', '__return_false' );
add_filter( 'wp_auto_update_core', '__return_false' );
// Disable automatic plugin and theme updates (used by WP to force push security fixes).
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
// Disable debug emails (used by core for rollback alerts in automatic update deployment).
add_filter( 'automatic_updates_send_debug_email', '__return_false' );
// Disable update emails (for when we push the new WordPress versions manually) as well
// as the notification there is a new version emails.
add_filter( 'auto_core_update_send_email', '__return_false' );
add_filter( 'send_core_update_notification_email', '__return_false' );
add_filter( 'automatic_updates_send_debug_email ', '__return_false', 1 );
// Get rid of the version number in the footer.
add_filter( 'update_footer', '__return_empty_string', 11 );
// Filter out the pre core option.
add_filter( 'pre_option_update_core', '__return_null' );
// Remove some actions.
remove_action( 'admin_init', 'wp_plugin_update_rows' );
remove_action( 'admin_init', 'wp_theme_update_rows' );
remove_action( 'admin_notices', 'maintenance_nag' );
remove_action( 'init', 'wp_schedule_update_checks' );
// Add back the upload tab.
add_action( 'install_themes_upload', 'install_themes_upload', 10, 0 );
// Define core contants for more protection.
if ( ! defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
define( 'AUTOMATIC_UPDATER_DISABLED', true );
}
if ( ! defined( 'WP_AUTO_UPDATE_CORE' ) ) {
define( 'WP_AUTO_UPDATE_CORE', false );
}
}
}
/**
* If an instance exists, this returns it. If not, it creates one and
* returns it.
*
* @return $instance
*/
public static function getInstance() {
if ( ! self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Load our textdomain for localization.
*
* @return void
*/
public function textdomain() {
load_plugin_textdomain( 'airplane-mode', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Set our initial airplane mode setting to 'on' on activation.
*/
public function create_setting() {
add_site_option( 'airplane-mode', 'on' );
set_transient( 'wporg_theme_feature_list', array(), 999999999999 );
}
/**
* Remove our setting on plugin deactivation.
*/
public function remove_setting() {
delete_option( 'airplane-mode' );
delete_site_option( 'airplane-mode' );
delete_transient( 'wporg_theme_feature_list' );
}
/**
* Helper function to check the current status.
*
* @return bool True if status is 'on'; false if not.
*/
public function enabled() {
// Bail if CLI.
if ( defined( 'WP_CLI' ) and WP_CLI ) {
return false;
}
// Pull our status from the options table.
$option = get_site_option( 'airplane-mode' );
// Backup check for regular options table.
if ( false === $option ) {
$option = get_option( 'airplane-mode' );
}
// Return the option flag.
return 'on' === $option;
}
/**
* Check the URL of a stylesheet and remove any that are not on the local URL.
*
* @param string|false $source The source URL of the CSS sheet, or false if there isn't one.
*
* @return string|false|Airplane_Mode_WP_Error $source The same URL, or an error object.
*/
public function block_style_load( $source ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $source;
}
// Plugins can set this to a messed up value that we don't want to pass to `parse_url()`.
if ( empty( $source ) ) {
return $source;
}
// Parse the URL being passed to pull out the host.
$parsed = parse_url( $source, PHP_URL_HOST );
// First run the filter to allow a source host to get through.
if ( false === apply_filters( 'airplane_mode_parse_style', true, $parsed ) ) {
return $source;
}
// If we don't share the same URL as the site itself, return an error object. Otherwise return the URL.
return isset( $parsed ) && false === strpos( home_url(), $parsed )
? new Airplane_Mode_WP_Error( 'airplane_mode_enabled', __( 'Airplane Mode blocked style', 'airplane-mode' ), array(
'return' => '',
'src' => $source,
) )
: $source;
}
/**
* Check the URL of a JS file and remove any that are not on the local URL.
*
* @param string|false $source The source URL of the JS file, or false if there isn't one.
*
* @return string|false|Airplane_Mode_WP_Error $source The same URL, or an error object.
*/
public function block_script_load( $source ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $source;
}
// Plugins can set this to a messed up value that we don't want to pass to `parse_url()`.
if ( empty( $source ) ) {
return $source;
}
// Parse the URL being passed to pull out the host.
$parsed = parse_url( $source, PHP_URL_HOST );
// First run the filter to allow a source host to get through.
if ( false === apply_filters( 'airplane_mode_parse_script', true, $parsed ) ) {
return $source;
}
// If we don't share the same URL as the site itself, return an error object. Otherwise return the URL.
return isset( $parsed ) && false === strpos( home_url(), $parsed )
? new Airplane_Mode_WP_Error( 'airplane_mode_enabled', __( 'Airplane Mode blocked script', 'airplane-mode' ), array(
'return' => '',
'src' => $source,
) )
: $source;
}
/**
* Use our existing filter to check for local assets.
*
* @param boolean $block Whether to block the specific asset. Defaults to 'true'.
* @param array $parsed The URL of the asset, parsed.
*
* @return boolean
*/
public function bypass_asset_block( $block, $parsed ) {
// Create an array of the approved local domains.
$local = apply_filters( 'airplane_mode_local_hosts', array( 'localhost', '127.0.0.1' ) );
// If our parsed URL host is in that array, return false. Otherwise, return our blocking choice.
return ! empty( $local ) && in_array( $parsed, $local ) ? false : $block;
}
/**
* Block oEmbeds from displaying.
*
* @param string $html The embed HTML.
* @param string $url The attempted embed URL.
* @param array $attr An array of shortcode attributes.
* @param int $post_ID Post ID.
*
* @return string
*/
public function block_oembed_html( $html, $url, $attr, $post_ID ) {
return $this->enabled() ? sprintf( '<div class="loading-placeholder airplane-mode-placeholder"><p>%s</p></div>', sprintf( __( 'Airplane Mode is enabled. oEmbed blocked for %1$s.', 'airplane-mode' ), esc_url( $url ) ) ) : $html;
}
/**
* Add body class to front-end pages and login based on plugin status.
*
* @param array $classes The existing array of body classes.
*
* @return array $classes The updated array of body classes.
*/
public function body_class( $classes ) {
// Add the class based on the current status.
$classes[] = $this->enabled() ? 'airplane-mode-enabled' : 'airplane-mode-disabled';
// Also add in the margin setup for Query Monitor because I'm a perfectionist.
if ( ! class_exists( 'QueryMonitor' ) || defined( 'QM_DISABLED' ) && QM_DISABLED ) {
$classes[] = 'airplane-mode-no-qm';
}
// Return our array of classes.
return $classes;
}
/**
* Add body class to admin pages based on plugin status.
*
* @param string $classes The existing space-separated list of CSS classes.
*
* @return string $classes The updated space-separated list of CSS classes.
*/
public function admin_body_class( $classes ) {
// First add the standard set of classes based on status.
$classes .= $this->enabled() ? ' airplane-mode-enabled' : ' airplane-mode-disabled';
// Also add in the margin setup for Query Monitor because I'm a perfectionist.
if ( ! class_exists( 'QueryMonitor' ) || defined( 'QM_DISABLED' ) && QM_DISABLED ) {
$classes .= ' airplane-mode-no-qm';
}
// Return our string of classes.
return $classes;
}
/**
* Remove menu items for updates from a standard WP install.
*
* @return null
*/
public function admin_menu_items() {
// Bail if disabled, or on a multisite.
if ( ! $this->enabled() || is_multisite() ) {
return;
}
// Remove our items.
remove_submenu_page( 'index.php', 'update-core.php' );
}
/**
* Remove menu items for updates from a multisite instance.
*
* @return null
*/
public function ms_admin_menu_items() {
// Bail if disabled or not on our network admin.
if ( ! $this->enabled() || ! is_network_admin() ) {
return;
}
// Remove the items.
remove_submenu_page( 'index.php', 'upgrade.php' );
}
/**
* Replace all instances of gravatar with a local image file
* to remove the call to remote service.
*
* @param string $avatar Image tag for the user's avatar.
* @param int|object|string $id_or_email A user ID, email address, or comment object.
* @param int $size Square avatar width and height in pixels to retrieve.
* @param string $default URL to a default image to use if no avatar is available.
* @param string $alt Alternative text to use in the avatar image tag.
*
* @return string `<img>` tag for the user's avatar.
*/
public function replace_gravatar( $avatar, $id_or_email, $size, $default, $alt ) {
// Bail if disabled.
if ( ! $this->enabled() || false === strpos( $avatar, 'gravatar.com' ) ) {
return $avatar;
}
// Swap out the file for a base64 encoded image generated based on the $id_or_email.
$image = $this->generate_color_avatar( $id_or_email );
// Build the image string.
$avatar = "<img alt='{$alt}' src='{$image}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' style='background:#eee;' />";
// Return the avatar.
return $avatar;
}
/**
* Remove avatar images from the default avatar list.
*
* @param string $avatar_list List of default avatars.
*
* @return string Updated list with images removed.
*/
public function default_avatar( $avatar_list ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $avatar_list;
}
// Remove images.
$avatar_list = preg_replace( '|<img([^>]+)> |i', '', $avatar_list );
// Send back the list.
return $avatar_list;
}
/**
* Disable all the HTTP requests being made with the action
* happening before the status check so others can allow certain
* items as desired.
*
* @param bool|array|WP_Error $status Whether to preempt an HTTP request return. Default false.
* @param array $args HTTP request arguments.
* @param string $url The request URL.
*
* @return bool|array|WP_Error A WP_Error object if Airplane Mode is enabled. Original $status if not.
*/
public function disable_http_reqs( $status = false, $args = array(), $url = '' ) {
// Pass our data to the action to allow a bypass.
do_action( 'airplane_mode_http_args', $status, $args, $url );
if ( ! $this->enabled() ) {
return $status;
}
$url_host = parse_url( $url, PHP_URL_HOST );
// Allow the request to pass through if the URL host matches the site's host.
if ( $url_host && parse_url( home_url(), PHP_URL_HOST ) === $url_host ) {
// But allow this to be disabled via a filter.
if ( apply_filters( 'airplane_mode_allow_local_bypass', true, $url, $args ) ) {
return $status;
}
}
// Allow certain HTTP API requests to pass through via a filter.
if ( apply_filters( 'airplane_mode_allow_http_api_request', false, $url, $args, $url_host ) ) {
return $status;
}
// Disable the http requests if enabled.
return new WP_Error( 'airplane_mode_enabled', __( 'Airplane Mode is enabled', 'airplane-mode' ) );
}
/**
* Load our small CSS file for the toggle switch.
*/
public function toggle_css() {
// Don't display CSS on the front-end if the admin bar is not loading.
if ( ! is_admin() && ! is_admin_bar_showing() ) {
return;
}
// Set a suffix for loading the minified or normal.
$file = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'airplane-mode.css' : 'airplane-mode.min.css';
// Set a version for browser caching.
$vers = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : AIRMDE_VER;
// Load the CSS file itself.
wp_enqueue_style( 'airplane-mode', plugins_url( '/lib/css/' . $file, __FILE__ ), array(), $vers, 'all' );
}
/**
* Sets the mode.
*
* @param string $mode Desired mode ('on' or 'off').
*
* @return bool Whether the setting changed.
*/
public function set_mode( $mode = 'on' ) {
// Check what mode we're currently in, with "on" as a fallback.
if ( ! in_array( $mode, array( 'on', 'off' ) ) ) {
$mode = 'on';
}
// Update the setting.
$return = update_site_option( 'airplane-mode', $mode );
// Fire action to allow for functions to run on status change.
do_action( 'airplane_mode_status_change', $mode );
// And return the status we just set.
return $return;
}
/**
* Enables airplane mode.
*
* @return bool Whether the setting changed.
*/
public function enable() {
return self::set_mode( 'on' );
}
/**
* Disables airplane mode.
*
* @return bool Whether the setting changed.
*/
public function disable() {
return self::set_mode( 'off' );
}
/**
* Check the user action from the toggle switch to set the option
* to 'on' or 'off'.
*
* @return void If any of the sanity checks fail and we bail early.
*/
public function toggle_check() {
// Bail if current user doesn't have cap.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Set a sanitized variable of our potential nonce and request.
$nonce = isset( $_GET['airmde_nonce'] ) ? sanitize_key( $_GET['airmde_nonce'] ) : '';
$switch = isset( $_REQUEST['airplane-mode'] ) ? sanitize_key( $_REQUEST['airplane-mode'] ) : '';
// Check for our nonce.
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'airmde_nonce' ) ) {
return;
}
// Now check for our query string.
if ( empty( $switch ) || ! in_array( $switch, array( 'on', 'off' ) ) ) {
return;
}
// Delete old per-site option.
delete_option( 'airplane-mode' );
// Set our mode based on the toggle action.
self::set_mode( $switch );
// And go about our business.
wp_redirect( self::get_redirect() );
exit;
}
/**
* Fetch the URL to redirect to after toggling Airplane Mode.
*
* @return string The URL to redirect to.
*/
protected static function get_redirect() {
// Return the args for the actual redirect.
$redirect = remove_query_arg( array(
'airplane-mode',
'airmde_nonce',
'user_switched',
'switched_off',
'switched_back',
'message',
'update',
'updated',
'settings-updated',
'saved',
'activated',
'activate',
'deactivate',
'enabled',
'disabled',
'locked',
'skipped',
'deleted',
'trashed',
'untrashed',
'force-check',
) );
// Redirect away from the update core page.
$redirect = str_replace( 'update-core.php', '', $redirect );
// And return the redirect.
return apply_filters( 'airplane_mode_redirect_url', $redirect );
}
/**
* Add our quick toggle to the admin bar to enable / disable.
*
* @param WP_Admin_Bar $wp_admin_bar The admin bar object.
*
* @return void if current user can't manage options and we bail early.
*/
public function admin_bar_toggle( WP_Admin_Bar $wp_admin_bar ) {
// Bail if current user doesn't have cap.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Get the current status.
$status = $this->enabled();
// Set a title message (translatable).
$title = $status ? __( 'Airplane Mode is enabled.', 'airplane-mode' ) : __( 'Airplane Mode is disabled.', 'airplane-mode' );
// Set our toggle variable parameter (in reverse since we want the opposite action).
$toggle = $status ? 'off' : 'on';
// Set my HTTP request count label to a blank string for now.
$label = '';
// Get and display the HTTP count when Query Monitor isn't active.
if ( ! class_exists( 'QueryMonitor' ) || defined( 'QM_DISABLED' ) && QM_DISABLED ) {
// Pull my HTTP count.
$count = ! empty( $this->http_count ) ? number_format_i18n( $this->http_count ) : 0;
$count_label = sprintf( _n( 'There was %s HTTP request.', 'There were %s HTTP requests.', $count, 'airplane-mode' ), $count );
// Build the markup for my label.
$label = '<span class="ab-label" aria-hidden="true">' . absint( $count ) . '</span>';
$label .= '<span class="screen-reader-text">' . esc_html( $count_label ) . '</span>';
// Amend the tooltip title with the count.
$title .= ' ' . $count_label;
}
// Get our link with the status parameter.
$link = wp_nonce_url( add_query_arg( 'airplane-mode', $toggle ), 'airmde_nonce', 'airmde_nonce' );
// Now add the admin bar link.
$wp_admin_bar->add_node(
array(
'id' => 'airplane-mode-toggle',
'title' => '<span class="ab-icon"></span>' . $label,
'href' => esc_url( $link ),
'position' => 0,
'meta' => array(
'title' => $title,
),
)
);
}
/**
* Filter a user's meta capabilities to prevent auto-updates from being attempted.
*
* @param array $caps Returns the user's actual capabilities.
* @param string $cap Capability name.
*
* @return array The user's filtered capabilities.
*/
public function prevent_auto_updates( $caps, $cap ) {
// Check for being enabled and look for specific cap requirements.
if ( $this->enabled() && in_array( $cap, array( 'update_plugins', 'update_themes', 'update_core' ) ) ) {
$caps[] = 'do_not_allow';
}
// Send back the data array.
return $caps;
}
/**
* Check the new status after airplane mode has been enabled or
* disabled and purge related transients.
*
* @param boolean $force Whether to force the purge.
*
* @return void
*/
public function purge_transients( $force = false ) {
// First check for the filter to avoid this action overall.
if ( empty( $force ) && false === $clear = apply_filters( 'airplane_mode_purge_transients', true ) ) {
return;
}
// Purge the transients related to updates when disabled or the force is called.
if ( ! $this->enabled() || ! empty( $force ) ) {
delete_site_transient( 'update_core' );
delete_site_transient( 'update_plugins' );
delete_site_transient( 'update_themes' );
delete_site_transient( 'wporg_theme_feature_list' );
}
}
/**
* Remove all the various places WP does the update checks. As you can see there are a lot of them.
*
* @return null
*/
public function remove_update_crons() {
// Bail if disabled.
if ( ! $this->enabled() ) {
return;
}
// Do a quick check to make sure we can remove things.
if ( ! function_exists( 'remove_action' ) ) {
return;
}
// Disable Theme Updates.
remove_action( 'load-update-core.php', 'wp_update_themes' );
remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action( 'load-update.php', 'wp_update_themes' );
remove_action( 'wp_update_themes', 'wp_update_themes' );
remove_action( 'admin_init', '_maybe_update_themes' );
// Disable Plugin Updates.
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'wp_update_plugins', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
// Disable Core updates
// Don't look for WordPress updates. Seriously!
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
// Not even maybe.
remove_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' );
remove_action( 'admin_init', 'wp_maybe_auto_update' );
remove_action( 'admin_init', 'wp_auto_update_core' );
// Don't forget when the language packs do it.
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
remove_action( 'upgrader_process_complete', 'wp_version_check' );
remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
remove_action( 'upgrader_process_complete', 'wp_update_themes' );
}
/**
* Remove all the various schedule hooks for themes, plugins, etc.
*
* @return null
*/
public function remove_schedule_hook() {
// Bail if disabled.
if ( ! $this->enabled() ) {
return;
}
// Clear all my hooks.
wp_clear_scheduled_hook( 'wp_update_themes' );
wp_clear_scheduled_hook( 'wp_update_plugins' );
wp_clear_scheduled_hook( 'wp_version_check' );
wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
}
/**
* Override the API call made for pulling themes from the .org repo.
*
* @param false|object|array $override Whether to override the WordPress.org Themes API. Default false.
* @param string $action Requested action. Likely values are 'theme_information',
* 'feature_list', or 'query_themes'.
* @param object $args Arguments used to query for installer pages from the Themes API.
*
* @return bool True if enabled, otherwise the existng value.
*/
public function bypass_theme_api_call( $override, $action, $args ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $override;
}
// Return false on feature list to avoid the API call.
return ! empty( $action ) && 'feature_list' === $action ? true : $override;
}
/**
* Hijack the expected themes API result.
*
* @param array|object|WP_Error $res WordPress.org Themes API response.
* @param string $action Requested action. Likely values are 'theme_information',
* 'feature_list', or 'query_themes'.
* @param object $args Arguments used to query for installer pages from the WordPress.org Themes API.
*
* @return bool An empty array if enabled, otherwise the existng result.
*/
public function bypass_theme_api_result( $res, $action, $args ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $res;
}
// Return false on feature list to avoid the API call.
return ! empty( $action ) && in_array( $action, array( 'feature_list', 'query_themes' ) ) ? array() : $res;
}
/**
* Always send back that the latest version of WordPress is the one we're running
*
* @return object the modified output with our information
*/
public function last_checked_core() {
// Bail if disabled.
if ( ! $this->enabled() ) {
return false;
}
// Call the global WP version.
global $wp_version;
// Return our object.
return (object) array(
'last_checked' => time(),
'updates' => array(),
'version_checked' => $wp_version,
);
}
/**
* Always send back that the latest version of our theme is the one we're running
*
* @return object the modified output with our information
*/
public function last_checked_themes() {
// Bail if disabled.
if ( ! $this->enabled() ) {
return false;
}
// Call the global WP version.
global $wp_version;
// Set a blank data array.
$data = array();
// Build my theme data array.
foreach ( wp_get_themes() as $theme ) {
$data[ $theme->get_stylesheet() ] = $theme->get( 'Version' );
}
// Return our object.
return (object) array(
'last_checked' => time(),
'updates' => array(),
'version_checked' => $wp_version,
'checked' => $data,
);
}
/**
* Always send back that the latest version of our plugins are the one we're running
*
* @return object the modified output with our information
*/
public function last_checked_plugins() {
// Bail if disabled.
if ( ! $this->enabled() ) {
return false;
}
// Call the global WP version.
global $wp_version;
// Set a blank data array.
$data = array();
// Add our plugin file if we don't have it.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
// Build my plugin data array.
foreach ( get_plugins() as $file => $pl ) {
$data[ $file ] = $pl['Version'];
}
// Return our object.
return (object) array(
'last_checked' => time(),
'updates' => array(),
'version_checked' => $wp_version,
'checked' => $data,
);
}
/**
* Filter for languages list transient. Returns locally available translations
* to avoid request into wp.org translation API.
*
* @param mixed $translations Translation data returned from transient API.
*
* @return array List of available languages.
*/
public function available_translations( $translations ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $translations;
}
/**
* If transient still contains list of languages just use those.
* Otherwise fallback to mimicked data which we create here.
*/
if ( $translations && ! empty( $translations ) ) {
return $translations;
} else {
$installed_languages = get_available_languages();
return $this->get_offline_languages( $installed_languages );
}
}
/**
* Returns list of languages installed locally with full mimicked meta data.
*
* @param array $installed_languages List of locally available languages.
*
* @return array List of available languages in offline mode.
*/
private function get_offline_languages( $installed_languages ) {
// This is list of languages which are available from translations API.
$offline_languages = $this->get_offline_translation_information();
// Call the global WP version.
global $wp_version;
// Tell WordPress that all translations are recent even though they can be old.
$date = date_i18n( 'Y-m-d H:is' , time() );
// Set an empty array of the available languages.
$available_languages = array();
// Loop through our installed languages.
foreach ( $installed_languages as $lang ) {
// Try to mimick the data that WordPress puts into 'available_translations' transient.
$settings = array(
'language' => $lang,
'iso' => array( $lang ),
'version' => $wp_version,
'updated' => $date,
'strings' => array(
'continue' => __( 'Continue' ),
),
'package' => "https://downloads.wordpress.org/translation/core/{$wp_version}/{$lang}.zip",
);
// Combine the mimicked data with data we have stored in $offline_languages to give realistic output.
if ( isset( $offline_languages[ $lang ] ) ) {
$available_languages[ $lang ] = array_merge( $settings, $offline_languages[ $lang ] );
}
}
// And return our language sets.
return $available_languages;
}
/**
* We can't use wp_get_available_translations() offine.
* This function tries to return something similiar.
*
* @return array List of wordpress language meta data.
*/
private function get_offline_translation_information() {
// Build out the list of languages to use.
$languages = array(
'af' => array( 'english_name' => 'Afrikaans', 'native_name' => 'Afrikaans' ),
'ar' => array( 'english_name' => 'Arabic', 'native_name' => 'العربية' ),
'ary' => array( 'english_name' => 'Moroccan Arabic', 'native_name' => 'العربية المغربية' ),
'as' => array( 'english_name' => 'Assamese', 'native_name' => 'অসমীয়া' ),
'az' => array( 'english_name' => 'Azerbaijani', 'native_name' => 'Azərbaycan dili' ),
'azb' => array( 'english_name' => 'South Azerbaijani', 'native_name' => 'گؤنئی آذربایجان' ),
'bel' => array( 'english_name' => 'Belarusian', 'native_name' => 'Беларуская мова' ),
'bg_BG' => array( 'english_name' => 'Bulgarian', 'native_name' => 'Български' ),
'bn_BD' => array( 'english_name' => 'Bengali', 'native_name' => 'বাংলা' ),
'bo' => array( 'english_name' => 'Tibetan', 'native_name' => 'བོད་ཡིག' ),
'bs_BA' => array( 'english_name' => 'Bosnian', 'native_name' => 'Bosanski' ),
'ca' => array( 'english_name' => 'Catalan', 'native_name' => 'Català' ),
'ceb' => array( 'english_name' => 'Cebuano', 'native_name' => 'Cebuano' ),
'ckb' => array( 'english_name' => 'Kurdish (Sorani)', 'native_name' => 'كوردی' ),
'cs_CZ' => array( 'english_name' => 'Czech', 'native_name' => 'Čeština' ),
'cy' => array( 'english_name' => 'Welsh', 'native_name' => 'Cymraeg' ),
'da_DK' => array( 'english_name' => 'Danish', 'native_name' => 'Dansk' ),
'de_DE_formal' => array( 'english_name' => 'German (Formal)', 'native_name' => 'Deutsch (Sie)' ),
'de_DE' => array( 'english_name' => 'German', 'native_name' => 'Deutsch' ),
'de_CH_informal' => array( 'english_name' => 'German (Switzerland, Informal)', 'native_name' => 'Deutsch (Schweiz, Du)' ),
'de_CH' => array( 'english_name' => 'German (Switzerland)', 'native_name' => 'Deutsch (Schweiz)' ),
'dzo' => array( 'english_name' => 'Dzongkha', 'native_name' => 'རྫོང་ཁ' ),
'el' => array( 'english_name' => 'Greek', 'native_name' => 'Ελληνικά' ),
'en_CA' => array( 'english_name' => 'English (Canada)', 'native_name' => 'English (Canada)' ),
'en_ZA' => array( 'english_name' => 'English (South Africa)', 'native_name' => 'English (South Africa)' ),
'en_AU' => array( 'english_name' => 'English (Australia)', 'native_name' => 'English (Australia)' ),
'en_NZ' => array( 'english_name' => 'English (New Zealand)', 'native_name' => 'English (New Zealand)' ),
'en_GB' => array( 'english_name' => 'English (UK)', 'native_name' => 'English (UK)' ),
'eo' => array( 'english_name' => 'Esperanto', 'native_name' => 'Esperanto' ),
'es_CL' => array( 'english_name' => 'Spanish (Chile)', 'native_name' => 'Español de Chile' ),
'es_AR' => array( 'english_name' => 'Spanish (Argentina)', 'native_name' => 'Español de Argentina' ),
'es_PE' => array( 'english_name' => 'Spanish (Peru)', 'native_name' => 'Español de Perú' ),
'es_MX' => array( 'english_name' => 'Spanish (Mexico)', 'native_name' => 'Español de México' ),
'es_CO' => array( 'english_name' => 'Spanish (Colombia)', 'native_name' => 'Español de Colombia' ),
'es_ES' => array( 'english_name' => 'Spanish (Spain)', 'native_name' => 'Español' ),
'es_VE' => array( 'english_name' => 'Spanish (Venezuela)', 'native_name' => 'Español de Venezuela' ),
'es_GT' => array( 'english_name' => 'Spanish (Guatemala)', 'native_name' => 'Español de Guatemala' ),
'et' => array( 'english_name' => 'Estonian', 'native_name' => 'Eesti' ),
'eu' => array( 'english_name' => 'Basque', 'native_name' => 'Euskara' ),
'fa_IR' => array( 'english_name' => 'Persian', 'native_name' => 'فارسی' ),
'fi' => array( 'english_name' => 'Finnish', 'native_name' => 'Suomi' ),
'fr_BE' => array( 'english_name' => 'French (Belgium)', 'native_name' => 'Français de Belgique' ),
'fr_FR' => array( 'english_name' => 'French (France)', 'native_name' => 'Français' ),
'fr_CA' => array( 'english_name' => 'French (Canada)', 'native_name' => 'Français du Canada' ),
'gd' => array( 'english_name' => 'Scottish Gaelic', 'native_name' => 'Gàidhlig' ),
'gl_ES' => array( 'english_name' => 'Galician', 'native_name' => 'Galego' ),
'gu' => array( 'english_name' => 'Gujarati', 'native_name' => 'ગુજરાતી' ),
'haz' => array( 'english_name' => 'Hazaragi', 'native_name' => 'هزاره گی' ),
'he_IL' => array( 'english_name' => 'Hebrew', 'native_name' => 'עִבְרִית' ),
'hi_IN' => array( 'english_name' => 'Hindi', 'native_name' => 'हिन्दी' ),
'hr' => array( 'english_name' => 'Croatian', 'native_name' => 'Hrvatski' ),
'hu_HU' => array( 'english_name' => 'Hungarian', 'native_name' => 'Magyar' ),
'hy' => array( 'english_name' => 'Armenian', 'native_name' => 'Հայերեն' ),
'id_ID' => array( 'english_name' => 'Indonesian', 'native_name' => 'Bahasa Indonesia' ),
'is_IS' => array( 'english_name' => 'Icelandic', 'native_name' => 'Íslenska' ),
'it_IT' => array( 'english_name' => 'Italian', 'native_name' => 'Italiano' ),
'ja' => array( 'english_name' => 'Japanese', 'native_name' => '日本語' ),
'ka_GE' => array( 'english_name' => 'Georgian', 'native_name' => 'ქართული' ),
'kab' => array( 'english_name' => 'Kabyle', 'native_name' => 'Taqbaylit' ),
'km' => array( 'english_name' => 'Khmer', 'native_name' => 'ភាសាខ្មែរ' ),
'ko_KR' => array( 'english_name' => 'Korean', 'native_name' => '한국어' ),
'lo' => array( 'english_name' => 'Lao', 'native_name' => 'ພາສາລາວ' ),
'lt_LT' => array( 'english_name' => 'Lithuanian', 'native_name' => 'Lietuvių kalba' ),
'lv' => array( 'english_name' => 'Latvian', 'native_name' => 'Latviešu valoda' ),
'mk_MK' => array( 'english_name' => 'Macedonian', 'native_name' => 'Македонски јазик' ),
'ml_IN' => array( 'english_name' => 'Malayalam', 'native_name' => 'മലയാളം' ),
'mn' => array( 'english_name' => 'Mongolian', 'native_name' => 'Монгол' ),
'mr' => array( 'english_name' => 'Marathi', 'native_name' => 'मराठी' ),
'ms_MY' => array( 'english_name' => 'Malay', 'native_name' => 'Bahasa Melayu' ),
'my_MM' => array( 'english_name' => 'Myanmar (Burmese)', 'native_name' => 'ဗမာစာ' ),
'nb_NO' => array( 'english_name' => 'Norwegian (Bokmål)', 'native_name' => 'Norsk bokmål' ),
'ne_NP' => array( 'english_name' => 'Nepali', 'native_name' => 'नेपाली' ),
'nl_BE' => array( 'english_name' => 'Dutch (Belgium)', 'native_name' => 'Nederlands (België)' ),
'nl_NL' => array( 'english_name' => 'Dutch', 'native_name' => 'Nederlands' ),
'nl_NL_formal' => array( 'english_name' => 'Dutch (Formal)', 'native_name' => 'Nederlands (Formeel)' ),
'nn_NO' => array( 'english_name' => 'Norwegian (Nynorsk)', 'native_name' => 'Norsk nynorsk' ),
'oci' => array( 'english_name' => 'Occitan', 'native_name' => 'Occitan' ),
'pa_IN' => array( 'english_name' => 'Punjabi', 'native_name' => 'ਪੰਜਾਬੀ' ),
'pl_PL' => array( 'english_name' => 'Polish', 'native_name' => 'Polski' ),
'ps' => array( 'english_name' => 'Pashto', 'native_name' => 'پښتو' ),
'pt_BR' => array( 'english_name' => 'Portuguese (Brazil)', 'native_name' => 'Português do Brasil' ),
'pt_PT' => array( 'english_name' => 'Portuguese (Portugal)', 'native_name' => 'Português' ),
'rhg' => array( 'english_name' => 'Rohingya', 'native_name' => 'Ruáinga' ),
'ro_RO' => array( 'english_name' => 'Romanian', 'native_name' => 'Română' ),
'ru_RU' => array( 'english_name' => 'Russian', 'native_name' => 'Русский' ),
'sah' => array( 'english_name' => 'Sakha', 'native_name' => 'Сахалыы' ),
'si_LK' => array( 'english_name' => 'Sinhala', 'native_name' => 'සිංහල' ),
'sk_SK' => array( 'english_name' => 'Slovak', 'native_name' => 'Slovenčina' ),
'sl_SI' => array( 'english_name' => 'Slovenian', 'native_name' => 'Slovenščina' ),
'sq' => array( 'english_name' => 'Albanian', 'native_name' => 'Shqip' ),
'sr_RS' => array( 'english_name' => 'Serbian', 'native_name' => 'Српски језик' ),
'sv_SE' => array( 'english_name' => 'Swedish', 'native_name' => 'Svenska' ),
'szl' => array( 'english_name' => 'Silesian', 'native_name' => 'Ślōnskŏ gŏdka' ),
'ta_IN' => array( 'english_name' => 'Tamil', 'native_name' => 'தமிழ்' ),
'tah' => array( 'english_name' => 'Tahitian', 'native_name' => 'Reo Tahiti' ),
'te' => array( 'english_name' => 'Telugu', 'native_name' => 'తెలుగు' ),
'th' => array( 'english_name' => 'Thai', 'native_name' => 'ไทย' ),
'tl' => array( 'english_name' => 'Tagalog', 'native_name' => 'Tagalog' ),
'tr_TR' => array( 'english_name' => 'Turkish', 'native_name' => 'Türkçe' ),
'tt_RU' => array( 'english_name' => 'Tatar', 'native_name' => 'Татар теле' ),
'ug_CN' => array( 'english_name' => 'Uighur', 'native_name' => 'Uyƣurqə' ),
'uk' => array( 'english_name' => 'Ukrainian', 'native_name' => 'Українська' ),
'ur' => array( 'english_name' => 'Urdu', 'native_name' => 'اردو' ),
'uz_UZ' => array( 'english_name' => 'Uzbek', 'native_name' => 'O‘zbekcha' ),
'vi' => array( 'english_name' => 'Vietnamese', 'native_name' => 'Tiếng Việt' ),
'zh_CN' => array( 'english_name' => 'Chinese (China)', 'native_name' => '简体中文' ),
'zh_HK' => array( 'english_name' => 'Chinese (Hong Kong)', 'native_name' => '香港中文版' ),
'zh_TW' => array( 'english_name' => 'Chinese (Taiwan)', 'native_name' => '繁體中文' ),
);
// Allow adding or removing languages.
return apply_filters( 'airplane_mode_offline_languages', $languages );
}
/**
* Return an empty array of items requiring update for both themes and plugins
*
* @param array $items All the items being passed for update.
*
* @return array An empty array, or the original items if not enabled.
*/
public function remove_update_array( $items ) {
return ! $this->enabled() ? $items : array();
}
/**
* Remove the ability to update plugins/themes from single
* site and multisite bulk actions
*
* @param array $actions All the bulk actions.
*
* @return array $actions The remaining actions
*/
public function remove_bulk_actions( $actions ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $actions;
}
// Set an array of items to be removed with optional filter.
if ( false === $remove = apply_filters( 'airplane_mode_bulk_items', array( 'update-selected', 'update', 'upgrade' ) ) ) {
return $actions;
}
// Loop the item array and unset each.
foreach ( $remove as $key ) {
unset( $actions[ $key ] );
}
// Return the remaining.
return $actions;
}
/**
* Remove the tabs on the plugin page to add new items
* since they require the WP connection and will fail.
*
* @param array $nonmenu_tabs All the tabs displayed.
* @return array $nonmenu_tabs The remaining tabs.
*/
public function plugin_add_tabs( $nonmenu_tabs ) {
// Bail if disabled.
if ( ! $this->enabled() ) {
return $nonmenu_tabs;
}
// Set an array of tabs to be removed with optional filter.
if ( false === $remove = apply_filters( 'airplane_mode_bulk_items', array( 'featured', 'popular', 'recommended', 'favorites', 'beta' ) ) ) {
return $nonmenu_tabs;
}
// Loop the item array and unset each.
foreach ( $remove as $key ) {
unset( $nonmenu_tabs[ $key ] );
}
// Return the tabs.
return $nonmenu_tabs;
}
/**
* Increase HTTP request counter by one.
*
* @return void
*/
public function count_http_requests() {
$this->http_count++;
}
/**
* Generate a color avatar because it looks nice.
*
* @param int|object|string $id_or_email A user ID, email address, or comment object.
*
* @return string
*/
public function generate_color_avatar( $id_or_email ) {
// Set the user string we are gonna use for the hash.
// If it's an object, then it's from comments, so parse it out.
$define_user_sr = is_object( $id_or_email ) ? $id_or_email->comment_author_email : $id_or_email;
// Swap out the file for a base64 encoded image generated based on the $id_or_email.
$generate_hash = md5( strtolower( trim( $define_user_sr ) ) );
// Set a color image.
$color_image = imagecreatetruecolor( 1, 1 );
// Set up the RGB base.
$base_rgb_array = sscanf( $generate_hash, '%2x%2x%2x' );
// Now generate the color itself.
$generate_color = imagecolorallocate( $color_image, $base_rgb_array[0], $base_rgb_array[1], $base_rgb_array[2] );
// Set pixels for the image.
imagesetpixel( $color_image, 0, 0, $generate_color );
// Begin generating the image.
$generate_image = fopen( 'php://memory', 'rb+' );
// Create the PNG.
imagepng( $color_image, $generate_image );
// Be Kind.
rewind( $generate_image );
// Finish up.
imagedestroy( $color_image );
// Set the data up.
$set_image_data = 'data:image/png;base64,' . base64_encode( stream_get_contents( $generate_image ) );
// Close the access.
fclose( $generate_image );
// And return the resulting image.
return $set_image_data;
}
// End class.
}
} // End class_exists.
// Only load the new error class if it hasn't already.
if ( ! class_exists( 'Airplane_Mode_WP_Error' ) ) {
/**
* Extend the WP_Error class to include our own.
*/
class Airplane_Mode_WP_Error extends WP_Error {
/**
* Get our error data and return it.
*
* @return string
*/
public function __tostring() {
$data = $this->get_error_data();
return $data['return'];
}
// End class.
}
}
// Instantiate our class.
$Airplane_Mode_Core = Airplane_Mode_Core::getInstance();
================================================
FILE: composer.json
================================================
{
"name": "norcross/airplane-mode",
"description": "Disables external data calls and loading for working on a purely local (i.e. no internet connection) WordPress site",
"type": "wordpress-plugin",
"license": "MIT",
"authors":[
{
"name": "Andrew Norcross",
"email": "andrew@andrewnorcross.com",
"homepage": "https://github.com/norcross"
},
{
"name": "John Blackbourn",
"homepage": "https://github.com/johnbillion"
},
{
"name": "Andy Fragen",
"homepage": "https://github.com/afragen"
},
{
"name": "Mark Jaquith",
"homepage": "https://github.com/markjaquith"
},
{
"name": "Chris Christoff",
"homepage": "https://github.com/chriscct7"
}
],
"require": {
"composer/installers": "^1 || ^2"
}
}
================================================
FILE: inc/wp-cli.php
================================================
<?php
class Airplane_Mode_Command extends WP_CLI_Command {
/**
* Enables airplane mode.
*
* ## EXAMPLES
*
* wp airplane-mode enable
*
* @when after_wp_load
* @subcommand on
* @alias enable
*/
function enable() {
Airplane_Mode_Core::getInstance()->enable();
WP_CLI::success( __( 'Airplane mode was enabled', 'airplane-mode' ) );
}
/**
* Disables airplane mode.
*
* ## EXAMPLES
*
* wp airplane-mode disable
*
* @when after_wp_load
* @subcommand off
* @alias disable
*/
function disable() {
Airplane_Mode_Core::getInstance()->disable();
WP_CLI::success( __( 'Airplane mode was disabled', 'airplane-mode' ) );
}
/**
* Provides the status of airplane mode.
*
* ## EXAMPLES
*
* wp airplane-mode status
*
* @when after_wp_load
*/
function status() {
$on = 'on' === get_site_option( 'airplane-mode' );
WP_CLI::success( $on ? __( 'Airplane mode is enabled', 'airplane-mode' ) : __( 'Airplane mode is disabled', 'airplane-mode' ) );
}
/**
* Purge the transients set from airplane mode.
*
* ## EXAMPLES
*
* wp airplane-mode clean
*
* @when after_wp_load
*/
function clean() {
Airplane_Mode_Core::getInstance()->purge_transients( true );
WP_CLI::success( __( 'Transients have been cleared', 'airplane-mode' ) );
}
}
WP_CLI::add_command( 'airplane-mode', 'Airplane_Mode_Command' );
================================================
FILE: languages/default.po
================================================
msgid ""
msgstr ""
"Project-Id-Version: Airplane Mode\n"
"POT-Creation-Date: 2015-12-07 17:24-0500\n"
"PO-Revision-Date: 2015-12-07 17:25-0500\n"
"Last-Translator: Andrew Norcross <andrew.norcross@gmail.com>\n"
"Language-Team: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.6\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _;__;_e;_n\n"
"X-Poedit-SearchPath-0: .\n"
#: airplane-mode.php:365
#, php-format
msgid "Airplane Mode is enabled. oEmbed blocked for %1$s."
msgstr "Airplane Mode is enabled. oEmbed blocked for %1$s."
#: airplane-mode.php:475
msgid "Airplane Mode is enabled"
msgstr "Airplane Mode is enabled"
#: airplane-mode.php:583
msgid "Airplane Mode is enabled."
msgstr "Airplane Mode is enabled."
#: airplane-mode.php:583
msgid "Airplane Mode is disabled."
msgstr "Airplane Mode is disabled."
#: airplane-mode.php:592
msgid "Active"
msgstr "Active"
#: airplane-mode.php:592
msgid "Inactive"
msgstr "Inactive"
#: airplane-mode.php:609
#, php-format
msgid "There was %s HTTP request."
msgstr "There was %s HTTP request."
================================================
FILE: lib/css/airplane-mode.css
================================================
@font-face {
font-family: "airplanemodeicons";
src:url("../fonts/airplanemodeicons.eot");
src:url("../fonts/airplanemodeicons.eot?#iefix") format("embedded-opentype"),
url("../fonts/airplanemodeicons.woff") format("woff"),
url("../fonts/airplanemodeicons.ttf") format("truetype"),
url("../fonts/airplanemodeicons.svg#airplanemodeicons") format("svg");
font-weight: normal;
font-style: normal;
}
#wp-admin-bar-airplane-mode-toggle .ab-icon {
top: 1px;
}
#wp-admin-bar-airplane-mode-toggle .ab-icon:before {
content: "\e000";
font: normal 18px/1 airplanemodeicons;
}
.airplane-mode-disabled #wp-admin-bar-airplane-mode-toggle .ab-icon:before {
content: "\e001";
}
#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default > #wp-admin-bar-airplane-mode-toggle .ab-icon,
#wpadminbar #wp-admin-bar-airplane-mode-toggle .ab-icon,
#wpadminbar #wp-admin-bar-airplane-mode-toggle .ab-item::before {
margin-right: 0;
}
.airplane-mode-no-qm #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default > #wp-admin-bar-airplane-mode-toggle .ab-icon,
.airplane-mode-no-qm #wpadminbar #wp-admin-bar-airplane-mode-toggle .ab-icon,
.airplane-mode-no-qm #wpadminbar #wp-admin-bar-airplane-mode-toggle .ab-item::before {
margin-right: 6px;
}
/* Set the opacity to mimic comment moderation queue. */
.airplane-mode-disabled #wp-admin-bar-airplane-mode-toggle .ab-label {
/* Theoretically for IE 8 & 9 (more valid) */
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=50); /* IE 5-7 */
/* Modern Browsers */
opacity: 0.5;
}
.airplane-mode-enabled.plugin-install-php.branch-4-6 h1 a.upload-view-toggle,
.airplane-mode-enabled.plugin-install-php h1 a.upload,
.airplane-mode-enabled.plugin-install-php .wp-filter,
.airplane-mode-enabled.theme-install-php .wp-filter,
.airplane-mode-enabled .theme-browser.content-filterable.rendered,
.airplane-mode-enabled.theme-install-php a.browse-themes {
display: none !important;
}
================================================
FILE: readme.txt
================================================
=== Airplane Mode ===
Contributors: norcross, johnbillion, afragen, szepeviktor, chriscct7, markjaquith
Website Link: https://github.com/norcross/airplane-mode
Donate link: https://andrewnorcross.com/donate
Tags: external calls, HTTP
Requires at least: 4.4
Tested up to: 6.7
Stable tag: 0.2.8
License: MIT
License URI: http://norcross.mit-license.org/
Control loading of external files when developing locally
== Description ==
Control loading of external files when developing locally. WP loads certain external files (fonts, gravatar, etc) and makes external HTTP calls. This isn't usually an issue, unless you're working in an evironment without a web connection. This plugin removes / unhooks those actions to reduce load time and avoid errors due to missing files.
Features
* removes external JS and CSS files from loading
* replaces all instances of Gravatar with a local image to remove external call
* removes all HTTP requests
* disables all WP update checks for core, themes, and plugins
* includes toggle in admin bar for quick enable / disable
== Installation ==
This section describes how to install the plugin and get it working.
1. Upload `airplane-mode` to the `/wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Toggle users as needed
If you need offline activation, see [this script](https://gist.github.com/solepixel/e1d03f4dcd1b9e86552b3cc6937325bf) written by [Brian DiChiara](https://github.com/solepixel)
== Frequently Asked Questions ==
= Why do I need this? =
Because you are a jet set developer who needs to work without internet.
== Screenshots ==
== Changelog ==
= 0.2.8 - 2024/12/02
* Confirming `get_plugin_data` or `is_plugin_active` is checked properly. props @swissspidy
= 0.2.7 - 2024/11/12
* Replacing dull monotone avatars with color ones. props @akirk
= 0.2.6 - 2022/10/13
* Remove usage of 'jetpack_development_mode' that's been deprecated. props @crstauf
* Gracefully handle empty values for script and stylesheet URLs. props @johnbillion
= 0.2.5 - 2019/11/15
* Remove usage of method that's been deprecated in WordPress trunk. props @johnbillion
= 0.2.4 - 2017/12/13
* Added localhost bypass for loading CSS and JS files when hot reloading. props @shadyvb
* Added additional hook removals for new automated updates and language packs.
* Removed outdated `create_function` call for PHP 7.2 compatibility. props @geminorum
* General cleanup
= 0.2.3 - 2017/03/05
* Adding option to force transient purge
* Adding `clean` action to WP-CLI functions
= 0.2.2 - 2016/12/07
* Adding WP-CLI support. props @markjaquith
= 0.2.1 - 2016/10/19
* Fix settings page language drowdown when used offline. props @onnimonni
= 0.2.0 - 2016/08/26
* modify CSS loading for front-end, removed loading for login page. props @barryceelen
* fixed WP.org theme API call request to avoid `WP_Error` return. props @onnimonni
= 0.1.9 - 2016/07/25
* Prevent BuddyPress from falling back to Gravatar. props @johnbillion
= 0.1.8 - 2016/07/12
* allow `JETPACK_DEV_DEBUG` constant to take priority over filter. props @kopepasah
* added additional CSS for upcoming 4.6. change to upload tab.
= 0.1.7 - 2016/05/18
* allow local HTTP calls with optional filter. props @johnbillion
* add back index.php link to main dashboard menu item
* bumped minimum WP version requirement to 4.4
= 0.1.6 - 2016/04/25
* minor tweak to include CSS for new icon font
= 0.1.5 - 2016/04/24
* adding custom icon font for display and removing label. props @barryceelen
= 0.1.4 - 2016/02/26
* better setup for blocked external assets. props @johnbillion
= 0.1.3 - 2016/02/22
* modified CSS rules to fix media bulk actions bar from disappearing
* moved `airplane_mode_status_change` action to run before redirect, and now includes the status being run.
= 0.1.2 - 2016/01/09
* added back HTTP count when inactive
* removed HTTP count completely when Query Monitor is active
= 0.1.1 - 2016/01/06
* fixed incorrect nonce check that was breaking toggle
* changed CSS and JS checks to include all themes and plugins as well as core
= 0.1.0 - 2015/12/30
* added `airplane_mode_purge_transients` filter to bypass transient purge
= 0.0.9 - 2015/12/07
* changed from colored circle to actual airplane icon for usability
* fixed dashboard link icon for multisite
* changed to exclude all external stylesheets, not just Open Sans
* added language files for translateable goodness
* general cleanup for WP coding standards
= 0.0.8 - 2015/05/18
* added `class_exists` as now included in DesktopServer and collisions could result
* fixed `if ( ! defined ...` for `AIRMDE_BASE` constant
= 0.0.7 - 2015/04/21 =
* fixed some CSS from hiding plugins page bar
* moved changelog to it's own file
* added `composer.json`
* added contributors to readme
* clarified license (MIT)
= 0.0.6 - 2015/04/02 =
* version bump for GitHub updater
= 0.0.5 - 2015/04/02 =
* fixed bug in update logic that was preventing checks when disabled (but activated). props @johnbillion
= 0.0.4 - 2015/04/02 =
* added multiple checks for all the various theme and plugin update calls. props @chriscct7
* added HTTP counter on a per-page basis. props @szepeviktor
= 0.0.3 - 2015/01/23 =
* added `airplane_mode_status_change` hook for functions to fire on status change
* purge update related transients on disable
* added WordPress formatted readme file
= 0.0.2 - 2015/01/21 =
* added GitHub Updater support
* fixed update capabilities when status is disabled
= 0.0.1 - 2014/06/01 =
* lots of stuff. I wasn't keeping a changelog. I apologize.
== Upgrade Notice ==
= 0.0.1 =
Initial release
gitextract_qj6t8kvq/ ├── .gitattributes ├── .gitignore ├── CHANGES.md ├── LICENSE ├── README.md ├── airplane-mode.php ├── composer.json ├── inc/ │ └── wp-cli.php ├── languages/ │ ├── default.mo │ └── default.po ├── lib/ │ └── css/ │ └── airplane-mode.css └── readme.txt
SYMBOL INDEX (49 symbols across 2 files)
FILE: airplane-mode.php
class Airplane_Mode_Core (line 66) | class Airplane_Mode_Core {
method __construct (line 85) | private function __construct() {
method getInstance (line 248) | public static function getInstance() {
method textdomain (line 261) | public function textdomain() {
method create_setting (line 268) | public function create_setting() {
method remove_setting (line 276) | public function remove_setting() {
method enabled (line 287) | public function enabled() {
method block_style_load (line 313) | public function block_style_load( $source ) {
method block_script_load (line 349) | public function block_script_load( $source ) {
method bypass_asset_block (line 386) | public function bypass_asset_block( $block, $parsed ) {
method block_oembed_html (line 405) | public function block_oembed_html( $html, $url, $attr, $post_ID ) {
method body_class (line 416) | public function body_class( $classes ) {
method admin_body_class (line 437) | public function admin_body_class( $classes ) {
method admin_menu_items (line 456) | public function admin_menu_items() {
method ms_admin_menu_items (line 472) | public function ms_admin_menu_items() {
method replace_gravatar (line 495) | public function replace_gravatar( $avatar, $id_or_email, $size, $defau...
method default_avatar (line 519) | public function default_avatar( $avatar_list ) {
method disable_http_reqs (line 544) | public function disable_http_reqs( $status = false, $args = array(), $...
method toggle_css (line 576) | public function toggle_css() {
method set_mode (line 600) | public function set_mode( $mode = 'on' ) {
method enable (line 622) | public function enable() {
method disable (line 631) | public function disable() {
method toggle_check (line 641) | public function toggle_check() {
method get_redirect (line 678) | protected static function get_redirect() {
method admin_bar_toggle (line 719) | public function admin_bar_toggle( WP_Admin_Bar $wp_admin_bar ) {
method prevent_auto_updates (line 779) | public function prevent_auto_updates( $caps, $cap ) {
method purge_transients (line 798) | public function purge_transients( $force = false ) {
method remove_update_crons (line 819) | public function remove_update_crons() {
method remove_schedule_hook (line 868) | public function remove_schedule_hook() {
method bypass_theme_api_call (line 892) | public function bypass_theme_api_call( $override, $action, $args ) {
method bypass_theme_api_result (line 913) | public function bypass_theme_api_result( $res, $action, $args ) {
method last_checked_core (line 929) | public function last_checked_core() {
method last_checked_themes (line 952) | public function last_checked_themes() {
method last_checked_plugins (line 984) | public function last_checked_plugins() {
method available_translations (line 1024) | public function available_translations( $translations ) {
method get_offline_languages (line 1050) | private function get_offline_languages( $installed_languages ) {
method get_offline_translation_information (line 1095) | private function get_offline_translation_information() {
method remove_update_array (line 1220) | public function remove_update_array( $items ) {
method remove_bulk_actions (line 1232) | public function remove_bulk_actions( $actions ) {
method plugin_add_tabs (line 1260) | public function plugin_add_tabs( $nonmenu_tabs ) {
method count_http_requests (line 1286) | public function count_http_requests() {
method generate_color_avatar (line 1297) | public function generate_color_avatar( $id_or_email ) {
class Airplane_Mode_WP_Error (line 1351) | class Airplane_Mode_WP_Error extends WP_Error {
method __tostring (line 1358) | public function __tostring() {
FILE: inc/wp-cli.php
class Airplane_Mode_Command (line 3) | class Airplane_Mode_Command extends WP_CLI_Command {
method enable (line 16) | function enable() {
method disable (line 32) | function disable() {
method status (line 46) | function status() {
method clean (line 60) | function clean() {
Condensed preview — 12 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (77K chars).
[
{
"path": ".gitattributes",
"chars": 82,
"preview": ".gitattributes export-ignore\n.gitignore export-ignore\ncomposer.json export-ignore\n"
},
{
"path": ".gitignore",
"chars": 240,
"preview": ".htaccess\nwp-content/uploads/\nwp-content/blogs.dir/\nwp-content/upgrade/\nwp-content/backup-db/\nwp-content/advanced-cache."
},
{
"path": "CHANGES.md",
"chars": 4080,
"preview": "#### Version 0.2.8 - 2024/12/02\n* Confirming `get_plugin_data` or `is_plugin_active` is checked properly. props @swisssp"
},
{
"path": "LICENSE",
"chars": 1074,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Norcross\n\nPermission is hereby granted, free of charge, to any person obtainin"
},
{
"path": "README.md",
"chars": 1464,
"preview": "Airplane Mode\n========================\n\n## Contributors\n* [Andrew Norcross](https://github.com/norcross)\n* [John Blackbo"
},
{
"path": "airplane-mode.php",
"chars": 52399,
"preview": "<?php\n/**\n * Plugin Name: Airplane Mode\n * Plugin URI: https://github.com/norcross/airplane-mode\n * Description: Control"
},
{
"path": "composer.json",
"chars": 940,
"preview": "{\n \"name\": \"norcross/airplane-mode\",\n \"description\": \"Disables external data calls and loading for working on a pu"
},
{
"path": "inc/wp-cli.php",
"chars": 1391,
"preview": "<?php\n\nclass Airplane_Mode_Command extends WP_CLI_Command {\n\n\t/**\n\t * Enables airplane mode.\n\t *\n\t * ## EXAMPLES\n\t *\n\t *"
},
{
"path": "languages/default.po",
"chars": 1230,
"preview": "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: Airplane Mode\\n\"\n\"POT-Creation-Date: 2015-12-07 17:24-0500\\n\"\n\"PO-Revision-Date:"
},
{
"path": "lib/css/airplane-mode.css",
"chars": 2130,
"preview": "@font-face {\n font-family: \"airplanemodeicons\";\n src:url(\"../fonts/airplanemodeicons.eot\");\n src:url(\"../fonts/airpla"
},
{
"path": "readme.txt",
"chars": 5619,
"preview": "=== Airplane Mode ===\nContributors: norcross, johnbillion, afragen, szepeviktor, chriscct7, markjaquith\nWebsite Link: ht"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the norcross/airplane-mode GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 12 files (69.0 KB), approximately 19.7k tokens, and a symbol index with 49 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.