://(www\.)?instagr(\.am|am\.com)/p/.*#i' => 'instagram', '#https?://(open|play)\.spotify\.com/.*#i' => 'spotify', '#https?://(.+\.)?imgur\.com/.*#i' => 'imgur', '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => 'meetup', '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => 'issuu', '#https?://(www\.)?collegehumor\.com/video/.*#i' => 'collegehumor', '#https?://(www\.)?mixcloud\.com/.*#i' => 'mixcloud', '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => 'ted', '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => 'animoto', '#https?://(.+)\.tumblr\.com/post/.*#i' => 'tumblr', '#https?://(www\.)?kickstarter\.com/projects/.*#i' => 'kickstarter', '#https?://kck\.st/.*#i' => 'kickstarter', '#https?://cloudup\.com/.*#i' => 'cloudup', '#https?://(www\.)?reverbnation\.com/.*#i' => 'reverbnation', '#https?://videopress.com/v/.*#' => 'wordpresscom', '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => 'reddit', '#https?://(www\.)?speakerdeck\.com/.*#i' => 'speakerdeck', '#https?://(www\.)?facebook\.com/.*#i' => 'facebook', ); return apply_filters( 'snax_oembed_url_to_provider_name_map', $map ); } /** * Return embed provider "unique name" => "WP post format" map * * @return array */ function snax_get_oembed_provider_name_to_post_format_map() { $map = array( 'youtube' => 'video', 'vimeo' => 'video', 'dailymotion' => 'video', 'flickr' => 'image', 'smugmug' => 'image', 'hulu' => 'video', 'photobucket' => 'image', 'scribd' => '', 'wordpresstv' => 'video', 'polldaddy' => '', 'funnyordie' => 'video', 'twitter' => 'status', 'vine' => 'video', 'soundcloud' => 'audio', 'slideshare' => '', 'instagram' => 'image', 'spotify' => 'audio', 'imgur' => 'image', 'meetup' => '', 'issuu' => 'image', 'collegehumor' => 'image', 'mixcloud' => 'audio', 'ted' => 'video', 'animoto' => 'video', 'tumblr' => 'image', 'kickstarter' => '', 'cloudup' => 'video', 'reverbnation' => 'audio', 'wordpresscom' => '', 'reddit' => '', 'speakerdeck' => '', 'facebook' => '', ); return apply_filters( 'snax_oembed_provider_name_to_post_format_map', $map ); } /** * Return predefined embed providers config * * @return array */ function snax_get_embed_code_providers() { $providers = array( /* * YOUTUBE * * Url to share: https://youtu.be/SyKSWlIioD0 * * Code to embed: * */ 'youtube' => array( 'url_pattern' => '/https?:\/\/www\.youtube\.com\/embed\/([^"]+)/', // Reguired. Pattern to find embed url in embed code. 'url_callback' => 'snax_convert_to_youtube_oembed_url', // Optional. Convert found embed url to be oEmbed valid url. Default: embed url. ), /* * TWITTER * * Url to share: https://twitter.com/sanderwagner/status/722002889498062848 * * Code to embed: *
*

* @GavinHJackson * @grodaeu i have a 100 Q forecasting spreadsheet w subspreadsheets for every question, searchterms and platform links inc *

