PHP Class Jetpack, jetpack

See also: Jetpack_Options::get_option_names() jetpack_register (string) Temporary verification secrets. jetpack_activated (int) 1: the plugin was activated normally 2: the plugin was activated on this site because of a network-wide activation 3: the plugin was auto-installed 4: the plugin was manually disconnected (but is still installed) jetpack_active_modules (array) Array of active module slugs. jetpack_do_activate (bool) Flag for "activating" the plugin on sites where the activation hook never fired (auto-installs)
Show file Open project: automattic/jetpack Class Usage Examples

Public Properties

Property Type Description
$HTTP_RAW_POST_DATA
$capability_translations
$concatenated_style_handles The handles of styles that are concatenated into jetpack.css
$error string Error to display in admin_notice
$instance Jetpack Holds the singleton instance of this class
$json_api_authorization_request Verified data for JSON authorization request
$message string Message to display in admin_notice
$plugins_to_deactivate
$privacy_checks string Modules that need more privacy description.
$stats array Stats to record once the page loads
$sync Jetpack_Sync object
$xmlrpc_server

Public Methods

Method Description
__destruct ( ) If there are any stats that need to be pushed, but haven't been, push them now.
absolutize_css_urls ( $css, $css_file_url ) : mixed | string Converts any url in a stylesheet, to the correct absolute url.
activate_default_modules ( $min_version = false, $max_version = false, $other_modules = [], $redirect = true )
activate_manage ( )
activate_module ( $module, $exit = true, $redirect = true )
activate_module_actions ( $module )
activate_new_modules ( $redirect = false )
active_plan_supports ( $feature ) : boolean Determine whether the active plan supports a particular feature
add_jetpack_pagestyles ( $admin_body_class = '' )
add_nonce ( $timestamp, $nonce )
add_remote_request_handlers ( )
add_token_to_login_redirect_json_api_authorization ( $redirect_to, $original_redirect_to, $user ) Add the Access Code details to the public-api.wordpress.com redirect
admin_banner_styles ( )
admin_body_class ( $admin_body_class = '' )
admin_head ( )
admin_help ( ) : false Add help to the Jetpack page
admin_init ( ) * Admin Pages
admin_jetpack_manage_notice ( ) : null This is the first banner It should be visible only to user that can update the option Are not connected
admin_menu_css ( )
admin_menu_order ( )
admin_notices ( )
admin_page_load ( ) Handles the page load events for the Jetpack admin page
admin_screen_configure_module ( $module_id )
admin_url ( $args = null )
ajax_recheck_ssl ( )
alert_auto_ssl_fail ( ) * Displays an admin_notice, alerting the user to their JETPACK_CLIENT__HTTPS constant being 'AUTO' but SSL isn't working.
allow_wpcom_public_api_domain ( $domains ) Add public-api.wordpress.com to the safe redirect whitelist - only added when someone allows API access
api_url ( $relative_url ) : string Returns the requested Jetpack API URL
authenticate_jetpack ( $user, $username, $password ) Authenticates XML-RPC and other requests from the Jetpack Server
bail_on_activation ( $message, $deactivate = true ) * Installation
build_connect_url ( boolean $raw = false, boolean | string $redirect = false, boolean | string $from = false ) : string Builds a URL to the Jetpack connection auth page
build_raw_urls ( $url ) * Strip http:// or https:// from a url, replaces forward slash with ::, so we can bring them directly to their site in calypso.
build_reconnect_url ( $raw = false )
build_stats_url ( $args ) : string Builds the stats url.
can_display_jetpack_manage_notice ( ) : (bool) Determines whether to show the notice of not true = display notice
catch_errors ( boolean $catch ) Catches PHP errors. Must be used in conjunction with output buffering.
catch_errors_on_shutdown ( ) Saves any generated PHP errors in ::state( 'php_errors', {errors} )
check_identity_crisis ( ) : array | boolean Checks if the site is currently in an identity crisis.
check_open_graph ( ) : null Check if Jetpack's Open Graph tags should be used.
check_privacy ( $file )
check_rest_api_compat ( ) : null Check if Jetpack's REST API compat file should be included
check_twitter_tags ( ) : null Check if Jetpack's Twitter tags should be used.
clean_nonces ( $all = false )
concat_remove_style_loader_tag ( $tag, $handle )
create_nonce ( $name ) Stores two secrets and a timestamp so WordPress.com can make a request back and verify an action Does some extra verification so urls (such as those to public-api, register, etc) can't just be crafted $name must be a registered option name.
current_user_is_connection_owner ( )
dashboard_widget ( )
dashboard_widget_connect_to_wpcom ( )
dashboard_widget_footer ( )
deactivate_module ( $module )
debugger_page ( )
delete_active_modules ( )
delete_option ( string | array $names ) Deletes the given option. May be passed multiple option names as an array.
deprecated_hooks ( ) Throws warnings for deprecated hooks to be removed from Jetpack
devicepx ( ) Device Pixels support This improves the resolution of gravatars and wordpress.com uploads on hi-res and zoomed browsers.
disconnect ( $update_activated_state = true ) Disconnects from the Jetpack servers.
dismiss_jetpack_notice ( )
display_activate_module_link ( string $module_id ) : null Display link to activate the module to see the settings screen.
dns_prefetch ( mixed $new_urls = null ) Stores and prints out domains to prefetch for page speed optimization.
do_server_side_stat ( $args ) : boolean Runs stats code for a one-off, server-side.
do_stats ( $method = '' ) Load stats pixels. $group is auto-prefixed with "x_jetpack-"
do_version_bump ( (string) $version, (string) $old_version ) : null Runs before bumping version numbers up to a new version
enable_module_configurable ( $module )
extra_oembed_providers ( ) Add any extra oEmbed providers that we know about and use on wpcom for feature parity.
featured_images_enabled ( ) : string Determines whether the current theme supports featured images or not.
file_system_write_access ( ) : string Returns true if the site has file write access false otherwise.
filter_default_modules ( array $modules ) : array Checks activated plugins during auto-activation to determine if any of those plugins are in the list with a corresponding module that is not compatible with the plugin. The module will not be allowed to auto-activate.
fix_url_for_bad_hosts ( $url ) Some hosts disable the OpenSSL extension and so cannot make outgoing HTTPS requsets
generate_secrets ( $action, $exp = 600 ) : array Creates two secret tokens and the end of life timestamp for them.
get_active_modules ( ) Get a list of activated modules as an array of module slugs.
get_active_plan ( ) : array Get the plan that this Jetpack site is currently using
get_active_plugins ( ) Gets all plugins currently active in values, regardless of whether they're traditionally activated or network activated.
get_additional_stat_data ( $prefix = '' ) Get additional stat data to sync to WPCOM
get_available_modules ( $min_version = false, $max_version = false ) List available Jetpack modules. Simply lists .php files in /modules/.
get_avatar_url ( integer | string | object $id_or_email, integer $size = 96, string $default = '', boolean $force_display = false ) : array Centralize the function here until it gets added to core.
get_cloud_site_options ( string | array $option_names ) : array Pings the WordPress.com Mirror Site for the specified options.
get_connected_user_data ( $user_id = null ) Get the wpcom user data of the current|specified connected user.
get_connected_user_email ( $user_id = null ) Get the wpcom email of the current|specified connected user.
get_content_width ( ) Get $content_width, but with a twist filter.
get_default_modules ( $min_version = false, $max_version = false ) Default modules loaded on activation.
get_file_data ( $file, $headers ) Like core's get_file_data implementation, but caches the result.
get_jetpack_options_for_reset ( ) * This method is used to organize all options that can be reset without disconnecting Jetpack.
get_jp_emblem ( ) : string Return string containing the Jetpack logo.
get_locale ( ) : string | boolean Get the locale.
get_log ( $event = false, $num = false ) : array Get the internal event log.
get_master_user_email ( ) Get the wpcom email of the master user.
get_module ( $module ) Load module data from module file. Headers differ from WordPress plugin headers to avoid them being identified as standalone plugins on the WordPress plugins page.
get_module_path ( $slug ) Generate a module's path from its slug.
get_module_slug ( $file ) Extract a module's slug from its full path.
get_option ( string $name, mixed $default = false ) Returns the requested option. Looks in jetpack_options or jetpack_$name as appropriate.
get_option_names ( $type = 'compact' ) * Jetpack Options API
get_other_linked_admins ( ) : mixed Checks to see if there are any other users available to become primary Users must both: - Be linked to wpcom - Be an admin
get_parsed_plugin_data ( ) : array Gets and parses additional plugin data to send with the heartbeat data
get_parsed_theme_data ( ) : array Gets and parses theme data to send with the heartbeat data
get_remote_query_timeout_limit ( ) : integer Builds the timeout limit for queries talking with the wpcom servers.
get_stat_data ( $encode = true, $extended = true ) Return stat data for WPCOM sync
get_sync_error_idc_option ( array $response = [] ) : array Gets the value that is to be saved in the jetpack_sync_error_idc option.
get_translated_modules ( array $modules ) : string | void Return module name translation. Uses matching string created in modules/module-headings.php.
get_update_details ( )
get_updates ( ) : array jetpack_updates is saved in the following schema:
get_user_option_meta_box_order_dashboard ( $sorted ) : mixed
glob_php ( string $absolute_path ) : array Returns an array of all PHP files in the specified absolute path.
guess_locale_from_lang ( string $lang ) : string | boolean Guess locale from language code.
handle_deprecated_modules ( array $modules ) : array Checks activated modules during auto-activation to determine if any of those modules are being deprecated. If so, close them out, and add any replacement modules.
implode_frontend_css ( $travis_test = false ) This methods removes all of the registered css files on the front end from Jetpack in favor of using a single file. In effect "imploding" all the files into one file.
init ( ) Singleton
intercept_plugin_error_scrape ( $action, $result )
intercept_plugin_error_scrape_init ( )
is_active ( ) Is Jetpack active?
is_development_mode ( ) Is Jetpack in development (offline) mode?
is_development_version ( ) Whether Jetpack's version maps to a public release, or a development version.
is_main_network_option ( boolean $option ) : boolean Return whether we are dealing with a multi network setup or not.
is_module ( $module )
is_module_active ( string $module ) : boolean Check whether or not a Jetpack module is active.
is_multi_network ( ) : boolean Implemented since there is no core is multi network function Right now there is no way to tell if we which network is the dominant network on the system
is_multisite ( string $option ) : boolean Return true if we are with multi-site or multi-network false if we are dealing with single site.
is_plugin_active ( $plugin = 'jetpack/jetpack.php' ) Checks whether a specific plugin is active.
is_single_user_site ( ) : boolean Get back if the current site is single user site.
is_staging_site ( ) : boolean Checks whether the home and siteurl specifically are whitelisted Written so that we don't have re-check $key and $value params every time we want to check if this site is whitelisted, for example in footer.php
is_user_connected ( $user_id = false ) Is a given user (or the current user if none is specified) linked to a WordPress.com user?
is_version_controlled ( ) : string Finds out if a site is using a version control system.
jetpack_admin_ajax_tracks_callback ( )
jetpack_check_heartbeat_data ( ) * Check the heartbeat data
jetpack_custom_caps ( $caps, $cap, $user_id, $args )
jetpack_getOptions ( $args )
jetpack_icon_user_connected ( $columns ) * Adds a "blank" column in the user admin table to display indication of user connection.
jetpack_jitm_ajax_callback ( ) The callback for the JITM ajax requests.
jetpack_main_network_site_option ( boolean $option ) : string Return the network_site_url so that .com knows what network this site is a part of.
jetpack_menu_order ( $menu_order )
jetpack_show_user_connected_icon ( $val, $col, $user_id ) * Show Jetpack icon if the user is linked.
jetpack_user_col_style ( ) * Style the Jetpack user column
jumpstart_has_updated_module_option ( string $option_name = '' ) : boolean Check if an option of a Jetpack module has been updated.
load_modules ( ) Loads the currently active modules.
load_view ( string $template, array $data = [] ) : boolean Loads a view file from the views
load_xml_rpc_client ( ) Loads the Jetpack XML-RPC client
log ( $code, $data = null ) Tracking an internal event log. Try not to put too much chaff in here.
log_settings_change ( $option, $old_value, $value ) Log modification of important settings.
login_form_json_api_authorization ( ) Handles the login action for Authorizing the JSON API
login_message_json_api_authorization ( $message )
manage_activate_screen ( )
maybe_clear_other_linked_admins_transient ( integer $user_id, string $role, array $old_roles = null ) If a user has been promoted to or demoted from admin, we need to clear the jetpack_other_linked_admins transient.
maybe_inline_style ( string $tag, string $handle ) : string Maybe inlines a stylesheet.
maybe_min_asset ( $url, $path, $plugin ) Maybe Use a .min.css stylesheet, maybe not.
maybe_set_version_option ( ) : bool: If the db version is showing something other that what we've got now, bump it to current.
module_configuration_activation_screen ( $module, $method )
module_configuration_head ( $module, $method )
module_configuration_load ( $module, $method )
module_configuration_screen ( $module, $method )
module_configuration_url ( $module )
network_add_new_users ( $option = null ) : boolian Does the network allow admins to add new users.
network_allow_new_registrations ( $option = null ) : string Does the network allow new user and site registrations.
network_enable_administration_menus ( $option = null ) : array Lets us know if a site allows admins to manage the network.
network_max_upload_file_size ( $option = null ) : number Maximum file upload size set by the network.
network_name ( $option = null ) Network Name.
network_site_upload_space ( $option = null ) : number File upload psace left per site in MB.
network_upload_file_types ( $option = null ) : string Network allowed file types.
nonce_url_no_esc ( $actionurl, $action, $name = '_wpnonce' )
normalize_url_protocol_agnostic ( string $url ) : WP_Error | string Normalizes a url by doing three things: - Strips protocol - Strips www - Adds a trailing slash
opt_in_jetpack_manage_notice ( )
opt_in_jetpack_manage_url ( ) : (string) Returns the url that the user clicks to opt in to Jetpack Manage
opt_out_jetpack_manage_url ( ) : (string) Returns the url that the user clicks to remove the notice for the big banner
permit_ssl ( $force_recheck = false ) : boolean Checks to see if the URL is using SSL to connect with Jetpack
plugin_action_links ( $actions )
plugin_activation ( $network_wide ) Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
plugin_deactivation ( ) Removes all connection options
plugin_initialize ( ) Sets the internal version number and activation state.
plugin_textdomain ( ) Load language files
plugin_upgrade ( ) Must never be called statically
post_login_form_to_signed_url ( $url, $path, $scheme ) Make sure the login form is POSTed to the signed URL so we can reverify the request
prepare_manage_jetpack_notice ( ) : null Call this function if you want the Big Jetpack Manage Notice to show up.
preserve_action_in_login_form_for_json_api_authorization ( ) Make sure the POSTed request is handled by the same action
public_xmlrpc_methods ( $methods )
refresh_active_plan_from_wpcom ( ) : boolean Make an API call to WordPress.com for plan status
refresh_theme_data ( )
refresh_update_data ( )
register ( ) : boolean | WP_Error
register_assets ( ) : null Register assets for use in various modules and the Jetpack admin page.
remote_request_handlers ( )
require_jetpack_authentication ( )
restate ( )
show_development_mode_notice ( ) Get Jetpack development mode notice text and notice class.
sign_role ( $role )
sort_modules ( $a, $b )
stat ( $group, $detail ) Record a stat for later output. This will only currently output in the admin_footer.
state ( string $key = null, string $value = null, boolean $restate = false ) State is passed via cookies from one request to the next, but never to subsequent requests.
staticize_subdomain ( $url )
store_json_api_authorization_token ( $user_login, $user ) If someone logs in to approve API access, store the Access Code in usermeta
submit_security_report ( string $type = '', string $plugin_file = '', array $args = [] ) Allows plugins to submit security reports.
sync_idc_optin ( ) : boolean Returns the value of the jetpack_sync_idc_optin filter, or constant.
throw_error_on_activate_plugin ( string $plugin ) Sometimes a plugin can activate without causing errors, but it will cause errors on the next page load.
translate_current_user_to_role ( )
translate_module_tag ( string $tag ) : mixed Return translated module tag.
translate_role_to_cap ( $role )
try_registration ( ) Attempts Jetpack registration. If it fail, a state flag is set: @see ::admin_page_load()
unlink_user ( $user_id = null ) Unlinks the current user from the linked WordPress.com user
update_active_modules ( $modules )
update_jetpack_main_network_site_option ( ) : null Trigger an update to the main_network_site when we update the siteurl of a site.
update_jetpack_network_settings ( ) Triggered after a user updates the network settings via Network Settings Admin Page
update_option ( string $name, mixed $value ) Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate.
update_options ( array $array ) Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate.
update_user_token ( integer $user_id, string $token, $is_master_user ) Enters a user token into the user_tokens option
upload_handler ( )
user_role_change ( $user_id ) Synchronize connected user role changes
validate_remote_register_response ( $response ) : true Takes the response from the Jetpack register new site endpoint and verifies it worked properly.
validate_sync_error_idc_option ( ) : boolean Checks whether the sync_error_idc option is valid or not, and if not, will do cleanup.
verify_json_api_authorization_request ( ) Verifies the request by checking the signature
verify_xml_rpc_signature ( )
wp_dashboard_setup ( )
xmlrpc_api_url ( ) : string Returns the Jetpack XML-RPC API
xmlrpc_async_call ( ) Helper method for multicall XMLRPC.
xmlrpc_methods ( $methods ) In some setups, $HTTP_RAW_POST_DATA can be emptied during some IXR_Server paths since it is passed by reference to various methods.
xmlrpc_options ( $options )

