SocialShareOG - Version 3.0.2

Version Notes

Open Graph Protocol Updates
Changed is_empty value check
added default price 0.00 for type 'product' as to Facebook requirements
Striping HTML Before using htmlspecialchars

Download this release

Release Info

Developer Roy Toledo
Extension SocialShareOG
Version 3.0.2
Comparing to
See all releases


Code changes from version 3.0.1 to 3.0.2

app/design/frontend/base/default/template/socialshare/head.phtml CHANGED
@@ -1,8 +1,5 @@
1
  <!-- BEGIN SocialShare - OpenGraphTags Head -->
2
  <?php
3
- /*
4
- TODO: Test Category Stuff
5
- */
6
 
7
  $_socialShareOgData = array();
8
  $_imageSize = array('x' => 200 , 'y' => 200);
@@ -15,36 +12,46 @@
15
 
16
  /* Defaults */
17
  $_socialShareOgData["og:type"] = "article";
18
- $_socialShareOgData["og:title"] = htmlspecialchars($this->getLayout()->getBlock('head')->getTitle());
19
  $_socialShareOgData["og:url"] = Mage::helper('core')->escapeHtml(Mage::helper('core/url')->getCurrentUrl());
20
- $_socialShareOgData["og:description"] = strip_tags( htmlspecialchars( $this->getLayout()->getBlock('head')->getDescription() ) );
21
  //$_socialShareOgData["og:description"] = strip_tags($this->getDescription());
22
  $_socialShareOgData["og:site_name"] = Mage::app()->getStore()->getFrontEndName();
23
 
24
  /* Product Pages */
