Difficulty including wordpress shortlink in am embedded (iframe) tweet button - php

I am trying to programmatically include a tweet button, in an iframe, on a page. I want this to tweet the wordpress shortlink of a specific post.
I am using PHP to insert into my wordpress database the following HTML iframe code to include the weet button. The code looks like this
'<iframe allowtransparency="true" frameborder="0" scrolling="no"
src="https://platform.twitter.com/widgets/tweet_button.html
?count=horizonatal?url=http://www.mywebsite.com?p= '
. $post_id . '"></iframe>'
As you can see I am concatenating the $post_id, which is in the PHP code, with the rest of the wordpress shortlink "http://www.mywebsite.com?p=". The problem appears to be that the twitter widget interprets the '?' in my url attribute as a query for itself -- as opposed to a query for my wordpress site - and what happens is I can only get http://www.mywebsite.com tweeted.
Does anyone know a way around this?

You need use urlencode:
'<iframe allowtransparency="true" frameborder="0" scrolling="no"
src="https://platform.twitter.com/widgets/tweet_button.html
?count=horizonatal?url='.urlencode('http://www.mywebsite.com?p='.$post_id)
.'"></iframe>'
Reading: http://www.php.net/urlencode

Related

How to get the iframe url for specific domain in WordPress

My WordPress WebSite Posts has different type of iframe tags:
eg:
<iframe src="http://examplesite1.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite2.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite3.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite4.tld/somepageordirectory"></iframe>
I Need WordPress Function for get and replace iframe src for specified (eg: examplesite3.tld) domain eg:
<iframe src="http://examplesite1.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite2.tld/somepageordirectory"></iframe>
<iframe src="/embed.php?ref=http://examplesite3.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite4.tld/somepageordirectory"></iframe>
I'm new in WordPress.
Any Help is Highly appreciated and a lot of sorry about my english.
We need the surrounding code to understand how the page is built, not the displayed code.
To do what you're talking about you would use the surrounding html tags and echo the wordpress variable within it, eg:
<iframe src="<?php echo wp_function( 'variable' );?>"></iframe>

Getting dynamic PHP links and iframe to work?

I'm creating a wordpress theme and am having trouble generating a video link to go into an iframe source. I've tried troubleshooting and it seems that the issue is beyond wordpress and I can't actually input any link with PHP to work with iframe. Here's an example for simplicity's sake.
<iframe src="<?php echo 'https://vimeo.com/159120552'; ?>" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
The PHP works as far as I can tell (when I inspect it, the link is in the correct place), but there appears to be a blank web document created in the iframe instead.
Am I doing something wrong or is this a known issue of iframe and PHP?
This issue not related to PHP . Its throwing an error refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Please refer How to set 'X-Frame-Options' on iframe?

Wordpress- <iframe> is incorrectly interpreting url page content

I'm trying to embed a vimeo player in my Wordpress 3.8 site. To make changing the video a little easier, I've created Page which just contains the url for a Vimeo video. On the site, I try to embed the video like so:
<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="<? echo apply_filters('the_content', get_page(925)->post_content); ?>" webkitallowfullscreen=""></iframe>
But when I view the site, it just loads an empty page template inside the frame! When I echo that php chunk outside the iframe, however, it returns the url as expected. Putting in the url directly causes it to work fine, and I've tried a ton of quotation configurations to make sure the error wasn't there. Any idea what is causing it to wig out?
why are you running apply_filters on this? Also, get_page is deprecated.
Try something like this:
<?php
$vidPost = get_post(925);
echo '<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="'.$vidPost->post_content.'" webkitallowfullscreen=""></iframe>';
?>

Embedded videos don't show up

I have a web site I'm working on and for some reason some of my videos don't display. The first videos display but the next one's don't.
So first one looks like this:
And the rest look like this:
I know the url's I am using are correct, I dump them to the screen and navigated to them to make sure they weren't broken. This is in chrome, same thing happens in IE.
This is the code I am using to embed:
<iframe width="420" height="315" alt="Jesus Culture" src="<?=$row?>"
frameborder="5" allowfullscreen></iframe>
I'm using similar code to yours for multiple videos on one page,
i.e.
<iframe width="425" height="349" src="http://www.youtube.com/embed/video-code" frameborder="0" allowfullscreen=""></iframe>
Make sure that your urls have the embed format. Also try to place the src value hardcoded (no php) to check whether in that case displaying multiple videos on the page will be an issue.

YouTube Embed, URL From Database Query

I want to display a youtube embed using the URL that the user put on their profile.
It works correctly if the URL in the database is http://youtube.com/embed/URL
I'd like users to be able to just input a regular URL (http://youtube.com/URL because I want it to be easy for them.
Is there a way to get around this?
Thanks a lot for any help, I'm quite new at this!
Try copying and pasting this, and see if it works:
echo '<br>';
echo '<iframe width="560" height="315" src="' . stripslashes($row['videourl']) . '" frameborder="0" allowfullscreen></iframe>';
If it's not showing up based on the fact that the person entering the URL doesn't place embed in their link, then what I would recommend is just having the person enter the ID of the video, and you create the rest of the URL.
For example, if the URL to the video a user wants to post is https://www.youtube.com/watch?v=0TL5CSPFzTU then they would just enter 0TL5CSPFzTU and you would output your code as such:
echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . stripslashes($row['videourl']) . '" frameborder="0" allowfullscreen></iframe>';
You'd have to put something in place that stops them from entering the full URL, or anything more than the ID, but there are plenty of tutorials out there for accomplishing that.

Categories