PHP Класс Airplane_Mode_Core

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$instance Static property to hold our singleton instance.

Открытые методы

Метод Описание
admin_bar_toggle ( WP_Admin_Bar $wp_admin_bar ) : void Add our quick toggle to the admin bar to enable / disable
admin_body_class ( string $classes ) : string Add body class to admin pages based on plugin status.
admin_menu_items ( ) : null Remove menu items for updates from a standard WP install.
available_translations ( mixed $translations ) : array Filter for languages list transient. Returns locally available translations to avoid request into wp.org translation API.
block_oembed_html ( string $html, string $url, array $attr, integer $post_ID ) : string Block oEmbeds from displaying.
block_script_load ( string $source ) : string Check the URL of a JS file and remove any that are not on the local URL.
block_style_load ( string $source ) : string Check the URL of a stylesheet and remove any that are not on the local URL.
body_class ( array $classes ) : array Add body class to front-end pages and login based on plugin status.
bypass_theme_api_call ( false | object | array $override, string $action, object $args ) : boolean Override the API call made for pulling themes from the .org repo.
bypass_theme_api_result ( array | object | WP_Error $res, string $action, object $args ) : boolean Hijack the expected themes API result.
count_http_requests ( ) : void Increase HTTP request counter by one.
create_setting ( ) Set our initial airplane mode setting to 'on' on activation.
default_avatar ( string $avatar_list ) : string Remove avatar images from the default avatar list
disable_http_reqs ( boolean | array | WP_Error $status = false, array $args = [], string $url = '' ) : boolean | array | WP_Error Disable all the HTTP requests being made with the action happening before the status check so others can allow certain items as desired.
enabled ( ) : boolean Helper function to check the current status.
getInstance ( ) If an instance exists, this returns it. If not, it creates one and returns it.
last_checked_core ( ) : object Always send back that the latest version of WordPress is the one we're running
last_checked_plugins ( ) : object Always send back that the latest version of our plugins are the one we're running
last_checked_themes ( ) : object Always send back that the latest version of our theme is the one we're running
ms_admin_menu_items ( ) : null Remove menu items for updates from a multisite instance.
plugin_add_tabs ( array $nonmenu_tabs ) : array Remove the tabs on the plugin page to add new items since they require the WP connection and will fail.
prevent_auto_updates ( array $caps, string $cap ) : array Filter a user's meta capabilities to prevent auto-updates from being attempted.
purge_transients ( ) : void Check the new status after airplane mode has been enabled or disabled and purge related transients
remove_bulk_actions ( array $actions ) : array Remove the ability to update plugins/themes from single site and multisite bulk actions
remove_schedule_hook ( ) : null Remove all the various schedule hooks for themes, plugins, etc.
remove_setting ( ) Remove our setting on plugin deactivation.
remove_update_array ( array $items ) : array Return an empty array of items requiring update for both themes and plugins
remove_update_crons ( ) : null Remove all the various places WP does the update checks. As you can see there are a lot of them.
replace_gravatar ( string $avatar, integer | object | string $id_or_email, integer $size, string $default, string $alt ) : string Replace all instances of gravatar with a local image file to remove the call to remote service.
textdomain ( ) : void Load our textdomain for localization.
toggle_check ( ) : void Check the user action from the toggle switch to set the option to 'on' or 'off'.
toggle_css ( ) Load our small CSS file for the toggle switch.

Защищенные методы

Метод Описание
get_redirect ( ) : string Fetch the URL to redirect to after toggling Airplane Mode.

Приватные методы

Метод Описание
__construct ( ) This is our constructor. There are many like it, but this one is mine.
get_offline_languages ( array $installed_languages ) : array Returns list of languages installed locally with full mimicked meta data.
get_offline_translation_information ( ) : array We can't use wp_get_available_translations() offine.

Описание методов

admin_bar_toggle() публичный Метод

Add our quick toggle to the admin bar to enable / disable
public admin_bar_toggle ( WP_Admin_Bar $wp_admin_bar ) : void
$wp_admin_bar WP_Admin_Bar The admin bar object.
Результат void if current user can't manage options and we bail early.

admin_body_class() публичный Метод

Add body class to admin pages based on plugin status.
public admin_body_class ( string $classes ) : string
$classes string The existing space-separated list of CSS classes.
Результат string $classes The updated space-separated list of CSS classes.

admin_menu_items() публичный Метод

Remove menu items for updates from a standard WP install.
public admin_menu_items ( ) : null
Результат null

available_translations() публичный Метод

Filter for languages list transient. Returns locally available translations to avoid request into wp.org translation API.
public available_translations ( mixed $translations ) : array
$translations mixed Translation data returned from transient API.
Результат array List of available languages.

block_oembed_html() публичный Метод

Block oEmbeds from displaying.
public block_oembed_html ( string $html, string $url, array $attr, integer $post_ID ) : string
$html string The embed HTML.
$url string The attempted embed URL.
$attr array An array of shortcode attributes.
$post_ID integer Post ID.
Результат string

block_script_load() публичный Метод

Check the URL of a JS file and remove any that are not on the local URL.
public block_script_load ( string $source ) : string
$source string The source URL of the JS file.
Результат string $source The same URL, or null.

block_style_load() публичный Метод

Check the URL of a stylesheet and remove any that are not on the local URL.
public block_style_load ( string $source ) : string
$source string The source URL of the CSS sheet.
Результат string $source The same URL, or null.

body_class() публичный Метод

Add body class to front-end pages and login based on plugin status.
public body_class ( array $classes ) : array
$classes array The existing array of body classes.
Результат array $classes The updated array of body classes.

