\Jetpack

Summary

Methods
Properties
Constants
init()
plugin_upgrade()
__destruct()
jetpack_custom_caps()
require_jetpack_authentication()
plugin_textdomain()
register_assets()
devicepx()
require_lib_dir()
is_active()
is_development_mode()
is_user_connected()
get_connected_user_email()
current_user_is_connection_owner()
extra_oembed_providers()
user_role_change()
load_modules()
check_rest_api_compat()
check_open_graph()
check_twitter_tags()
get_option_names()
get_option()
create_nonce()
update_option()
update_options()
delete_option()
update_user_token()
glob_php()
activate_new_modules()
get_available_modules()
get_default_modules()
handle_deprecated_modules()
filter_default_modules()
get_module_slug()
get_module_path()
get_module()
translate_module_tag()
get_active_modules()
is_module_active()
is_module()
catch_errors()
catch_errors_on_shutdown()
activate_default_modules()
activate_module()
activate_module_actions()
deactivate_module()
enable_module_configurable()
module_configuration_url()
module_configuration_load()
module_configuration_head()
module_configuration_screen()
bail_on_activation()
plugin_activation()
plugin_initialize()
plugin_deactivation()
disconnect()
unlink_user()
try_registration()
log()
get_log()
admin_init()
admin_body_class()
add_jetpack_pagestyles()
prepare_connect_notice()
throw_error_on_activate_plugin()
intercept_plugin_error_scrape_init()
intercept_plugin_error_scrape()
admin_menu()
add_remote_request_handlers()
remote_request_handlers()
upload_handler()
jetpack_help()
admin_help()
admin_menu_css()
admin_menu_order()
jetpack_menu_order()
admin_head()
admin_styles()
admin_scripts()
plugin_action_links()
admin_connect_notice()
network_connect_notice()
jetpack_comment_notice()
admin_page_load()
admin_notices()
stat()
do_stats()
do_server_side_stat()
build_stats_url()
translate_current_user_to_role()
translate_role_to_cap()
sign_role()
build_connect_url()
build_reconnect_url()
admin_url()
nonce_url_no_esc()
dismiss_jetpack_notice()
admin_page()
debugger_page()
admin_screen_configure_module()
sort_modules()
admin_screen_list_modules()
check_news_subscription()
subscribe_to_news()
sync_reindex_trigger()
sync_reindex_status()
api_url()
fix_url_for_bad_hosts()
permit_ssl()
force_url_to_non_ssl()
alert_required_ssl_fail()
xmlrpc_api_url()
generate_secrets()
get_remote_query_timeout_limit()
validate_remote_register_response()
register()
load_xml_rpc_client()
authenticate_jetpack()
add_nonce()
xmlrpc_methods()
xmlrpc_options()
clean_nonces()
state()
restate()
check_privacy()
xmlrpc_async_call()
staticize_subdomain()
login_form_json_api_authorization()
post_login_form_to_signed_url()
preserve_action_in_login_form_for_json_api_authorization()
store_json_api_authorization_token()
allow_wpcom_public_api_domain()
add_token_to_login_redirect_json_api_authorization()
verify_json_api_authorization_request()
login_message_json_api_authorization()
get_content_width()
get_avatar_url()
get_cloud_site_options()
identity_crisis_options_to_check()
check_identity_crisis()
whitelist_identity_crisis_value()
is_identity_crisis_value_whitelisted()
alert_identity_crisis()
$xmlrpc_server
$HTTP_RAW_POST_DATA
$plugins_to_deactivate
$capability_translations
$message
$error
$privacy_checks
$stats
$sync
$json_api_authorization_request
$instance
No constants found
No protected methods found
No protected properties found
N/A
Jetpack()
$conflicting_plugins
N/A

Properties

$xmlrpc_server

$xmlrpc_server

$HTTP_RAW_POST_DATA

$HTTP_RAW_POST_DATA

$plugins_to_deactivate

$plugins_to_deactivate

$capability_translations

$capability_translations

$message

$message : string

Message to display in admin_notice

Type

string

$error

$error : string

Error to display in admin_notice

Type

string

$privacy_checks

