PHP 클래스 Airplane_Mode_Core

파일 보기 프로젝트 열기: norcross/airplane-mode 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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