bypass_theme_api_call() публичный Метод

Override the API call made for pulling themes from the .org repo.
public bypass_theme_api_call ( false | object | array $override, string $action, object $args ) : boolean
$override false | object | array Whether to override the WordPress.org Themes API. Default false.
$action string Requested action. Likely values are 'theme_information', 'feature_list', or 'query_themes'.
$args object Arguments used to query for installer pages from the Themes API.
Результат boolean True if enabled, otherwise the existng value.

bypass_theme_api_result() публичный Метод

Hijack the expected themes API result.
public bypass_theme_api_result ( array | object | WP_Error $res, string $action, object $args ) : boolean
$res array | object | WP_Error WordPress.org Themes API response.
$action string Requested action. Likely values are 'theme_information', 'feature_list', or 'query_themes'.
$args object Arguments used to query for installer pages from the WordPress.org Themes API.
Результат boolean An empty array if enabled, otherwise the existng result.

count_http_requests() публичный Метод

Increase HTTP request counter by one.
public count_http_requests ( ) : void
Результат void

create_setting() публичный Метод

Set our initial airplane mode setting to 'on' on activation.
public create_setting ( )

default_avatar() публичный Метод

Remove avatar images from the default avatar list
public default_avatar ( string $avatar_list ) : string
$avatar_list string List of default avatars.
Результат string Updated list with images removed

disable_http_reqs() публичный Метод

Disable all the HTTP requests being made with the action happening before the status check so others can allow certain items as desired.
public disable_http_reqs ( boolean | array | WP_Error $status = false, array $args = [], string $url = '' ) : boolean | array | WP_Error
$status boolean | array | WP_Error Whether to preempt an HTTP request return. Default false.
$args array HTTP request arguments.
$url string The request URL.
Результат boolean | array | WP_Error A WP_Error object if Airplane Mode is enabled. Original $status if not.

enabled() публичный Метод

Helper function to check the current status.
public enabled ( ) : boolean
Результат boolean True if status is 'on'; false if not.

getInstance() публичный статический Метод

If an instance exists, this returns it. If not, it creates one and returns it.
public static getInstance ( )

get_redirect() защищенный статический Метод

Fetch the URL to redirect to after toggling Airplane Mode.
protected static get_redirect ( ) : string
Результат string The URL to redirect to.

last_checked_core() публичный Метод

Always send back that the latest version of WordPress is the one we're running
public last_checked_core ( ) : object
Результат object the modified output with our information

last_checked_plugins() публичный Метод

Always send back that the latest version of our plugins are the one we're running
public last_checked_plugins ( ) : object
Результат object the modified output with our information

last_checked_themes() публичный Метод

Always send back that the latest version of our theme is the one we're running
public last_checked_themes ( ) : object
Результат object the modified output with our information

ms_admin_menu_items() публичный Метод

Remove menu items for updates from a multisite instance.
public ms_admin_menu_items ( ) : null
Результат null

plugin_add_tabs() публичный Метод

Remove the tabs on the plugin page to add new items since they require the WP connection and will fail.
public plugin_add_tabs ( array $nonmenu_tabs ) : array
$nonmenu_tabs array All the tabs displayed.
Результат array $nonmenu_tabs The remaining tabs.

prevent_auto_updates() публичный Метод

Filter a user's meta capabilities to prevent auto-updates from being attempted.
public prevent_auto_updates ( array $caps, string $cap ) : array
$caps array Returns the user's actual capabilities.
$cap string Capability name.
Результат array The user's filtered capabilities.

purge_transients() публичный Метод

Check the new status after airplane mode has been enabled or disabled and purge related transients
public purge_transients ( ) : void
Результат void

remove_bulk_actions() публичный Метод

Remove the ability to update plugins/themes from single site and multisite bulk actions
public remove_bulk_actions ( array $actions ) : array
$actions array All the bulk actions.
Результат array $actions The remaining actions

remove_schedule_hook() публичный Метод

Remove all the various schedule hooks for themes, plugins, etc.
public remove_schedule_hook ( ) : null
Результат null

remove_setting() публичный Метод

Remove our setting on plugin deactivation.
public remove_setting ( )

remove_update_array() публичный Метод

Return an empty array of items requiring update for both themes and plugins
public remove_update_array ( array $items ) : array
$items array All the items being passed for update.
Результат array An empty array, or the original items if not enabled.

remove_update_crons() публичный Метод

Remove all the various places WP does the update checks. As you can see there are a lot of them.
public remove_update_crons ( ) : null
Результат null

replace_gravatar() публичный Метод

Replace all instances of gravatar with a local image file to remove the call to remote service.
public replace_gravatar ( string $avatar, integer | object | string $id_or_email, integer $size, string $default, string $alt ) : string
$avatar string Image tag for the user's avatar.
$id_or_email integer | object | string A user ID, email address, or comment object.
$size integer Square avatar width and height in pixels to retrieve.
$default string URL to a default image to use if no avatar is available.
$alt string Alternative text to use in the avatar image tag.
Результат string `` tag for the user's avatar.

textdomain() публичный Метод

Load our textdomain for localization.
public textdomain ( ) : void
Результат void

toggle_check() публичный Метод

Check the user action from the toggle switch to set the option to 'on' or 'off'.
public toggle_check ( ) : void
Результат void if any of the sanity checks fail and we bail early.

toggle_css() публичный Метод

Load our small CSS file for the toggle switch.
public toggle_css ( )

Описание свойств

$instance статическое публичное свойство

Static property to hold our singleton instance.
static public $instance