$privacy_checks : string

Modules that need more privacy description.

Type

string

$stats

$stats : array

Stats to record once the page loads

Type

array

$sync

$sync

Jetpack_Sync object

$json_api_authorization_request

$json_api_authorization_request

Verified data for JSON authorization request

$instance

$instance : \Jetpack

Holds the singleton instance of this class

Type

\Jetpack

$conflicting_plugins

$conflicting_plugins : array

Map of modules that have conflicts with plugins and should not be auto-activated if the plugins are active. Used by filter_default_modules

Plugin Authors: If you'd like to prevent a single module from auto-activating, change module-slug and add this to your plugin:

add_filter( 'jetpack_get_default_modules', 'my_jetpack_get_default_modules' ); function my_jetpack_get_default_modules( $modules ) {

return array_diff( $modules, array( 'module-slug' ) );

}

Type

array

Methods

init()

init()

Singleton

plugin_upgrade()

plugin_upgrade()

Must never be called statically

__destruct()

__destruct()

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

jetpack_custom_caps()

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

Parameters

$caps
$cap
$user_id
$args

require_jetpack_authentication()

require_jetpack_authentication()

plugin_textdomain()

plugin_textdomain()

Load language files

register_assets()

register_assets() : null

Register assets for use in various modules and the Jetpack admin page.

Returns

null

devicepx()

devicepx()

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

require_lib_dir()

require_lib_dir( $lib_dir)

Parameters

$lib_dir

is_active()

is_active()

Is Jetpack active?

is_development_mode()

is_development_mode()

Is Jetpack in development (offline) mode?

is_user_connected()

is_user_connected( $user_id)

Is a given user (or the current user if none is specified) linked to a WordPress.com user?

Parameters

$user_id

get_connected_user_email()

get_connected_user_email()

Get the wpcom email of the current connected user.

current_user_is_connection_owner()

current_user_is_connection_owner()

extra_oembed_providers()

extra_oembed_providers()

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

user_role_change()

user_role_change( $user_id)

Synchronize connected user role changes

Parameters

$user_id

load_modules()

load_modules()

Loads the currently active modules.

check_rest_api_compat()

check_rest_api_compat() : null

Check if Jetpack's REST API compat file should be included

Returns

null

check_open_graph()

check_open_graph() : null

Check if Jetpack's Open Graph tags should be used.

If certain plugins are active, Jetpack's og tags are suppressed.

Returns

null

check_twitter_tags()

check_twitter_tags() : null

Check if Jetpack's Twitter tags should be used.

If certain plugins are active, Jetpack's twitter tags are suppressed.

Returns

null

get_option_names()

get_option_names( $type)

Parameters

$type

get_option()

get_option(string $name, mixed $default)

Returns the requested option. Looks in jetpack_options or jetpack_$name as appropriate.

Parameters

string $name

Option name

mixed $default

(optional)

create_nonce()

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) cant just be crafted $name must be a registered option name.

Parameters

$name

update_option()

update_option(string $name, mixed $value)

Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate.

Parameters

string $name

Option name

mixed $value

Option value

update_options()

update_options(array $array)

Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate.

Parameters

array $array

array( option name => option value, ... )

delete_option()

delete_option(string|array $names)

Deletes the given option. May be passed multiple option names as an array.

Updates jetpackoptions and/or deletes jetpack$name as appropriate.

Parameters

string|array $names

update_user_token()

update_user_token(int $user_id, string $token,  $is_master_user)

Enters a user token into the user_tokens option

Parameters

int $user_id
string $token

return bool

$is_master_user

glob_php()

glob_php(string $absolute_path) : array

Returns an array of all PHP files in the specified absolute path.

Equivalent to glob( "$absolute_path/*.php" ).

Parameters

string $absolute_path

The absolute path of the directory to search.

Returns

array —

Array of absolute paths to the PHP files.

activate_new_modules()

activate_new_modules()

get_available_modules()

get_available_modules( $min_version,  $max_version)

List available Jetpack modules. Simply lists .php files in /modules/.

Make sure to tuck away module "library" files in a sub-directory.

Parameters

$min_version
$max_version