Private Methods

Method Description
__construct ( ) Constructor. Initializes WordPress hooks
get_site_user_count ( )

Method Details

__destruct() public method

If there are any stats that need to be pushed, but haven't been, push them now.
public __destruct ( )

absolutize_css_urls() public static method

Considerations: - Normal, relative URLs feh.png - Data URLs data:image/gif;base64,eh129ehiuehjdhsa== - Schema-agnostic URLs //domain.com/feh.png - Absolute URLs http://domain.com/feh.png - Domain root relative URLs /feh.png
public static absolutize_css_urls ( $css, $css_file_url ) : mixed | string
$css string: The raw CSS -- should be read in directly from the file.
$css_file_url : The URL that the file can be accessed at, for calculating paths from.
return mixed | string

activate_default_modules() public static method

public static activate_default_modules ( $min_version = false, $max_version = false, $other_modules = [], $redirect = true )

activate_manage() static public method

static public activate_manage ( )

activate_module() public static method

public static activate_module ( $module, $exit = true, $redirect = true )

activate_module_actions() public method

public activate_module_actions ( $module )

activate_new_modules() public static method

public static activate_new_modules ( $redirect = false )

active_plan_supports() public static method

Determine whether the active plan supports a particular feature
public static active_plan_supports ( $feature ) : boolean
return boolean True if plan supports feature, false if not

