Plugin Directory

Changeset 1901559


Ignore:
Timestamp:
06/30/2018 05:14:20 AM (8 years ago)
Author:
alexmacarthur
Message:

Update to version 3.3.0.

Location:
complete-open-graph
Files:
34 added
5 edited

Legend:

Unmodified
Added
Removed
  • complete-open-graph/trunk/complete-open-graph.php

    r1896779 r1901559  
    33* Plugin Name: Complete Open Graph
    44* Description: Simple, comprehensive, highly customizable Open Graph management.
    5 * Version: 3.2.7
     5* Version: 3.3.0
    66* Author: Alex MacArthur
    77* Author URI: https://macarthur.me
  • complete-open-graph/trunk/composer.json

    r1896779 r1901559  
    55  "minimum-stability": "stable",
    66  "license": "GPL-2.0",
    7   "version": "3.2.7",
     7  "version": "3.3.0",
    88  "authors": [
    99    {
     
    1616  "support" : {
    1717    "issues": "https://wordpress.org/support/plugin/complete-open-graph",
    18     "source": "https://downloads.wordpress.org/plugin/complete-open-graph.3.2.7.zip"
     18    "source": "https://downloads.wordpress.org/plugin/complete-open-graph.3.3.0.zip"
    1919    },
    2020    "autoload-dev": {
  • complete-open-graph/trunk/readme.txt

    r1896779 r1901559  
    66Requires at least: 3.9
    77Tested up to: 4.9.6
    8 Stable tag: 3.2.7
     8Stable tag: 3.3.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    127127`
    128128
     129The `complete_open_graph_maybe_enable` filter allows you to disable tag generation altogether by returning a boolean.
     130
     131Example for disabling generation altogether:
     132`
     133add_filter('complete_open_graph_maybe_enable', '__return_false');
     134`
     135
     136Example for disabling generation on a specific page:
     137`
     138add_filter('complete_open_graph_maybe_enable', function ($maybeEnable) {
     139    global $post;
     140
     141    if($post->post_name === 'my-page') {
     142        return false;
     143    }
     144
     145    return $maybeEnable;
     146});
     147`
     148
    129149== Advanced Filtering ==
    130150If, 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.
     
    263283* Improve handling of default values and how they're handled if left empty.
    264284
     285= 3.3.0 =
     286* Fix errors being thrown in PHP versions under 5.6.
     287* Add filter to disable Open Graph tags per page.
     288
    265289== Feedback ==
    266290
  • complete-open-graph/trunk/src/Filters.php

    r1893749 r1901559  
    1313    add_filter(self::$options_prefix . '_twitter:site', array($this, 'append_at_symbol'), 10, 2);
    1414    add_filter(self::$options_prefix . '_twitter:creator', array($this, 'append_at_symbol'), 10, 2);
    15     add_filter(self::$options_prefix . '_og:image', array($this, 'process_image'), 10, 2);
    16     add_filter(self::$options_prefix . '_twitter:image', array($this, 'process_image'), 10, 2);
     15    add_filter(self::$options_prefix . '_og:image', array($this, 'attach_image_dimensions'), 10, 2);
     16    add_filter(self::$options_prefix . '_twitter:image', array($this, 'attach_image_dimensions'), 10, 2);
    1717  }
    1818
     
    2424   * @return string
    2525   */
    26   public function process_image($value, $field_name) {
     26  public function attach_image_dimensions($value, $field_name) {
    2727
    2828    $width = '';
     
    3030
    3131        if(!is_numeric($value)) return $value;
     32
     33        //-- Ensure this is actually an integer.
     34        $value = intval($value);
    3235
    3336        //-- If this attachment doesn't actually exist or isn't an image, just get out of here.
  • complete-open-graph/trunk/src/Generator.php

    r1896779 r1901559  
    77  public function __construct() {
    88    add_action('wp_head', array($this, 'generate_open_graph_markup'));
    9         add_filter('language_attributes', array($this, 'add_open_graph_prefix'), 10, 2 );
     9        add_filter('language_attributes', array($this, 'add_open_graph_prefix'), 10, 2);
    1010    }
    1111
     
    1717   */
    1818  public function add_open_graph_prefix( $output, $doctype ) {
     19        if(!apply_filters(self::$options_prefix . '_maybe_enable', true)) return $output;
     20
    1921    return $output . ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# website: http://ogp.me/ns/website#"';
    20   }
     22    }
    2123
    2224  /**
     
    2628   */
    2729  public function generate_open_graph_markup() {
     30        if(!apply_filters(self::$options_prefix . '_maybe_enable', true)) return;
    2831
    2932    echo "\n\n<!-- Open Graph data is managed by Alex MacArthur's Complete Open Graph plugin. (v" . self::$plugin_data['Version'] . ") -->\n";
     
    8083            //-- Remove non-protected items before we tack on our global value.
    8184            //-- This way, we can have a fallback system in place in case a global value is empty.
    82             $progression = array_filter($progression, function ($key) use($protectedKeys) {
    83                 return in_array($key, $protectedKeys);
    84             }, ARRAY_FILTER_USE_KEY);
    85 
    86             //-- Place our global value at the top of progression.
     85            $progression = $this->get_only_protected_values($progression, $protectedKeys);
     86
    8787            array_unshift($progression, $value);
    8888
     
    9999        );
    100100
     101    }
     102
     103    /**
     104     * Ideally, this would be array_filter(), but was causing PHP fallback issues.
     105     *
     106     * @param array $progression
     107     * @param array $protectedKeys
     108     * @return array
     109     */
     110    public function get_only_protected_values($progression, $protectedKeys) {
     111        $protectedValues = array();
     112
     113        foreach($protectedKeys as $key) {
     114            if(!isset($progression[$key])) continue;
     115            $protectedValues[] = $progression[$key];
     116        }
     117
     118        return $protectedValues;
    101119    }
    102120
Note: See TracChangeset for help on using the changeset viewer.