WordPress.org

Plugin Directory

Changeset 632788


Ignore:
Timestamp:
12/01/12 23:03:53 (17 months ago)
Author:
niallkennedy
Message:

version 1.1.7. improved comments filters; Comments Box admin for post author; use settings API error function if present

Location:
facebook/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • facebook/trunk/admin/login.php

    r632569 r632788  
    3232 
    3333        if ( ! class_exists( 'Facebook_User' ) ) 
    34             require_once( dirname(__FILE__) . '/facebook-user.php' ); 
     34            require_once( dirname( dirname(__FILE__) ) . '/facebook-user.php' ); 
    3535 
    3636        $facebook_user_data_exists = false; 
  • facebook/trunk/admin/settings-app.php

    r632569 r632788  
    254254                } else if ( preg_match( '/^[0-9]+$/', $app_id ) ) { 
    255255                    $clean_options['app_id'] = $app_id; 
    256                 } else { 
     256                } else if ( function_exists( 'add_settings_error' ) ) { 
    257257                    add_settings_error( 'facebook-app-id', 'facebook-app-id-error', __( 'App ID must contain only digits.', 'facebook' ) ); 
    258258                } 
     
    269269                if ( preg_match( '/^[0-9a-f]+$/', $app_secret ) ) // hex 
    270270                    $clean_options['app_secret'] = $app_secret; 
    271                 else 
     271                else if ( function_exists( 'add_settings_error' ) ) 
    272272                    add_settings_error( 'facebook-app-secret', 'facebook-app-secret-error', __( 'Invalid app secret.', 'facebook' ) ); 
    273273            } 
     
    296296                        unset( $app_info ); 
    297297                    } else { 
    298                         add_settings_error( 'facebook-app-auth', 'facebook-app-auth-error', __( 'Application ID and secret failed on authentication with Facebook.', 'facebook' ) ); 
     298                        if ( function_exists( 'add_settings_error' ) ) 
     299                            add_settings_error( 'facebook-app-auth', 'facebook-app-auth-error', __( 'Application ID and secret failed on authentication with Facebook.', 'facebook' ) ); 
    299300                        unset( $clean_options['app_id'] ); 
    300301                        unset( $clean_options['app_secret'] ); 
  • facebook/trunk/admin/settings.php

    r632569 r632788  
    2121     */ 
    2222    public static function init() { 
    23         self::migrate_options_10(); 
     23        self::migrate_options(); 
    2424        add_action( 'admin_menu', array( 'Facebook_Settings', 'settings_menu_items' ) ); 
    2525        add_filter( 'plugin_action_links', array( 'Facebook_Settings', 'plugin_action_links' ), 10, 2 ); 
     
    361361     * @since 1.1 
    362362     */ 
    363     public static function migrate_options_10() { 
     363    public static function migrate_options() { 
    364364        if ( get_option( 'facebook_migration_10' ) ) { 
    365365            // run 1.1.5 migration if 1.0 migration already run 
  • facebook/trunk/facebook.php

    r632569 r632788  
    22/** 
    33 * @package Facebook 
    4  * @version 1.1.5 
     4 * @version 1.1.7 
    55 */ 
    66/* 
     
    1010Author: Facebook 
    1111Author URI: https://developers.facebook.com/wordpress/ 
    12 Version: 1.1.6 
     12Version: 1.1.7 
    1313License: GPL2 
    1414License URI: license.txt 
     
    2929     * @var string 
    3030     */ 
    31     const VERSION = '1.1.6'; 
     31    const VERSION = '1.1.7'; 
    3232 
    3333    /** 
     
    228228        // include comment count filters on all pages 
    229229        if ( get_option( 'facebook_comments_enabled' ) ) { 
    230             add_filter( 'comments_array', '__return_null' ); 
    231             add_filter( 'comments_open', '__return_true' ); // comments are always open 
    232  
    233             // short-circuit special template behavior for comment count = 0 
    234             // prevents linking to #respond anchor which leads nowhere 
    235             add_filter( 'get_comments_number', create_function('', 'return -1;') ); 
    236  
    237230            if ( ! class_exists( 'Facebook_Comments' ) ) 
    238231                require_once( $this->plugin_directory . 'social-plugins/class-facebook-comments.php' ); 
    239232 
     233            add_filter( 'comments_array', array( 'Facebook_Comments', 'comments_array_filter' ), 10, 2 ); 
     234            add_filter( 'comments_open', array( 'Facebook_Comments', 'comments_open_filter' ), 10, 2 ); 
     235 
     236            // override comment count to a garbage number 
     237            add_filter( 'get_comments_number', array( 'Facebook_Comments', 'get_comments_number_filter' ), 10, 2 ); 
    240238            // display comments number if used in template 
    241             add_filter( 'comments_number', array( 'Facebook_Comments', 'comments_count_xfbml' ) ); 
     239            add_filter( 'comments_number', array( 'Facebook_Comments', 'comments_number_filter' ), 10, 2 ); 
    242240        } 
    243241 
  • facebook/trunk/open-graph-protocol.php

    r632569 r632788  
    199199            setup_postdata( $post ); 
    200200            $post_type = get_post_type(); 
    201             $meta_tags[ self::OGP_NS . 'type' ] = 'article'; 
    202201            $meta_tags[ self::OGP_NS . 'url' ] = apply_filters( 'facebook_rel_canonical', get_permalink() ); 
    203202            if ( post_type_supports( $post_type, 'title' ) ) 
     
    217216            } 
    218217 
     218            $meta_tags[ self::OGP_NS . 'type' ] = 'article'; 
    219219            $meta_tags[ self::ARTICLE_NS . 'published_time' ] = date( 'c', strtotime( $post->post_date_gmt ) ); 
    220220            $meta_tags[ self::ARTICLE_NS . 'modified_time' ] = date( 'c', strtotime( $post->post_modified_gmt ) ); 
    221221 
    222             if ( post_type_supports( $post_type, 'author' ) && isset( $post->post_author ) ) 
     222            if ( post_type_supports( $post_type, 'author' ) && isset( $post->post_author ) ) { 
    223223                $meta_tags[ self::ARTICLE_NS . 'author' ] = get_author_posts_url( $post->post_author ); 
     224                // adding an fb:admin grants comment moderation permissions for Comment Box 
     225                if ( get_option( 'facebook_comments_enabled' ) && user_can( $post->post_author, 'moderate_comments' ) ) { 
     226                    if ( ! class_exists( 'Facebook_Comments' ) ) 
     227                        require_once( dirname(__FILE__) . '/social-plugins/class-facebook-comments.php' ); 
     228                    if ( Facebook_Comments::comments_enabled_for_post_type( $post ) ) { 
     229                        if ( ! class_exists( 'Facebook_User' ) ) 
     230                            require_once( dirname(__FILE__) . '/facebook-user.php' ); 
     231                        $facebook_user_data = Facebook_User::get_user_meta( $post->post_author, 'fb_data', true ); 
     232                        if ( is_array( $facebook_user_data ) && isset( $facebook_user_data['fb_uid'] ) ) 
     233                            $meta_tags[ self::FB_NS . 'admins' ] = $facebook_user_data['fb_uid']; 
     234                        unset( $facebook_user_data ); 
     235                    } 
     236                } 
     237            } 
    224238 
    225239            // add the first category as a section. all other categories as tags 
  • facebook/trunk/readme.txt

    r632569 r632788  
    66License: GPLv2 
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    8 Stable tag: 1.1.6 
     8Stable tag: 1.1.7 
    99 
    1010Make your WordPress site social in a couple of clicks, powered by Facebook. 
     
    116116== Upgrade Notice == 
    117117 
     118= 1.1.7 = 
     119Improved comment filters. Add post author as Comment Box admin/moderator. Hide settings error displayed if no output functions exist. 
     120 
    118121= 1.1.6 = 
    119122Debug page, og: prefixed Open Graph protocol properties, Shortcode API support for Like and Send buttons, comments improvements. 
     
    141144 
    142145== Changelog == 
     146 
     147= 1.1.7 = 
     148* Comments Box - overrides of WordPress comment system applied at the post level, allowing more fine-grained control of comments by post type or mixed in a single loop 
     149* Comments Box - declare post author with `moderate_comments` capability an admin of the individual page, granting comment moderation capabilities on Facebook for the post 
     150* Hide settings error display if function is not yet defined 
    143151 
    144152= 1.1.6 = 
  • facebook/trunk/social-plugins/class-facebook-comments.php

    r632569 r632788  
    1616    public static function css_hide_comments() { 
    1717        wp_enqueue_style( 'fb_hide_wp_comments', plugins_url( 'static/css/hide-wp-comments.min.css', dirname(__FILE__) ), array(), '1.1' ); 
     18    } 
     19 
     20    /** 
     21     * Is Comments Box enabled for the current post type? 
     22     * 
     23     * @since 1.1.7 
     24     * @param object $post post object 
     25     * @return bool true if Comments Box enabled 
     26     */ 
     27    public static function comments_enabled_for_post_type( $post = null ) { 
     28        $post_type = get_post_type( $post ); 
     29        if ( ! $post_type ) 
     30            return false; 
     31 
     32        $features = get_option( 'facebook_' . $post_type . '_features' ); 
     33        if ( is_array( $features ) && isset( $features['comments'] ) ) 
     34            return true; 
     35 
     36        return false; 
     37    } 
     38 
     39    /** 
     40     * Override returned comments if Comments Box handles comments for the post type 
     41     * 
     42     * @since 1.1.7 
     43     * @see comments_template() 
     44     * @param array $comments comments for a post 
     45     * @param int $post_id post identifier 
     46     * @return array to be stored in WP_Query 
     47     */ 
     48    public static function comments_array_filter( $comments, $post_id = null ) { 
     49        if ( ! empty( $comments ) && $post_id ) { 
     50            $_post = get_post( $post_id ); 
     51            if ( $_post && self::comments_enabled_for_post_type( $_post ) ) 
     52                return array(); 
     53        } 
     54        return $comments; 
     55    } 
     56 
     57    /** 
     58     * Turn on comments open if Comments Box enabled for the post type 
     59     * A Comment Box always solicits new comments 
     60     * 
     61     * @since 1.1.7 
     62     * @see comments_open() 
     63     * @param bool $open comment status == 'open' 
     64     * @param int $post_id post identifier 
     65     * @return bool are comments open? 
     66     */ 
     67    public static function comments_open_filter( $open, $post_id = null ) { 
     68        if ( ! $open && $post_id ) { 
     69            $_post = get_post( $post_id ); 
     70            if ( $_post && self::comments_enabled_for_post_type( $_post ) ) 
     71                return true; 
     72        } 
     73        return $open; 
     74    } 
     75 
     76    /** 
     77     * Override post->comment_count returned value 
     78     * Short-circuit special template behavior for comment count = 0 
     79     * Prevents linking to #respond anchor which leads nowhere 
     80     * 
     81     * @see get_comments_number() 
     82     * @param int $count comment count 
     83     * @param int $post_id post identifier 
     84     * @return int comment count 
     85     */ 
     86    public static function get_comments_number_filter( $count, $post_id = null ) { 
     87        if ( $post_id ) { 
     88            $_post = get_post( $post_id ); 
     89            if ( $_post && self::comments_enabled_for_post_type( $_post ) ) 
     90                return -1; 
     91        } 
     92        return $count; 
     93    } 
     94 
     95    /** 
     96     * Overrides text displayed with comments number, inserting Facebook XFBML to be replaced by a number with the Facebook JavaScript SDK 
     97     * 
     98     * @param string $output number of comments text 
     99     * @param number of comments returned by get_comments_number() 
     100     * @return string passed output or XFBML string 
     101     */ 
     102    public static function comments_number_filter( $output, $number = null ) { 
     103        $_post = get_post(); 
     104        if ( $_post && self::comments_enabled_for_post_type( $_post ) ) 
     105            return self::comments_count_xfbml(); 
     106        return $output; 
    18107    } 
    19108 
Note: See TracChangeset for help on using the changeset viewer.