add_jetpack_pagestyles() static public method

static public add_jetpack_pagestyles ( $admin_body_class = '' )

add_nonce() public method

public add_nonce ( $timestamp, $nonce )

add_remote_request_handlers() public method

add_token_to_login_redirect_json_api_authorization() public method

Add the Access Code details to the public-api.wordpress.com redirect
public add_token_to_login_redirect_json_api_authorization ( $redirect_to, $original_redirect_to, $user )

admin_banner_styles() public method

public admin_banner_styles ( )

admin_body_class() public method

public admin_body_class ( $admin_body_class = '' )

admin_head() public method

public admin_head ( )

admin_help() public method

Add help to the Jetpack page
public admin_help ( ) : false
return false if not the Jetpack page

admin_init() public method

* Admin Pages
public admin_init ( )

admin_jetpack_manage_notice() public method

This is the first banner It should be visible only to user that can update the option Are not connected
public admin_jetpack_manage_notice ( ) : null
return null

admin_menu_css() public method

public admin_menu_css ( )

admin_menu_order() public method

public admin_menu_order ( )

admin_notices() public method

public admin_notices ( )

admin_page_load() public method

Handles the page load events for the Jetpack admin page
public admin_page_load ( )

admin_screen_configure_module() public static method

public static admin_screen_configure_module ( $module_id )

