WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Page Publish 2
[resolved] Make meta tags optional (2 posts)

  1. David Hunt
    Member
    Posted 1 year ago #

    Would it be possible to provide an option in the plugin settings, to make the rendering of the Open Graph tags optional?

    Like many other people, I use Yoast's WordPress SEO plugin, which can also add the Facebook meta tags to the header, so there is conflict with this plugin. It would be useful to allow the user to choose which plugin's approach to the meta tags he/she wants to use.

    Therefore, adding a "Add Facebook meta tags?" checkbox to this plugin's settings would be a very welcome feature.

    http://wordpress.org/extend/plugins/facebook-page-publish-2/

  2. David Hunt
    Member
    Posted 1 year ago #

    I've managed to add this feature myself. Anyone looking to also add it (or if the developers want to considering adding to the next version), here is a rough guide of how to edit fpp_index.php:

    • Look for the function fpp_render_options_page() which renders the plugin's settings. Inside that function, just before the submit button code, add the following:
      <table class="form-table">
      	<tr valign="top">
      		<th scope="row"><?php _e('Open Graph meta data', FPP_TEXT_DOMAIN) ?></th>
      		<td>
      			<label><input id="fpp_options-add_meta_data" type="checkbox" name="fpp_options[add_meta_data]" value="1" <?php checked('1', $options['add_meta_data']); ?> /> <?php _e('Add meta tags to header?', FPP_TEXT_DOMAIN) ?></label>
      		</td>
      	</tr>
      </table>
    • Now locate the fpp_render_meta_tags() function, and enclose its contents in an if statement which tests for the add_meta_data option:
      $options = get_option('fpp_options');
      if ($options['add_meta_data']) :
      	echo '<meta property="og:type" content="article"/>'; // Required by FB
      	.
      	.
      	.
      	echo '<meta property="og:image" content="'.esc_attr($image_url)/*, ENT_COMPAT, 'UTF-8')*/.'"/>';
      endif;
    • Locate fpp_validate_options() and add the following to the "Customization options" section:
      $options['add_meta_data'] = array_key_exists('add_meta_data', $input) && !empty($input['add_meta_data']);
    • Locate fpp_initialize_options() and add 'add_meta_data' => false to the $options array.

    I hope that's clear enough!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic