All_in_One_SEO_Pack_Opengraph

The All In One SEO Pack All in One SEO Pack Opengraph class.

Defined (1)

The class is defined in the following location(s).

/modules/aioseop_opengraph.php  
  1. class All_in_One_SEO_Pack_Opengraph extends All_in_One_SEO_Pack_Module { 
  2. var $fb_object_types; 
  3. var $type; 
  4.  
  5. function __construct() { 
  6. $this->name = __( 'Social Meta', 'all-in-one-seo-pack' ); // Human-readable name of the plugin 
  7. $this->prefix = 'aiosp_opengraph_'; // option prefix 
  8. $this->file = __FILE__; // the current file 
  9. $this->fb_object_types = Array( 
  10. 'Activities' => Array( 
  11. 'activity' => __( 'Activity', 'all-in-one-seo-pack' ),  
  12. 'sport' => __( 'Sport', 'all-in-one-seo-pack' ),  
  13. ),  
  14. 'Businesses' => Array( 
  15. 'bar' => __( 'Bar', 'all-in-one-seo-pack' ),  
  16. 'company' => __( 'Company', 'all-in-one-seo-pack' ),  
  17. 'cafe' => __( 'Cafe', 'all-in-one-seo-pack' ),  
  18. 'hotel' => __( 'Hotel', 'all-in-one-seo-pack' ),  
  19. 'restaurant' => __( 'Restaurant', 'all-in-one-seo-pack' ),  
  20. ),  
  21. 'Groups' => Array( 
  22. 'cause' => __( 'Cause', 'all-in-one-seo-pack' ),  
  23. 'sports_league' => __( 'Sports League', 'all-in-one-seo-pack' ),  
  24. 'sports_team' => __( 'Sports Team', 'all-in-one-seo-pack' ),  
  25. ),  
  26. 'Organizations' => Array( 
  27. 'band' => __( 'Band', 'all-in-one-seo-pack' ),  
  28. 'government' => __( 'Government', 'all-in-one-seo-pack' ),  
  29. 'non_profit' => __( 'Non Profit', 'all-in-one-seo-pack' ),  
  30. 'school' => __( 'School', 'all-in-one-seo-pack' ),  
  31. 'university' => __( 'University', 'all-in-one-seo-pack' ),  
  32. ),  
  33. 'People' => Array( 
  34. 'actor' => __( 'Actor', 'all-in-one-seo-pack' ),  
  35. 'athlete' => __( 'Athlete', 'all-in-one-seo-pack' ),  
  36. 'author' => __( 'Author', 'all-in-one-seo-pack' ),  
  37. 'director' => __( 'Director', 'all-in-one-seo-pack' ),  
  38. 'musician' => __( 'Musician', 'all-in-one-seo-pack' ),  
  39. 'politician' => __( 'Politician', 'all-in-one-seo-pack' ),  
  40. 'profile' => __( 'Profile', 'all-in-one-seo-pack' ),  
  41. 'public_figure' => __( 'Public Figure', 'all-in-one-seo-pack' ),  
  42. ),  
  43. 'Places' => Array( 
  44. 'city' => __( 'City', 'all-in-one-seo-pack' ),  
  45. 'country' => __( 'Country', 'all-in-one-seo-pack' ),  
  46. 'landmark' => __( 'Landmark', 'all-in-one-seo-pack' ),  
  47. 'state_province' => __( 'State Province', 'all-in-one-seo-pack' ),  
  48. ),  
  49. 'Products and Entertainment' => Array( 
  50. 'album' => __( 'Album', 'all-in-one-seo-pack' ),  
  51. 'book' => __( 'Book', 'all-in-one-seo-pack' ),  
  52. 'drink' => __( 'Drink', 'all-in-one-seo-pack' ),  
  53. 'food' => __( 'Food', 'all-in-one-seo-pack' ),  
  54. 'game' => __( 'Game', 'all-in-one-seo-pack' ),  
  55. 'movie' => __( 'Movie', 'all-in-one-seo-pack' ),  
  56. 'product' => __( 'Product', 'all-in-one-seo-pack' ),  
  57. 'song' => __( 'Song', 'all-in-one-seo-pack' ),  
  58. 'tv_show' => __( 'TV Show', 'all-in-one-seo-pack' ),  
  59. 'episode' => __( 'Episode', 'all-in-one-seo-pack' ),  
  60. ),  
  61. 'Websites' => Array( 
  62. 'article' => __( 'Article', 'all-in-one-seo-pack' ),  
  63. 'blog' => __( 'Blog', 'all-in-one-seo-pack' ),  
  64. 'website' => __( 'Website', 'all-in-one-seo-pack' ),  
  65. ),  
  66. ); 
  67. parent::__construct(); 
  68.  
  69. $categories = Array( 
  70. 'blog' => __( 'Blog', 'all-in-one-seo-pack' ),  
  71. 'website' => __( 'Website', 'all-in-one-seo-pack' ),  
  72. 'article' => __( 'Article', 'all-in-one-seo-pack' ),  
  73. ); 
  74.  
  75. $this->help_text = Array( 
  76. "setmeta" => __( "Checking this box will use the Home Title and Home Description set in All in One SEO Pack, General Settings as the Open Graph title and description for your home page.", 'all-in-one-seo-pack' ),  
  77. "key" => __( "Enter your Facebook Admin ID here. Information about how to get your Facebook Admin ID can be found at https://developers.facebook.com/docs/platforminsights/domains", 'all-in-one-seo-pack' ),  
  78. "appid" => __( "Enter your Facebook App ID here. Information about how to get your Facebook App ID can be found at https://developers.facebook.com/docs/platforminsights/domains", 'all-in-one-seo-pack' ),  
  79. "title_shortcodes" => __( "Run shortcodes that appear in social title meta tags.", 'all-in-one-seo-pack' ),  
  80. "description_shortcodes" => __( "Run shortcodes that appear in social description meta tags.", 'all-in-one-seo-pack' ),  
  81. "sitename" => __( "The Site Name is the name that is used to identify your website.", 'all-in-one-seo-pack' ),  
  82. "hometitle" => __( "The Home Title is the Open Graph title for your home page.", 'all-in-one-seo-pack' ),  
  83. "description" => __( "The Home Description is the Open Graph description for your home page.", 'all-in-one-seo-pack' ),  
  84. "homeimage" => __( "The Home Image is the Open Graph image for your home page.", 'all-in-one-seo-pack' ),  
  85. "hometag" => __( "The Home Tag allows you to add a list of keywords that best describe your home page content.", 'all-in-one-seo-pack' ),  
  86. "generate_descriptions" => __( "Check this and your Open Graph descriptions will be auto-generated from your content.", 'all-in-one-seo-pack' ),  
  87. "defimg" => __( "This option lets you choose which image will be displayed by default for the Open Graph image. You may override this on individual posts.", 'all-in-one-seo-pack' ),  
  88. "fallback" => __( "This option lets you fall back to the default image if no image could be found above.", 'all-in-one-seo-pack' ),  
  89. "dimg" => __( "This option sets a default image that can be used for the Open Graph image. You can upload an image, select an image from your Media Library or paste the URL of an image here.", 'all-in-one-seo-pack' ),  
  90. "dimgwidth" => __( "This option lets you set a default width for your images, where unspecified.", 'all-in-one-seo-pack' ),  
  91. "dimgheight" => __( "This option lets you set a default height for your images, where unspecified.", 'all-in-one-seo-pack' ),  
  92. "meta_key" => __( "Enter the name of a custom field (or multiple field names separated by commas) to use that field to specify the Open Graph image on Pages or Posts.", 'all-in-one-seo-pack' ),  
  93. "categories" => __( "Set the Open Graph type for your website as either a blog or a website.", 'all-in-one-seo-pack' ),  
  94. "image" => __( "This option lets you select the Open Graph image that will be used for this Page or Post, overriding the default settings.", 'all-in-one-seo-pack' ),  
  95. "customimg" => __( "This option lets you upload an image to use as the Open Graph image for this Page or Post.", 'all-in-one-seo-pack' ),  
  96. "imagewidth" => __( "Enter the width for your Open Graph image in pixels (i.e. 600).", 'all-in-one-seo-pack' ),  
  97. "imageheight" => __( "Enter the height for your Open Graph image in pixels (i.e. 600).", 'all-in-one-seo-pack' ),  
  98. "video" => __( "This option lets you specify a link to the Open Graph video used on this Page or Post.", 'all-in-one-seo-pack' ),  
  99. "videowidth" => __( "Enter the width for your Open Graph video in pixels (i.e. 600).", 'all-in-one-seo-pack' ),  
  100. "videoheight" => __( "Enter the height for your Open Graph video in pixels (i.e. 600).", 'all-in-one-seo-pack' ),  
  101. "defcard" => __( "Select the default type of Twitter card to display.", 'all-in-one-seo-pack' ),  
  102. "setcard" => __( "Select the default type of Twitter card to display.", 'all-in-one-seo-pack' ),  
  103. "twitter_site" => __( "Enter the Twitter username associated with your website here.", 'all-in-one-seo-pack' ),  
  104. "twitter_creator" => __( "Allows your authors to be identified by their Twitter usernames as content creators on the Twitter cards for their posts.", 'all-in-one-seo-pack' ),  
  105. "twitter_domain" => __( "Enter the name of your website here.", 'all-in-one-seo-pack' ),  
  106. "customimg_twitter" => __( "This option lets you upload an image to use as the Twitter image for this Page or Post.", 'all-in-one-seo-pack' ),  
  107. "gen_tags" => __( "Automatically generate article tags for Facebook type article when not provided.", 'all-in-one-seo-pack' ),  
  108. "gen_keywords" => __( "Use keywords in generated article tags.", 'all-in-one-seo-pack' ),  
  109. "gen_categories" => __( "Use catergories in generated article tags.", 'all-in-one-seo-pack' ),  
  110. "gen_post_tags" => __( "Use post tags in generated article tags.", 'all-in-one-seo-pack' ),  
  111. "types" => __( "Select which Post Types you want to use All in One SEO Pack to set Open Graph meta values for.", 'all-in-one-seo-pack' ),  
  112. "title" => __( "This is the Open Graph title of this Page or Post.", 'all-in-one-seo-pack' ),  
  113. "desc" => __( "This is the Open Graph description of this Page or Post.", 'all-in-one-seo-pack' ),  
  114. "category" => __( "Select the Open Graph type that best describes the content of this Page or Post.", 'all-in-one-seo-pack' ),  
  115. "facebook_debug" => __( "Press this button to have Facebook re-fetch and debug this page.", 'all-in-one-seo-pack' ),  
  116. "section" => __( "This Open Graph meta allows you to add a general section name that best describes this content.", 'all-in-one-seo-pack' ),  
  117. "tag" => __( "This Open Graph meta allows you to add a list of keywords that best describe this content.", 'all-in-one-seo-pack' ),  
  118. "facebook_publisher" => __( "Link articles to the Facebook page associated with your website.", 'all-in-one-seo-pack' ),  
  119. "facebook_author" => __( "Allows your authors to be identified by their Facebook pages as content authors on the Opengraph meta for their articles.", 'all-in-one-seo-pack' ),  
  120. "person_or_org" => __( "Are the social profile links for your website for a person or an organization?", 'all-in-one-seo-pack' ),  
  121. "profile_links" => __( "Add URLs for your website's social profiles here (Facebook, Twitter, Google+, Instagram, LinkedIn), one per line.", 'all-in-one-seo-pack' ),  
  122. "social_name" => __( "Add the name of the person or organization who owns these profiles.", 'all-in-one-seo-pack' ),  
  123. ); 
  124.  
  125. $this->help_anchors = Array( 
  126. 'title_shortcodes' => '#run-shortcodes-in-title',  
  127. 'description_shortcodes' => '#run-shortcodes-in-description',  
  128. 'generate_descriptions' => '#auto-generate-og-descriptions',  
  129. 'setmeta' => '#use-aioseo-title-and-description',  
  130. 'sitename' => '#site-name',  
  131. 'hometitle' => '#home-title-and-description',  
  132. 'description' => '#home-title-and-description',  
  133. 'homeimage' => '#home-image',  
  134. 'hometag' => '#home-article-tags',  
  135. 'defimg' => '#select-og-image-source',  
  136. 'fallback' => '#use-default-if-no-image-found',  
  137. 'dimg' => '#default-og-image',  
  138. 'dimgwidth' => '#default-image-width',  
  139. 'dimgheight' => '#default-image-height',  
  140. 'meta_key' => '#use-custom-field-for-image',  
  141. 'profile_links' => '#social-profile-links',  
  142. 'person_or_org' => '#social-profile-links',  
  143. 'social_name' => '#social-profile-links',  
  144. 'key' => '#facebook-admin-id',  
  145. 'appid' => '#facebook-app-id',  
  146. 'categories' => '#facebook-object-type',  
  147. 'gen_tags' => '#automatically-generate-article-tags',  
  148. 'gen_keywords' => '#use-keywords-in-article-tags',  
  149. 'gen_categories' => '#use-categories-in-article-tags',  
  150. 'gen_post_tags' => '#use-post-tags-in-article-tags',  
  151. 'facebook_publisher' => '#show-facebook-publisher-on-articles',  
  152. 'facebook_author' => '#show-facebook-author-on-articles',  
  153. 'types' => '#enable-facebook-meta-for',  
  154. 'defcard' => '#default-twitter-card',  
  155. 'setcard' => '#default-twitter-card',  
  156. 'twitter_site' => '#twitter-site',  
  157. 'twitter_creator' => '#show-twitter-author',  
  158. 'twitter_domain' => '#twitter-domain',  
  159. 'scan_header' => '#scan-social-meta',  
  160. 'title' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#title',  
  161. 'desc' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#description',  
  162. 'image' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#image',  
  163. 'customimg' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#custom-image',  
  164. 'imagewidth' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#specify-image-width-height',  
  165. 'imageheight' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#specify-image-width-height',  
  166. 'video' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#custom-video',  
  167. 'videowidth' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#specify-video-width-height',  
  168. 'videoheight' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#specify-video-width-height',  
  169. 'category' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#facebook-object-type',  
  170. 'facebook_debug' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#facebook-debug',  
  171. 'section' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#article-section',  
  172. 'tag' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#article-tags',  
  173. 'setcard' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#twitter-card-type',  
  174. 'customimg_twitter' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#custom-twitter-image',  
  175. ); 
  176.  
  177. $count_desc = __( " characters. Open Graph allows up to a maximum of %s chars for the %s.", 'all-in-one-seo-pack' ); 
  178. $this->default_options = array( 
  179. 'scan_header' => Array( 
  180. 'name' => __( 'Scan Header', 'all-in-one-seo-pack' ),  
  181. 'type' => 'custom',  
  182. 'save' => true,  
  183. ),  
  184. 'setmeta' => Array( 
  185. 'name' => __( 'Use AIOSEO Title and Description', 'all-in-one-seo-pack' ),  
  186. 'type' => 'checkbox',  
  187. ),  
  188. 'key' => Array( 
  189. 'name' => __( 'Facebook Admin ID', 'all-in-one-seo-pack' ),  
  190. 'default' => '',  
  191. 'type' => 'text',  
  192. ),  
  193. 'appid' => Array( 
  194. 'name' => __( 'Facebook App ID', 'all-in-one-seo-pack' ),  
  195. 'default' => '',  
  196. 'type' => 'text',  
  197. ),  
  198. 'title_shortcodes' => Array( 'name' => __( 'Run Shortcodes In Title', 'all-in-one-seo-pack' ) ),  
  199. 'description_shortcodes' => Array( 'name' => __( 'Run Shortcodes In Description', 'all-in-one-seo-pack' ) ),  
  200. 'sitename' => Array( 
  201. 'name' => __( 'Site Name', 'all-in-one-seo-pack' ),  
  202. 'default' => get_bloginfo( 'name' ),  
  203. 'type' => 'text',  
  204. ),  
  205. 'hometitle' => Array( 
  206. 'name' => __( 'Home Title', 'all-in-one-seo-pack' ),  
  207. 'default' => '',  
  208. 'type' => 'textarea',  
  209. 'condshow' => Array( 
  210. 'aiosp_opengraph_setmeta' => Array( 
  211. 'lhs' => "aiosp_opengraph_setmeta",  
  212. 'op' => '!=',  
  213. 'rhs' => 'on',  
  214. ),  
  215. ),  
  216. ),  
  217. 'description' => Array( 
  218. 'name' => __( 'Home Description', 'all-in-one-seo-pack' ),  
  219. 'default' => '',  
  220. 'type' => 'textarea',  
  221. 'condshow' => Array( 
  222. 'aiosp_opengraph_setmeta' => Array( 
  223. 'lhs' => "aiosp_opengraph_setmeta",  
  224. 'op' => '!=',  
  225. 'rhs' => 'on',  
  226. ),  
  227. ),  
  228. ),  
  229. 'homeimage' => Array( 
  230. 'name' => __( 'Home Image', 'all-in-one-seo-pack' ),  
  231. 'type' => 'image',  
  232. ),  
  233. 'hometag' => Array( 
  234. 'name' => __( 'Home Article Tags', 'all-in-one-seo-pack' ),  
  235. 'type' => 'text',  
  236. 'default' => '',  
  237. 'condshow' => Array( 'aiosp_opengraph_categories' => 'article' ),  
  238. ),  
  239. 'generate_descriptions' => Array( 
  240. 'name' => __( 'Autogenerate OG Descriptions', 'all-in-one-seo-pack' ),  
  241. 'default' => 1,  
  242. ),  
  243. 'defimg' => Array( 
  244. 'name' => __( 'Select OG:Image Source', 'all-in-one-seo-pack' ),  
  245. 'type' => 'select',  
  246. 'initial_options' => Array( 
  247. '' => __( 'Default Image' ),  
  248. 'featured' => __( 'Featured Image' ),  
  249. 'attach' => __( 'First Attached Image' ),  
  250. 'content' => __( 'First Image In Content' ),  
  251. 'custom' => __( 'Image From Custom Field' ),  
  252. 'author' => __( 'Post Author Image' ),  
  253. 'auto' => __( 'First Available Image' ),  
  254. ),  
  255. ),  
  256. 'fallback' => Array( 
  257. 'name' => __( 'Use Default If No Image Found', 'all-in-one-seo-pack' ),  
  258. 'type' => 'checkbox',  
  259. ),  
  260. 'dimg' => Array( 
  261. 'name' => __( 'Default OG:Image', 'all-in-one-seo-pack' ),  
  262. 'default' => AIOSEOP_PLUGIN_IMAGES_URL . 'default-user-image.png',  
  263. 'type' => 'image',  
  264. ),  
  265. 'dimgwidth' => Array( 
  266. 'name' => __( 'Default Image Width', 'all-in-one-seo-pack' ),  
  267. 'type' => 'text',  
  268. 'default' => '',  
  269. ),  
  270. 'dimgheight' => Array( 
  271. 'name' => __( 'Default Image Height', 'all-in-one-seo-pack' ),  
  272. 'type' => 'text',  
  273. 'default' => '',  
  274. ),  
  275. 'meta_key' => Array( 
  276. 'name' => __( 'Use Custom Field For Image', 'all-in-one-seo-pack' ),  
  277. 'type' => 'text',  
  278. 'default' => '',  
  279. ),  
  280. 'categories' => Array( 
  281. 'name' => __( 'Facebook Object Type', 'all-in-one-seo-pack' ),  
  282. 'type' => 'radio',  
  283. 'initial_options' => $categories,  
  284. 'default' => 'blog',  
  285. ),  
  286. 'image' => Array( 
  287. 'name' => __( 'Image', 'all-in-one-seo-pack' ),  
  288. 'type' => 'radio',  
  289. 'initial_options' => Array( 0 => '<img style="width:50px;height:auto;display:inline-block;vertical-align:bottom;" src="' . AIOSEOP_PLUGIN_IMAGES_URL . 'default-user-image.png' . '">' ),  
  290. ),  
  291. 'customimg' => Array( 
  292. 'name' => __( 'Custom Image', 'all-in-one-seo-pack' ),  
  293. 'type' => 'image',  
  294. ),  
  295. 'imagewidth' => Array( 
  296. 'name' => __( 'Specify Image Width', 'all-in-one-seo-pack' ),  
  297. 'type' => 'text',  
  298. 'default' => '',  
  299. ),  
  300. 'imageheight' => Array( 
  301. 'name' => __( 'Specify Image Height', 'all-in-one-seo-pack' ),  
  302. 'type' => 'text',  
  303. 'default' => '',  
  304. ),  
  305. 'video' => Array( 
  306. 'name' => __( 'Custom Video', 'all-in-one-seo-pack' ),  
  307. 'type' => 'text',  
  308. ),  
  309. 'videowidth' => Array( 
  310. 'name' => __( 'Specify Video Width', 'all-in-one-seo-pack' ),  
  311. 'type' => 'text',  
  312. 'default' => '',  
  313. 'condshow' => Array( 
  314. 'aioseop_opengraph_settings_video' => Array( 
  315. 'lhs' => "aioseop_opengraph_settings_video",  
  316. 'op' => '!=',  
  317. 'rhs' => '',  
  318. ),  
  319. ),  
  320. ),  
  321. 'videoheight' => Array( 
  322. 'name' => __( 'Specify Video Height', 'all-in-one-seo-pack' ),  
  323. 'type' => 'text',  
  324. 'default' => '',  
  325. 'condshow' => Array( 
  326. 'aioseop_opengraph_settings_video' => Array( 
  327. 'lhs' => "aioseop_opengraph_settings_video",  
  328. 'op' => '!=',  
  329. 'rhs' => '',  
  330. ),  
  331. ),  
  332. ),  
  333. 'defcard' => Array( 
  334. 'name' => __( 'Default Twitter Card', 'all-in-one-seo-pack' ),  
  335. 'type' => 'select',  
  336. 'initial_options' => Array( 
  337. 'summary' => __( 'Summary', 'all-in-one-seo-pack' ),  
  338. 'summary_large_image' => __( 'Summary Large Image', 'all-in-one-seo-pack' ) 
  339. /**, *******REMOVING THIS TWITTER CARD TYPE FROM SOCIAL META MODULE****** 'photo' => __( 'Photo', 'all-in-one-seo-pack' ) */ 
  340. ),  
  341. 'default' => 'summary',  
  342. ),  
  343. 'setcard' => Array( 
  344. 'name' => __( 'Twitter Card Type', 'all-in-one-seo-pack' ),  
  345. 'type' => 'select',  
  346. 'initial_options' => Array( 
  347. 'summary_large_image' => __( 'Summary Large Image', 'all-in-one-seo-pack' ),  
  348. 'summary' => __( 'Summary', 'all-in-one-seo-pack' ) 
  349. /**, *******REMOVING THIS TWITTER CARD TYPE FROM SOCIAL META MODULE****** 'photo' => __( 'Photo', 'all-in-one-seo-pack' ) */ 
  350. ),  
  351. ),  
  352. 'twitter_site' => Array( 
  353. 'name' => __( 'Twitter Site', 'all-in-one-seo-pack' ),  
  354. 'type' => 'text',  
  355. 'default' => '',  
  356. ),  
  357. 'twitter_creator' => Array( 'name' => __( 'Show Twitter Author', 'all-in-one-seo-pack' ) ),  
  358. 'twitter_domain' => Array( 
  359. 'name' => __( 'Twitter Domain', 'all-in-one-seo-pack' ),  
  360. 'type' => 'text',  
  361. 'default' => '',  
  362. ),  
  363. 'customimg_twitter' => Array( 
  364. 'name' => __( 'Custom Twitter Image', 'all-in-one-seo-pack' ),  
  365. 'type' => 'image',  
  366. ),  
  367. 'gen_tags' => Array( 'name' => __( 'Automatically Generate Article Tags', 'all-in-one-seo-pack' ) ),  
  368. 'gen_keywords' => Array( 
  369. 'name' => __( 'Use Keywords In Article Tags', 'all-in-one-seo-pack' ),  
  370. 'default' => 'on',  
  371. 'condshow' => Array( 'aiosp_opengraph_gen_tags' => 'on' ),  
  372. ),  
  373. 'gen_categories' => Array( 
  374. 'name' => __( 'Use Categories In Article Tags', 'all-in-one-seo-pack' ),  
  375. 'default' => 'on',  
  376. 'condshow' => Array( 'aiosp_opengraph_gen_tags' => 'on' ),  
  377. ),  
  378. 'gen_post_tags' => Array( 
  379. 'name' => __( 'Use Post Tags In Article Tags', 'all-in-one-seo-pack' ),  
  380. 'default' => 'on',  
  381. 'condshow' => Array( 'aiosp_opengraph_gen_tags' => 'on' ),  
  382. ),  
  383. 'types' => Array( 
  384. 'name' => __( 'Enable Facebook Meta for', 'all-in-one-seo-pack' ),  
  385. 'type' => 'multicheckbox',  
  386. 'initial_options' => $this->get_post_type_titles( Array( '_builtin' => false ) ),  
  387. 'default' => Array( 'post' => 'post', 'page' => 'page' ),  
  388. ),  
  389. 'title' => Array( 
  390. 'name' => __( 'Title', 'all-in-one-seo-pack' ),  
  391. 'default' => '',  
  392. 'type' => 'text',  
  393. 'size' => 95,  
  394. 'count' => 1,  
  395. 'count_desc' => $count_desc,  
  396. ),  
  397. 'desc' => Array( 
  398. 'name' => __( 'Description', 'all-in-one-seo-pack' ),  
  399. 'default' => '',  
  400. 'type' => 'textarea',  
  401. 'cols' => 250,  
  402. 'rows' => 4,  
  403. 'count' => 1,  
  404. 'count_desc' => $count_desc,  
  405. ),  
  406. 'category' => Array( 
  407. 'name' => __( 'Facebook Object Type', 'all-in-one-seo-pack' ),  
  408. 'type' => 'select',  
  409. 'style' => '',  
  410. 'initial_options' => $this->fb_object_types,  
  411. 'default' => '',  
  412. ),  
  413. 'facebook_debug' => Array( 
  414. 'name' => __( 'Facebook Debug', 'all-in-one-seo-pack' ),  
  415. 'type' => 'html',  
  416. 'save' => false,  
  417. 'default' => 
  418. '<script> 
  419. jQuery(document).ready(function() { 
  420. var snippet = jQuery("#aioseop_snippet_link"); 
  421. if ( !snippet ) { 
  422. jQuery( "#aioseop_opengraph_settings_facebook_debug_wrapper").hide(); 
  423. } else { 
  424. snippet = snippet.html(); 
  425. jQuery("#aioseop_opengraph_settings_facebook_debug").attr( "href", "https://developers.facebook.com/tools/debug/og/object?q=" + snippet ); 
  426. }); 
  427. </script> 
  428. <a name="aioseop_opengraph_settings_facebook_debug" id="aioseop_opengraph_settings_facebook_debug" class="button-primary" href="" target=_blank>' . __( 'Debug This Post', 'all-in-one-seo-pack' ) 
  429. . '</a>',  
  430. ),  
  431.  
  432. 'section' => Array( 
  433. 'name' => __( 'Article Section', 'all-in-one-seo-pack' ),  
  434. 'type' => 'text',  
  435. 'default' => '',  
  436. 'condshow' => Array( 'aioseop_opengraph_settings_category' => 'article' ),  
  437. ),  
  438. 'tag' => Array( 
  439. 'name' => __( 'Article Tags', 'all-in-one-seo-pack' ),  
  440. 'type' => 'text',  
  441. 'default' => '',  
  442. 'condshow' => Array( 'aioseop_opengraph_settings_category' => 'article' ),  
  443. ),  
  444. 'facebook_publisher' => Array( 
  445. 'name' => __( 'Show Facebook Publisher on Articles', 'all-in-one-seo-pack' ),  
  446. 'type' => 'text',  
  447. 'default' => '',  
  448. ),  
  449. 'facebook_author' => Array( 'name' => __( 'Show Facebook Author on Articles', 'all-in-one-seo-pack' ) ),  
  450. 'profile_links' => Array( 
  451. 'name' => __( 'Social Profile Links', 'all-in-one-seo-pack' ),  
  452. 'type' => 'textarea',  
  453. 'cols' => 60,  
  454. 'rows' => 5,  
  455. ),  
  456. 'person_or_org' => Array( 
  457. 'name' => __( 'Person or Organization?', 'all-in-one-seo-pack' ),  
  458. 'type' => 'radio',  
  459. 'initial_options' => Array( 
  460. 'person' => __( 'Person', 'all-in-one-seo-pack' ),  
  461. 'org' => __( 'Organization', 'all-in-one-seo-pack' ),  
  462. ),  
  463. ),  
  464. 'social_name' => Array( 
  465. 'name' => __( "Associated Name", 'all-in-one-seo-pack' ),  
  466. 'type' => 'text',  
  467. 'default' => "",  
  468. ),  
  469. ); 
  470.  
  471. // load initial options / set defaults 
  472. $this->update_options(); 
  473.  
  474. $display = Array(); 
  475. if ( isset( $this->options['aiosp_opengraph_types'] ) ) { 
  476. $display = $this->options['aiosp_opengraph_types']; 
  477.  
  478. $this->locations = array( 
  479. 'opengraph' => Array( 
  480. 'name' => $this->name,  
  481. 'prefix' => 'aiosp_',  
  482. 'type' => 'settings',  
  483. 'options' => Array( 
  484. 'scan_header',  
  485. 'setmeta',  
  486. 'key',  
  487. 'appid',  
  488. 'sitename',  
  489. 'title_shortcodes',  
  490. 'description_shortcodes',  
  491. 'hometitle',  
  492. 'description',  
  493. 'homeimage',  
  494. 'hometag',  
  495. 'generate_descriptions',  
  496. 'defimg',  
  497. 'fallback',  
  498. 'dimg',  
  499. 'dimgwidth',  
  500. 'dimgheight',  
  501. 'meta_key',  
  502. 'categories',  
  503. 'defcard',  
  504. 'profile_links',  
  505. 'person_or_org',  
  506. 'social_name',  
  507. 'twitter_site',  
  508. 'twitter_creator',  
  509. 'twitter_domain',  
  510. 'gen_tags',  
  511. 'gen_keywords',  
  512. 'gen_categories',  
  513. 'gen_post_tags',  
  514. 'types',  
  515. 'facebook_publisher',  
  516. 'facebook_author',  
  517. ),  
  518. ),  
  519. 'settings' => Array( 
  520. 'name' => __( 'Social Settings', 'all-in-one-seo-pack' ),  
  521. 'type' => 'metabox',  
  522. 'help_link' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/',  
  523. 'options' => Array( 
  524. 'title',  
  525. 'desc',  
  526. 'image',  
  527. 'customimg',  
  528. 'imagewidth',  
  529. 'imageheight',  
  530. 'video',  
  531. 'videowidth',  
  532. 'videoheight',  
  533. 'category',  
  534. 'facebook_debug',  
  535. 'section',  
  536. 'tag',  
  537. 'setcard',  
  538. 'customimg_twitter',  
  539. ),  
  540. 'display' => $display,  
  541. 'prefix' => 'aioseop_opengraph_',  
  542. ),  
  543. ); 
  544.  
  545. $this->layout = Array( 
  546. 'default' => Array( 
  547. 'name' => __( 'General Settings', 'all-in-one-seo-pack' ),  
  548. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/',  
  549. 'options' => Array() // this is set below, to the remaining options -- pdb 
  550. ),  
  551. 'home' => Array( 
  552. 'name' => __( 'Home Page Settings', 'all-in-one-seo-pack' ),  
  553. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#use-aioseo-title-and-description',  
  554. 'options' => Array( 'setmeta', 'sitename', 'hometitle', 'description', 'homeimage', 'hometag' ),  
  555. ),  
  556. 'image' => Array( 
  557. 'name' => __( 'Image Settings', 'all-in-one-seo-pack' ),  
  558. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#select-og-image-source',  
  559. 'options' => Array( 'defimg', 'fallback', 'dimg', 'dimgwidth', 'dimgheight', 'meta_key' ),  
  560. ),  
  561. 'links' => Array( 
  562. 'name' => __( 'Social Profile Links', 'all-in-one-seo-pack' ),  
  563. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#social-profile-links',  
  564. 'options' => Array( 'profile_links', 'person_or_org', 'social_name' ),  
  565. ),  
  566. 'facebook' => Array( 
  567. 'name' => __( 'Facebook Settings', 'all-in-one-seo-pack' ),  
  568. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#facebook-settings',  
  569. 'options' => Array( 
  570. 'key',  
  571. 'appid',  
  572. 'types',  
  573. 'gen_tags',  
  574. 'gen_keywords',  
  575. 'gen_categories',  
  576. 'gen_post_tags',  
  577. 'categories',  
  578. 'facebook_publisher',  
  579. 'facebook_author',  
  580. ),  
  581. ),  
  582. 'twitter' => Array( 
  583. 'name' => __( 'Twitter Settings', 'all-in-one-seo-pack' ),  
  584. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#default-twitter-card',  
  585. 'options' => Array( 'defcard', 'setcard', 'twitter_site', 'twitter_creator', 'twitter_domain' ),  
  586. ),  
  587. 'scan_meta' => Array( 
  588. 'name' => __( 'Scan Social Meta', 'all-in-one-seo-pack' ),  
  589. 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#scan_meta',  
  590. 'options' => Array( 'scan_header' ),  
  591. ),  
  592. ); 
  593.  
  594. $other_options = Array(); 
  595. foreach ( $this->layout as $k => $v ) { 
  596. $other_options = array_merge( $other_options, $v['options'] ); 
  597.  
  598. $this->layout['default']['options'] = array_diff( array_keys( $this->default_options ), $other_options ); 
  599.  
  600. if ( is_admin() ) { 
  601. add_action( 'admin_init', Array( $this, 'debug_post_types' ), 5 ); 
  602. } else { 
  603. add_action( 'wp', Array( $this, 'type_setup' ) ); 
  604.  
  605. if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { 
  606. $this->do_opengraph(); 
  607.  
  608. // Avoid having duplicate meta tags 
  609. add_filter( 'jetpack_enable_open_graph', '__return_false' ); 
  610.  
  611. function settings_page_init() { 
  612. add_filter( 'aiosp_output_option', Array( $this, 'display_custom_options' ), 10, 2 ); 
  613. $cat = $this->options["{$this->prefix}categories"]; 
  614. if ( ! empty( $cat ) ) { 
  615. if ( $cat == 'blog' ) { 
  616. $show_on_front = get_option( 'show_on_front' ); 
  617. if ( ( $show_on_front == 'page' ) && ( get_option( 'page_on_front' ) ) ) { 
  618. $this->output_error( '<p>' . __( "Static front page detected, suggested Facebook Object Type is 'website'.", 'all-in-one-seo-pack' ) . '</p>' ); 
  619. } elseif ( $cat == 'website' ) { 
  620. $show_on_front = get_option( 'show_on_front' ); 
  621. if ( ( $show_on_front == 'posts' ) ) { 
  622. $this->output_error( '<p>' . __( "Blog on front page detected, suggested Facebook Object Type is 'blog'.", 'all-in-one-seo-pack' ) . '</p>' ); 
  623.  
  624. function filter_options( $options, $location ) { 
  625. if ( $location == 'settings' ) { 
  626. $prefix = $this->get_prefix( $location ) . $location . '_'; 
  627. list( $legacy, $images ) = $this->get_all_images( $options ); 
  628. if ( isset( $options ) && isset( $options["{$prefix}image"] ) ) { 
  629. $thumbnail = $options["{$prefix}image"]; 
  630. if ( ctype_digit( (string) $thumbnail ) || ( $thumbnail == 'post' ) ) { 
  631. if ( $thumbnail == 'post' ) { 
  632. $thumbnail = $images['post1']; 
  633. } else if ( ! empty( $legacy[ $thumbnail ] ) ) { 
  634. $thumbnail = $legacy[ $thumbnail ]; 
  635. $options["{$prefix}image"] = $thumbnail; 
  636. if ( empty( $options[ $prefix . 'image' ] ) ) { 
  637. $img = array_keys( $images ); 
  638. if ( ! empty( $img ) && ! empty( $img[1] ) ) { 
  639. $options[ $prefix . 'image' ] = $img[1]; 
  640.  
  641. return $options; 
  642.  
  643. function filter_settings( $settings, $location, $current ) { 
  644. if ( $location == 'opengraph' || $location == 'settings' ) { 
  645. $prefix = $this->get_prefix( $location ) . $location . '_'; 
  646. if ( $location == 'opengraph' ) { 
  647. return $settings; 
  648. if ( $location == 'settings' ) { 
  649. list( $legacy, $settings[ $prefix . 'image' ]['initial_options'] ) = $this->get_all_images( $current ); 
  650. $opts = Array( 'title', 'desc' ); 
  651. $current_post_type = get_post_type(); 
  652. if ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) { 
  653. $flat_type_list = Array(); 
  654. foreach ( $this->fb_object_types as $k => $v ) { 
  655. if ( is_array( $v ) ) { 
  656. $flat_type_list = array_merge( $flat_type_list, $v ); 
  657. } else { 
  658. $flat_type_list[ $k ] = $v; 
  659. $settings[ $prefix . 'category' ]['initial_options'] = array_merge( Array( 
  660. $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] => __( 'Default ', 'all-in-one-seo-pack' ) . ' - ' 
  661. . $flat_type_list[ $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ],  
  662. ),  
  663. $settings[ $prefix . 'category' ]['initial_options'] ); 
  664. if ( isset( $this->options["aiosp_opengraph_defcard"] ) ) { 
  665. $settings[ $prefix . 'setcard' ]['default'] = $this->options["aiosp_opengraph_defcard"]; 
  666. global $aiosp; 
  667. $info = $aiosp->get_page_snippet_info(); 
  668. extract( $info ); 
  669. $settings["{$prefix}title"]['placeholder'] = $title; 
  670. $settings["{$prefix}desc"]['placeholder'] = $description; 
  671. if ( isset( $current[ $prefix . 'setmeta' ] ) && $current[ $prefix . 'setmeta' ] ) { 
  672. foreach ( $opts as $opt ) { 
  673. if ( isset( $settings[ $prefix . $opt ] ) ) { 
  674. $settings[ $prefix . $opt ]['type'] = 'hidden'; 
  675. $settings[ $prefix . $opt ]['label'] = 'none'; 
  676. $settings[ $prefix . $opt ]['help_text'] = ''; 
  677. unset( $settings[ $prefix . $opt ]['count'] ); 
  678.  
  679. return $settings; 
  680.  
  681. function override_options( $options, $location, $settings ) { 
  682. $opts = Array(); 
  683. foreach ( $settings as $k => $v ) { 
  684. if ( $v['save'] ) { 
  685. $opts[ $k ] = $v['default']; 
  686. foreach ( $options as $k => $v ) { 
  687. if ( $v === null ) { 
  688. unset( $options[ $k ] ); 
  689. $options = wp_parse_args( $options, $opts ); 
  690.  
  691. return $options; 
  692.  
  693. function filter_metabox_options( $options, $location, $post_id ) { 
  694. if ( $location == 'settings' ) { 
  695. $prefix = $this->get_prefix( $location ) . $location; 
  696. if ( ! empty( $options[ $prefix . '_customimg' ] ) ) { 
  697. $old_options = get_post_meta( $post_id, '_' . $prefix ); 
  698. $prefix .= '_'; 
  699. if ( empty( $old_options[ $prefix . 'customimg' ] ) || ( $old_options[ $prefix . 'customimg' ] != $options[ $prefix . 'customimg' ] ) ) { 
  700. $options[ $prefix . 'image' ] = $options[ $prefix . 'customimg' ]; 
  701.  
  702. return $options; 
  703.  
  704. /** Custom settings **/ 
  705. function display_custom_options( $buf, $args ) { 
  706. if ( $args['name'] == 'aiosp_opengraph_scan_header' ) { 
  707. $buf .= '<div class="aioseop aioseop_options aiosp_opengraph_settings"><div class="aioseop_wrapper aioseop_custom_type" id="aiosp_opengraph_scan_header_wrapper"><div class="aioseop_input" id="aiosp_opengraph_scan_header" style="padding-left:20px;">'; 
  708. $args['options']['type'] = 'submit'; 
  709. $args['attr'] = " class='button-primary' "; 
  710. $args['value'] = $args['options']['default'] = __( 'Scan Now', 'all-in-one-seo-pack' ); 
  711. $buf .= __( 'Scan your site for duplicate social meta tags.', 'all-in-one-seo-pack' ); 
  712. $buf .= '<br /><br />' . $this->get_option_html( $args ); 
  713. $buf .= '</div></div></div>'; 
  714.  
  715. return $buf; 
  716.  
  717. function add_attributes( $output ) { // avoid having duplicate meta tags 
  718. $type = $this->type; 
  719. if ( empty( $type ) ) { 
  720. $type = 'website'; 
  721.  
  722. $schema_types = Array( 
  723. 'album' => 'MusicAlbum',  
  724. 'article' => 'Article',  
  725. 'bar' => 'BarOrPub',  
  726. 'blog' => 'Blog',  
  727. 'book' => 'Book',  
  728. 'cafe' => 'CafeOrCoffeeShop',  
  729. 'city' => 'City',  
  730. 'country' => 'Country',  
  731. 'episode' => 'Episode',  
  732. 'food' => 'FoodEvent',  
  733. 'game' => 'Game',  
  734. 'hotel' => 'Hotel',  
  735. 'landmark' => 'LandmarksOrHistoricalBuildings',  
  736. 'movie' => 'Movie',  
  737. 'product' => 'Product',  
  738. 'profile' => 'ProfilePage',  
  739. 'restaurant' => 'Restaurant',  
  740. 'school' => 'School',  
  741. 'sport' => 'SportsEvent',  
  742. 'website' => 'WebSite',  
  743. ); 
  744.  
  745. if ( ! empty( $schema_types[ $type ] ) ) { 
  746. $type = $schema_types[ $type ]; 
  747. } else { 
  748. $type = 'WebSite'; 
  749.  
  750. $attributes = apply_filters( $this->prefix . 'attributes', Array( 
  751. 'itemscope',  
  752. 'itemtype="http://schema.org/' . ucfirst( $type ) . '"',  
  753. 'prefix="og: http://ogp.me/ns#"',  
  754. ) ); 
  755. foreach ( $attributes as $attr ) { 
  756. if ( strpos( $output, $attr ) === false ) { 
  757. $output .= "\n\t$attr "; 
  758.  
  759. return $output; 
  760.  
  761. function add_meta() { 
  762. global $post, $aiosp, $aioseop_options, $wp_query; 
  763. $metabox = $this->get_current_options( Array(), 'settings' ); 
  764. $key = $this->options['aiosp_opengraph_key']; 
  765. $dimg = $this->options['aiosp_opengraph_dimg']; 
  766. $current_post_type = get_post_type(); 
  767. $title = $description = $image = $video = ''; 
  768. $type = $this->type; 
  769. $sitename = $this->options['aiosp_opengraph_sitename']; 
  770.  
  771. $appid = isset( $this->options['aiosp_opengraph_appid'] ) ? $this->options['aiosp_opengraph_appid'] : ''; 
  772.  
  773. if ( ! empty( $aioseop_options['aiosp_hide_paginated_descriptions'] ) ) { 
  774. $first_page = false; 
  775. if ( $aiosp->get_page_number() < 2 ) { 
  776. $first_page = true; 
  777. } else { 
  778. $first_page = true; 
  779. $url = $aiosp->aiosp_mrt_get_url( $wp_query ); 
  780. $url = apply_filters( 'aioseop_canonical_url', $url ); 
  781.  
  782. $setmeta = $this->options['aiosp_opengraph_setmeta']; 
  783. $social_links = ''; 
  784. if ( is_front_page() ) { 
  785. $title = $this->options['aiosp_opengraph_hometitle']; 
  786. if ( $first_page ) { 
  787. $description = $this->options['aiosp_opengraph_description']; 
  788. if ( ! empty( $this->options['aiosp_opengraph_homeimage'] ) ) { 
  789. $thumbnail = $this->options['aiosp_opengraph_homeimage']; 
  790. } else { 
  791. $thumbnail = $this->options['aiosp_opengraph_dimg']; 
  792.  
  793. /** If Use AIOSEO Title and Desc Selected */ 
  794. if ( $setmeta ) { 
  795. $title = $aiosp->wp_title(); 
  796. if ( $first_page ) { 
  797. $description = $aiosp->get_aioseop_description( $post ); 
  798.  
  799. /** Add some defaults */ 
  800. if ( empty( $title ) ) { 
  801. $title = get_bloginfo( 'name' ); 
  802. if ( empty( $sitename ) ) { 
  803. $sitename = get_bloginfo( 'name' ); 
  804.  
  805. if ( empty( $description ) && $first_page && ( ! empty( $this->options['aiosp_opengraph_generate_descriptions'] ) ) && ! empty( $post ) && ! empty( $post->post_content ) && ! post_password_required( $post ) ) { 
  806. $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( preg_replace( '/\s+/', ' ', $post->post_content ) ), 1000 ); 
  807.  
  808. if ( empty( $description ) && $first_page ) { 
  809. $description = get_bloginfo( 'description' ); 
  810. if ( $type == 'article' && ( ! empty( $this->options['aiosp_opengraph_hometag'] ) ) ) { 
  811. $tag = $this->options['aiosp_opengraph_hometag']; 
  812. if ( ! empty( $this->options['aiosp_opengraph_profile_links'] ) ) { 
  813. $social_links = $this->options['aiosp_opengraph_profile_links']; 
  814. if ( ! empty( $this->options['aiosp_opengraph_social_name'] ) ) { 
  815. $social_name = $this->options['aiosp_opengraph_social_name']; 
  816. if ( $this->options['aiosp_opengraph_person_or_org'] == 'person' ) { 
  817. $social_type = "Person"; 
  818. } else { 
  819. $social_type = "Organization"; 
  820. } elseif ( is_singular() && $this->option_isset( 'types' ) 
  821. && is_array( $this->options['aiosp_opengraph_types'] ) 
  822. && in_array( $current_post_type, $this->options['aiosp_opengraph_types'] ) 
  823. ) { 
  824.  
  825. if ( $type == 'article' ) { 
  826. if ( ! empty( $metabox['aioseop_opengraph_settings_section'] ) ) { 
  827. $section = $metabox['aioseop_opengraph_settings_section']; 
  828. if ( ! empty( $metabox['aioseop_opengraph_settings_tag'] ) ) { 
  829. $tag = $metabox['aioseop_opengraph_settings_tag']; 
  830. if ( ! empty( $this->options['aiosp_opengraph_facebook_publisher'] ) ) { 
  831. $publisher = $this->options['aiosp_opengraph_facebook_publisher']; 
  832.  
  833. if ( ! empty( $this->options['aiosp_opengraph_twitter_domain'] ) ) { 
  834. $domain = $this->options['aiosp_opengraph_twitter_domain']; 
  835.  
  836. if ( $type == 'article' && ! empty( $post ) ) { 
  837. if ( isset( $post->post_author ) && ! empty( $this->options['aiosp_opengraph_facebook_author'] ) ) { 
  838. $author = get_the_author_meta( 'facebook', $post->post_author ); 
  839.  
  840. if ( isset( $post->post_date ) ) { 
  841. $published_time = date( 'Y-m-d\TH:i:s\Z', mysql2date( 'U', $post->post_date ) ); 
  842.  
  843. if ( isset( $post->post_modified ) ) { 
  844. $modified_time = date( 'Y-m-d\TH:i:s\Z', mysql2date( 'U', $post->post_modified ) ); 
  845.  
  846. $image = $metabox['aioseop_opengraph_settings_image']; 
  847. $video = $metabox['aioseop_opengraph_settings_video']; 
  848. $title = $metabox['aioseop_opengraph_settings_title']; 
  849. $description = $metabox['aioseop_opengraph_settings_desc']; 
  850.  
  851. /** Add AIOSEO variables if Site Title and Desc from AIOSEOP not selected */ 
  852. global $aiosp; 
  853. if ( empty( $title ) ) { 
  854. $title = $aiosp->wp_title(); 
  855. if ( empty( $description ) ) { 
  856. $description = trim( strip_tags( get_post_meta( $post->ID, "_aioseop_description", true ) ) ); 
  857.  
  858. /** Add some defaults */ 
  859. if ( empty( $title ) ) { 
  860. $title = get_the_title(); 
  861. if ( empty( $description ) && ( $this->options['aiosp_opengraph_generate_descriptions'] ) && ! post_password_required( $post ) ) { 
  862. $description = $post->post_content; 
  863. if ( empty( $type ) ) { 
  864. $type = 'article'; 
  865. } else { 
  866. return; 
  867.  
  868. if ( $type == 'article' ) { 
  869. if ( ! empty( $this->options['aiosp_opengraph_gen_tags'] ) ) { 
  870. if ( ! empty( $this->options['aiosp_opengraph_gen_keywords'] ) ) { 
  871. $keywords = $aiosp->get_main_keywords(); 
  872. $keywords = $this->apply_cf_fields( $keywords ); 
  873. $keywords = apply_filters( 'aioseop_keywords', $keywords ); 
  874. if ( ! empty( $keywords ) && ! empty( $tag ) ) { 
  875. $tag .= ', ' . $keywords; 
  876. } elseif ( empty( $tag ) ) { 
  877. $tag = $keywords; 
  878. $tag = $aiosp->keyword_string_to_list( $tag ); 
  879. if ( ! empty( $this->options['aiosp_opengraph_gen_categories'] ) ) { 
  880. $tag = array_merge( $tag, $aiosp->get_all_categories( $post->ID ) ); 
  881. if ( ! empty( $this->options['aiosp_opengraph_gen_post_tags'] ) ) { 
  882. $tag = array_merge( $tag, $aiosp->get_all_tags( $post->ID ) ); 
  883. if ( ! empty( $tag ) ) { 
  884. $tag = $aiosp->clean_keyword_list( $tag ); 
  885.  
  886. if ( ! empty( $this->options['aiosp_opengraph_title_shortcodes'] ) ) { 
  887. $title = do_shortcode( $title ); 
  888.  
  889. if ( ! empty( $description ) ) { 
  890. $description = $aiosp->internationalize( preg_replace( '/\s+/', ' ', $description ) ); 
  891. if ( ! empty( $this->options['aiosp_opengraph_description_shortcodes'] ) ) { 
  892. $description = do_shortcode( $description ); 
  893. $description = $aiosp->trim_excerpt_without_filters( $description, 1000 ); 
  894.  
  895. $title = $this->apply_cf_fields( $title ); 
  896. $description = $this->apply_cf_fields( $description ); 
  897.  
  898. /** Data Validation */ 
  899. $title = strip_tags( esc_attr( $title ) ); 
  900. $sitename = strip_tags( esc_attr( $sitename ) ); 
  901. $description = strip_tags( esc_attr( $description ) ); 
  902.  
  903. if ( empty( $thumbnail ) && ! empty( $image ) ) { 
  904. $thumbnail = $image; 
  905.  
  906. /** Get the first image attachment on the post */ 
  907. // if( empty($thumbnail) ) $thumbnail = $this->get_the_image(); 
  908.  
  909. /** Add user supplied default image */ 
  910. if ( empty( $thumbnail ) ) { 
  911. if ( empty( $this->options['aiosp_opengraph_defimg'] ) ) { 
  912. $thumbnail = $this->options['aiosp_opengraph_dimg']; 
  913. } else { 
  914. switch ( $this->options['aiosp_opengraph_defimg'] ) { 
  915. case 'featured' : 
  916. $thumbnail = $this->get_the_image_by_post_thumbnail(); 
  917. break; 
  918. case 'attach' : 
  919. $thumbnail = $this->get_the_image_by_attachment(); 
  920. break; 
  921. case 'content' : 
  922. $thumbnail = $this->get_the_image_by_scan(); 
  923. break; 
  924. case 'custom' : 
  925. $meta_key = $this->options['aiosp_opengraph_meta_key']; 
  926. if ( ! empty( $meta_key ) && ! empty( $post ) ) { 
  927. $meta_key = explode( ', ', $meta_key ); 
  928. $thumbnail = $this->get_the_image_by_meta_key( Array( 
  929. 'post_id' => $post->ID,  
  930. 'meta_key' => $meta_key,  
  931. ) ); 
  932. break; 
  933. case 'auto' : 
  934. $thumbnail = $this->get_the_image(); 
  935. break; 
  936. case 'author' : 
  937. $thumbnail = $this->get_the_image_by_author(); 
  938. break; 
  939. default : 
  940. $thumbnail = $this->options['aiosp_opengraph_dimg']; 
  941.  
  942. if ( ( empty( $thumbnail ) && ! empty( $this->options['aiosp_opengraph_fallback'] ) ) ) { 
  943. $thumbnail = $this->options['aiosp_opengraph_dimg']; 
  944.  
  945. if ( ! empty( $thumbnail ) ) { 
  946. $thumbnail = esc_url( $thumbnail ); 
  947.  
  948. $width = $height = ''; 
  949. if ( ! empty( $thumbnail ) ) { 
  950. if ( ! empty( $metabox['aioseop_opengraph_settings_imagewidth'] ) ) { 
  951. $width = $metabox['aioseop_opengraph_settings_imagewidth']; 
  952. if ( ! empty( $metabox['aioseop_opengraph_settings_imageheight'] ) ) { 
  953. $height = $metabox['aioseop_opengraph_settings_imageheight']; 
  954. if ( empty( $width ) && ! empty( $this->options['aiosp_opengraph_dimgwidth'] ) ) { 
  955. $width = $this->options['aiosp_opengraph_dimgwidth']; 
  956. if ( empty( $height ) && ! empty( $this->options['aiosp_opengraph_dimgheight'] ) ) { 
  957. $height = $this->options['aiosp_opengraph_dimgheight']; 
  958.  
  959. if ( ! empty( $video ) ) { 
  960. if ( ! empty( $metabox['aioseop_opengraph_settings_videowidth'] ) ) { 
  961. $videowidth = $metabox['aioseop_opengraph_settings_videowidth']; 
  962. if ( ! empty( $metabox['aioseop_opengraph_settings_videoheight'] ) ) { 
  963. $videoheight = $metabox['aioseop_opengraph_settings_videoheight']; 
  964.  
  965. $card = 'summary'; 
  966. if ( ! empty( $this->options['aiosp_opengraph_defcard'] ) ) { 
  967. $card = $this->options['aiosp_opengraph_defcard']; 
  968.  
  969. if ( ! empty( $metabox['aioseop_opengraph_settings_setcard'] ) ) { 
  970. $card = $metabox['aioseop_opengraph_settings_setcard']; 
  971.  
  972. //support for changing legacy twitter cardtype-photo to summary large image 
  973. if ( $card == 'photo' ) { 
  974. $card = 'summary_large_image'; 
  975.  
  976. $site = $domain = $creator = ''; 
  977.  
  978. if ( ! empty( $this->options['aiosp_opengraph_twitter_site'] ) ) { 
  979. $site = $this->options['aiosp_opengraph_twitter_site']; 
  980. $site = AIOSEOP_Opengraph_Public::prepare_twitter_username( $site ); 
  981.  
  982. if ( ! empty( $this->options['aiosp_opengraph_twitter_domain'] ) ) { 
  983. $domain = $this->options['aiosp_opengraph_twitter_domain']; 
  984.  
  985. if ( ! empty( $post ) && isset( $post->post_author ) && ! empty( $this->options['aiosp_opengraph_twitter_creator'] ) ) { 
  986. $creator = get_the_author_meta( 'twitter', $post->post_author ); 
  987. $creator = AIOSEOP_Opengraph_Public::prepare_twitter_username( $creator ); 
  988.  
  989. $twitter_thumbnail = $thumbnail; // Default Twitter image if custom isn't set. 
  990.  
  991. if ( isset( $metabox['aioseop_opengraph_settings_customimg_twitter'] ) && ! empty( $metabox['aioseop_opengraph_settings_customimg_twitter'] ) ) { 
  992. // Set Twitter image from custom. 
  993. $twitter_thumbnail = $metabox['aioseop_opengraph_settings_customimg_twitter']; 
  994.  
  995. $meta = Array( 
  996. 'facebook' => Array( 
  997. 'title' => 'og:title',  
  998. 'type' => 'og:type',  
  999. 'url' => 'og:url',  
  1000. 'thumbnail' => 'og:image',  
  1001. 'width' => 'og:image:width',  
  1002. 'height' => 'og:image:height',  
  1003. 'video' => 'og:video',  
  1004. 'videowidth' => 'og:video:width',  
  1005. 'videoheight' => 'og:video:height',  
  1006. 'sitename' => 'og:site_name',  
  1007. 'key' => 'fb:admins',  
  1008. 'appid' => 'fb:app_id',  
  1009. 'description' => 'og:description',  
  1010. 'section' => 'article:section',  
  1011. 'tag' => 'article:tag',  
  1012. 'publisher' => 'article:publisher',  
  1013. 'author' => 'article:author',  
  1014. 'published_time' => 'article:published_time',  
  1015. 'modified_time' => 'article:modified_time',  
  1016. ),  
  1017. 'twitter' => Array( 
  1018. 'card' => 'twitter:card',  
  1019. 'site' => 'twitter:site',  
  1020. 'creator' => 'twitter:creator',  
  1021. 'domain' => 'twitter:domain',  
  1022. 'title' => 'twitter:title',  
  1023. 'description' => 'twitter:description',  
  1024. 'twitter_thumbnail' => 'twitter:image',  
  1025. ),  
  1026. ); 
  1027.  
  1028. //Only show if "use schema.org markup is checked" 
  1029. if ( ! empty( $aioseop_options['aiosp_schema_markup'] ) ) { 
  1030. $meta['google+'] = Array( 'thumbnail' => 'image' ); 
  1031.  
  1032. // Add links to testing tools 
  1033.  
  1034. /** 
  1035. http://developers.facebook.com/tools/debug 
  1036. https://dev.twitter.com/docs/cards/preview 
  1037. http://www.google.com/webmasters/tools/richsnippets 
  1038. */ 
  1039. /** 
  1040. $meta = Array( 
  1041. 'facebook' => Array( 
  1042. 'title' => 'og:title',  
  1043. 'type' => 'og:type',  
  1044. 'url' => 'og:url',  
  1045. 'thumbnail' => 'og:image',  
  1046. 'sitename' => 'og:site_name',  
  1047. 'key' => 'fb:admins',  
  1048. 'description' => 'og:description' 
  1049. ),  
  1050. 'google+' => Array( 
  1051. 'thumbnail' => 'image',  
  1052. 'title' => 'name',  
  1053. 'description' => 'description' 
  1054. ),  
  1055. 'twitter' => Array( 
  1056. 'card' => 'twitter:card',  
  1057. 'url' => 'twitter:url',  
  1058. 'title' => 'twitter:title',  
  1059. 'description' => 'twitter:description',  
  1060. 'thumbnail' => 'twitter:image' 
  1061.   
  1062. ); 
  1063. */ 
  1064.  
  1065. $tags = Array( 
  1066. 'facebook' => Array( 'name' => 'property', 'value' => 'content' ),  
  1067. 'twitter' => Array( 'name' => 'name', 'value' => 'content' ),  
  1068. 'google+' => Array( 'name' => 'itemprop', 'value' => 'content' ),  
  1069. ); 
  1070.  
  1071. foreach ( $meta as $t => $data ) { 
  1072. foreach ( $data as $k => $v ) { 
  1073. if ( empty( $$k ) ) { 
  1074. $$k = ''; 
  1075. $filtered_value = $$k; 
  1076. $filtered_value = apply_filters( $this->prefix . 'meta', $filtered_value, $t, $k ); 
  1077. if ( ! empty( $filtered_value ) ) { 
  1078. if ( ! is_array( $filtered_value ) ) { 
  1079. $filtered_value = Array( $filtered_value ); 
  1080. foreach ( $filtered_value as $f ) { 
  1081. echo '<meta ' . $tags[ $t ]['name'] . '="' . $v . '" ' . $tags[ $t ]['value'] . '="' . $f . '" />' . "\n"; 
  1082. $social_link_schema = ''; 
  1083. if ( ! empty( $social_links ) ) { 
  1084. $home_url = esc_url( get_home_url() ); 
  1085. $social_links = explode( "\n", $social_links ); 
  1086. foreach ( $social_links as $k => $v ) { 
  1087. $v = trim( $v ); 
  1088. if ( empty( $v ) ) { 
  1089. unset( $social_links[ $k ] ); 
  1090. } else { 
  1091. $v = esc_url( $v ); 
  1092. $social_links[ $k ] = $v; 
  1093. $social_links = join( '", "', $social_links ); 
  1094. $social_link_schema = <<<END 
  1095. <script type="application/ld+json"> 
  1096. { "@context" : "http://schema.org",  
  1097. "@type" : "{$social_type}",  
  1098. "name" : "{$social_name}",  
  1099. "url" : "{$home_url}",  
  1100. "sameAs" : ["{$social_links}"]  
  1101. </script> 
  1102.  
  1103. END; 
  1104. echo apply_filters( 'aiosp_opengraph_social_link_schema', $social_link_schema ); 
  1105.  
  1106. function do_opengraph() { 
  1107. global $aioseop_options; 
  1108. if ( ! empty( $aioseop_options ) && ! empty( $aioseop_options['aiosp_schema_markup'] ) ) { 
  1109. add_filter( 'language_attributes', Array( $this, 'add_attributes' ) ); 
  1110. if ( ! defined( 'DOING_AJAX' ) ) { 
  1111. add_action( 'aioseop_modules_wp_head', Array( $this, 'add_meta' ), 5 ); 
  1112.  
  1113. function type_setup() { 
  1114. global $aiosp, $wp_query; 
  1115. $this->type = ''; 
  1116. if ( $aiosp->is_static_front_page() ) { 
  1117. if ( ! empty( $this->options ) && ! empty( $this->options['aiosp_opengraph_categories'] ) ) { 
  1118. $this->type = $this->options['aiosp_opengraph_categories']; 
  1119. } elseif ( is_singular() && $this->option_isset( 'types' ) ) { 
  1120. $metabox = $this->get_current_options( Array(), 'settings' ); 
  1121. $current_post_type = get_post_type(); 
  1122. if ( ! empty( $metabox['aioseop_opengraph_settings_category'] ) ) { 
  1123. $this->type = $metabox['aioseop_opengraph_settings_category']; 
  1124. } elseif ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) { 
  1125. $this->type = $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"]; 
  1126.  
  1127. function debug_post_types() { 
  1128. add_filter( $this->prefix . 'display_settings', Array( $this, 'filter_settings' ), 10, 3 ); 
  1129. add_filter( $this->prefix . 'override_options', Array( $this, 'override_options' ), 10, 3 ); 
  1130. add_filter( $this->get_prefix( 'settings' ) . 'filter_metabox_options', Array( 
  1131. $this,  
  1132. 'filter_metabox_options',  
  1133. ), 10, 3 ); 
  1134. $post_types = $this->get_post_type_titles(); 
  1135. $rempost = array( 'revision' => 1, 'nav_menu_item' => 1 ); 
  1136. $post_types = array_diff_key( $post_types, $rempost ); 
  1137. $this->default_options['types']['initial_options'] = $post_types; 
  1138. foreach ( $post_types as $slug => $name ) { 
  1139. $field = $slug . '_fb_object_type'; 
  1140. $this->default_options[ $field ] = Array( 
  1141. 'name' => "$name " . __( 'Object Type', 'all-in-one-seo-pack' ) . "<br />($slug)",  
  1142. 'type' => 'select',  
  1143. 'style' => '',  
  1144. 'initial_options' => $this->fb_object_types,  
  1145. 'default' => 'article',  
  1146. 'condshow' => Array( 'aiosp_opengraph_types\[\]' => $slug ),  
  1147. ); 
  1148. $this->help_text[ $field ] = __( 'Choose a default value that best describes the content of your post type.', 'all-in-one-seo-pack' ); 
  1149. $this->help_anchors[ $field ] = '#content-object-types'; 
  1150. $this->locations['opengraph']['options'][] = $field; 
  1151. $this->layout['facebook']['options'][] = $field; 
  1152. $this->setting_options(); 
  1153. $this->add_help_text_links(); 
  1154.  
  1155.  
  1156. function get_all_images( $options = null, $p = null ) { 
  1157. static $img = Array(); 
  1158. if ( ! is_array( $options ) ) { 
  1159. $options = Array(); 
  1160. if ( ! empty( $this->options['aiosp_opengraph_meta_key'] ) ) { 
  1161. $options['meta_key'] = $this->options['aiosp_opengraph_meta_key']; 
  1162. if ( empty( $img ) ) { 
  1163. $size = apply_filters( 'post_thumbnail_size', 'large' ); 
  1164. $default = $this->get_the_image_by_default(); 
  1165. if ( ! empty( $default ) ) { 
  1166. $img[ $default ] = 0; 
  1167. $img = array_merge( $img, parent::get_all_images( $options, null ) ); 
  1168.  
  1169. if ( ! empty( $options ) && ! empty( $options['aioseop_opengraph_settings_customimg'] ) ) { 
  1170. $img[ $options['aioseop_opengraph_settings_customimg'] ] = 'customimg'; 
  1171.  
  1172. if ( ! empty( $options ) && ! empty( $options['aioseop_opengraph_settings_customimg'] ) ) { 
  1173. $img[ $options['aioseop_opengraph_settings_customimg'] ] = 'customimg'; 
  1174. $img[ $options['aioseop_opengraph_settings_customimg_twitter'] ] = 'customimg_twitter'; 
  1175.  
  1176. if ( $author_img = $this->get_the_image_by_author( $p ) ) { 
  1177. $image["author"] = $author_img; 
  1178. $image = array_flip( $img ); 
  1179. $images = Array(); 
  1180. if ( ! empty( $image ) ) { 
  1181. foreach ( $image as $k => $v ) { 
  1182. $images[ $v ] = '<img height=150 src="' . $v . '">'; 
  1183.  
  1184. return Array( $image, $images ); 
  1185.  
  1186. function get_the_image_by_author( $options = null, $p = null ) { 
  1187. if ( $p === null ) { 
  1188. global $post; 
  1189. } else { 
  1190. $post = $p; 
  1191. if ( ! empty( $post ) && ! empty( $post->post_author ) ) { 
  1192. $matches = Array(); 
  1193. $get_avatar = get_avatar( $post->post_author, 300 ); 
  1194. if ( preg_match( "/src='(.*?)'/i", $get_avatar, $matches ) ) { 
  1195. return $matches[1]; 
  1196.  
  1197. return false; 
  1198.  
  1199. function get_the_image( $options = null, $p = null ) { 
  1200. $meta_key = $this->options['aiosp_opengraph_meta_key']; 
  1201.  
  1202. return parent::get_the_image( Array( 'meta_key' => $meta_key ), $p ); 
  1203.  
  1204. function get_the_image_by_default( $args = array() ) { 
  1205. return $this->options['aiosp_opengraph_dimg']; 
  1206.  
  1207. function settings_update() { 
  1208.