admin_url() public static method

public static admin_url ( $args = null )

ajax_recheck_ssl() public method

public ajax_recheck_ssl ( )

alert_auto_ssl_fail() public method

* Displays an admin_notice, alerting the user to their JETPACK_CLIENT__HTTPS constant being 'AUTO' but SSL isn't working.
public alert_auto_ssl_fail ( )

allow_wpcom_public_api_domain() public method

Add public-api.wordpress.com to the safe redirect whitelist - only added when someone allows API access
public allow_wpcom_public_api_domain ( $domains )

api_url() public static method

Returns the requested Jetpack API URL
public static api_url ( $relative_url ) : string
return string

authenticate_jetpack() public method

Authenticates XML-RPC and other requests from the Jetpack Server
public authenticate_jetpack ( $user, $username, $password )

bail_on_activation() public static method

* Installation
public static bail_on_activation ( $message, $deactivate = true )

build_connect_url() public method

Builds a URL to the Jetpack connection auth page
Since: 3.9.5
public build_connect_url ( boolean $raw = false, boolean | string $redirect = false, boolean | string $from = false ) : string
$raw boolean If true, URL will not be escaped.
$redirect boolean | string If true, will redirect back to Jetpack wp-admin landing page after connection. If string, will be a custom redirect.
$from boolean | string If not false, adds 'from=$from' param to the connect URL.
return string Connect URL

build_raw_urls() public static method

* Strip http:// or https:// from a url, replaces forward slash with ::, so we can bring them directly to their site in calypso.
public static build_raw_urls ( $url )

build_reconnect_url() public method

public build_reconnect_url ( $raw = false )

build_stats_url() static public method

Builds the stats url.
static public build_stats_url ( $args ) : string
$args array|string The arguments to append to the URL.
return string The URL to be pinged.

can_display_jetpack_manage_notice() public method

Determines whether to show the notice of not true = display notice
public can_display_jetpack_manage_notice ( ) : (bool)
return (bool)

catch_errors() public static method

Catches PHP errors. Must be used in conjunction with output buffering.
public static catch_errors ( boolean $catch )
$catch boolean True to start catching, False to stop.

catch_errors_on_shutdown() public static method

Saves any generated PHP errors in ::state( 'php_errors', {errors} )
public static catch_errors_on_shutdown ( )

check_identity_crisis() public static method

Checks if the site is currently in an identity crisis.
public static check_identity_crisis ( ) : array | boolean
return array | boolean Array of options that are in a crisis, or false if everything is OK.

check_open_graph() public method

If certain plugins are active, Jetpack's og tags are suppressed.
public check_open_graph ( ) : null
return null

check_privacy() public static method

public static check_privacy ( $file )

check_rest_api_compat() public method

Check if Jetpack's REST API compat file should be included
public check_rest_api_compat ( ) : null
return null

check_twitter_tags() public method

If certain plugins are active, Jetpack's twitter tags are suppressed.
public check_twitter_tags ( ) : null
return null

clean_nonces() public static method

public static clean_nonces ( $all = false )

concat_remove_style_loader_tag() public method

public concat_remove_style_loader_tag ( $tag, $handle )

