GithubHelp home page GithubHelp logo

norcross / airplane-mode Goto Github PK

View Code? Open in Web Editor NEW
466.0 28.0 64.0 284 KB

Disables external data calls and loading for working on a purely local (i.e. no internet connection) WordPress site

License: MIT License

CSS 3.89% PHP 96.11%
wordpress offline-mode airplane-mode wp-cli

airplane-mode's Introduction

Airplane Mode

Contributors

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.

Notes

If you need offline activation, see this script written by Brian DiChiara

Roadmap

  • fine tune HTTP request removal
  • find other calls from core
  • add other requests from popular plugins

Pull requests are very much welcome and encouraged.

airplane-mode's People

Contributors

afragen avatar barryceelen avatar chriscct7 avatar crstauf avatar georgestephanis avatar grappler avatar johnbillion avatar kopepasah avatar lucatume avatar markjaquith avatar michaelbeil avatar morganestes avatar norcross avatar onnimonni avatar orkan avatar szepeviktor avatar westonruter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

airplane-mode's Issues

disable from listed oembeds

Hey Guys!
+1 for this plugin.

Can you add an option to disable from listed oembeds in wp-core (eg spotify, soundcloud, youtube, google maps, etc).

Thanks!

Inline CSS

Please consider wp_add_inline_style( 'wp-admin', $style_string );

Don't clear transients when toggling airplane mode

The purge_transients() method clears the transients for core updates, plugin updates, and theme updates every time the airplane mode status changes.

This means that every time I need to temporarily disable airplane mode, everything is slowed down because the update checks always fire because the transients are always empty.

Clearing these transients serves no purpose, so I think this code should be removed. Thoughts?

problem since merge #30

Hey!
Since merge #30 I can not access updates for WP, Plugins and themes. Airplane-mode is disabled.
I have to completely disable the plugin to have under installed plugins to access updates. Is this intended do?

Improve script blocking

Instead of setting the src to an error object on the script loader tag (where a string is expected), I propose

  • setting the src to an empty string
  • adding the error as data on the _WP_Dependency object

I'd be happy to PR this.

Plugin Breaks Plugin & Theme Repository Search

I'm really excited about this plugin! I can't wait to stop Gravatar requests on my localsites.

Right now, it seems the plugin blocks/breaks searches from the dashboard of the Plugin and Theme Repositories. Since these are explicitly triggered by admin action rather than passively loaded in the background, I think it makes sense to let those features continue working.

What is the difference?

define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.github.com' );

Could you point out what the difference is between these and your plugin?

This plugin could hide/deny add new theme button

Hey!

I'm using whoops errors in my local development. Sometimes the local WordPress can't reach the internet and I'll get warning like this one:

screen shot 2016-08-25 at 10 19 12 pm

I want to have these warnings displayed in the frontend so that I can find problems in my code asap. Your plugin seems to solve most of these issues but not this one:

What I was trying to do:
When I go to themes folder I can see the Add new button.

install-theme-button

If I click it all the hooks from this plugin and WordPress create a situation where I'll get error like this one:
screen shot 2016-08-25 at 10 11 10 pm

What I wanted to achieve:

Add new button begone:
add-new-button-begone

Add console notice about blocked scripts

It would be nice to have a console notice whether a script/style has been blocked. I spent an hour debugging before I noticed I had airplane mode on...

Thoughts?

check for all Google fonts

currently Open Sans is checked for and removed due to its inclusion in core. Should check for all Google fonts (perhaps even all external URLs)

Ability to allow certain requests

Is there a way to allow requests from a specific domains/URLs/IPs?

I want to be able to allow access to a few specific plugins and IPs without having to turn off airplane mode.

Breaks Dashboard admin menu on Multisite

When Airplane Mode is enabled on Multisite, the Dashboard admin menu points to my-sites.php instead of index.php.

Haven't looked into why this is happening yet.

Built in ways to disable external HTTP requests in WordPress

Great plugin but I am wondering why you did not use the pre_http_request filter like so:

add_filter( 'pre_http_request', '__return_true', 100 );

