You’ll need to edit the code. If you have suggestions based on how other plugins do it, let us know. Thanks
To customize positions in your template without altering the plugin core; what you can do is disable Facebook plugin’s main init filter which automates the whole sequence, and custom manage each widgets/hooks in your theme.
Put remove_action( ‘init’, ‘fb_apply_filters’ ) in your theme’s functions.php, then apply each filters (or just echo each functions) individually in your templates.
For example, you can do:
<?php if (comments_open() && isset($fb_ver) && isset($options[‘comments’][‘enabled’])) echo fb_comments_automatic(”); ?>
to insert the comments where ever you like, instead of “in the_content() filter”.
You’ll find the list of functions and default filters in the fb-social-plugin.php file for reference.
That’s how I decided to deal with it, to have more flexibility, yet have the benefits of an untouched plugin, which can be updated safely. At least for minor versions.
Down the road, major plugin updates could affect your theme here and there, and/or require a few adjustments for new features. But at least, it prevents from having to touch the plugin at all, and still benefit of its overall functionality and fixes.
I hope it help others too.
Matt, would have to have an option to hide the comments not only on certain pages as well as the other buttons.
As you requested a plugin here is a sample:
Matt: Most of the plugins provide a method to implement the comments box using a shortcode which is highly preferred by the developers as it gives the ability to include the box where we want. I am currently using the http://wordpress.org/extend/plugins/facebook-awd/ plugin which provides the ability to add the comment box using a shortcode. I am sure the rest will prefer the same way as well.
B: Thank you for the method. I will give it a shot when I get some time and will let you know how it works out. That is the most important point I decided to use the official plugin as well so that it doesnt interfere with anything and works as it should. A non touched plugin.
Every time one finds inefficient code like this. God kills a kitten!
require_once( dirname(__FILE__) . ‘/fb-activity-feed.php’);
require_once( dirname(__FILE__) . ‘/fb-recommendations.php’);
require_once( dirname(__FILE__) . ‘/fb-like.php’ );
require_once( dirname(__FILE__) . ‘/fb-send.php’ );
require_once( dirname(__FILE__) . ‘/fb-subscribe.php’ );
require_once( dirname(__FILE__) . ‘/fb-comments.php’ );
require_once( dirname(__FILE__) . ‘/fb-recommendations-bar.php’ );
An instead of:
if ( array_key_exists( ‘comments’, $options ) && array_key_exists( ‘enabled’, $options[‘comments’] ) && $options[‘comments’][‘enabled’] )
if ( isset($options[‘comments’][‘enabled’]) )
Needless to say:
array_key_exists( ‘enabled’, $options[‘comments’] )
is the the exact same thing as:
Come one guys. This is utter redundant fail!
WordPress is already a bloated pile of repetitive code with its countless inefficient plugins. Let’s not keep piling needless junk code on top of it please.
That fb-social-plugin.php file alone could be twice as efficient and small, as it is now.
I followed what you said I inserted the code in the desired position but Facebook comment is not showing up.
I add this code to function.php
remove_action( 'init', 'fb_apply_filters' );
And add this to single.php
<?php if (comments_open() && isset($fb_ver) && isset($options['comments']['enabled'])) echo fb_comments_automatic(''); ?>
I also try
<?php echo fb_comments_automatic(''); ?>
But its also not working.
Sorry, I forgot to mention that $options is for get_option(‘fb_options’);
You can do this instead:
<?php if (comments_open() && isset($fb_ver) && ($fb_options = get_option(‘fb_options’)) && isset($fb_options[‘comments’][‘enabled’])) echo fb_comments_automatic(”); ?>
Though keep in mind that this will ignore the “Show on” post types selection which was later added with revisions 1.0.x.
And don’t forget you might also need to add the other filters manually in your functions.php, such as fb_hide_wp_comments or fb_get_comments_count, etc… which are normally called within the fb_apply_filters() function.
Thank you for your quick response and helping hand. But I am afraid to say, I don’t know how to apply fb_get_comments_count and fb_hide_wp_comments filter in function.php
so I put the new code in the desired area and it is showing this error message:
<b>Fatal error</b>: Call to undefined function fb_comments_automatic() in <b>/..../public_html/wp-content/themes/nbee/single.php</b> on line <b>1</b>
If fb_comments_automatic() is undefined; your plugin is likely not activated…
While the code I gave you should work for just displaying comments. It’s not a complete implementation… It seems like you probably shouldn’t try and do this without the adequate php/wordpress hooks knowledge.
My hint was directed at someone who can understand the fb_apply_filters() hooks in the fb-social-plugin.php. Without that, it’s a little too complicated for me to assist you with details.
The above won’t work with the latest version, because the ‘geniuses’ at Facebook decided to change everything with the new version 1.1.x, which is not backward compatible.
So just think twice before updating the plugin beyond 1.0.2!
Nods @jbx, I personally managed to upgrade but figuring the drastic changes was a PITA.
Sadly, Niall now made it impossible to easily remove the “new” public_init filter/sequence and customize it, so I can’t really help with any easy solution.
For savvy phpers who need a hint… Now the only “wp like” solution one could think of is to remove the filters() used in Facebook_Loader::public_init(), then call the Facebook render functions for what you need, directly in your template…
- The topic ‘[Plugin: Facebook] Re position the comments box’ is closed to new replies.