create_nonce() public static method

Stores two secrets and a timestamp so WordPress.com can make a request back and verify an action Does some extra verification so urls (such as those to public-api, register, etc) can't just be crafted $name must be a registered option name.
public static create_nonce ( $name )

current_user_is_connection_owner() public method

dashboard_widget() public static method

public static dashboard_widget ( )

dashboard_widget_connect_to_wpcom() public method

deactivate_module() public static method

public static deactivate_module ( $module )

debugger_page() public method

public debugger_page ( )

delete_active_modules() static public method

static public delete_active_modules ( )

delete_option() public static method

Updates jetpack_options and/or deletes jetpack_$name as appropriate.
Deprecation: 3.4 use Jetpack_Options::delete_option() instead.
public static delete_option ( string | array $names )
$names string | array

deprecated_hooks() public method

Throws warnings for deprecated hooks to be removed from Jetpack
public deprecated_hooks ( )

devicepx() public method

Device Pixels support This improves the resolution of gravatars and wordpress.com uploads on hi-res and zoomed browsers.
public devicepx ( )

disconnect() public static method

Forgets all connection details and tells the Jetpack servers to do the same.
public static disconnect ( $update_activated_state = true )

dismiss_jetpack_notice() public method

dns_prefetch() public static method

Stores and prints out domains to prefetch for page speed optimization.
public static dns_prefetch ( mixed $new_urls = null )
$new_urls mixed

do_server_side_stat() static public method

Runs stats code for a one-off, server-side.
static public do_server_side_stat ( $args ) : boolean
$args array|string The arguments to append to the URL. Should include `x_jetpack-{$group}={$stats}` or whatever we want to store.
return boolean If it worked.

do_stats() public method

Load stats pixels. $group is auto-prefixed with "x_jetpack-"
public do_stats ( $method = '' )

do_version_bump() public static method

Runs before bumping version numbers up to a new version
public static do_version_bump ( (string) $version, (string) $old_version ) : null
$version (string)
$old_version (string)
return null [description]

enable_module_configurable() public static method

public static enable_module_configurable ( $module )

extra_oembed_providers() public method

Add any extra oEmbed providers that we know about and use on wpcom for feature parity.

file_system_write_access() public static method

Returns true if the site has file write access false otherwise.
public static file_system_write_access ( ) : string
return string ( '1' | '0' )

filter_default_modules() public method

Checks activated plugins during auto-activation to determine if any of those plugins are in the list with a corresponding module that is not compatible with the plugin. The module will not be allowed to auto-activate.
Since: 2.6
public filter_default_modules ( array $modules ) : array
$modules array
return array

fix_url_for_bad_hosts() public static method

Some hosts disable the OpenSSL extension and so cannot make outgoing HTTPS requsets
public static fix_url_for_bad_hosts ( $url )

generate_secrets() public method

Note these tokens are unique per call, NOT static per site for connecting.
Since: 2.6
public generate_secrets ( $action, $exp = 600 ) : array
return array

get_active_modules() public static method

Get a list of activated modules as an array of module slugs.
public static get_active_modules ( )

get_active_plan() public static method

Get the plan that this Jetpack site is currently using
public static get_active_plan ( ) : array
return array Active Jetpack plan details

get_active_plugins() public static method

Gets all plugins currently active in values, regardless of whether they're traditionally activated or network activated.
public static get_active_plugins ( )

get_additional_stat_data() public static method

Get additional stat data to sync to WPCOM
public static get_additional_stat_data ( $prefix = '' )

get_available_modules() public static method

Make sure to tuck away module "library" files in a sub-directory.
public static get_available_modules ( $min_version = false, $max_version = false )

get_avatar_url() public static method

Centralize the function here until it gets added to core.
public static get_avatar_url ( integer | string | object $id_or_email, integer $size = 96, string $default = '', boolean $force_display = false ) : array
$id_or_email integer | string | object A user ID, email address, or comment object
$size integer Size of the avatar image
$default string URL to a default image to use if no avatar is available
$force_display boolean Whether to force it to return an avatar even if show_avatars is disabled
return array First element is the URL, second is the class.

get_cloud_site_options() public method

Pings the WordPress.com Mirror Site for the specified options.
public get_cloud_site_options ( string | array $option_names ) : array
$option_names string | array The option names to request from the WordPress.com Mirror Site
return array An associative array of the option values as stored in the WordPress.com Mirror Site

get_connected_user_data() public static method

Get the wpcom user data of the current|specified connected user.
public static get_connected_user_data ( $user_id = null )

get_connected_user_email() public static method

Get the wpcom email of the current|specified connected user.
public static get_connected_user_email ( $user_id = null )

get_content_width() public static method

Get $content_width, but with a twist filter.
public static get_content_width ( )

get_default_modules() public static method

Default modules loaded on activation.
public static get_default_modules ( $min_version = false, $max_version = false )

get_file_data() public static method

Like core's get_file_data implementation, but caches the result.
public static get_file_data ( $file, $headers )

get_jetpack_options_for_reset() public static method

It is used in class.jetpack-cli.php to reset options
public static get_jetpack_options_for_reset ( )

get_jp_emblem() public static method

Return string containing the Jetpack logo.
Since: 3.9.0
public static get_jp_emblem ( ) : string
return string

get_locale() public method

Get the locale.
public get_locale ( ) : string | boolean
return string | boolean

get_log() public static method

Get the internal event log.
public static get_log ( $event = false, $num = false ) : array
$event (string) - only return the specific log events
$num (int) - get specific number of latest results, limited to 200
return array of log events || WP_Error for invalid params

get_master_user_email() public static method

Get the wpcom email of the master user.
public static get_master_user_email ( )

get_module() public static method

Load module data from module file. Headers differ from WordPress plugin headers to avoid them being identified as standalone plugins on the WordPress plugins page.
public static get_module ( $module )

get_module_path() public static method

Generate a module's path from its slug.
public static get_module_path ( $slug )

get_module_slug() public static method