That should disable all requests via a plugin.
Or the more manual way of editing wp-config.php with:

define('WP_HTTP_BLOCK_EXTERNAL', true);

Changes in WP 4.6

Hello :) Just wanted to ping you and inform a small is going to land on WP 4.6. Specifically, in the Add Plugin screen, the ".upload" button will behave a bit differently and will have a new CSS class. So if you want to still hide it completely you should use the new CSS class. upload-view-toggle

WP CLI support

It would be useful to be able to toggle Airplane mode from WP CLI. Yeah, you could just set the option, but having an official command would be easier, and insulate them from changes made to the option in the future.

[Deleted second part about requests being disabled silently on the command line. That site was running an old version of the plugin that didn't have 7fbf84c]

Don't block local requests

Airplane Mode blocks all outgoing HTTP requests. It shouldn't block outgoing requests to the current host (for example, requests to example.dev/wp-cron.php when you're using example.dev) because this host must be accessible due to the fact the user is using the site over this host.

I'll knock up a patch.

Add Plugins

I am very sorry to report that the Add Plugins page is cleaned even when Airplane-Mode is disabled.

Load Open Sans locally

Currently, the Open Sans font loader is removed entirely. Would it be better to bundle the Open Sans font files with this plugin, and load them locally? This way Open Sans would still be available despite not being loaded from a remote source.

Stop displaying toggle URLs

When toggling, your URL changes to some gnarly stuff. That should be stripped out so the user doesn't have to see it.

Favored option: use admin-post.php and redirect back.

Less good: keep it how it is, and use JS to remove the junk from the URL.

Updates no longer display while Airplane Mode activated and off

Updates are hidden while Airplane Mode is activated and off. If I deactivate Airplane Mode the updates now show.

I still have to dig further. Below are some screenshots to explain.

screenshot_02
Airplane Mode deactivated.

screenshot_03
Airplane Mode activated and on

screenshot_04
Airplane Mode activated and off

Integration with WP Debug Bar

Currently the warning is shown:

WARNING: wp-includes/update.php:457 - An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)
require_once('wp-admin/admin.php'), do_action('load-themes.php'), call_user_func_array, wp_update_themes, trigger_error

Would be ideal to have this integrated so this doesn't show. As currently if there are other warnings, they could go unnoticed because the Debug will always be lit up as red. Will look into integration. Perhaps as an extension.

Screenshot: https://www.dropbox.com/s/zwg5wowc1ui9ap7/Screenshot%202014-12-10%2013.18.07.png?dl=0

/wp-admin/options-general.php makes http request to translation api

Problem
I found that the settings page /wp-admin/options-general.php makes http request to translation api when the site is also installed while not having a internet connection.

Steps to reproduce

Disable internet connection
Install WordPress locally.
Enable airplane-mode plugin.

Click into the settings page:
airplane-mode-admin

Get error because the site doesn't have connection
settings-page-translation-api-http-error

I noticed that the wp-admin/options-general.php:323 is calling the wp_get_available_translations() function which calls the api.

Solution 1:

I tried to fix this by adding:

<?php
add_filter( 'site_transient_available_translations', '__return_empty_array'  );

But this wasn't really satisfying because my language list started to look like this one:

( I have only Finnish translations available locally )
screen shot 2016-08-27 at 3 40 15 pm

Solution 2:

I created a PR #87 which makes the translation dropdown to look normal:

( It shows the native version of locally available language instead of iso code )
screen shot 2016-08-27 at 3 40 32 pm

Consider releasing to Plugin Directory

It would be convenient to have this plugin available through the normal WordPress plugin directory, so that it could be trivially installed with WP-CLI, installed via composer using wpackagist, or consumed by any number of other tools which are designed to key off of plugin name slugs within the directory.

Disable for WP_CLI requests

Opening this issue for consideration, but it might be cool to disable airplane mode for WP_CLI requests. (In particular I was trying to update plugins, and it wasn't working, until I had that "DOH" moment)

PHP 7.2 Deprecated

PHP Deprecated: Function create_function() is deprecated in \wp-content\plugins\airplane-mode\airplane-mode.php on line 789

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.