jetpack
Last commit date
3rd-party
10 years ago
_inc
10 years ago
languages
10 years ago
modules
5 years ago
views
10 years ago
.svnignore
10 years ago
class.jetpack-bbpress-json-api-compat.php
10 years ago
class.jetpack-cli.php
10 years ago
class.jetpack-client-server.php
10 years ago
class.jetpack-client.php
10 years ago
class.jetpack-data.php
10 years ago
class.jetpack-debugger.php
10 years ago
class.jetpack-error.php
10 years ago
class.jetpack-heartbeat.php
10 years ago
class.jetpack-ixr-client.php
10 years ago
class.jetpack-network-sites-list-table.php
10 years ago
class.jetpack-network.php
10 years ago
class.jetpack-options.php
10 years ago
class.jetpack-post-images.php
10 years ago
class.jetpack-signature.php
10 years ago
class.jetpack-sync.php
10 years ago
class.jetpack-user-agent.php
10 years ago
class.jetpack-xmlrpc-server.php
10 years ago
class.jetpack.php
10 years ago
class.json-api-endpoints.php
3 years ago
class.json-api.php
10 years ago
class.media-extractor.php
10 years ago
class.media-summary.php
10 years ago
class.photon.php
10 years ago
composer.json
10 years ago
functions.compat.php
10 years ago
functions.gallery.php
10 years ago
functions.opengraph.php
10 years ago
functions.photon.php
10 years ago
functions.twitter-cards.php
10 years ago
jetpack.php
3 years ago
locales.php
10 years ago
readme.txt
3 years ago
require-lib.php
10 years ago
uninstall.php
10 years ago
functions.compat.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | if ( !function_exists( 'rawurlencode_deep' ) ) : |
| 4 | /** |
| 5 | * Navigates through an array and raw encodes the values to be used in a URL. |
| 6 | * |
| 7 | * @since WordPress 3.4.0 |
| 8 | * |
| 9 | * @param array|string $value The array or string to be encoded. |
| 10 | * @return array|string $value The encoded array (or string from the callback). |
| 11 | */ |
| 12 | function rawurlencode_deep( $value ) { |
| 13 | return is_array( $value ) ? array_map( 'rawurlencode_deep', $value ) : rawurlencode( $value ); |
| 14 | } |
| 15 | endif; |
| 16 | |
| 17 | if ( !function_exists( 'get_youtube_id' ) ) : |
| 18 | /** |
| 19 | * @param $url Can be just the $url or the whole $atts array |
| 20 | * @return bool|mixed The Youtube video ID |
| 21 | */ |
| 22 | function get_youtube_id( $url ) { |
| 23 | // Do we have an $atts array? Get first att |
| 24 | if ( is_array( $url ) ) |
| 25 | $url = $url[0]; |
| 26 | |
| 27 | $url = youtube_sanitize_url( $url ); |
| 28 | $url = parse_url( $url ); |
| 29 | $id = false; |
| 30 | |
| 31 | if ( ! isset( $url['query'] ) ) |
| 32 | return false; |
| 33 | |
| 34 | parse_str( $url['query'], $qargs ); |
| 35 | |
| 36 | if ( ! isset( $qargs['v'] ) && ! isset( $qargs['list'] ) ) |
| 37 | return false; |
| 38 | |
| 39 | if ( isset( $qargs['list'] ) ) |
| 40 | $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['list'] ); |
| 41 | |
| 42 | if ( empty( $id ) ) |
| 43 | $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['v'] ); |
| 44 | |
| 45 | return $id; |
| 46 | } |
| 47 | endif; |
| 48 | |
| 49 | if ( !function_exists( 'youtube_sanitize_url' ) ) : |
| 50 | /** |
| 51 | * Normalizes a YouTube URL to include a v= parameter and a query string free of encoded ampersands. |
| 52 | * |
| 53 | * @param string $url |
| 54 | * @return string The normalized URL |
| 55 | */ |
| 56 | function youtube_sanitize_url( $url ) { |
| 57 | $url = trim( $url, ' "' ); |
| 58 | $url = trim( $url ); |
| 59 | $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url ); |
| 60 | |
| 61 | // Replace any extra question marks with ampersands - the result of a URL like "http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in. |
| 62 | $query_string_start = strpos( $url, "?" ); |
| 63 | |
| 64 | if ( false !== $query_string_start ) { |
| 65 | $url = substr( $url, 0, $query_string_start + 1 ) . str_replace( "?", "&", substr( $url, $query_string_start + 1 ) ); |
| 66 | } |
| 67 | |
| 68 | return $url; |
| 69 | } |
| 70 | endif; |