YouTube API 403 error when website restriction set

If you restrict the application (or API key) by HTTP referrers, then your remote HTTP request should include a valid HTTP_REFERER header, which wp_remote_get() does not set by default. And you can set the header using the headers argument like so where the array key is referer (note that it’s not double “r” as in … Read more

Custom youtube shortcode that uses $content

Shortcode functions accept a second parameter which contains the value in between the shortcode opening and closing tags: function youtube( $atts, $value=”http://” ) { extract( shortcode_atts( array( “width” => ‘620’, “height” => ‘350’, “name”=> ‘movie’, “allowFullScreen” => ‘true’, “allowScriptAccess”=>’always’, ), $atts ) ); return ‘<object style=”height: ‘.$height.’px; width: ‘.$width.’px”><param name=”‘.$name.'” value=”‘.$value.'”><param name=”allowFullScreen” value=”‘.$allowFullScreen.'”></param><param name=”allowScriptAccess” value=”‘.$allowScriptAccess.'”></param><embed … Read more

Embedding Youtube video on comments

Just add the comments to oEmbed. Here’s a small plugin that you can use as MU-Plugin or normal plugin and that should explain what’s going on pretty well. <?php defined( ‘ABSPATH’ ) or exit; /* Plugin Name: (#105942) oEmbed Comments */ add_filter( ‘comment_text’, ‘wpse_105942_oembed_comments’, 0 ); function wpse_105942_oembed_comments( $comment ) { add_filter( ’embed_oembed_discover’, ‘__return_false’, 999 … Read more

Div around YouTube video

I’m not sure why that’s not working except maybe you need to put the returned stuff in a variable? This is what works for me when I put it in my functions.php file: add_filter( ’embed_oembed_html’, ‘tdd_oembed_filter’, 10, 4 ) ; function tdd_oembed_filter($html, $url, $attr, $post_ID) { $return = ‘<figure class=”video-container”>’.$html.'</figure>’; return $return; }

Forcing WP to embedd a video when using a shortcode

There may be a more graceful way to do this, but it works: function shortcode_youtube($atts) { extract(shortcode_atts(array( “id” => ”, “align” => ‘aligncenter’ ), $atts)); global $wp_embed; $content=”‘; $embed = $wp_embed->run_shortcode( $content ); return ‘<div class=”‘.$align.'”>’ . $embed . ‘</div>’; } add_shortcode(“youtube”, “shortcode_youtube”);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)