chuckreynolds / wpfbogp Goto Github PK
View Code? Open in Web Editor NEWWordPress Open Graph plugin development
Home Page: wordpress.org/plugins/wp-facebook-open-graph-protocol/
WordPress Open Graph plugin development
Home Page: wordpress.org/plugins/wp-facebook-open-graph-protocol/
I have the plugin configured in a way that it always adds the fallback image.
Right now I see a behavior where the fallback image is the first image and the (for example) post-image is the second.
<meta property="og:image" content="https://asset1.betterplace.org/assets/default/og-image.betterplace.png"/>
<meta property="og:image" content="http://www.betterplace.org/c/ueber-uns/files/2014/05/generic-content-header_desktop-1024x448.jpg"/>
With this code Facebook takes the fallback as primary image.
Screenshot: https://developers.facebook.com/tools/debug/og/object/ shows:
In the code, there is a place that manually changes the order of the array. So it looks like, the plugin should behave correctly already. See https://github.com/chuckreynolds/WPFBOGP/blob/master/wp-facebook-ogp.php#L188
Question:
Thanks
right now if there's a default image it shows up last in the array according to the debugger (and google plus). Need to flip that order so if there's a default image link it'll show first on FB.
Also consider if the checkbox is set to only default then we may not want to display the rest of images in the array at all.
Considering adding some small designators in the comment output code that would tell me the setup people have a little more.. only this plugin.. nothing invasive but...
for example:
In order as an example.. maybe something like diYftNfbN
.
Would help me with support in the WP forums as nobody ever relays that info.
Just to make the repo prettier and I plan to look into setting up unit tests with travis at some point.
Add:
This should allow us to grab all images in the post, whether they are in a gallery or included directly in the post content.
Mobile (which is bigger ?? hokay - should default to this)
~~> Image aspect ratio: 1.91:1 ~~
> Image specs in ad: 560x292 px
~~> If the uploaded image is smaller than ~~
~~> 560x292 px, then it will render as 100x100px ~~
> MAX 110 characters (90 preferable)
Desktop
~~> Image aspect ratio: 1.91:1 ~~
~~> Image specs in ad: 400x209 px ~~
~~> If the uploaded image is smaller than ~~
~~> 400x209 px, then it will render as 154x154 ~~
~~> or 90x90 px (the largest available size) ~~
> MAX 500 characters
edit: optimal sizes now: "Use images that are at least 1200 x 630 pixels for the best display on high resolution devices. At the minimum, you should use images that are 600 x 315 pixels to display link page posts with larger images."
source:
Is there a way to set the fallback image globally for my multiside? The same as with the app_id (#2 (comment))?
Thanks
This support request had some weird shit going on in adminID
and appID
output... not sure what they did but need to make sure we're scrubbing that.
<meta property="fb:admins" content="100000195032462"100000195032462"/>
<meta property="fb:app_id" content="1801701280113135"1801701280113135"/>
edit: need to better sanitize them all lol.
<meta property="og:title" content="Nutrition : qui écouter ?"/>
Nutrition : qui écouter ?
The Facebook Debug Tool (https://developers.facebook.com/tools/debug/og/object/) gives me the following error for our wordpress pages.
I see this error for the first time so I guess facebook changed their behavior!
We have some logik somewhere in wordpress (probably core, since I cannot find any plugins or custom changes about this) that will always redirect you to the version of an url that ends in "/" -> https://www.betterplace.org/c/neues is redirected to https://www.betterplace.org/c/neues/
The bug:
The the og-URL says <meta property="og:url" content="https://www.betterplace.org/c/ueber-uns"/>
(without the trailing slash)
How can I fix this?
function wpfbogp_admin_warnings
is being displayed to all logged in users - even on the subscriber level.
solution is adding: if ( current_user_can('manage_options') )
as condition but it does not work due to some wordpress limitation because the user level can not be determined at that point.
Although in my OOP code https://github.com/Foe-Services-Labs/WPFBOGP/blob/oop-conversion/wp-facebook-ogp.php#L128 it's working fine.
-> OOP rulez! 👿
https://developers.facebook.com/docs/technical-guides/opengraph/built-in-objects/
probably need to add in
if is_home -> type=blog
else is_single -> type=article
else is_page -> type=website
something like that
Nothing serious. Just to clarify.
What is the right license so I can sync it all around the files?
GPLv2
or
GPLv2 or later
We have this in for twentyten and twentyeleven as they add stuff to the excerpt... wanted to check if twentytwelve did the same thing and if so add it in
Notice: Undefined index: wpfbogp_force_fallback in /var/www/public/wp-content/plugins/WPFBOGP/wp-facebook-ogp.php on line 408
function wpfbogp_validate($input) {
$input['wpfbogp_admin_ids'] = wp_filter_nohtml_kses($input['wpfbogp_admin_ids']);
$input['wpfbogp_app_id'] = wp_filter_nohtml_kses($input['wpfbogp_app_id']);
$input['wpfbogp_fallback_img'] = wp_filter_nohtml_kses($input['wpfbogp_fallback_img']);
$input['wpfbogp_force_fallback'] = ($input['wpfbogp_force_fallback'] == 1) ? 1 : 0;
return $input;
}
Need to check if WordPress is 3.5 or higher.
Thoughts?
Would like to be able to exclude the itunes image buttons on my site from being included in the og:image tags. A field on the settings page where we could paste the URLs to such images, maybe as a comma separated list, would be useful.
is_home() && get_option('page_for_posts')
is a page that's showing the blog. we should check to see if that has a featured image and then display it. currently it ignores it because it's is_home.
Update helper_codes at bottom of output too.
article:publisher lets a publisher link an article to their own Facebook page. When the article is shared in News Feed, a "like" button is displayed so people can like the publisher page.
<meta property="article:publisher" content="https://www.facebook.com/cnn" />
article:author lets a publisher link an article to the Facebook profile of the author. When the article is shared in News Feed, a "follow" button is displayed so people can follow the author. The author needs to have Follow activated on his or her profile for this button to appear.
<meta property="article:author" content="https://www.facebook.com/fareedzakaria" />
Problem comes in when they don't have social links in meta w/ a plugin or anything... do I want to add that to this plugin? fuck no.
Plugin still works fine for the "good" rules for FB w/o these but just consider for future:
https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content/#tags
Why did you place the uninstall outside of the class?
It will work fine within the main class.
After I upgraded to 2.0.12 the plugin is adding a trailing slash to the og:url. Like this:
whereas before it was like this:
So now Facebook debugger says that there is a circular redirect path detected.
Let me know how I can change this to work how it was before.
Thanks!
add_filter( 'jetpack_enable_open_graph', '__return_false' );
seems *.html extensions forced in urls - we're still adding the trailing slash. ugh.
In edge-cases the canonical URL returned via WP has a trailing slash when some apache installs do not enforce it therefore wpfbogp returns the og:url with no trailing slash triggering a redirect loop error with Facebook Debugger.
Consider optional replacement:
http://kovshenin.com/2012/current-url-in-wordpress/
global $wp;
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
First off it needs a super fallback in case no excerpt or no content; which agreeably is rare but it happens. Also need a fallback if description is empty. which again; rare but... happens.
Secondly, and optionally, I'd like to try and filter for seo plugins. Hence smarter.
Hi @chuckreynolds ,
I moved the whole code to a class and everything is working.
If you got some time have a look at the changes: https://github.com/Foe-Services-Labs/WPFBOGP/tree/oop-conversion
Let me know what you think.
Regards,
Christian
We use img tags with src="//imghostname/path_to/xyz.jpg" URLs that don't have the protocol. This allows HTTP pages to use an HTTP URL and HTTPS pages to use an HTTPS URL.
The WPFBOG plugin turns this into:
<meta property="og:image" content="https://bloghostname/blogpath/imghostname/path_to/xyz.jpg"/>
The preg_match() call on line 57 needs to be modified to check for a valid "//" prefix URL match.
<meta property="og:image" content="http://redacted.com/wp-content/uploads/2014/04/facebookicon.jpg"/>
<meta property="og:image" content="http://redacted.com/wp-content/uploads/2014/04/facebookicon.jpg"/>
look into it
Should be using the built-in sanitize_text_field
options instead of running wp_filter_nohtml_kses
on everything...
https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/formatting.php#L3792
"$1350" in title in 2.0.7 displays fine in meta
displays as "| 50" in 2.1b
The software uses incorrect headings in admin screens. See https://make.wordpress.org/core/2015/10/28/headings-hierarchy-changes-in-the-admin-screens/ for more.
The find_images
method already does this for all images in the post that aren't the featured image. (lines 92-96)
The same logic would need to be added starting around line 266 where the post thumbnail is added to the $wpfbogp_images
array. I didn't think it would be possible for this to not have the full URL, but if a site has the "Full URL path to files" set in the Media settings (ugh), this will happen.
If, by chance, this could make it into a 2.0.11 release, that would be awesome and I can happily throw away my forked version of the plugin. 😃
stuff like nextgen facebook, ultimate seo?, wpseo fb setting, facebook plugin, aioseo, etc.
[edit] jetpack jetpack_enable_open_graph
exists already
On some posts (written in Icelandic) I've noticed that the meta description is missing.
This happens on wp 3.6.1 with plugin version 2.0.7.
I'm not sure what exactly triggers this, but I managed to solve it by replacing this line:
$description = str_replace( "\r\n", ' ' , substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, 160 ) );
with:
$charset = get_option( 'blog_charset' );
if( ! $charset )
$charset = 'UTF-8';
$wpfbogp_description = str_replace( "\r\n", ' ' , mb_substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, 160, $charset ) );
where I use mb_substr() instead of substr(), i.e. the multi-byte version of substr().
This is one request of many. http://wordpress.org/support/topic/oglocale-for-japan-needs-a-little-change
I'd like to not get to a point where it needs to be a dropdown in settings but that's super super last resort. Should just handle with locale() but fix WP's weirdness.
Lately I've been considering not showing the fallback image if there's a featured image present. Thought is - if you have a featured image it's probably more important than a fallback image and because FB sometimes pulls the image array in different orders - the fallback gets shown sometimes when it should use the featured image.
Open to opinions here.
Look into adding in this. https://github.com/Automattic/get-the-image
should clear up the rare image acquisition problems.
Facebook doesn't seem to require those be filled out anymore. They're still there for Domain Insights but not required.
References:
Only things marked as required now are og:title
and og:type
if ( ! function_exists( 'get_attached_media' ) ) {
$attachments = get_attached_media( 'image', $post->ID );
}
http://codex.wordpress.org/Function_Reference/get_attached_media
have to use the array format [http://ogp.me/#array]
instead of
meta property="fb:admins" content="1111111111,222222222" />
must now be
meta property="fb:admins" content="1111111111" />
meta property="fb:admins" content="2222222222" />
need to add if
add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
code they use to detect FB I should add too:
if ( in_array( 'facebook/facebook.php', $active_plugins ) )
add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.