Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack
File: functions.global.php
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
[0] Fix | Delete
/**
[1] Fix | Delete
* This file is meant to be the home for any generic & reusable functions
[2] Fix | Delete
* that can be accessed anywhere within Jetpack.
[3] Fix | Delete
*
[4] Fix | Delete
* This file is loaded whether Jetpack is active.
[5] Fix | Delete
*
[6] Fix | Delete
* Please namespace with jetpack_
[7] Fix | Delete
*
[8] Fix | Delete
* @package automattic/jetpack
[9] Fix | Delete
*/
[10] Fix | Delete
[11] Fix | Delete
use Automattic\Jetpack\Connection\Client;
[12] Fix | Delete
use Automattic\Jetpack\Redirect;
[13] Fix | Delete
use Automattic\Jetpack\Status\Host;
[14] Fix | Delete
use Automattic\Jetpack\Status\Request;
[15] Fix | Delete
use Automattic\Jetpack\Sync\Functions;
[16] Fix | Delete
[17] Fix | Delete
// Disable direct access.
[18] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[19] Fix | Delete
exit( 0 );
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
require_once __DIR__ . '/functions.is-mobile.php';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Hook into Core's _deprecated_function
[26] Fix | Delete
* Add more details about when a deprecated function will be removed.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 8.8.0
[29] Fix | Delete
*
[30] Fix | Delete
* @param string $function The function that was called.
[31] Fix | Delete
* @param string $replacement Optional. The function that should have been called. Default null.
[32] Fix | Delete
* @param string $version The version of Jetpack that deprecated the function.
[33] Fix | Delete
*/
[34] Fix | Delete
function jetpack_deprecated_function( $function, $replacement, $version ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[35] Fix | Delete
// Bail early for non-Jetpack deprecations.
[36] Fix | Delete
if ( ! str_starts_with( $version, 'jetpack-' ) ) {
[37] Fix | Delete
return;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// Look for when a function will be removed based on when it was deprecated.
[41] Fix | Delete
$removed_version = jetpack_get_future_removed_version( $version );
[42] Fix | Delete
[43] Fix | Delete
// If we could find a version, let's log a message about when removal will happen.
[44] Fix | Delete
if (
[45] Fix | Delete
! empty( $removed_version )
[46] Fix | Delete
&& ( defined( 'WP_DEBUG' ) && WP_DEBUG )
[47] Fix | Delete
/** This filter is documented in core/src/wp-includes/functions.php */
[48] Fix | Delete
&& apply_filters( 'deprecated_function_trigger_error', true )
[49] Fix | Delete
) {
[50] Fix | Delete
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
[51] Fix | Delete
sprintf(
[52] Fix | Delete
doing_action( 'after_setup_theme' ) || did_action( 'after_setup_theme' ) ?
[53] Fix | Delete
/* Translators: 1. Function name. 2. Jetpack version number. */
[54] Fix | Delete
__( 'The %1$s function will be removed from the Jetpack plugin in version %2$s.', 'jetpack' )
[55] Fix | Delete
: 'The %1$s function will be removed from the Jetpack plugin in version %2$s.',
[56] Fix | Delete
$function,
[57] Fix | Delete
$removed_version
[58] Fix | Delete
)
[59] Fix | Delete
);
[60] Fix | Delete
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
add_action( 'deprecated_function_run', 'jetpack_deprecated_function', 10, 3 );
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Hook into Core's _deprecated_file
[67] Fix | Delete
* Add more details about when a deprecated file will be removed.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 8.8.0
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $file The file that was called.
[72] Fix | Delete
* @param string $replacement The file that should have been included based on ABSPATH.
[73] Fix | Delete
* @param string $version The version of WordPress that deprecated the file.
[74] Fix | Delete
* @param string $message A message regarding the change.
[75] Fix | Delete
*/
[76] Fix | Delete
function jetpack_deprecated_file( $file, $replacement, $version, $message ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[77] Fix | Delete
// Bail early for non-Jetpack deprecations.
[78] Fix | Delete
if ( ! str_starts_with( $version, 'jetpack-' ) ) {
[79] Fix | Delete
return;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
// Look for when a file will be removed based on when it was deprecated.
[83] Fix | Delete
$removed_version = jetpack_get_future_removed_version( $version );
[84] Fix | Delete
[85] Fix | Delete
// If we could find a version, let's log a message about when removal will happen.
[86] Fix | Delete
if (
[87] Fix | Delete
! empty( $removed_version )
[88] Fix | Delete
&& ( defined( 'WP_DEBUG' ) && WP_DEBUG )
[89] Fix | Delete
/** This filter is documented in core/src/wp-includes/functions.php */
[90] Fix | Delete
&& apply_filters( 'deprecated_file_trigger_error', true )
[91] Fix | Delete
) {
[92] Fix | Delete
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
[93] Fix | Delete
sprintf(
[94] Fix | Delete
/* Translators: 1. File name. 2. Jetpack version number. */
[95] Fix | Delete
__( 'The %1$s file will be removed from the Jetpack plugin in version %2$s.', 'jetpack' ),
[96] Fix | Delete
$file,
[97] Fix | Delete
$removed_version
[98] Fix | Delete
)
[99] Fix | Delete
);
[100] Fix | Delete
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
add_action( 'deprecated_file_included', 'jetpack_deprecated_file', 10, 4 );
[104] Fix | Delete
[105] Fix | Delete
/**
[106] Fix | Delete
* Get the major version number of Jetpack 6 months after provided version.
[107] Fix | Delete
* Useful to indicate when a deprecated function will be removed from Jetpack.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 8.8.0
[110] Fix | Delete
*
[111] Fix | Delete
* @param string $version The version of WordPress that deprecated the function.
[112] Fix | Delete
*
[113] Fix | Delete
* @return bool|float Return a Jetpack Major version number, or false.
[114] Fix | Delete
*/
[115] Fix | Delete
function jetpack_get_future_removed_version( $version ) {
[116] Fix | Delete
/*
[117] Fix | Delete
* Extract the version number from a deprecation notice.
[118] Fix | Delete
* (let's only keep the first decimal, e.g. 8.8 and not 8.8.0)
[119] Fix | Delete
*/
[120] Fix | Delete
preg_match( '#(([0-9]+\.([0-9]+))(?:\.[0-9]+)*)#', $version, $matches );
[121] Fix | Delete
[122] Fix | Delete
if ( isset( $matches[2] ) && isset( $matches[3] ) ) {
[123] Fix | Delete
$deprecated_version = (float) $matches[2];
[124] Fix | Delete
$deprecated_minor = (float) $matches[3];
[125] Fix | Delete
[126] Fix | Delete
/*
[127] Fix | Delete
* If the detected minor version number
[128] Fix | Delete
* (e.g. "7" in "8.7")
[129] Fix | Delete
* is higher than 9, we know the version number is malformed.
[130] Fix | Delete
* Jetpack does not use semver yet.
[131] Fix | Delete
* Bail.
[132] Fix | Delete
*/
[133] Fix | Delete
if ( 10 <= $deprecated_minor ) {
[134] Fix | Delete
return false;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
// We'll remove the function from the code 6 months later, thus 6 major versions later.
[138] Fix | Delete
$removed_version = $deprecated_version + 0.6;
[139] Fix | Delete
[140] Fix | Delete
return (float) $removed_version;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
return false;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
/**
[147] Fix | Delete
* Determine if this site is an WoA site or not by looking for presence of the wpcomsh plugin.
[148] Fix | Delete
*
[149] Fix | Delete
* @since 4.8.1
[150] Fix | Delete
* @deprecated 10.3.0
[151] Fix | Delete
*
[152] Fix | Delete
* @return bool
[153] Fix | Delete
*/
[154] Fix | Delete
function jetpack_is_atomic_site() {
[155] Fix | Delete
jetpack_deprecated_function( __FUNCTION__, 'Automattic/Jetpack/Status/Host::is_woa_site', 'jetpack-10.3.0' );
[156] Fix | Delete
return ( new Host() )->is_woa_site();
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
/**
[160] Fix | Delete
* Register post type for migration.
[161] Fix | Delete
*
[162] Fix | Delete
* @since 5.2
[163] Fix | Delete
*/
[164] Fix | Delete
function jetpack_register_migration_post_type() {
[165] Fix | Delete
register_post_type(
[166] Fix | Delete
'jetpack_migration',
[167] Fix | Delete
array(
[168] Fix | Delete
'supports' => array(),
[169] Fix | Delete
'taxonomies' => array(),
[170] Fix | Delete
'hierarchical' => false,
[171] Fix | Delete
'public' => false,
[172] Fix | Delete
'has_archive' => false,
[173] Fix | Delete
'can_export' => true,
[174] Fix | Delete
)
[175] Fix | Delete
);
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Checks whether the Post DB threat currently exists on the site.
[180] Fix | Delete
*
[181] Fix | Delete
* @since 12.0
[182] Fix | Delete
*
[183] Fix | Delete
* @param string $option_name Option name.
[184] Fix | Delete
*
[185] Fix | Delete
* @return WP_Post|bool
[186] Fix | Delete
*/
[187] Fix | Delete
function jetpack_migration_post_exists( $option_name ) {
[188] Fix | Delete
$query = new WP_Query(
[189] Fix | Delete
array(
[190] Fix | Delete
'post_type' => 'jetpack_migration',
[191] Fix | Delete
'title' => $option_name,
[192] Fix | Delete
'post_status' => 'all',
[193] Fix | Delete
'posts_per_page' => 1,
[194] Fix | Delete
'no_found_rows' => true,
[195] Fix | Delete
'ignore_sticky_posts' => true,
[196] Fix | Delete
'update_post_term_cache' => false,
[197] Fix | Delete
'update_post_meta_cache' => false,
[198] Fix | Delete
'orderby' => 'post_date ID',
[199] Fix | Delete
'order' => 'ASC',
[200] Fix | Delete
)
[201] Fix | Delete
);
[202] Fix | Delete
if ( ! empty( $query->post ) ) {
[203] Fix | Delete
return $query->post;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
return false;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
/**
[210] Fix | Delete
* Stores migration data in the database.
[211] Fix | Delete
*
[212] Fix | Delete
* @since 5.2
[213] Fix | Delete
*
[214] Fix | Delete
* @param string $option_name Option name.
[215] Fix | Delete
* @param bool $option_value Option value.
[216] Fix | Delete
*
[217] Fix | Delete
* @return int|WP_Error
[218] Fix | Delete
*/
[219] Fix | Delete
function jetpack_store_migration_data( $option_name, $option_value ) {
[220] Fix | Delete
jetpack_register_migration_post_type();
[221] Fix | Delete
[222] Fix | Delete
$insert = array(
[223] Fix | Delete
'post_title' => $option_name,
[224] Fix | Delete
'post_content_filtered' => $option_value,
[225] Fix | Delete
'post_type' => 'jetpack_migration',
[226] Fix | Delete
'post_date' => gmdate( 'Y-m-d H:i:s', time() ),
[227] Fix | Delete
);
[228] Fix | Delete
[229] Fix | Delete
$migration_post = jetpack_migration_post_exists( $option_name );
[230] Fix | Delete
if ( $migration_post ) {
[231] Fix | Delete
$insert['ID'] = $migration_post->ID;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
return wp_insert_post( $insert, true );
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Retrieves legacy image widget data.
[239] Fix | Delete
*
[240] Fix | Delete
* @since 5.2
[241] Fix | Delete
*
[242] Fix | Delete
* @param string $option_name Option name.
[243] Fix | Delete
*
[244] Fix | Delete
* @return mixed|null
[245] Fix | Delete
*/
[246] Fix | Delete
function jetpack_get_migration_data( $option_name ) {
[247] Fix | Delete
$post = jetpack_migration_post_exists( $option_name );
[248] Fix | Delete
[249] Fix | Delete
return null !== $post ? maybe_unserialize( $post->post_content_filtered ) : null;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
/**
[253] Fix | Delete
* Prints a TOS blurb used throughout the connection prompts.
[254] Fix | Delete
*
[255] Fix | Delete
* @since 5.3
[256] Fix | Delete
*
[257] Fix | Delete
* @echo string
[258] Fix | Delete
*/
[259] Fix | Delete
function jetpack_render_tos_blurb() {
[260] Fix | Delete
printf(
[261] Fix | Delete
wp_kses(
[262] Fix | Delete
/* Translators: placeholders are links. */
[263] Fix | Delete
__( 'By clicking <strong>Set up Jetpack</strong>, you agree to our <a href="%1$s" target="_blank" rel="noopener noreferrer">Terms of Service</a> and to <a href="%2$s" target="_blank" rel="noopener noreferrer">sync your site‘s data</a> with us.', 'jetpack' ),
[264] Fix | Delete
array(
[265] Fix | Delete
'a' => array(
[266] Fix | Delete
'href' => array(),
[267] Fix | Delete
'target' => array(),
[268] Fix | Delete
'rel' => array(),
[269] Fix | Delete
),
[270] Fix | Delete
'strong' => true,
[271] Fix | Delete
)
[272] Fix | Delete
),
[273] Fix | Delete
esc_url( Redirect::get_url( 'wpcom-tos' ) ),
[274] Fix | Delete
esc_url( Redirect::get_url( 'jetpack-support-what-data-does-jetpack-sync' ) )
[275] Fix | Delete
);
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Intervene upgrade process so Jetpack themes are downloaded with credentials.
[280] Fix | Delete
*
[281] Fix | Delete
* @since 5.3
[282] Fix | Delete
*
[283] Fix | Delete
* @param bool $preempt Whether to preempt an HTTP request's return value. Default false.
[284] Fix | Delete
* @param array $r HTTP request arguments.
[285] Fix | Delete
* @param string $url The request URL.
[286] Fix | Delete
*
[287] Fix | Delete
* @return array|bool|WP_Error
[288] Fix | Delete
*/
[289] Fix | Delete
function jetpack_theme_update( $preempt, $r, $url ) {
[290] Fix | Delete
if ( 0 === stripos( $url, JETPACK__WPCOM_JSON_API_BASE . '/rest/v1/themes/download' ) ) {
[291] Fix | Delete
$file = $r['filename'];
[292] Fix | Delete
if ( ! $file ) {
[293] Fix | Delete
return new WP_Error( 'problem_creating_theme_file', esc_html__( 'Problem creating file for theme download', 'jetpack' ) );
[294] Fix | Delete
}
[295] Fix | Delete
$theme = pathinfo( wp_parse_url( $url, PHP_URL_PATH ), PATHINFO_FILENAME );
[296] Fix | Delete
[297] Fix | Delete
// Remove filter to avoid endless loop since wpcom_json_api_request_as_blog uses this too.
[298] Fix | Delete
remove_filter( 'pre_http_request', 'jetpack_theme_update' );
[299] Fix | Delete
$result = Client::wpcom_json_api_request_as_blog(
[300] Fix | Delete
"themes/download/$theme.zip",
[301] Fix | Delete
'1.1',
[302] Fix | Delete
array(
[303] Fix | Delete
'stream' => true,
[304] Fix | Delete
'filename' => $file,
[305] Fix | Delete
)
[306] Fix | Delete
);
[307] Fix | Delete
[308] Fix | Delete
if ( 200 !== wp_remote_retrieve_response_code( $result ) ) {
[309] Fix | Delete
return new WP_Error( 'problem_fetching_theme', esc_html__( 'Problem downloading theme', 'jetpack' ) );
[310] Fix | Delete
}
[311] Fix | Delete
return $result;
[312] Fix | Delete
}
[313] Fix | Delete
return $preempt;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
/**
[317] Fix | Delete
* Add the filter when a upgrade is going to be downloaded.
[318] Fix | Delete
*
[319] Fix | Delete
* @since 5.3
[320] Fix | Delete
*
[321] Fix | Delete
* @param bool $reply Whether to bail without returning the package. Default false.
[322] Fix | Delete
*
[323] Fix | Delete
* @return bool
[324] Fix | Delete
*/
[325] Fix | Delete
function jetpack_upgrader_pre_download( $reply ) {
[326] Fix | Delete
add_filter( 'pre_http_request', 'jetpack_theme_update', 10, 3 );
[327] Fix | Delete
return $reply;
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
add_filter( 'upgrader_pre_download', 'jetpack_upgrader_pre_download' );
[331] Fix | Delete
[332] Fix | Delete
/**
[333] Fix | Delete
* Wraps data in a way so that we can distinguish between objects and array and also prevent object recursion.
[334] Fix | Delete
*
[335] Fix | Delete
* @since 6.1.0
[336] Fix | Delete
[337] Fix | Delete
* @deprecated Automattic\Jetpack\Sync\Functions::json_wrap
[338] Fix | Delete
*
[339] Fix | Delete
* @param mixed $any Source data to be cleaned up.
[340] Fix | Delete
* @param array $seen_nodes Built array of nodes.
[341] Fix | Delete
*
[342] Fix | Delete
* @return array
[343] Fix | Delete
*/
[344] Fix | Delete
function jetpack_json_wrap( &$any, $seen_nodes = array() ) {
[345] Fix | Delete
_deprecated_function( __METHOD__, 'jetpack-9.5', 'Automattic\Jetpack\Sync\Functions' );
[346] Fix | Delete
[347] Fix | Delete
return Functions::json_wrap( $any, $seen_nodes );
[348] Fix | Delete
}
[349] Fix | Delete
[350] Fix | Delete
/**
[351] Fix | Delete
* Checks if the mime_content_type function is available and return it if so.
[352] Fix | Delete
*
[353] Fix | Delete
* The function mime_content_type is enabled by default in PHP, but can be disabled. We attempt to
[354] Fix | Delete
* enforce this via composer.json, but that won't be checked in majority of cases where
[355] Fix | Delete
* this would be happening.
[356] Fix | Delete
*
[357] Fix | Delete
* @since 7.8.0
[358] Fix | Delete
*
[359] Fix | Delete
* @param string $file File location.
[360] Fix | Delete
*
[361] Fix | Delete
* @return string|false MIME type or false if functionality is not available.
[362] Fix | Delete
*/
[363] Fix | Delete
function jetpack_mime_content_type( $file ) {
[364] Fix | Delete
if ( function_exists( 'mime_content_type' ) ) {
[365] Fix | Delete
return mime_content_type( $file );
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
return false;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Checks that the mime type of the specified file is among those in a filterable list of mime types.
[373] Fix | Delete
*
[374] Fix | Delete
* @since 7.8.0
[375] Fix | Delete
*
[376] Fix | Delete
* @param string $file Path to file to get its mime type.
[377] Fix | Delete
*
[378] Fix | Delete
* @return bool
[379] Fix | Delete
*/
[380] Fix | Delete
function jetpack_is_file_supported_for_sideloading( $file ) {
[381] Fix | Delete
$type = jetpack_mime_content_type( $file );
[382] Fix | Delete
[383] Fix | Delete
if ( ! $type ) {
[384] Fix | Delete
return false;
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Filter the list of supported mime types for media sideloading.
[389] Fix | Delete
*
[390] Fix | Delete
* @since 4.0.0
[391] Fix | Delete
*
[392] Fix | Delete
* @module json-api
[393] Fix | Delete
*
[394] Fix | Delete
* @param array $supported_mime_types Array of the supported mime types for media sideloading.
[395] Fix | Delete
*/
[396] Fix | Delete
$supported_mime_types = apply_filters(
[397] Fix | Delete
'jetpack_supported_media_sideload_types',
[398] Fix | Delete
array(
[399] Fix | Delete
'image/png',
[400] Fix | Delete
'image/jpeg',
[401] Fix | Delete
'image/gif',
[402] Fix | Delete
'image/bmp',
[403] Fix | Delete
'image/webp',
[404] Fix | Delete
'video/quicktime',
[405] Fix | Delete
'video/mp4',
[406] Fix | Delete
'video/mpeg',
[407] Fix | Delete
'video/ogg',
[408] Fix | Delete
'video/3gpp',
[409] Fix | Delete
'video/3gpp2',
[410] Fix | Delete
'video/h261',
[411] Fix | Delete
'video/h262',
[412] Fix | Delete
'video/h264',
[413] Fix | Delete
'video/x-msvideo',
[414] Fix | Delete
'video/x-ms-wmv',
[415] Fix | Delete
'video/x-ms-asf',
[416] Fix | Delete
)
[417] Fix | Delete
);
[418] Fix | Delete
[419] Fix | Delete
// If the type returned was not an array as expected, then we know we don't have a match.
[420] Fix | Delete
if ( ! is_array( $supported_mime_types ) ) {
[421] Fix | Delete
return false;
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
return in_array( $type, $supported_mime_types, true );
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
/**
[428] Fix | Delete
* Go through headers and get a list of Vary headers to add,
[429] Fix | Delete
* including a Vary Accept header if necessary.
[430] Fix | Delete
*
[431] Fix | Delete
* @since 12.2
[432] Fix | Delete
* @deprecated 14.8
[433] Fix | Delete
*
[434] Fix | Delete
* @param array $headers The headers to be sent.
[435] Fix | Delete
*
[436] Fix | Delete
* @return array $vary_header_parts Vary Headers to be sent.
[437] Fix | Delete
*/
[438] Fix | Delete
function jetpack_get_vary_headers( $headers = array() ) {
[439] Fix | Delete
_deprecated_function( __FUNCTION__, '14.8', 'Automattic\Jetpack\Status\Request::get_vary_headers' );
[440] Fix | Delete
[441] Fix | Delete
return ( new Request() )->get_vary_headers( $headers );
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
/**
[445] Fix | Delete
* Determine whether the current request is for accessing the frontend.
[446] Fix | Delete
* Also update Vary headers to indicate that the response may vary by Accept header.
[447] Fix | Delete
*
[448] Fix | Delete
* @deprecated 14.8
[449] Fix | Delete
*
[450] Fix | Delete
* @return bool True if it's a frontend request, false otherwise.
[451] Fix | Delete
*/
[452] Fix | Delete
function jetpack_is_frontend() {
[453] Fix | Delete
_deprecated_function( __FUNCTION__, '14.8', 'Automattic\Jetpack\Status\Request::is_frontend' );
[454] Fix | Delete
[455] Fix | Delete
return Request::is_frontend();
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
if ( ! function_exists( 'jetpack_mastodon_get_instance_list' ) ) {
[459] Fix | Delete
/**
[460] Fix | Delete
* Build a list of Mastodon instance hosts.
[461] Fix | Delete
* That list can be extended via a filter.
[462] Fix | Delete
*
[463] Fix | Delete
* @todo This function is now replicated in the Classic Theme Helper package and can be
[464] Fix | Delete
* removed here once Social Links are moved out of Jetpack.
[465] Fix | Delete
*
[466] Fix | Delete
* @since 11.8
[467] Fix | Delete
*
[468] Fix | Delete
* @return array
[469] Fix | Delete
*/
[470] Fix | Delete
function jetpack_mastodon_get_instance_list() {
[471] Fix | Delete
$mastodon_instance_list = array(
[472] Fix | Delete
// Regex pattern to match any .tld for the mastodon host name.
[473] Fix | Delete
'#https?:\/\/(www\.)?mastodon\.(\w+)(\.\w+)?#',
[474] Fix | Delete
// Regex pattern to match any .tld for the mstdn host name.
[475] Fix | Delete
'#https?:\/\/(www\.)?mstdn\.(\w+)(\.\w+)?#',
[476] Fix | Delete
'counter.social',
[477] Fix | Delete
'fosstodon.org',
[478] Fix | Delete
'gc2.jp',
[479] Fix | Delete
'hachyderm.io',
[480] Fix | Delete
'infosec.exchange',
[481] Fix | Delete
'mas.to',
[482] Fix | Delete
'pawoo.net',
[483] Fix | Delete
);
[484] Fix | Delete
[485] Fix | Delete
/**
[486] Fix | Delete
* Filter the list of Mastodon instances.
[487] Fix | Delete
*
[488] Fix | Delete
* @since 11.8
[489] Fix | Delete
*
[490] Fix | Delete
* @module widgets, theme-tools
[491] Fix | Delete
*
[492] Fix | Delete
* @param array $mastodon_instance_list Array of Mastodon instances.
[493] Fix | Delete
*/
[494] Fix | Delete
return (array) apply_filters( 'jetpack_mastodon_instance_list', $mastodon_instance_list );
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function