Changeset 2021606
- Timestamp:
- 01/30/2019 04:14:05 AM (7 years ago)
- Location:
- complete-open-graph
- Files:
-
- 38 added
- 10 edited
-
tags/3.4.4 (added)
-
tags/3.4.4/complete-open-graph.php (added)
-
tags/3.4.4/index.php (added)
-
tags/3.4.4/readme.txt (added)
-
tags/3.4.4/src (added)
-
tags/3.4.4/src/Field.php (added)
-
tags/3.4.4/src/Generator.php (added)
-
tags/3.4.4/src/PostDecorator.php (added)
-
tags/3.4.4/src/Utilities.php (added)
-
tags/3.4.4/src/assets (added)
-
tags/3.4.4/src/assets/css (added)
-
tags/3.4.4/src/assets/css/style.css (added)
-
tags/3.4.4/src/assets/img (added)
-
tags/3.4.4/src/assets/img/github.svg.php (added)
-
tags/3.4.4/src/assets/img/twitter.svg.php (added)
-
tags/3.4.4/src/assets/img/wordpress.svg.php (added)
-
tags/3.4.4/src/assets/js (added)
-
tags/3.4.4/src/assets/js/scripts.js (added)
-
tags/3.4.4/src/assets/scss (added)
-
tags/3.4.4/src/assets/scss/_variables.scss (added)
-
tags/3.4.4/src/assets/scss/components (added)
-
tags/3.4.4/src/assets/scss/components/_SK_Box.scss (added)
-
tags/3.4.4/src/assets/scss/components/_SK_FeedbackList.scss (added)
-
tags/3.4.4/src/assets/scss/components/_SK_ImageHolder.scss (added)
-
tags/3.4.4/src/assets/scss/components/_SK_SidebarBlock.scss (added)
-
tags/3.4.4/src/assets/scss/layouts (added)
-
tags/3.4.4/src/assets/scss/layouts/_metabox.scss (added)
-
tags/3.4.4/src/assets/scss/layouts/_settings.scss (added)
-
tags/3.4.4/src/assets/scss/style.scss (added)
-
tags/3.4.4/src/fields.php (added)
-
tags/3.4.4/src/helpers.php (added)
-
tags/3.4.4/src/hooks (added)
-
tags/3.4.4/src/hooks/content-filters.php (added)
-
tags/3.4.4/src/hooks/generate-open-graph-markup.php (added)
-
tags/3.4.4/src/hooks/metabox.php (added)
-
tags/3.4.4/src/hooks/settings.php (added)
-
tags/3.4.4/src/hooks/support.php (added)
-
tags/3.4.4/src/index.php (added)
-
trunk/complete-open-graph.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Field.php (modified) (3 diffs)
-
trunk/src/Utilities.php (modified) (2 diffs)
-
trunk/src/assets/js/scripts.js (modified) (1 diff)
-
trunk/src/hooks/content-filters.php (modified) (3 diffs)
-
trunk/src/hooks/generate-open-graph-markup.php (modified) (2 diffs)
-
trunk/src/hooks/metabox.php (modified) (3 diffs)
-
trunk/src/hooks/settings.php (modified) (3 diffs)
-
trunk/src/hooks/support.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
complete-open-graph/trunk/complete-open-graph.php
r2020886 r2021606 3 3 * Plugin Name: Complete Open Graph 4 4 * Description: Simple, comprehensive, highly customizable Open Graph management. 5 * Version: 3.4. 35 * Version: 3.4.4 6 6 * Author: Alex MacArthur 7 7 * Author URI: https://macarthur.me … … 24 24 define('COMPLETE_OPEN_GRAPH_ADMIN_SETTINGS_PAGE_SLUG', 'complete_open_graph'); 25 25 define('COMPLETE_OPEN_GRAPH_REAL_PATH', trailingslashit(realpath(dirname(__FILE__)))); 26 define('COMPLETE_OPEN_GRAPH_IMAGE_WIDTH', 1200); 27 define('COMPLETE_OPEN_GRAPH_IMAGE_HEIGHT', 1200); 26 28 27 29 require_once COMPLETE_OPEN_GRAPH_REAL_PATH . 'src/Generator.php'; -
complete-open-graph/trunk/readme.txt
r2020886 r2021606 7 7 Requires PHP: 5.6 8 8 Tested up to: 5.0.3 9 Stable tag: 3.4. 39 Stable tag: 3.4.4 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 150 150 ` 151 151 152 == Advanced Filtering ==153 If, for whatever reason, you need to access any of the hooks registered by this plugin, you may do so by referencing the `CompleteOpenGraph\App` key in the `$GLOBALS` array. Each controller is saved to this central instance, so you can remove actions (or whatever) by using it. For example, the following snippet will completely remove the `Open Graph` settings page from the sidebar menu.154 155 `156 remove_action('admin_menu', array($GLOBALS['CompleteOpenGraph\App']->controllers['Settings'], 'open_graph_settings_page'));157 `158 159 152 == Order of Priority == 160 153 … … 307 300 * On author archive pages, if author has an avatar image, use that as OG image. 308 301 302 = 3.4.4 = 303 * Fix sizing issue with uploaded images less than 1200px wide. 304 * Require that selected OG images be, at minimum, 200px x 200px. 305 * Ensure that OG URLs are never relative. 306 309 307 == Feedback == 310 308 -
complete-open-graph/trunk/src/Field.php
r2017039 r2021606 8 8 class Field 9 9 { 10 11 10 public function __construct($key) 12 11 { … … 18 17 public function __get($property) 19 18 { 20 21 19 if ($property === 'name') { 22 20 return 'complete_open_graph_' . $this->key; … … 48 46 public static function getConfigurable($fields = null) 49 47 { 50 51 48 $fields = is_null($fields) ? Utilities::getFields() : $fields; 52 49 -
complete-open-graph/trunk/src/Utilities.php
r2017039 r2021606 7 7 class Utilities 8 8 { 9 10 9 public static function getFields() 11 10 { … … 189 188 self::get_option('force_all') === 'on' || 190 189 self::get_option($field_name . '_force') === 'on' || 191 ( is_home() || is_archive())190 (is_home() || is_archive()) 192 191 ); 193 192 -
complete-open-graph/trunk/src/assets/js/scripts.js
r2017039 r2021606 22 22 23 23 customUploader.on('select', function (e) { 24 attachment = customUploader.state().get('selection').first().toJSON(); 25 thumbURL = attachment.sizes['medium'] == undefined ? attachment.url : attachment.sizes['medium'].url; 24 attachment = customUploader.state().get('selection').first().toJSON(); 25 thumbURL = attachment.sizes['medium'] == undefined ? attachment.url : attachment.sizes['medium'].url; 26 27 //-- Require that images be minimum dimensions. 28 if(attachment.width < 200 || attachment.height < 200) { 29 alert("Sorry! Your Open Graph image must be at least 200px wide and 200px high.") 30 return; 31 } 26 32 27 33 if ($COGMetaBox) { -
complete-open-graph/trunk/src/hooks/content-filters.php
r2020886 r2021606 12 12 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:site', 'CompleteOpenGraph\append_at_symbol', 10, 2); 13 13 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:creator', 'CompleteOpenGraph\append_at_symbol', 10, 2); 14 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_og:image', 'CompleteOpenGraph\ attach_image_dimensions', 10, 2);15 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:image', 'CompleteOpenGraph\ attach_image_dimensions', 10, 2);14 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_og:image', 'CompleteOpenGraph\get_image_url_from_attachment_id', 10, 2); 15 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:image', 'CompleteOpenGraph\get_image_url_from_attachment_id', 10, 2); 16 16 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_og:image', 'CompleteOpenGraph\maybe_use_author_avatar', 10, 2); 17 17 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:image', 'CompleteOpenGraph\maybe_use_author_avatar', 10, 2); 18 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_og:image', 'CompleteOpenGraph\ensure_full_url', 10, 2); 19 add_filter(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_twitter:image', 'CompleteOpenGraph\ensure_full_url', 10, 2); 20 21 /** 22 * If, for some weird reason, we have an image URL that starts with a slash, 23 * append the site URL so a full URL is actually generated. 24 * 25 * @param string $value 26 * @param string $field_name 27 * @return void 28 */ 29 function ensure_full_url($value, $field_name = '') 30 { 31 if (substr($value, 0, 1) === '/') { 32 return untrailingslashit(get_site_url()) . $value; 33 } 34 35 return $value; 36 } 18 37 19 38 /** … … 25 44 * @return void 26 45 */ 27 function maybe_use_author_avatar($value, $field_name )46 function maybe_use_author_avatar($value, $field_name = '') 28 47 { 29 48 if (!is_author()) { … … 47 66 * @return string 48 67 */ 49 function attach_image_dimensions($value, $field_name)68 function get_image_url_from_attachment_id($value, $field_name = '') 50 69 { 51 52 // -- This is probably a URL from an older version of the plugin. Just return it.53 if (! is_numeric($value)) {70 // -- This is a URL. Just leave it be. 71 // -- @todo: Require that it is an absolute URL. 72 if (!is_numeric($value)) { 54 73 return $value; 55 74 } 56 75 57 $image_sizes = array( 58 'complete_open_graph', 59 'large', 60 'medium_large', 61 'medium', 62 'full', 63 ); 64 65 $data = false; 66 $attachment_meta = wp_get_attachment_metadata($value); 67 $sizes = isset($attachment_meta['sizes']) ? $attachment_meta['sizes'] : array(); 68 69 // -- The 'full' size isn't included by default. 70 $sizes['full'] = true; 71 72 // -- Loop over each image size. Serves as a fallback mechanism if it doesn't exist at the ideal size. 73 foreach ($image_sizes as $size) { 74 // -- We have an image! 75 if (array_key_exists($size, $sizes)) { 76 $data = wp_get_attachment_image_src($value, $size); 77 break; 78 } 79 } 76 $data = wp_get_attachment_image_src($value, 'complete_open_graph'); 80 77 81 78 // -- If, for some reason, no image is returned, exit. Should NEVER actually happen, but you know... #WordPress. -
complete-open-graph/trunk/src/hooks/generate-open-graph-markup.php
r2017039 r2021606 18 18 function generate_open_graph_markup() 19 19 { 20 21 20 if (! apply_filters(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_maybe_enable', true)) { 22 21 return; … … 48 47 } 49 48 50 echo '<!-- End Complete Open Graph. | ' . ( microtime(true) - $start_time) . "s -->\n\n";49 echo '<!-- End Complete Open Graph. | ' . (microtime(true) - $start_time) . "s -->\n\n"; 51 50 } 52 51 -
complete-open-graph/trunk/src/hooks/metabox.php
r2017092 r2021606 39 39 wp_nonce_field(COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_nonce_verification', COMPLETE_OPEN_GRAPH_OPTIONS_PREFIX . '_nonce'); 40 40 41 $imageURL = wp_get_attachment_image_src(Utilities::get_post_option('og:image'), 'medium')[0]; 42 43 ?> 41 $imageURL = wp_get_attachment_image_src(Utilities::get_post_option('og:image'), 'medium')[0]; ?> 44 42 <p class="main-description">These fields will allow you to customize the open graph data for the page or post.</p> 45 43 … … 80 78 <?php 81 79 break; 82 } 83 ?> 80 } ?> 84 81 </fieldset> 85 82 … … 114 111 function save($post_id) 115 112 { 116 117 113 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 118 114 return; -
complete-open-graph/trunk/src/hooks/settings.php
r2017039 r2021606 57 57 function open_graph_settings_page_cb() 58 58 { 59 60 59 $github_url = 'https://github.com/alexmacarthur/wp-complete-open-graph'; 61 60 $wordpress_url = 'https://wordpress.org/support/plugin/complete-open-graph/reviews/?rate=5#new-post'; 62 $twitter_url = 'https://twitter.com/intent/tweet?text=I%20highly%20recommend%20the%20Complete%20Open%20Graph%20%23WordPress%20plugin%20from%20%40amacarthur!%20https%3A//wordpress.org/plugins/complete-open-graph/'; 63 64 ?> 61 $twitter_url = 'https://twitter.com/intent/tweet?text=I%20highly%20recommend%20the%20Complete%20Open%20Graph%20%23WordPress%20plugin%20from%20%40amacarthur!%20https%3A//wordpress.org/plugins/complete-open-graph/'; ?> 65 62 <div 66 63 id="cogSettingsPage" … … 79 76 <?php 80 77 settings_fields('complete_open_graph_settings'); 81 do_settings_sections(COMPLETE_OPEN_GRAPH_ADMIN_SETTINGS_PAGE_SLUG); 82 submit_button(); 83 ?> 78 do_settings_sections(COMPLETE_OPEN_GRAPH_ADMIN_SETTINGS_PAGE_SLUG); 79 submit_button(); ?> 84 80 </form> 85 81 </div> … … 401 397 $imageAttachment = wp_get_attachment_image_src($imageID, 'medium'); 402 398 $imageURL = isset($imageAttachment[0]) ? $imageAttachment[0] : ''; 403 } 404 405 ?> 399 } ?> 406 400 <fieldset class="SK_Box SK_Box--standOut"> 407 401 <p>If left blank, the featured image on the home page will be used.</p> -
complete-open-graph/trunk/src/hooks/support.php
r2017039 r2021606 14 14 { 15 15 add_theme_support('post-thumbnails'); 16 add_image_size('complete_open_graph', 1200, 1200, false);16 add_image_size('complete_open_graph', COMPLETE_OPEN_GRAPH_IMAGE_WIDTH, COMPLETE_OPEN_GRAPH_IMAGE_HEIGHT, false); 17 17 } 18 18
Note: See TracChangeset
for help on using the changeset viewer.