get_default_modules()

get_default_modules( $min_version,  $max_version)

Default modules loaded on activation.

Parameters

$min_version
$max_version

handle_deprecated_modules()

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.

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.

Parameters

array $modules

Returns

array

filter_default_modules()

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.

Parameters

array $modules

Returns

array

get_module_slug()

get_module_slug( $file)

Extract a module's slug from its full path.

Parameters

$file

get_module_path()

get_module_path( $slug)

Generate a module's path from its slug.

Parameters

$slug

get_module()

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.

Parameters

$module

translate_module_tag()

translate_module_tag( $untranslated_tag)

Parameters

$untranslated_tag

get_active_modules()

get_active_modules()

Get a list of activated modules as an array of module slugs.

is_module_active()

is_module_active(string $module) : bool

Check whether or not a Jetpack module is active.

Parameters

string $module

The slug of a Jetpack module.

Returns

bool

is_module()

is_module( $module)

Parameters

$module

catch_errors()

catch_errors(bool $catch)

Catches PHP errors. Must be used in conjunction with output buffering.

Parameters

bool $catch

True to start catching, False to stop.

catch_errors_on_shutdown()

catch_errors_on_shutdown()

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

activate_default_modules()

activate_default_modules( $min_version,  $max_version,  $other_modules)

Parameters

$min_version
$max_version
$other_modules

activate_module()

activate_module( $module,  $exit)

Parameters

$module
$exit

activate_module_actions()

activate_module_actions( $module)

Parameters

$module

deactivate_module()

deactivate_module( $module)

Parameters

$module

enable_module_configurable()

enable_module_configurable( $module)

Parameters

$module

module_configuration_url()

module_configuration_url( $module)

Parameters

$module

module_configuration_load()

module_configuration_load( $module,  $method)

Parameters

$module
$method

module_configuration_head()

module_configuration_head( $module,  $method)

Parameters

$module
$method

module_configuration_screen()

module_configuration_screen( $module,  $method)

Parameters

$module
$method

bail_on_activation()

bail_on_activation( $message,  $deactivate)

Parameters

$message
$deactivate

plugin_activation()

plugin_activation( $network_wide)

Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()

Parameters

$network_wide

plugin_initialize()

plugin_initialize()

Sets the internal version number and activation state.

plugin_deactivation()

plugin_deactivation()

Removes all connection options

disconnect()

disconnect( $update_activated_state)

Disconnects from the Jetpack servers.

Forgets all connection details and tells the Jetpack servers to do the same.

Parameters

$update_activated_state

unlink_user()

unlink_user( $user_id)

Unlinks the current user from the linked WordPress.com user

Parameters

$user_id

try_registration()

try_registration()

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

log()

log( $code,  $data)

Tracking an internal event log. Try not to put too much chaff in here.

Everyone Loves a Log!

Parameters

$code
$data

get_log()

get_log()

Get the internal event log.

admin_init()

admin_init()

admin_body_class()

admin_body_class( $admin_body_class)

Parameters

$admin_body_class

add_jetpack_pagestyles()

add_jetpack_pagestyles( $admin_body_class)

Parameters

$admin_body_class

prepare_connect_notice()

prepare_connect_notice()

throw_error_on_activate_plugin()

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.

This function artificially throws errors for such cases (whitelisted).

Parameters

string $plugin

The activated plugin.

intercept_plugin_error_scrape_init()

intercept_plugin_error_scrape_init()

intercept_plugin_error_scrape()

intercept_plugin_error_scrape( $action,  $result)

Parameters

$action
$result

admin_menu()

admin_menu()

add_remote_request_handlers()

add_remote_request_handlers()

remote_request_handlers()

remote_request_handlers()

upload_handler()

upload_handler()

jetpack_help()

jetpack_help()

Add help to the Jetpack page

Deprecated. Remove when Jetpack requires WP 3.3+

admin_help()

admin_help() : false

Add help to the Jetpack page

Returns

false —

if not the Jetpack page

admin_menu_css()

admin_menu_css()

admin_menu_order()

admin_menu_order()

jetpack_menu_order()

jetpack_menu_order( $menu_order)

