Export $fb_ variables value
-
First, many thanks Marco for your useful plugin.
I’m trying to use the values of some variables values after calculated in your webdados_fb_open_graph() function.
So I’ve added an external class to export these values in a file called:
include/class-wonderm00n_og_export.php
Here’s the code:if ( ! class_exists( 'wonderm00n_og_export' ) ) { class wonderm00n_og_export { public static $instance; public $locale; public $title; public $url; public $type; public $desc; public $image; public $image_additional; public function __construct() { self::$instance = $this; } public static function get_instance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } public function save_external( $locale, $title, $url, $type, $desc, $image, $image_additional ) { $this->locale = $locale; $this->title = $title; $this->url = $url; $this->type = $type; $this->desc = $desc; $this->image = $image; $this->image_additional = $image_additional; } } // end class wonderm00n_og_export } // end class_exists $wm00nOgExp = new wonderm00n_og_export();
And few lines just before the end of webdados_fb_open_graph() function:
function webdados_fb_open_graph() { [...] include_once 'includes/class-wonderm00n_og_export.php'; $wm00nOgExp->save_external( $fb_locale, $fb_title, $fb_url, $fb_type, $fb_desc, $fb_image, $fb_image_additional ); echo $html; }
In this way I can refer to any of these variable in my pages, after that action wp_head fires. For instance :
$canonical = ""; if(class_exists( 'wonderm00n_og_export' )) { $wm00nOgExp = wonderm00n_og_export::get_instance(); if(isset($wm00nOgExp->url)) $canonical = $wm00nOgExp->url; }
It should be better if you could calculate these values before wp_head action, to be useful also for other wp_head functions.
Hope you can integrate this code, or something like this, in your future release of the plugin.
https://www.ads-software.com/plugins/wonderm00ns-simple-facebook-open-graph-tags/
- The topic ‘Export $fb_ variables value’ is closed to new replies.