* — Sander Wagner (@sanderwagner) * April 18, 2016 *
* */ 'twitter' => array( 'url_pattern' => '/https?:\/\/twitter\.com\/[^\/]+\/status\/\d+/', ), /* * INSTAGRAM * * Url to share: https://www.instagram.com/p/BEappqDuS3M/?taken-by=kimkardashian * * Code to embed: *
*
*
*
*
*
*

* blue lagoon! *

*

* Zdjęcie zamieszczone przez użytkownika Kim Kardashian West (@kimkardashian) *

*
*
* */ 'instagram' => array( 'url_pattern' => '/https?:\/\/www\.instagram\.com\/p\/[^\/]+\//', 'url_callback' => 'snax_convert_to_instagram_oembed_url', ), /* * VIMEO * * Url to share: https://vimeo.com/73252373 * * Code to embed: * *

* Day edit at Lower Big Sandy, West Virginia * from * FATTY BROWN * on * Vimeo. *

*/ 'vimeo' => array( 'url_pattern' => '/https?:\/\/vimeo\.com\/\d+/', ), /* * VINE * * Url to share: https://vine.co/v/iUrEF7eQmdb * * Code to embed: * * */ 'vine' => array( 'url_pattern' => '/https?:\/\/vine\.co\/v\/[^\/]+/', ), /* * DAILYMOTION * * Url to share: http://dai.ly/x47155f * * Code to embed: * *
* CAPTAIN AMERICA VS GREY HULK - EPIC BATTLE * przez KjraGaming */ 'dailymotion' => array( 'url_pattern' => '/dailymotion\.com\/embed\/video\/([^\/"]+)/', 'url_callback' => 'snax_convert_to_dailymotion_oembed_url', ), /* * FACEBOOK * * Url to share: WP doesn't support (1.08.16) FaceBook oEmbed * * Code to embed (Post): * * * Code to embed (Video): * */ 'facebook' => array( 'url_pattern' => '/(https?:\/\/www\.facebook\.com\/plugins\/[a-z]+\.php\?href=[^&]+)[^"]+" width="(\d+)" height="(\d+)"/', 'url_callback' => 'snax_convert_to_facebook_oembed_url', ), ); return apply_filters( 'snax_get_embed_code_providers', $providers ); } /** * Filter the embed HTML * * @param string $html Embed code. * @param string $url Embed URL. * @param array $attr Attributes. * * @return string */ function snax_filter_embed_html( $html, $url, $attr ) { $providers = snax_get_embed_code_providers(); // Instagram. if ( preg_match( $providers['instagram']['url_pattern'], $url, $matches ) ) { // Disable captions. if ( false !== strpos( $url, 'snax-ig-captions=0' ) ) { $html = str_replace( 'data-instgrm-captioned', '', $html ); } } return $html; } /** * Try to extract url from passed embed code * * @param string $code Iframe. * * @return string Valid url or empty string. */ function snax_extract_oembed_url( $code ) { $url = ''; $providers = snax_get_embed_code_providers(); foreach ( $providers as $provider_id => $provider ) { if ( preg_match( $provider['url_pattern'], $code, $matches ) ) { $url = $matches[0]; // Run extra parser to conver url if needed. if ( ! empty( $provider['url_callback'] ) && is_callable( $provider['url_callback'] ) ) { $url = call_user_func( $provider['url_callback'], $matches, $code ); } break; } } return apply_filters( 'snax_extract_oembed_url', $url, $code ); } /** * Check whether url points to valid oEmbed service * * @param string $url oEmbed url. * * @return bool */ function snax_is_oembed_url( $url ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $html = $oembed->get_html( $url ); return false !== $html; } /** * Return oEmbed provider * * @param string $url oEmbed url. * * @return false|string */ function snax_get_oembed_provider( $url ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); return $oembed->get_provider( $url ); } /** * Build oEmbed YouTube url * * @param array $matches Regex found parts. * * @return mixed|void */ function snax_convert_to_youtube_oembed_url( $matches ) { $youtube_movie_id = $matches[1]; $url = 'https://youtu.be/' . $youtube_movie_id; return apply_filters( 'snax_convert_to_youtube_oembed_url', $url, $matches ); } /** * Build oEmbed Instagram URL * * @param array $matches Regex found parts. * @param string $code Embed code. * * @return mixed|void */ function snax_convert_to_instagram_oembed_url( $matches, $code ) { $url = $matches[0]; // Instagram without captions. if ( false === strpos( $code, 'data-instgrm-captioned' ) ) { $url = add_query_arg( 'snax-ig-captions', '0', $url ); } return apply_filters( 'snax_convert_to_instagram_oembed_url', $url, $matches ); } /** * Build oEmbed Dailymotion url * * @param array $matches Regex found parts. * * @return mixed|void */ function snax_convert_to_dailymotion_oembed_url( $matches ) { $movie_id = $matches[1]; $url = 'http://dai.ly/' . $movie_id; return apply_filters( 'snax_convert_to_dailymotion_oembed_url', $url, $matches ); } /** * Build oEmbed FaceBook url * * @param array $matches Regex found parts. * * @return mixed|void */ function snax_convert_to_facebook_oembed_url( $matches ) { $url = $matches[1]; $width = $matches[2]; $height = $matches[3]; $width_height = sprintf( '&width=%d&height=%d', $width, $height ); $url .= $width_height; return apply_filters( 'snax_convert_to_facebook_oembed_url', $url, $matches ); } /** * Use short-circuit to compose Facebook oEmbed HTML, until FB native support will be added. * * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. * @param string $url The URL to the content that should be attempted to be embedded. * * @return mixed HTML or null if not allowed. */ function snax_facebook_oembed_result( $result, $url ) { // FB regular post. if ( false !== strpos( $url, 'facebook.com/plugins/post.php' ) ) { // Grab the post width and height from url query string. if ( preg_match( '/width=(\d+)&height=(\d+)/', $url, $matches ) ) { $attr = array( 'width' => $matches[1], 'height' => $matches[2], ); // If failed, fall back to embed defaults. } else { $attr = wp_embed_defaults( $url ); } $result = sprintf( '', $url, $attr['width'], $attr['height'] ); } // FB video post. if ( false !== strpos( $url, 'facebook.com/plugins/video.php' ) ) { $attr = wp_embed_defaults( $url ); $result = sprintf( '', $url, $attr['width'], $attr['height'] ); } return $result; } /** * Get the embed title TODO * * @param str $embed_code Url or iframe code. * @return str */ function snax_get_embed_title( $embed_code ) { $embed_meta = snax_get_embed_metadata( $embed_code ); $title = false; remove_filter( 'oembed_providers', '__return_empty_array' ); $wp_oembed = new WP_oEmbed(); add_filter( 'oembed_providers', '__return_empty_array' ); $provider_url = $wp_oembed->get_provider( $embed_meta['url'] ); if ( ! empty( $provider_url ) ) { $json = file_get_contents( $provider_url . '?url=' . $embed_meta['url']); $json = json_decode( $json ); $title = $json->title; } return (string) $title; } /** * Set Embedly as the only oEmbed provider */ function snax_add_embedly_providers() { if ( ! snax_is_embedly_enabled() ) { return; } add_filter( 'oembed_providers', '__return_empty_array' ); $provider_uri = snax_embedly_uri(); wp_oembed_add_provider( '#https?://[^\s]+#i', $provider_uri, true ); } /** * Build Embedly provider URL * * @return str */ function snax_embedly_uri() { $embedly_api_key = snax_get_embedly_api_key(); $cards_controls = snax_is_embedly_buttons() ? '1' : '0'; $cards_theme = snax_is_embedly_dark_skin() ? '1' : '0'; $cards_width = snax_get_embedly_width(); $cards_align = snax_get_embedly_alignment(); if ( $cards_theme) { $cards_theme = 'dark'; } else { $cards_theme = 'light'; } $option_params = array( 'cards_controls=' . $cards_controls, '&cards_theme=' . $cards_theme, '&cards_align=' . $cards_align, ); if ( $cards_width> 0 ) { $option_params[] = '&cards_width=' . $cards_width; } $base = apply_filters( 'snax_embedly_base_uri', 'https://api.embedly.com/2/card' ); $param_str = '?'; foreach ( $option_params as $key => $value ) { $param_str .= $value; } $key = apply_filters( 'snax_embedly_base_key', 'cedd0120dd674379ab8c9689f2cfe588' ); if ( snax_embedly_verify_cards_key( $embedly_api_key ) ) { $param_str .= '&cards_key=' . $embedly_api_key; } $key_param = '&key=' . $key; $param_str .= $key_param; return $base . $param_str; } /** * Get and save the cards API key using the Embedly API key set in options * * @param str $api_key Embedly API key. * @return bool */ function snax_embedly_verify_cards_key( $api_key ) { if ( ! $api_key ) { return false; } $transient = '_snax_verification_embedly_api_key_' . $api_key; if ( '1' === get_transient( $transient ) ){ return true; } $url = apply_filters( 'snax_embedly_obtain_key_url', 'http://api.embed.ly/1/feature?feature=card_details&key=' ); $url .= $api_key; $result = wp_remote_retrieve_body( wp_remote_get( $url ) ); $result = json_decode( $result ); if ( isset( $result->error_code ) ) { return false; } if ( $result ) { $verification = $result->card_details; set_transient( $transient, $verification, 4 * 60 * 60 ); return true; } else { return false; } } /** * Ensure that the Embedly script is there if needed * * @param str $content The post content. * @return str */ function snax_add_embedly_script( $content ) { if ( ! snax_is_embedly_enabled() ) { return $content; } $embedly_script = apply_filters( 'snax_embedly_script_code', '' ); preg_match_all( '/ 0 && substr_count( $content, $embedly_script ) === 0 ) { $content .= $embedly_script; } return $content; }
Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "snax_add_embedly_providers" not found or invalid function name in /htdocs/wp-includes/class-wp-hook.php:324 Stack trace: #0 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #1 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #2 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #3 /htdocs/wp-config.php(98): require_once('/htdocs/wp-sett...') #4 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #5 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #6 /htdocs/index.php(17): require('/htdocs/wp-blog...') #7 {main} thrown in /htdocs/wp-includes/class-wp-hook.php on line 324