Parameters

$menu_order

admin_head()

admin_head()

admin_styles()

admin_styles()

admin_scripts()

admin_scripts()

plugin_action_links()

plugin_action_links( $actions)

Parameters

$actions

admin_connect_notice()

admin_connect_notice()

network_connect_notice()

network_connect_notice()

jetpack_comment_notice()

jetpack_comment_notice()

admin_page_load()

admin_page_load()

Handles the page load events for the Jetpack admin page

admin_notices()

admin_notices()

stat()

stat( $group,  $detail)

Record a stat for later output. This will only currently output in the admin_footer.

Parameters

$group
$detail

do_stats()

do_stats( $method)

Load stats pixels. $group is auto-prefixed with "x_jetpack-"

Parameters

$method

do_server_side_stat()

do_server_side_stat(mixed $args) : bool

Runs stats code for a one-off, server-side.

Parameters

mixed $args

array|string The arguments to append to the URL. Should include x_jetpack-{$group}={$stats} or whatever we want to store.

Returns

bool —

If it worked.

build_stats_url()

build_stats_url(mixed $args) : string

Builds the stats url.

Parameters

mixed $args

array|string The arguments to append to the URL.

Returns

string —

The URL to be pinged.

translate_current_user_to_role()

translate_current_user_to_role()

translate_role_to_cap()

translate_role_to_cap( $role)

Parameters

$role

sign_role()

sign_role( $role)

Parameters

$role

build_connect_url()

build_connect_url( $raw,  $redirect)

Parameters

$raw
$redirect

build_reconnect_url()

build_reconnect_url( $raw)

Parameters

$raw

admin_url()

admin_url( $args)

Parameters

$args

nonce_url_no_esc()

nonce_url_no_esc( $actionurl,  $action,  $name)

Parameters

$actionurl
$action
$name

dismiss_jetpack_notice()

dismiss_jetpack_notice()

admin_page()

admin_page()

debugger_page()

debugger_page()

admin_screen_configure_module()

admin_screen_configure_module( $module_id)

Parameters

$module_id

sort_modules()

sort_modules( $a,  $b)

Parameters

$a
$b

admin_screen_list_modules()

admin_screen_list_modules()

check_news_subscription()

check_news_subscription()

subscribe_to_news()

subscribe_to_news()

sync_reindex_trigger()

sync_reindex_trigger()

sync_reindex_status()

sync_reindex_status()

api_url()

api_url( $relative_url) : string

Returns the requested Jetpack API URL

Parameters

$relative_url

Returns

string

fix_url_for_bad_hosts()

fix_url_for_bad_hosts( $url)

Some hosts disable the OpenSSL extension and so cannot make outgoing HTTPS requsets

Parameters

$url

permit_ssl()

permit_ssl( $force_recheck) : boolean

Checks to see if the URL is using SSL to connect with Jetpack

Parameters

$force_recheck

Returns

boolean

force_url_to_non_ssl()

force_url_to_non_ssl( $url)

Take any URL, and if it starts with https:// change it to http://

Parameters

$url

alert_required_ssl_fail()

alert_required_ssl_fail()

xmlrpc_api_url()

xmlrpc_api_url() : string

Returns the Jetpack XML-RPC API

Returns

string

generate_secrets()

generate_secrets() : array

Creates two secret tokens and the end of life timestamp for them.

Note these tokens are unique per call, NOT static per site for connecting.

Returns

array

get_remote_query_timeout_limit()

get_remote_query_timeout_limit() : int

Builds the timeout limit for queries talking with the wpcom servers.

Based on local php max_execution_time in php.ini

Returns

int

validate_remote_register_response()

validate_remote_register_response( $response) : true

Takes the response from the Jetpack register new site endpoint and verifies it worked properly.

Parameters

$response

Returns

true —

or Jetpack_Error

register()

register() : bool|\WP_Error

Returns

bool|\WP_Error

load_xml_rpc_client()

load_xml_rpc_client()

Loads the Jetpack XML-RPC client

authenticate_jetpack()

authenticate_jetpack( $user,  $username,  $password)

Authenticates XML-RPC and other requests from the Jetpack Server

