File Editor
Directories:
.. (Back)
3rd-party
_inc
bin
css
extensions
images
json-endpoints
modules
sal
src
vendor
views
Files:
changelog.txt
class-jetpack-wizard-banner.php
class.frame-nonce-preview.php
class.jetpack-admin.php
class.jetpack-affiliate.php
class.jetpack-autoupdate.php
class.jetpack-bbpress-json-api.compat.php
class.jetpack-cli.php
class.jetpack-client-server.php
class.jetpack-connection-banner.php
class.jetpack-data.php
class.jetpack-debugger.php
class.jetpack-error.php
class.jetpack-gutenberg.php
class.jetpack-heartbeat.php
class.jetpack-idc.php
class.jetpack-ixr-client.php
class.jetpack-modules-list-table.php
class.jetpack-network-sites-list-table.php
class.jetpack-network.php
class.jetpack-plan.php
class.jetpack-post-images.php
class.jetpack-twitter-cards.php
class.jetpack-user-agent.php
class.jetpack-xmlrpc-server.php
class.jetpack.php
class.json-api-endpoints.php
class.json-api.php
class.photon.php
functions.compat.php
functions.cookies.php
functions.gallery.php
functions.global.php
functions.opengraph.php
functions.photon.php
jest.config.js
jetpack.php
json-api-config.php
json-endpoints.php
load-jetpack.php
locales.php
readme.txt
require-lib.php
uninstall.php
Create New File
Create
Edit File: functions.compat.php
<?php use Automattic\Jetpack\Connection\Manager as Connection_Manager; /** * Required for class.media-extractor.php to match expected function naming convention. * * @param $url Can be just the $url or the whole $atts array * @return bool|mixed The Youtube video ID via jetpack_get_youtube_id */ function jetpack_shortcode_get_youtube_id( $url ) { return jetpack_get_youtube_id( $url ); } /** * @param string $url Can be just the $url or the whole $atts array * @return bool|mixed The Youtube video ID */ function jetpack_get_youtube_id( $url ) { // Do we have an $atts array? Get first att if ( is_array( $url ) ) { $url = reset( $url ); } $url = youtube_sanitize_url( $url ); $url = wp_parse_url( $url ); $id = false; if ( ! isset( $url['query'] ) ) return false; parse_str( $url['query'], $qargs ); if ( ! isset( $qargs['v'] ) && ! isset( $qargs['list'] ) ) return false; if ( isset( $qargs['list'] ) ) $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['list'] ); if ( empty( $id ) ) $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['v'] ); return $id; } if ( !function_exists( 'youtube_sanitize_url' ) ) : /** * Normalizes a YouTube URL to include a v= parameter and a query string free of encoded ampersands. * * @param string $url * @return string The normalized URL */ function youtube_sanitize_url( $url ) { $url = trim( $url, ' "' ); $url = trim( $url ); $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url ); // Replace any extra question marks with ampersands - the result of a URL like "https://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in. $query_string_start = strpos( $url, "?" ); if ( false !== $query_string_start ) { $url = substr( $url, 0, $query_string_start + 1 ) . str_replace( "?", "&", substr( $url, $query_string_start + 1 ) ); } return $url; } endif; /** * Merge in three string helper functions from WPCOM. * * @see WPCOM/wp-content/mu-plugins/string-helpers.php */ if ( ! function_exists( 'wp_startswith' ) ) : function wp_startswith( $haystack, $needle ) { return 0 === strpos( $haystack, $needle ); } endif; if ( ! function_exists( 'wp_endswith' ) ) : function wp_endswith( $haystack, $needle ) { return $needle === substr( $haystack, -strlen( $needle )); } endif; if ( ! function_exists( 'wp_in' ) ) : function wp_in( $needle, $haystack ) { return false !== strpos( $haystack, $needle ); } endif; /** * @deprecated 7.5 Use Connection_Manager instead. */ function jetpack_sha1_base64( $text ) { $connection = new Connection_Manager(); return $connection->sha1_base64( $text ); }
Save Changes
Rename File
Rename