Extract a module's slug from its full path.
public static get_module_slug ( $file )

get_option() public static method

Returns the requested option. Looks in jetpack_options or jetpack_$name as appropriate.
public static get_option ( string $name, mixed $default = false )
$name string Option name
$default mixed (optional)

get_option_names() public static method

* Jetpack Options API
public static get_option_names ( $type = 'compact' )

get_other_linked_admins() static public method

Checks to see if there are any other users available to become primary Users must both: - Be linked to wpcom - Be an admin
static public get_other_linked_admins ( ) : mixed
return mixed False if no other users are linked, Int if there are.

get_parsed_plugin_data() public static method

Gets and parses additional plugin data to send with the heartbeat data
Since: 3.8.1
public static get_parsed_plugin_data ( ) : array
return array Array of plugin data

get_parsed_theme_data() public static method

Gets and parses theme data to send with the heartbeat data
Since: 3.8.1
public static get_parsed_theme_data ( ) : array
return array Array of theme data

get_remote_query_timeout_limit() public method

Based on local php max_execution_time in php.ini
Since: 2.6

get_stat_data() public static method

Return stat data for WPCOM sync
public static get_stat_data ( $encode = true, $extended = true )

get_sync_error_idc_option() public static method

Gets the value that is to be saved in the jetpack_sync_error_idc option.
Since: 4.4.0
public static get_sync_error_idc_option ( array $response = [] ) : array
$response array
return array Array of the local urls, wpcom urls, and error code

get_translated_modules() public static method

Return module name translation. Uses matching string created in modules/module-headings.php.
Since: 3.9.2
public static get_translated_modules ( array $modules ) : string | void
$modules array
return string | void

get_update_details() public static method

public static get_update_details ( )

get_updates() public static method

array ( 'plugins' => (int) Number of plugin updates available. 'themes' => (int) Number of theme updates available. 'wordpress' => (int) Number of WordPress core updates available. 'translations' => (int) Number of translation updates available. 'total' => (int) Total of all available updates. 'wp_update_version' => (string) The latest available version of WordPress, only present if a WordPress update is needed. )
public static get_updates ( ) : array
return array

get_user_option_meta_box_order_dashboard() public method

glob_php() public static method

Equivalent to glob( "$absolute_path/*.php" ).
public static glob_php ( string $absolute_path ) : array
$absolute_path string The absolute path of the directory to search.
return array Array of absolute paths to the PHP files.

guess_locale_from_lang() public method

Guess locale from language code.
public guess_locale_from_lang ( string $lang ) : string | boolean
$lang string Language code.
return string | boolean

handle_deprecated_modules() public method

Runs at priority 99 by default. This is run late, so that it can still activate a module if the new module is a replacement for another that the user currently has active, even if something at the normal priority would kibosh everything.
Since: 2.6
public handle_deprecated_modules ( array $modules ) : array
$modules array
return array

implode_frontend_css() public method

Pros: - Uses only ONE css asset connection instead of 15 - Saves a minimum of 56k - Reduces server load - Reduces time to first painted byte Cons: - Loads css for ALL modules. However all selectors are prefixed so it should not cause any issues with themes. - Plugins/themes dequeuing styles no longer do anything. See jetpack_implode_frontend_css filter for a workaround For some situations developers may wish to disable css imploding and instead operate in legacy mode where each file loads seperately and can be edited individually or dequeued. This can be accomplished with the following line: add_filter( 'jetpack_implode_frontend_css', '__return_false' );
Since: 3.2
public implode_frontend_css ( $travis_test = false )

init() public static method

Singleton
public static init ( )

intercept_plugin_error_scrape() public method

public intercept_plugin_error_scrape ( $action, $result )

intercept_plugin_error_scrape_init() public method

is_active() public static method

Is Jetpack active?
public static is_active ( )

is_development_mode() public static method

Is Jetpack in development (offline) mode?
public static is_development_mode ( )

is_development_version() public static method

Whether Jetpack's version maps to a public release, or a development version.
public static is_development_version ( )

is_main_network_option() public method

The reason we are type casting this is because we want to avoid the situation where the result is false since when is_main_network_option return false it cases the rest the get_option( 'jetpack_is_multi_network' ); to return the value that is set in the database which could be set to anything as opposed to what this function returns.
public is_main_network_option ( boolean $option ) : boolean
$option boolean
return boolean

is_module() public static method

public static is_module ( $module )

is_module_active() public static method

Check whether or not a Jetpack module is active.
public static is_module_active ( string $module ) : boolean
$module string The slug of a Jetpack module.
return boolean

is_multi_network() public static method

Implemented since there is no core is multi network function Right now there is no way to tell if we which network is the dominant network on the system
Since: 3.3
public static is_multi_network ( ) : boolean
return boolean

is_multisite() public method

Return true if we are with multi-site or multi-network false if we are dealing with single site.
public is_multisite ( string $option ) : boolean
$option string
return boolean

is_plugin_active() public static method

We don't want to store these in a static variable, in case there are switch_to_blog() calls involved.
public static is_plugin_active ( $plugin = 'jetpack/jetpack.php' )

is_single_user_site() public static method

Get back if the current site is single user site.
public static is_single_user_site ( ) : boolean
return boolean

is_staging_site() public static method

Checks whether the home and siteurl specifically are whitelisted Written so that we don't have re-check $key and $value params every time we want to check if this site is whitelisted, for example in footer.php
Since: 3.8.0
public static is_staging_site ( ) : boolean
return boolean True = already whitelisted False = not whitelisted

is_user_connected() public static method

Is a given user (or the current user if none is specified) linked to a WordPress.com user?
public static is_user_connected ( $user_id = false )

is_version_controlled() public static method

Finds out if a site is using a version control system.
public static is_version_controlled ( ) : string
return string ( '1' | '0' )

jetpack_admin_ajax_tracks_callback() public method

jetpack_check_heartbeat_data() public static method