Parameters

$user
$username
$password

add_nonce()

add_nonce( $timestamp,  $nonce)

Parameters

$timestamp
$nonce

xmlrpc_methods()

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.

Capture it here so we can verify the signature later.

Parameters

$methods

xmlrpc_options()

xmlrpc_options( $options)

Parameters

$options

clean_nonces()

clean_nonces( $all)

Parameters

$all

state()

state(string $key, string $value, bool $restate)

State is passed via cookies from one request to the next, but never to subsequent requests.

SET: state( $key, $value ); GET: $value = state( $key );

Parameters

string $key
string $value
bool $restate

private

restate()

restate()

check_privacy()

check_privacy( $file)

Parameters

$file

xmlrpc_async_call()

xmlrpc_async_call()

Helper method for multicall XMLRPC.

staticize_subdomain()

staticize_subdomain( $url)

Parameters

$url

login_form_json_api_authorization()

login_form_json_api_authorization()

Handles the login action for Authorizing the JSON API

post_login_form_to_signed_url()

post_login_form_to_signed_url( $url,  $path,  $scheme)

Parameters

$url
$path
$scheme

preserve_action_in_login_form_for_json_api_authorization()

preserve_action_in_login_form_for_json_api_authorization()

store_json_api_authorization_token()

store_json_api_authorization_token( $user_login,  $user)

Parameters

$user_login
$user

allow_wpcom_public_api_domain()

allow_wpcom_public_api_domain( $domains)

Parameters

$domains

add_token_to_login_redirect_json_api_authorization()

add_token_to_login_redirect_json_api_authorization( $redirect_to,  $original_redirect_to,  $user)

Parameters

$redirect_to
$original_redirect_to
$user

verify_json_api_authorization_request()

verify_json_api_authorization_request()

login_message_json_api_authorization()

login_message_json_api_authorization( $message)

Parameters

$message

get_content_width()

get_content_width()

Get $content_width, but with a <s>twist</s> filter.

get_avatar_url()

get_avatar_url(int|string|object $id_or_email, int $size, string $default, bool $force_display) : array

Centralize the function here until it gets added to core.

Parameters

int|string|object $id_or_email

A user ID, email address, or comment object

int $size

Size of the avatar image

string $default

URL to a default image to use if no avatar is available

bool $force_display

Whether to force it to return an avatar even if show_avatars is disabled

Returns

array —

First element is the URL, second is the class.

get_cloud_site_options()

get_cloud_site_options(string|array $option_names) : array

Pings the WordPress.com Mirror Site for the specified options.

Parameters

string|array $option_names

The option names to request from the WordPress.com Mirror Site

Returns

array —

An associative array of the option values as stored in the WordPress.com Mirror Site

identity_crisis_options_to_check()

identity_crisis_options_to_check() : array

Fetch the filtered array of options that we should compare to determine an identity crisis.

Returns

array —

An array of options to check.

check_identity_crisis()

check_identity_crisis(bool $force_recheck) : array

Checks to make sure that local options have the same values as remote options. Will cache the results for up to 24 hours.

Parameters

bool $force_recheck

Whether to ignore any cached transient and manually re-check.

Returns

array —

An array of options that do not match. If everything is good, it will evaluate to false.

whitelist_identity_crisis_value()

whitelist_identity_crisis_value(string $key, string $value) : bool

Adds a value to the whitelist for the specified key.

Parameters

string $key

The option name that we're whitelisting the value for.

string $value

The value that we're intending to add to the whitelist.

Returns

bool —

Whether the value was added to the whitelist, or false if it was already there.

is_identity_crisis_value_whitelisted()

is_identity_crisis_value_whitelisted(string $key, string $value) : bool

Checks whether a value is already whitelisted.

Parameters

string $key

The option name that we're checking the value for.

string $value

The value that we're curious to see if it's on the whitelist.

Returns

bool —

Whether the value is whitelisted.

alert_identity_crisis()

alert_identity_crisis()

Displays an admin_notice, alerting the user to an identity crisis.

Jetpack()

Jetpack()

Constructor. Initializes WordPress hooks