25
  if($_product = Mage::registry('current_product')) {
26
  $_socialShareOgData["og:type"] = "product";
27
- $_socialShareOgData["og:title"] = htmlspecialchars($_product->getName());
28
  $_socialShareOgData["og:image"] = Mage::helper('catalog/image')->init($_product, 'image');//->resize($_imageSize['x'], $_imageSize['y']); //Causes Errors with the Facebook Debugger
29
  $_socialShareOgData["og:url"] = $_product->getProductUrl();
 
30
  if( empty($_socialShareOgData["og:description"]) )
31
  $_socialShareOgData["og:description"] = htmlspecialchars(strip_tags(($_product->getShortDescription())));
32
 
33
  /* Pricing */
34
  if (Mage::getStoreConfig('sales/msrp/enabled') != "1") { // MAP pricing NOT enabled
35
  if ($_product->getFinalPrice() && $_product->getFinalPrice() <> $_product->getPrice()) { // Product on sale (or catalog price rule applied)
36
- $_socialShareOgData["og:price:standard_amount"] = $_product->getPrice();
37
- $_socialShareOgData["og:price:amount"] = $_product->getFinalPrice();
38
- $_socialShareOgData["og:product:price:amount"] = $_product->getFinalPrice(); // required by FB in lieue if the standard og:price:amount
 
 
 
 
39
  } else { // Product not on sale
40
- $_socialShareOgData["og:price:standard_amount"] = $_product->getPrice();
41
- $_socialShareOgData["og:price:amount"] = $_product->getSpecialPrice();
42
- $_socialShareOgData["og:product:price:amount"] = 0.00; // required by FB
43
  }
44
- $_socialShareOgData["og:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
45
  } elseif ($_product->getMsrp()) { // MAP pricing enabled and product has MSRP
46
- $_socialShareOgData["og:price:standard_amount"] = $_product->getMsrp();
47
- $_socialShareOgData["og:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
 
 
 
 
 
 
48
  }
49
 
50
  /* Product Rating */
@@ -65,7 +72,7 @@
65
  // $cur_category = Mage::getModel('catalog/category')->load($_category->getId());
66
  // $imageUrl = $cur_category->getImageUrl();
67
  $_socialShareOgData["og:type"] = "product.group";
68
- $_socialShareOgData["og:title"] = htmlspecialchars($_category->getName());
69
  $_socialShareOgData["og:url"] = $_category->getUrl();
70
  $_socialShareOgData["og:image"] = $_category->getImageUrl();
71
  }
@@ -75,9 +82,6 @@
75
  $_socialShareOgData["og:type"] = "website";
76
  }
77
 
78
- /* Clear null/empty keys */
79
- $_socialShareOgData = array_filter($_socialShareOgData);
80
-
81
  /* Default Image */
82
  if(!array_key_exists("og:image", $_socialShareOgData)) {
83
  if (Mage::getStoreConfig('opengraphtags/defaults/default_image')) {
@@ -88,7 +92,8 @@
88
 
89
  /* Print OG Tags */
90
  foreach($_socialShareOgData as $key => $value) {
91
- echo "<meta property=\"{$key}\" content=\"{$value}\" />\n";
 
92
  }
93
  ?>
94
  <!-- END SocialShare - OpenGraphTags Head -->
1
  <!-- BEGIN SocialShare - OpenGraphTags Head -->
2
  <?php
 
 
 
3
 
4
  $_socialShareOgData = array();
5
  $_imageSize = array('x' => 200 , 'y' => 200);
12
 
13
  /* Defaults */
14
  $_socialShareOgData["og:type"] = "article";
15
+ $_socialShareOgData["og:title"] = strip_tags($this->getLayout()->getBlock('head')->getTitle());
16
  $_socialShareOgData["og:url"] = Mage::helper('core')->escapeHtml(Mage::helper('core/url')->getCurrentUrl());
17
+ $_socialShareOgData["og:description"] = strip_tags( $this->getLayout()->getBlock('head')->getDescription() ); //Head Meta Descripion
18
  //$_socialShareOgData["og:description"] = strip_tags($this->getDescription());
19
  $_socialShareOgData["og:site_name"] = Mage::app()->getStore()->getFrontEndName();
20
 
21
  /* Product Pages */
22
  if($_product = Mage::registry('current_product')) {
23
  $_socialShareOgData["og:type"] = "product";
24
+ $_socialShareOgData["og:title"] = strip_tags($_product->getName());
25
  $_socialShareOgData["og:image"] = Mage::helper('catalog/image')->init($_product, 'image');//->resize($_imageSize['x'], $_imageSize['y']); //Causes Errors with the Facebook Debugger
26
  $_socialShareOgData["og:url"] = $_product->getProductUrl();
27
+
28
  if( empty($_socialShareOgData["og:description"]) )
29
  $_socialShareOgData["og:description"] = htmlspecialchars(strip_tags(($_product->getShortDescription())));
30
 
31
  /* Pricing */
32
  if (Mage::getStoreConfig('sales/msrp/enabled') != "1") { // MAP pricing NOT enabled
33
  if ($_product->getFinalPrice() && $_product->getFinalPrice() <> $_product->getPrice()) { // Product on sale (or catalog price rule applied)
34
+
35
+ $_socialShareOgData["product:original_price:amount"] = $_product->getPrice();
36
+ $_socialShareOgData["product:original_price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
37
+
38
+ $_socialShareOgData["product:price:amount"] = $_product->getFinalPrice();
39
+ $_socialShareOgData["product:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
40
+
41
  } else { // Product not on sale
42
+ $_socialShareOgData["product:price:amount"] = $_product->getPrice();
43
+ $_socialShareOgData["product:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
44
+
45
  }
 
46
  } elseif ($_product->getMsrp()) { // MAP pricing enabled and product has MSRP
47
+ $_socialShareOgData["product:price:amount"] = $_product->getMsrp();
48
+ $_socialShareOgData["product:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
49
+ }
50
+
51
+ if(empty($_socialShareOgData["product:price:amount"])){
52
+ //Default Price, Mandetory Value
53
+ $_socialShareOgData["product:price:amount"] = '0.00'; //Default, Price is mendatory for this object
54
+ $_socialShareOgData["product:price:currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
55
  }
56
 
57
  /* Product Rating */
72
  // $cur_category = Mage::getModel('catalog/category')->load($_category->getId());
73
  // $imageUrl = $cur_category->getImageUrl();
74
  $_socialShareOgData["og:type"] = "product.group";
75
+ $_socialShareOgData["og:title"] = strip_tags($_category->getName());
76
  $_socialShareOgData["og:url"] = $_category->getUrl();
77
  $_socialShareOgData["og:image"] = $_category->getImageUrl();
78
  }
82
  $_socialShareOgData["og:type"] = "website";
83
  }
84
 
 
 
 
85
  /* Default Image */
86
  if(!array_key_exists("og:image", $_socialShareOgData)) {
87
  if (Mage::getStoreConfig('opengraphtags/defaults/default_image')) {
92
 
93
  /* Print OG Tags */
94
  foreach($_socialShareOgData as $key => $value) {
95
+ if(!empty($value))
96
+ echo "<meta property=\"{$key}\" content=\"{$value}\" />\n";
97
  }
98
  ?>
99
  <!-- END SocialShare - OpenGraphTags Head -->
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SocialShareOG</name>
4
- <version>3.0.1</version>
5
  <stability>stable</stability>
6
  <license>GNU</license>
7
  <channel>community</channel>
@@ -9,22 +9,14 @@
9
  <summary>Open Graph Tags support for Magento store</summary>
10
  <description>This Easy to use extension adds automatic Open Graph Meta Tags for your Magento store&#xD;
11
  </description>
12
- <notes>1. Moved layout XML into a socialshare folder&#xD;
13
- 2. Moved design phtml into base/default to support fallback of non-default based themes&#xD;
14
- 3. Added logic to prevent Facebook Share JS from loading if no FB app-id is specified (body.html) -&gt; prevents load &amp; js errors for users who only need the OG metadata.&#xD;
15
- 4. Added image upload functionality in adminhtml configuration for a default OG image (website logo, for instance). This is only loaded if no other image is found, and is not required.&#xD;
16
- 5. Added OG Tags support for the homepage and Category pages&#xD;
17
- 6. Added support for category images&#xD;
18
- 7. Added support for MAP (if enabled in magento core config), final price vs special price/price and related logic.&#xD;
19
- 8. Added support for product ratings&#xD;
20
- 9. Built logic around an array to allow for defaults to be inserted for missing data.&#xD;
21
- 10. Naming, capitalization and spelling in system.xml -&gt; nothing that changes configuration values that already existed.&#xD;
22
- 11. Added Price tag to priceless products&#xD;
23
- </notes>
24
  <authors><author><name>Roy Toledo</name><user>NikNak</user><email>toledoroy@gmail.com</email></author></authors>
25
- <date>2015-08-31</date>
26
- <time>17:00:59</time>
27
- <contents><target name="magecommunity"><dir name="SocialShare"><dir name="OpenGraphTags"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Color.php" hash="ec237e9de0c6de32f75f1419a337defb"/><file name="Font.php" hash="a25370be2d6777fc30fa295888d59800"/><file name="Language.php" hash="d31bd885a47e85565d2b553d41664cdf"/><file name="Layout.php" hash="0e0c072db9b994d340e5a876fabfc470"/><file name="Verb.php" hash="502714d6b8e0b6dfb592e8f78753869a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0d955fa9a94fddc4e5fe8b6c87f1cece"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Localization.php" hash="124bfcf8e6be20123772da9c5c458989"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="000d6508eaaec0ab8f9ca63d5bd1418a"/><file name="config.xml" hash="efdb49f4ced5ec95afd300797f1ec187"/><file name="system.xml" hash="bbbba32503774d6adabaf78aeafecd8c"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="socialshare"><file name="OpenGraphTags.xml" hash="fab44e385036aa51b436aee01baed864"/></dir></dir><dir name="template"><dir name="socialshare"><file name="head.phtml" hash="a42bc12db3810eaf86987a00a8b0160c"/><file name="body.phtml" hash="a978f917347c374dbe8fb9145d22df94"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SocialShare_OpenGraphTags.xml" hash="820d4be224ecac5ad1ba1a7e23cb7b55"/></dir></target></contents>
28
  <compatible/>
29
- <dependencies><required><php><min>4.0.0</min><max>6.8.0</max></php></required></dependencies>
30
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SocialShareOG</name>
4
+ <version>3.0.2</version>
5
  <stability>stable</stability>
6
  <license>GNU</license>
7
  <channel>community</channel>
9
  <summary>Open Graph Tags support for Magento store</summary>
10
  <description>This Easy to use extension adds automatic Open Graph Meta Tags for your Magento store&#xD;
11
  </description>
12
+ <notes>Open Graph Protocol Updates&#xD;
13
+ Changed is_empty value check&#xD;
14
+ added default price 0.00 for type 'product' as to Facebook requirements&#xD;
15
+ Striping HTML Before using htmlspecialchars</notes>
 
 
 
 
 
 
 
 
16
  <authors><author><name>Roy Toledo</name><user>NikNak</user><email>toledoroy@gmail.com</email></author></authors>
17
+ <date>2015-09-14</date>
18
+ <time>05:35:59</time>
19
+ <contents><target name="magecommunity"><dir name="SocialShare"><dir name="OpenGraphTags"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Color.php" hash="ec237e9de0c6de32f75f1419a337defb"/><file name="Font.php" hash="a25370be2d6777fc30fa295888d59800"/><file name="Language.php" hash="d31bd885a47e85565d2b553d41664cdf"/><file name="Layout.php" hash="0e0c072db9b994d340e5a876fabfc470"/><file name="Verb.php" hash="502714d6b8e0b6dfb592e8f78753869a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0d955fa9a94fddc4e5fe8b6c87f1cece"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Localization.php" hash="124bfcf8e6be20123772da9c5c458989"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="000d6508eaaec0ab8f9ca63d5bd1418a"/><file name="config.xml" hash="efdb49f4ced5ec95afd300797f1ec187"/><file name="system.xml" hash="bbbba32503774d6adabaf78aeafecd8c"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="socialshare"><file name="OpenGraphTags.xml" hash="fab44e385036aa51b436aee01baed864"/></dir></dir><dir name="template"><dir name="socialshare"><file name="head.phtml" hash="98ca8e26361f7aec07520a3574a3788e"/><file name="body.phtml" hash="a978f917347c374dbe8fb9145d22df94"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SocialShare_OpenGraphTags.xml" hash="820d4be224ecac5ad1ba1a7e23cb7b55"/></dir></target></contents>
20
  <compatible/>
21
+ <dependencies><required><php><min>4.0.0</min><max>7.0.0</max></php></required></dependencies>
22
  </package>