Organizes the heartbeat data by severity. For example, if the site is in an ID crisis, it will be in the $filtered_data['bad'] array. Data will be added to "caution" array, if it either: - Out of date Jetpack version - Out of date WP version - Out of date PHP version $return array $filtered_data
public static jetpack_check_heartbeat_data ( )

jetpack_custom_caps() public method

public jetpack_custom_caps ( $caps, $cap, $user_id, $args )

jetpack_getOptions() public method

public jetpack_getOptions ( $args )

jetpack_icon_user_connected() public method

* Adds a "blank" column in the user admin table to display indication of user connection.
public jetpack_icon_user_connected ( $columns )

jetpack_jitm_ajax_callback() public method

The callback for the JITM ajax requests.

jetpack_main_network_site_option() public method

Return the network_site_url so that .com knows what network this site is a part of.
public jetpack_main_network_site_option ( boolean $option ) : string
$option boolean
return string

jetpack_menu_order() public method

public jetpack_menu_order ( $menu_order )

jetpack_show_user_connected_icon() public method

* Show Jetpack icon if the user is linked.
public jetpack_show_user_connected_icon ( $val, $col, $user_id )

jetpack_user_col_style() public method

* Style the Jetpack user column

jumpstart_has_updated_module_option() public static method

If any module option has been updated before Jump Start has been dismissed, update the 'jumpstart' option so we can hide Jump Start.
public static jumpstart_has_updated_module_option ( string $option_name = '' ) : boolean
$option_name string
return boolean

load_modules() public static method

Loads the currently active modules.
public static load_modules ( )

load_view() public method

Data passed in with the $data parameter will be available in the template file as $data['value']
public load_view ( string $template, array $data = [] ) : boolean
$template string - Template file to load
$data array - Any data to pass along to the template
return boolean - If template file was found

load_xml_rpc_client() public static method

Loads the Jetpack XML-RPC client
public static load_xml_rpc_client ( )

log() public static method

public static log ( $code, $data = null )

log_settings_change() public static method

Log modification of important settings.
public static log_settings_change ( $option, $old_value, $value )

login_form_json_api_authorization() public method

Handles the login action for Authorizing the JSON API

login_message_json_api_authorization() public method

manage_activate_screen() public method

maybe_clear_other_linked_admins_transient() public method

If a user has been promoted to or demoted from admin, we need to clear the jetpack_other_linked_admins transient.
Since: 4.3.2
Since: 4.4.0 $old_roles is null by default and if it's not passed, the transient is cleared.
public maybe_clear_other_linked_admins_transient ( integer $user_id, string $role, array $old_roles = null )
$user_id integer The user ID whose role changed.
$role string The new role.
$old_roles array An array of the user's previous roles.

maybe_inline_style() public static method

If you'd like to inline a stylesheet instead of printing a link to it, wp_style_add_data( 'handle', 'jetpack-inline', true ); Attached to style_loader_tag filter.
public static maybe_inline_style ( string $tag, string $handle ) : string
$tag string The tag that would link to the external asset.
$handle string The registered handle of the script in question.
return string

maybe_min_asset() public static method

Hooks onto plugins_url filter at priority 1, and accepts all 3 args.
public static maybe_min_asset ( $url, $path, $plugin )

maybe_set_version_option() public static method

If the db version is showing something other that what we've got now, bump it to current.
public static maybe_set_version_option ( ) : bool:
return bool:

module_configuration_activation_screen() public static method

public static module_configuration_activation_screen ( $module, $method )

module_configuration_head() public static method

public static module_configuration_head ( $module, $method )

module_configuration_load() public static method

public static module_configuration_load ( $module, $method )

module_configuration_screen() public static method

public static module_configuration_screen ( $module, $method )

module_configuration_url() public static method

public static module_configuration_url ( $module )

network_add_new_users() static public method

Does the network allow admins to add new users.
static public network_add_new_users ( $option = null ) : boolian
return boolian

network_allow_new_registrations() static public method

Does the network allow new user and site registrations.
static public network_allow_new_registrations ( $option = null ) : string
return string

network_enable_administration_menus() static public method

Lets us know if a site allows admins to manage the network.
static public network_enable_administration_menus ( $option = null ) : array
return array

network_max_upload_file_size() static public method

Maximum file upload size set by the network.
static public network_max_upload_file_size ( $option = null ) : number
return number

network_name() static public method

Network Name.
static public network_name ( $option = null )

network_site_upload_space() static public method

-1 means NO LIMIT.
static public network_site_upload_space ( $option = null ) : number
return number

network_upload_file_types() static public method

Network allowed file types.
static public network_upload_file_types ( $option = null ) : string
return string

nonce_url_no_esc() public static method

public static nonce_url_no_esc ( $actionurl, $action, $name = '_wpnonce' )

normalize_url_protocol_agnostic() public static method

Normalizes a url by doing three things: - Strips protocol - Strips www - Adds a trailing slash
Since: 4.4.0
public static normalize_url_protocol_agnostic ( string $url ) : WP_Error | string
$url string
return WP_Error | string

opt_in_jetpack_manage_notice() public method

opt_in_jetpack_manage_url() public method

Returns the url that the user clicks to opt in to Jetpack Manage
public opt_in_jetpack_manage_url ( ) : (string)
return (string)

opt_out_jetpack_manage_url() public method

Returns the url that the user clicks to remove the notice for the big banner
public opt_out_jetpack_manage_url ( ) : (string)
return (string)

permit_ssl() public static method

Checks to see if the URL is using SSL to connect with Jetpack
Since: 2.3.3
public static permit_ssl ( $force_recheck = false ) : boolean
return boolean

plugin_activation() public static method

Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
public static plugin_activation ( $network_wide )

plugin_deactivation() public static method

Removes all connection options
public static plugin_deactivation ( )

plugin_initialize() public static method

Sets the internal version number and activation state.
public static plugin_initialize ( )

plugin_textdomain() public static method

Load language files
public static plugin_textdomain ( )

plugin_upgrade() public method

Must never be called statically
public plugin_upgrade ( )

post_login_form_to_signed_url() public method

Make sure the login form is POSTed to the signed URL so we can reverify the request
public post_login_form_to_signed_url ( $url, $path, $scheme )

prepare_manage_jetpack_notice() public method

Call this function if you want the Big Jetpack Manage Notice to show up.

preserve_action_in_login_form_for_json_api_authorization() public method

Make sure the POSTed request is handled by the same action

public_xmlrpc_methods() public method

public public_xmlrpc_methods ( $methods )

refresh_active_plan_from_wpcom() public static method

Make an API call to WordPress.com for plan status
public static refresh_active_plan_from_wpcom ( ) : boolean
return boolean True if plan is updated, false if no update

refresh_theme_data() public static method

public static refresh_theme_data ( )

refresh_update_data() public static method

public static refresh_update_data ( )

register() public static method

public static register ( ) : boolean | WP_Error
return boolean | WP_Error

register_assets() public method

Register assets for use in various modules and the Jetpack admin page.
public register_assets ( ) : null
return null

remote_request_handlers() public method

require_jetpack_authentication() public method

restate() public static method

public static restate ( )

show_development_mode_notice() public static method

Mirrors the checks made in Jetpack::is_development_mode
public static show_development_mode_notice ( )

sign_role() static public method

static public sign_role ( $role )

sort_modules() public static method

public static sort_modules ( $a, $b )

stat() public method

Record a stat for later output. This will only currently output in the admin_footer.
public stat ( $group, $detail )

state() public static method

SET: state( $key, $value ); GET: $value = state( $key );
public static state ( string $key = null, string $value = null, boolean $restate = false )
$key string
$value string
$restate boolean private

staticize_subdomain() public static method

public static staticize_subdomain ( $url )

store_json_api_authorization_token() public method

If someone logs in to approve API access, store the Access Code in usermeta
public store_json_api_authorization_token ( $user_login, $user )

submit_security_report() public static method

Allows plugins to submit security reports.
public static submit_security_report ( string $type = '', string $plugin_file = '', array $args = [] )
$type string Report type (login_form, backup, file_scanning, spam)
$plugin_file string Plugin __FILE__, so that we can pull plugin data
$args array See definitions above

sync_idc_optin() public static method

If set to true, the site will be put into staging mode.
Since: 4.3.2
public static sync_idc_optin ( ) : boolean
return boolean

throw_error_on_activate_plugin() public method

This function artificially throws errors for such cases (whitelisted).
public throw_error_on_activate_plugin ( string $plugin )
$plugin string The activated plugin.

translate_current_user_to_role() static public method

static public translate_current_user_to_role ( )

translate_module_tag() public static method

Return translated module tag.
public static translate_module_tag ( string $tag ) : mixed
$tag string Tag as it appears in each module heading.
return mixed

translate_role_to_cap() static public method

static public translate_role_to_cap ( $role )

try_registration() public static method

Attempts Jetpack registration. If it fail, a state flag is set: @see ::admin_page_load()
public static try_registration ( )

update_active_modules() static public method

static public update_active_modules ( $modules )

update_jetpack_main_network_site_option() public method

Trigger an update to the main_network_site when we update the siteurl of a site.

update_jetpack_network_settings() public method

Triggered after a user updates the network settings via Network Settings Admin Page

update_option() public static method

Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate.
Deprecation: 3.4 use Jetpack_Options::update_option() instead.
public static update_option ( string $name, mixed $value )
$name string Option name
$value mixed Option value

update_options() public static method

Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate.
Deprecation: 3.4 use Jetpack_Options::update_options() instead.
public static update_options ( array $array )
$array array array( option name => option value, ... )

update_user_token() public static method

Enters a user token into the user_tokens option
public static update_user_token ( integer $user_id, string $token, $is_master_user )
$user_id integer
$token string return bool

upload_handler() public method

public upload_handler ( )

user_role_change() public method

Synchronize connected user role changes
public user_role_change ( $user_id )

validate_remote_register_response() public method

Takes the response from the Jetpack register new site endpoint and verifies it worked properly.
Since: 2.6
public validate_remote_register_response ( $response ) : true
return true or Jetpack_Error

validate_sync_error_idc_option() public static method

Checks whether the sync_error_idc option is valid or not, and if not, will do cleanup.
public static validate_sync_error_idc_option ( ) : boolean
return boolean

verify_json_api_authorization_request() public method

Verifies the request by checking the signature

verify_xml_rpc_signature() public method

wp_dashboard_setup() public method

public wp_dashboard_setup ( )

xmlrpc_api_url() public static method

Returns the Jetpack XML-RPC API
public static xmlrpc_api_url ( ) : string
return string

xmlrpc_async_call() public static method

Helper method for multicall XMLRPC.
public static xmlrpc_async_call ( )

xmlrpc_methods() public method

Capture it here so we can verify the signature later.
public xmlrpc_methods ( $methods )

xmlrpc_options() public method

public xmlrpc_options ( $options )

Property Details

$HTTP_RAW_POST_DATA public property

public $HTTP_RAW_POST_DATA

$capability_translations static public property

static public $capability_translations

$concatenated_style_handles public property

The handles of styles that are concatenated into jetpack.css
public $concatenated_style_handles

$error public property

Error to display in admin_notice
public string $error
return string

$instance static public property

Holds the singleton instance of this class
Since: 2.3.3
static public Jetpack $instance
return Jetpack

$json_api_authorization_request public property

Verified data for JSON authorization request
public $json_api_authorization_request

$message public property

Message to display in admin_notice
public string $message
return string

$plugins_to_deactivate public property

public $plugins_to_deactivate

$privacy_checks public property

Modules that need more privacy description.
public string $privacy_checks
return string

$stats public property

Stats to record once the page loads
public array $stats
return array

$sync public property

Jetpack_Sync object
public $sync

$xmlrpc_server public property

public $xmlrpc_server