Plugin Directory

Changeset 790780


Ignore:
Timestamp:
10/20/2013 07:42:08 AM (12 years ago)
Author:
mobius5150
Message:

A large number of bug fixes and compatibility optimizations. See README

Location:
globalfeed/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • globalfeed/trunk/class-mb_globalfeed_feed.php

    r593074 r790780  
    3030     * @var str
    3131     */
    32     private $feed_name = 'Example Feed';
     32    protected $feed_name = 'Example Feed';
    3333   
    3434    /**
     
    3737     * @var str
    3838     */
    39     private $feed_slug = 'example_feed';
     39    protected $feed_slug = 'example_feed';
    4040   
    4141    /**
     
    4444     * @var str
    4545     */
    46     private $feed_type = 'request';
     46    protected $feed_type = 'request';
    4747   
    4848    /**
     
    5151     * @var array
    5252     */
    53     private $pages_to_show = array(
     53    protected $pages_to_show = array(
    5454        'all'
    5555    );
     
    5959     * @var array
    6060     */
    61     private $pages_not_to_show = array(
     61    protected $pages_not_to_show = array(
    6262       
    6363    );
     
    7070     * @var array $feed_options
    7171     */
    72     private $feed_options = array(
     72    protected $feed_options = array(
    7373        'auto_contain_feed_items' => true
    7474    );
     
    7979     * @var type array
    8080     */
    81     private $allowed_actions = array(
     81    protected $allowed_actions = array(
    8282        'update_feed',
    8383        'do_maintenance'
     
    232232   
    233233    /**
    234      * This function take the rawdata returned by the feed source (ie Titter, Facebook etc...) and converts it into
     234     * Adds an alert that should be displayed to the user
     235     *
     236     * If an alert with the same $alert_code already exists, it will be overwritten.
     237     *
     238     * @global type $current_user
     239     *
     240     * @param str $alert_code A slug-style code for the alert
     241     * @param str $alert_text The alert text
     242     * @param type $important Whether the alert should be shown as a notice or an error
     243     * @param bool $sitewide (optional, defaults to false) Whether the alert should be shown sitewide, or just within GlobalFeed.
     244     * @param type $require_priv What privilege the alert requires to be seen. '' if none.
     245     * @param type $dismissable Whether the alert should be dismissable by the user
     246     */
     247    public function add_alert( $alert_code, $alert_text, $important = false, $sitewide = false, $require_priv = 'manage_options', $dismissable = true ) {
     248        global $current_user, $mb_globalfeed;
     249       
     250        if (!isset($this->feed_options['alerts']))
     251            $this->feed_options['alerts'] = array();
     252       
     253        $this->feed_options['alerts'][$alert_code] = array(
     254            'alert_code' => $alert_code,
     255            'alert_text' => $alert_text,
     256            'sitewide'   => $sitewide,
     257            'hidden'     => false,
     258            'remind'     => 0,
     259            'important'  => $important,
     260            'require_priv' => $require_priv,
     261            'never_show' => (isset($this->feed_options['alerts'][$alert_code]) ? $this->feed_options['alerts'][$alert_code]['never_show'] : false),
     262            'dismissable'=> $dismissable,
     263        );
     264       
     265        $this->register_feed(true);
     266       
     267        delete_user_meta($current_user->ID, $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_hide_alert_" . $alert_code);
     268    }
     269   
     270    /**
     271     * When an alert no longer applies, hide it from the user.
     272     *
     273     * @param type $alert_code
     274     */
     275    function hide_alert( $alert_code ) {
     276        if (!isset($this->feed_options['alerts']))
     277            return;
     278       
     279        if ( isset($this->feed_options['alerts'][$alert_code]) )
     280            $this->feed_options['alerts'][$alert_code]['hidden'] = true;
     281       
     282        $this->register_feed(true);
     283    }
     284   
     285    /**
     286     * When several alerts no longer apply, hide them from the user.
     287     *
     288     * @param array $alert_codes
     289     */
     290    function hide_alerts( $alert_codes ) {
     291        if (!isset($this->feed_options['alerts']))
     292            return;
     293       
     294        foreach ($alert_codes as $alert_code) {
     295            if ( isset($this->feed_options['alerts'][$alert_code]) )
     296                $this->feed_options['alerts'][$alert_code]['hidden'] = true;
     297        }
     298       
     299        $this->register_feed(true);
     300    }
     301   
     302    /**
     303     * Shows any queued alerts. Also detects if the user hides an alert
     304     *
     305     * Called by WordPress Action 'admin_notices'
     306     *
     307     */
     308    function show_alerts() {
     309        global $current_user, $mb_globalfeed;
     310       
     311        // Check if there are alerts
     312        if ( !count($this->feed_options['alerts']) )
     313            return;
     314       
     315        $hide_text = __('Hide', 'mb_globalfeed');
     316        $never_show_text = __('Never show again', 'mb_globalfeed');
     317       
     318        // Used for show/hide urls
     319        $server_args = array();
     320        parse_str($_SERVER['QUERY_STRING'], $server_args);
     321       
     322        // Loop through alerts
     323        foreach ($this->feed_options['alerts'] as $alert_code => $alert) {
     324            // Check if this alert should be hidden from the user
     325            $hide_alert = $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_hide_alert_" . $alert['alert_code'];
     326            $never_show_alert = $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_never_show_alert_" . $alert['alert_code'];
     327           
     328            // Check if alert show status changed
     329            if ( isset($_GET[$hide_alert]) ) {
     330                add_user_meta($current_user->ID, $hide_alert, true);
     331                continue;
     332            }
     333           
     334            if ( isset($_GET[$never_show_alert]) ) {
     335                $this->globalfeed->print_debug_info("Never show");
     336                $this->feed_options['alerts'][$alert_code]['never_show'] = true;
     337                $this->register_feed(true);
     338                continue;
     339            }
     340           
     341            // Check if alert is disabled -- but make sure we catch anything telling us to hide the alert (but make sure the user has permission)
     342            if ( ( $alert['require_priv'] == '' || current_user_can($alert['require_priv']) ) && (
     343                    // Is this alert disabled?
     344                    $alert['hidden'] || $alert['never_show']
     345                   
     346                    // Check if the alert should be shown accross WP-Admin
     347                    || ( $mb_globalfeed->in_admin() === false && !$alert['sitewide'] )
     348                   
     349                    // Check if the user has previously hidden this alert
     350                    || get_user_meta($current_user->ID, $hide_alert, true) === true ) )
     351                continue;
     352           
     353            // This alert should be shown to the user
     354            echo "<div class='{$alert['alert_code']} " . ($alert['important'] ? 'error' : 'updated') . "'><p>{$alert['alert_text']}</p>";
     355           
     356            if ( $alert['dismissable'] ) {
     357                $hide_addr = http_build_query(array_merge($server_args, array($hide_alert=>1)));
     358                $never_addr=  http_build_query(array_merge($server_args, array($never_show_alert=>1)));
     359                echo "<div class='align_right'><a href='?$hide_addr' title='$hide_text'>$hide_text</a> | <a href='?$never_addr' title='$never_show_text'>$never_show_text</a></div></div>";
     360            } else
     361                echo '</div>';
     362        }
     363    }
     364   
     365    /**
     366     * Gets the translated text for a message for the feed.
     367     * @param string $message_slug The message text to retrieve.
     368     * @return string The translated message text
     369     */
     370    function get_message($message_slug) {
     371        return '';
     372    }
     373   
     374    /**
     375     * This function take the rawdata returned by the feed source (ie Twitter, Facebook etc...) and converts it into
    235376     * the array format expected by $mb_globalfeed->save_feed_items(), then it saves it using this function.
    236377     *
  • globalfeed/trunk/feeds/mb_facebook/mb_facebook.php

    r711609 r790780  
    3939     * @var str
    4040     */
    41     private $feed_name = 'Facebook Connect';
     41    protected $feed_name = 'Facebook Connect';
    4242   
    4343    /**
     
    4646     * @var str
    4747     */
    48     private $feed_slug = 'facebook_connect';
     48    protected $feed_slug = 'facebook_connect';
    4949   
    5050    /**
     
    5353     * @var str
    5454     */
    55     private $feed_type = 'request';
     55    protected $feed_type = 'request';
    5656   
    5757    /**
     
    5959     * @var boolean
    6060     */
    61     private $auto_interupt_flow = true;
     61    protected $auto_interupt_flow = true;
    6262   
    6363    /**
     
    6666     * @var array
    6767     */
    68     private $pages_to_show = array(
     68    protected $pages_to_show = array(
    6969        'all' => 'all'
    7070    );
     
    7474     * @var array
    7575     */
    76     private $pages_not_to_show = array(
     76    protected $pages_not_to_show = array(
    7777       
    7878    );
    7979   
    80     private $admin_pages = array();
     80    protected $admin_pages = array();
    8181
    8282
     
    8585     * @var mb_globalfeed
    8686     */
    87     private $globalfeed;
     87    protected $globalfeed;
    8888   
    8989   
     
    127127        'override_post_time_on_timezone_discrepency' => false,
    128128        'show_posts_from_other_users' => false,
     129        'alerts' => array(),
    129130    );
    130131   
     
    136137     * @var array $feed_options
    137138     */
    138     private $feed_options = null;
     139    protected $feed_options = null;
    139140   
    140141    public function get_queryvar() {
     
    215216        // These action are related to the setup while were in admin...
    216217        if (is_admin()) {
     218            add_action( 'wp_ajax_mbgf_facebook_connect_ajax_get_fb_obj', array( &$this, 'ajax_get_fb_obj' ));
    217219            add_action( 'wp_ajax_mbgf_facebook_connect_set_app_info', array( &$this, 'set_app_info' ));
    218220            add_action( 'wp_ajax_mbgf_facebook_connect_is_authed', array( &$this, 'ajax_app_is_authed' ));
     
    223225            add_action( 'wp_ajax_mbgf_facebook_connect_manual_feed_update', array( &$this, 'ajax_do_update' ));
    224226           
     227            // General Hooks
     228            add_action( 'admin_notices', array( &$this, 'show_alerts' ) );
    225229           
    226230            add_action( 'mbgf_feed_menu-' . $this->get_slug(), array(&$this, 'register_admin_menus'));
    227231            add_action( 'mbgf_unregister_feed-' . $this->get_slug(), array( &$this, 'unregister_feed') );
     232        }
     233    }
     234   
     235    function get_message($message_slug) {
     236        $text_domain = 'mb_globalfeed';
     237       
     238        switch ($message_slug) {
     239            case 'image_introspection_error':
     240                return __('GlobalFeed Facebook Connect encountered an error performing introspection on image elements while fetching additional data from Facebook. <br /><br />If this continues to occur please report it using the bug report feature.', $text_domain);
     241            case 'story_introspection_error':
     242                return __('GlobalFeed Facebook Connect encountered an error performing introspection on story elements while fetching additional data from Facebook. <br /><br />If this continues to occur please report it using the bug report feature.', $text_domain);
     243            case 'need_reauth':
     244                return __('GlobalFeed Facebook Connect needs you to reauthenticate the application with Facebook to continue receiving updates.', $text_domain);
     245            case 'rate_limiting':
     246                return __('GlobalFeed Facebook Connect is currently being rate limited. If you have issued a manual update please wait several minutes. Otherwise please reduce the update frequency.', $text_domain);
     247            default:
     248                return 'GlobalFeed Facebook error 404: Unknown message slug.';
    228249        }
    229250    }
     
    282303        $this->feed_options['ouath_app_expires'] = '';
    283304       
     305        $this->feed_options['last_feed_update'] = 0;
     306       
    284307        $this->register_feed(true);
    285308       
     
    380403            die( json_encode(false) );
    381404        }
     405    }
     406   
     407    /**
     408     * Serves as a runner to fetch facebook objects from Facebook so that the
     409     * client browser doesn't have to contact Facebook directly.
     410     * @return type
     411     */
     412    public function ajax_get_fb_obj() {
     413        check_admin_referer( 'facebook-connect-settings_main' );
     414        wp_verify_nonce( 'facebook-connect-settings_main' );
     415       
     416        // Check that the Facebook object was provided
     417        if (!isset($_GET['fb_obj']) || empty($_GET['fb_obj'])) {
     418            header('HTTP/1.1 500 Internal Server Error', true, 500);
     419            die('{"error": "FB Object not specified in request."}');
     420        }
     421       
     422        $obj_id = $_GET['fb_obj'];
     423       
     424        // Validate the values we've received
     425        if (preg_match('/^[0-9a-zA-Z_-]+$/', $obj_id) == 0) {
     426            header('HTTP/1.1 500 Internal Server Error', true, 500);
     427            die('{"error": "Input arguments are not of the right format"}');
     428        }
     429       
     430        // Check that GlobalFeed has been authorized with facebook
     431        if ( empty($this->feed_options['oauth_user_token']) ) {
     432            header('HTTP/1.1 400 No OAUTH access token', true, 400);
     433            die('{"error": "The application has not yet been authorized with facebook."}');
     434            return;
     435        }
     436       
     437        // Fetch the object from facebook
     438        $fb_obj = wp_remote_get("https://graph.facebook.com/$obj_id?metadata=1&access_token={$this->feed_options['oauth_user_token']}");
     439       
     440        // Check for an error
     441        if (is_wp_error($fb_obj) || $fb_obj['response']['code'] != '200') {
     442            header("HTTP/1.1 {$fb_obj['response']['code']} {$fb_obj['response']['message']}", true, (int) $fb_obj['response']['code']);
     443            if (isset($fb_obj['body'])) {
     444                die($fb_obj['body']);
     445            } else {
     446                die('{"error": "An unknown error occured retrievint the facebook object. Please try again."}');
     447            }
     448        }
     449       
     450        die ($fb_obj['body']);
    382451    }
    383452
     
    632701                }
    633702            }
    634            
    635703        }
    636704        exit;
     
    667735        $globalfeed = &$this->globalfeed;
    668736        $feed_options = &$this->feed_options;
    669         $globalfeed->print_debug_info('Update Feed Called.', $this->feed_slug);
    670737       
    671738        // Check and make sure the oauth token is set
    672         if ( empty($feed_options['oauth_user_token']) )
     739        if ( empty($feed_options['oauth_user_token']) ) {
     740            $globalfeed->print_debug_info('No OAUTH User Token.', $this->feed_slug);
    673741            return;
     742        }
    674743       
    675744        // Different facebook objects require that we query different things
     
    683752        }
    684753       
    685         $graph_url = "https://graph.facebook.com/{$feed_options['object_to_subscribe']}/{$query_object}?access_token={$access_token}&since={$feed_options['last_feed_update']}&limit={$feed_options['max_feed_items']}";
     754        $graph_url = "https://graph.facebook.com/{$feed_options['object_to_subscribe']}/{$query_object}?access_token={$access_token}&since={$feed_options['last_feed_update']}";
     755       
     756        if ($feed_options['max_feed_items'] > 0)
     757            $graph_url .= "&limit={$feed_options['max_feed_items']}";
     758           
    686759        $updates = wp_remote_get($graph_url);
    687760       
    688         if (is_wp_error($updates) || $updates['response']['code'] != '200')
     761        if (is_wp_error($updates) || $updates['response']['code'] != '200') {
     762            if (isset($updates['body'])) {
     763                $body = json_decode($updates['body'], true);
     764               
     765                if (!isset($body['error']) || !isset($body['error']['code'])) {
     766                    $this->globalfeed->print_debug_info("this is whats happening");
     767                    $this->add_alert('unknown error', "An unknown error occured with an update request. The response was {$updates['response']['code']}: {$updates['response']['message']}.");
     768                    return false;
     769                }
     770               
     771                $ival = intval($body['error']['code']);
     772                if ( in_array( $ival, array(190, 102, 10) ) || ( $ival >= 200 && $ival <= 299 ) ) {
     773                    $this->add_alert('need_reauth', $this->get_message('need_reauth'), true, true);
     774                } elseif ( in_array($ival, array(1, 2, 4, 17)) ) {
     775                    $this->add_alert('rate_limiting', $this->get_message('rate_limiting'), false, false);
     776                }
     777            } else {
     778                $this->globalfeed->print_debug_info('unknown error');
     779                $this->add_alert('unknown_error', "An unknown error occured with an update request. The response was {$updates['response']['code']}: {$updates['response']['message']}.");
     780            }
     781           
    689782            return false;
     783        }
     784       
     785        $this->hide_alerts(array('need_reauth', 'rate_limiting', 'unknown_error'));
    690786       
    691787        // Use the regex to replace numerical values to strings for older versions of php
    692         $updates = json_decode( preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $updates['body']) );
    693        
    694         $globalfeed->print_debug_info($updates, 'mb_facebook');
     788        $updates = json_decode( preg_replace('/("\w+"):([0-9.]+)/', '\\1:"\\2"', $updates['body']), false);
    695789       
    696790        $feed_items = array();
     
    735829            switch ($update->type) {
    736830                case 'video' :
    737                     $post_args['post_title'] = $update->name;
    738                     $post_args['post_excerpt'] = $update->description;
     831                    $post_args['post_title'] = $this->get_prop($update, 'name');//$update->name;
     832                    $post_args['post_excerpt'] = $this->get_prop($update, 'description');//$update->description;
    739833                    $post_args['post_format'] = 'video';
    740                     $post_args['meta']['source'] = $update->source;
    741                     $post_args['meta']['picture'] = $update->picture;
    742                     $post_args['meta']['link'] = $update->link;
    743                     $post_args['meta']['caption'] = $update->caption;
     834                    $post_args['meta']['source'] = $this->get_prop($update, 'source');//$update->source;
     835                    $post_args['meta']['picture'] = $this->get_prop($update, 'picture');//$update->picture;
     836                    $post_args['meta']['link'] = $this->get_prop($update, 'link');//$update->link;
     837                    $post_args['meta']['caption'] = $this->get_prop($update, 'caption');//$update->caption;
    744838                   
    745839                    // figure out where this video resides to display the correct content.
     
    748842                        if ($globalfeed->media_display_mode() == 'embed') {
    749843                            $content_args['media_format'] = 'video';
    750                             $content_args['media_info'] = array('facebook_embed_html' => array_pop(array_values($update->format)), 'width'=>'100%');
     844                            $content_args['media_info'] = array(
     845                                    'facebook_embed_html' => array_pop(array_values($this->get_prop($update, 'format'))),
     846                                    'width'=>'100%'
     847                                );
    751848                        } else {
    752                             $post_args['meta']['embed_html'] = array_pop(array_values($update->format));
     849                            $post_args['meta']['embed_html'] = array_pop(array_values($this->get_prop($update, 'format')));
    753850                        }
    754851                    } else {
     
    757854                            // The link is to a youtube video. Extract the id, then call the embedder.
    758855                            $post_args['meta']['video_source'] = 'youtube';
    759                             $globalfeed->print_debug_info("Parsing youtube id:" . $post_args['meta']['link']);
    760856                            parse_str( parse_url( $post_args['meta']['link'], PHP_URL_QUERY ), $url_params );
    761857                            $post_args['meta']['youtube_id'] = $url_params['v'];
    762 //                            $post_args['meta']['youtube_id'] = substr( $post_args['meta']['link'], strripos( $post_args['meta']['link'], '/' ) + 9 );
    763858                           
    764859                            $content_args['media_format'] = 'video';
     
    769864                case 'link' :
    770865                    $post_args['post_format'] = 'link';
    771                     $post_args['meta']['link'] = $update->link;
    772                     $post_args['meta']['link_title'] = $update->name;
    773                     $post_args['meta']['description'] = $update->description;
    774                     $post_args['meta']['picture'] = $update->picture;
     866                    $post_args['meta']['link'] = $this->get_prop($update, 'link');
     867                    $post_args['meta']['link_title'] = $this->get_prop($update, 'name');
     868                    $post_args['meta']['description'] = $this->get_prop($update, 'link');
     869                    $post_args['meta']['picture'] = $this->get_prop($update, 'link');
    775870                   
    776871                    $content_args['media_format'] = 'link';
     
    786881                    if ( !is_wp_error($img) )
    787882                        $post_args['meta']['picture'] = $img['headers']['location'];
    788                     else
    789                         $globalfeed->print_debug_info ($img);
    790 //                    $globalfeed->print_debug_info($update);
    791                     $post_args['meta']['link'] = $update->link;
     883                    else {
     884                        $this->add_alert('image_introspection_error', $this->get_message('image_introspection_error'), false, false);
     885                    }
     886                   
     887                    $post_args['meta']['link'] = $this->get_prop($update, 'link');//$update->link;
    792888                    $content_args['media_format'] = 'image';
    793889                    $content_args['media_info'] = array('source_url' => $post_args['meta']['picture']);
     
    816912                        $graph_url = "https://graph.facebook.com/{$value[0]->id}?access_token={$access_token}&metadata=1";
    817913                        $introspect = wp_remote_get($graph_url);
    818 
    819                         if (is_wp_error($introspect))
    820                             return false;
    821                         $introspect = json_decode($introspect['body']);
    822                         $type = $introspect->type;
     914                       
     915                        if ( is_wp_error($introspect) ) {
     916                            $this->add_alert('story_introspection_error', $this->get_message('story_introspection_error'), false, false);
     917                        } else {
     918                            $introspect = json_decode($introspect['body']);
     919                            $type = $introspect->type;
     920                        }
    823921                    }
    824922
     
    874972            return 0;
    875973        }
     974    }
     975   
     976    /**
     977     * Retrieves the property from the object or array or null if not defined.
     978     * @param type $obj
     979     * @param type $prop
     980     * @return type
     981     */
     982    private function get_prop($obj, $prop) {
     983        if ( is_object($obj) )
     984            return isset($obj->$prop) ? $obj->$prop : null;
     985        elseif ( is_array($obj) )
     986            return isset($obj[$prop]) ? $obj[$prop] : null;
     987        else
     988            return null;
    876989    }
    877990   
  • globalfeed/trunk/feeds/mb_facebook/pages/js/mb_facebook.js

    r711217 r790780  
    44function get_fb_object( object_id, element_id ) {
    55    return jQuery.ajax({
    6         url: 'https://graph.facebook.com/' + object_id + "?metadata=1",
    7         dataType: 'jsonp',
    8         data: {},
     6        url: ajaxurl,
     7        dataType: 'json',
     8        data: {
     9            action:'mbgf_facebook_connect_ajax_get_fb_obj',
     10            _wpnonce:jQuery('#_wpnonce').val(),
     11            fb_obj: object_id
     12        },
     13        crossDomain: true,
    914        statusCode: {
    1015            200: function (response) {
     
    8994        checkAuthWindow( statusdiv, fail, redir_url );
    9095    }, 1000);
    91     //authWindowChecker = setTimeout('checkAuthWindow("' + statusdiv + ',' + fail + ',' + '")', 1000);
    9296    return;
    9397}
     98
     99error_count = 0;
    94100function checkAuthWindow( statusdiv, fail, redir_url ) {
    95101    clearTimeout(authWindowChecker);
  • globalfeed/trunk/feeds/mb_twitter/mb_twitter.php

    r790774 r790780  
    644644        $parameters = array(
    645645            'oauth_callback' => get_bloginfo('wpurl').'/',
    646 //            'x_auth_access_type' => 'read'
    647646        );
    648647       
     
    744743            'oauth_consumer_key' => $this->feed_options['consumer_key'],
    745744            'oauth_nonce' => $_SESSION['state'],
    746 //            'oauth_nonce' => "f9b649e39402a68e3ebbdbd2f8968fd3",
    747745            'oauth_signature_method' => 'HMAC-SHA1',
    748746            'oauth_timestamp' => (string) time(),
    749 //            'oauth_timestamp' => "1382247124",
    750 //            'oauth_token' => $this->feed_options['oauth_access_token'],
    751747            'oauth_version' => '1.0',
    752 //            'oauth_callback' => get_bloginfo('wpurl').'/',
    753 //            'x_auth_access_type' => 'read'
    754748        );
    755749       
    756        
    757        
    758 //        if ( !empty($this->feed_options['oauth_access_token']) )
    759 //            $default_parameters['oauth_token'] = $this->feed_options['oauth_access_token'];
    760        
    761         // Parse the default parameters
    762 //        $parameters = wp_parse_args($parameters, $default_parameters);
     750        if (!empty($this->feed_options['oauth_access_token']))
     751            $default_parameters['oauth_token'] = $this->feed_options['oauth_access_token'];
     752       
    763753        $auth_params = wp_parse_args($auth_params, $default_parameters);
    764754        $all_params = wp_parse_args($parameters, $auth_params);
     
    772762        ksort($auth_params);
    773763       
    774         $this->globalfeed->print_debug_info($auth_params);
    775        
    776         $this->globalfeed->print_debug_info($parameters);
    777        
    778764        $endpoint .= '?';
    779765        foreach ( $parameters as $key => $value )
     
    782768        $endpoint = substr($endpoint, 0, -1);
    783769       
    784         $this->globalfeed->print_debug_info($endpoint);
    785        
    786770        $auth_header = "OAuth ";
    787771        foreach ( $auth_params as $key => $value )
    788772            $auth_header .= rawurlencode($key) . "=\"" . rawurlencode($value) . "\", ";
    789        
    790         $this->globalfeed->print_debug_info(substr($auth_header, 0, -2));
    791773       
    792774        // Execute the request, and return whatever results
     
    803785     */
    804786    private function generate_twitter_request_signature( $endpoint, $method, $parameters ) {
    805         $this->globalfeed->print_debug_info("------------------------Beginning signature generation");
    806        
    807787        // Sort the parameters alphabetically
    808788        ksort($parameters);
     
    818798        // The base string is the parameter string appendd to the base string (as per oauth spec)
    819799        $base_str = strtoupper($method) . '&' . rawurlencode($endpoint) . '&' . rawurlencode($param_str);
    820         $this->globalfeed->print_debug_info('base string:');
    821         $this->globalfeed->print_debug_info($base_str);
    822800       
    823801        // Build the signing key
     
    827805        if ( !empty($this->feed_options['oauth_access_token_secret']) )
    828806            $signing_key .= rawurlencode($this->feed_options['oauth_access_token_secret']);
    829        
    830         $this->globalfeed->print_debug_info('signing key:');
    831         $this->globalfeed->print_debug_info($signing_key);
    832        
    833         $this->globalfeed->print_debug_info("------------------------Done signature generation");
    834807       
    835808        // Create and return the signature
     
    938911
    939912            // Use the regex to replace numerical values to strings for older versions of php
    940             $updates = json_decode( preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $request['body']), true );
     913            $updates = json_decode( preg_replace('/("\w+"):([0-9.]+)/', '\\1:"\\2"', $request['body']), true );
    941914
    942915            // Check that we actually have content
  • globalfeed/trunk/feeds/mb_twitter/pages/js/mb_twitter.js

    r612743 r790780  
    2020    var tw_object_sn_match = new RegExp(/^(\?|@)??([A-Za-z0-9_]+)$/); // Check for a user screen name
    2121    var querystring = '';
    22 
     22    var data = { action: 'mbgf_twitter_connect_get_user', _wpnonce:jQuery('#_wpnonce').val() };
     23   
    2324    // Check which object type we have...
    2425    if (tw_object_id_match.exec( tw_object_id )){
    25         querystring = '?user_id=' + tw_object_id + '&callback=?';
     26        data['user_id'] = tw_object_id;
     27//        querystring = '?user_id=' + tw_object_id + '&callback=?';
    2628    } else if (tw_object_sn_match.exec( tw_object_id )){
    2729        tw_object_id = tw_object_sn_match.exec( tw_object_id );// Replace question marks
    28         querystring = '?screen_name=' + tw_object_id[tw_object_id.length - 1] + '&callback=?';
     30//        querystring = '?screen_name=' + tw_object_id[tw_object_id.length - 1] + '&callback=?';
     31        data['screen_name'] = tw_object_id[tw_object_id.length - 1];
    2932    } else {
    3033        showMessage('You must provide a valid object id (must be only numbers) or screen name (can be letters, numbers or underscores)', 'tw_object_id', true);
     
    3942
    4043    // Check that the object ID is valid, and that we have access to that object.
     44//    jQuery.post(ajaxurl, {action:'mbgf_twitter_connect_is_authed',_wpnonce:jQuery('#_wpnonce').val()}
    4145    return jQuery.ajax({
    4246        type: 'GET',
    43         url: 'https://api.twitter.com/1/users/lookup.json' + querystring,
    44         dataType: 'jsonp',
    45         data: {},
     47        url: ajaxurl,
     48        dataType: 'json',
     49        data: data,
    4650        timeout: 3000,
    4751        statusCode: {
    4852            200: function (response) {
    49                 response = response[0];// Data received from Twitter is an array
    50                
    5153                // Save the twitter obj id publicly
    5254                mb_twitter_info.tw_obj_id = response.id;
  • globalfeed/trunk/feeds/mb_twitter/pages/setup.php

    r612743 r790780  
    2424    <div id="step-1">
    2525        <p><h2>How would you like to connect to Twitter?</h2></p>
    26         <div class="optgrp bottom-button" style="min-height:270px;">
    27             <p class="center"><h2>Without a Twitter App</h2></p>
    28             <p>
    29                 Setting up Twitter Connect without an App is the quickest and easiest way to get started with Twitter Connect.
    30             </p>
    31             <p>
    32                 When you setup without using a Twitter App, Twitter Connect will not authenticate with Twitter
    33                 (although all of your data is still communicated over SSL.) The caveat to this approach
    34                 is that if your site is located on shared hosting Twitter Connect may become rate limited by Twitter
    35                 and may not be able to consistently fetch content.
    36             </p>
    37             <p>
    38                 If you encounter issues with not receiving new content while using Twitter Connect without a Twitter App
    39                 you can always supply App information to switch to Authenticated mode at a later time.
    40             </p>
    41             <p class="center"><input type="button" id="setup_without_app" value="Without a Twitter App" class="button-primary" /></p>
    42         </div>
    4326        <div class="optgrp" style="min-height:270px;">
    4427            <p class="center"><h2>With a Twitter App</h2></p>
     
    5134            </p>
    5235            <p class="center bottom-button"><input type="button" id="setup_with_app" value="With a Twitter App"  class="button-primary" /></p>
     36        </div>
     37        <div class="optgrp bottom-button" style="min-height:270px;">
     38            <p class="center"><h2>Without a Twitter App</h2></p>
     39            <p>
     40                Oops! With the new Twitter API, we're unable to offer this feature. If you were previously setup with this option - we apologize! You will need to setup GlobalFeed with a Twitter application.
     41            </p>
    5342        </div>
    5443    </div>
  • globalfeed/trunk/feeds/mb_youtube/mb_youtube.php

    r625019 r790780  
    4040     * @var str
    4141     */
    42     private $feed_name = 'YouTube Connect';
     42    protected $feed_name = 'YouTube Connect';
    4343   
    4444    /**
     
    4747     * @var str
    4848     */
    49     private $feed_slug = 'youtube_connect';
     49    protected $feed_slug = 'youtube_connect';
    5050   
    5151    /**
     
    5454     * @var str
    5555     */
    56     private $feed_type = 'request';
     56    protected $feed_type = 'request';
    5757   
    5858    /**
     
    6060     * @var boolean
    6161     */
    62     private $auto_interupt_flow = true;
     62    protected $auto_interupt_flow = true;
    6363   
    6464    /**
     
    6767     * @var array
    6868     */
    69     private $pages_to_show = array(
     69    protected $pages_to_show = array(
    7070        'all' => 'all'
    7171    );
     
    7575     * @var array
    7676     */
    77     private $pages_not_to_show = array(
     77    protected $pages_not_to_show = array(
    7878       
    7979    );
     
    8888     * @var type
    8989     */
    90     private $globalfeed;
     90    protected $globalfeed;
    9191   
    9292    private $_apiurl = 'http://gdata.youtube.com/';
     
    127127        'show_welcome_message' => false,
    128128        'use_https' => true,
    129         'override_post_time_on_timezone_discrepency' => false
     129        'override_post_time_on_timezone_discrepency' => false,
     130        'alerts' => array(),
    130131    );
    131132   
     
    137138     * @var array $feed_options
    138139     */
    139     private $feed_options = null;
     140    protected $feed_options = null;
    140141
    141142    /**
  • globalfeed/trunk/feeds/mbgf_rss/mbgf_rss.php

    r625019 r790780  
    4343     * @var str
    4444     */
    45     private $feed_name = 'MB RSS';
     45    protected $feed_name = 'MB RSS';
    4646   
    4747    /**
     
    5050     * @var str
    5151     */
    52     private $feed_slug = 'mbgf_rss';
     52    protected $feed_slug = 'mbgf_rss';
    5353   
    5454    /**
     
    5757     * @var str
    5858     */
    59     private $feed_type = 'request';
     59    protected $feed_type = 'request';
    6060   
    6161    /**
     
    6363     * @var boolean
    6464     */
    65     private $auto_interupt_flow = true;
     65    protected $auto_interupt_flow = true;
    6666   
    6767    /**
     
    7070     * @var array
    7171     */
    72     private $pages_to_show = array(
     72    protected $pages_to_show = array(
    7373        'all' => 'all'
    7474    );
     
    7878     * @var array
    7979     */
    80     private $pages_not_to_show = array(
     80    protected $pages_not_to_show = array(
    8181       
    8282    );
     
    9797     * @var type
    9898     */
    99     private $globalfeed;
     99    protected $globalfeed;
    100100   
    101101    /**
     
    123123        'errors' => array(),
    124124        'override_post_time_on_timezone_discrepency' => false,
     125        'alerts' => array(),
    125126    );
    126127
     
    132133     * @var array $feed_options
    133134     */
    134     private $feed_options = null;
     135    protected $feed_options = null;
    135136   
    136137    /**
     
    177178            add_action( 'wp_ajax_mbgf_rss_reset_feed_defaults', array( &$this, 'reset_feed_defaults' ) );
    178179            add_action( 'mbgf_unregister_feed-' . $this->get_slug(), array( &$this, 'unregister_feed') );
     180        }
     181    }
     182   
     183    function get_message($message_slug) {
     184        $text_domain = 'mb_globalfeed';
     185       
     186        switch ($message_slug) {
     187            case 'rss_parsing_error':
     188                return __('GlobalFeed RSS has encountered a problem parsing an RSS feed. Please report the error using the bug reports feature and detail the feed source.', $text_domain);
     189            case 'feed_not_configured':
     190                return __('GlobalFeed RSS has encountered a problem updating an RSS feed. Please visit the GlobalFeed RSS configuration for more information.', $text_domain);
     191            default:
     192                return 'GlobalFeed RSS error 404: Unknown message slug.';
    179193        }
    180194    }
     
    495509
    496510            // If the request did not succeed, log the error and continue.
    497             if (is_wp_error($request) ) {
     511            if ( is_wp_error($request) ) {
    498512                $feed_options['errors'][] = array(
    499513                    'error' => 'Error updating feed: ' . (empty($feed->title)) ? $feed_url : $feed->title,
     
    502516                    'time' => time(),
    503517                );
     518               
     519                $this->add_alert('feed_not_configured', $this->get_message('feed_not_configured'), true, false);
    504520                continue;
    505521            }
     
    520536                    'time' => time(),
    521537                );
     538               
     539                $this->add_alert('rss_parsing_error', $this->get_message('rss_parsing_error'), true, false);
    522540                continue;
    523541            }
     
    525543            // Loop through the updates and convert to WP Posts.
    526544            foreach ( $updates->item as $update ) {
    527                
    528545                // Check if the feed date is less than the processed date and that were supposed to check that.
    529546                if ( strtotime( (string) trim($update->pubDate) ) < $feed['last_update'] && $feed['enforce_dates'] )
     
    623640       
    624641        // Save all of the feed items.
    625        
    626         //$globalfeed->print_debug_info(
    627             $globalfeed->save_feed_items( $this->feed_slug, $feed_items );
    628         //);
     642        $globalfeed->save_feed_items( $this->feed_slug, $feed_items );
    629643       
    630644        return count( $feed_items );
     
    638652     * @return str
    639653     */
    640     function get_xml_attr( $obj, $attr ){
     654    private function get_xml_attr( $obj, $attr ){
    641655        $atts = $obj->attributes();
    642656        return (string) trim( $atts[$attr] );
  • globalfeed/trunk/mb_globalfeed.php

    r711609 r790780  
    5555            'notification',
    5656            'debug',
    57             'mb_facebook',
     57            'facebook_connec',
     58            'twitter_connect',
    5859            'register_feeds',
    5960            'request_modify',
     
    714715            // For tags and categories, make the tag/category number the array key
    715716            $cats = array();
    716             if ( $current_page_info[ 'category' ] )
     717            if ( $current_page_info[ 'category' ] ) {
    717718                foreach ($current_page_info[ 'category' ] as $category) {
    718719                    $cats[ $category ] = $category;
    719720                };
     721            }
    720722
    721723            $tags = array();
     
    11221124         * @return bool True if activated, false if not.
    11231125         */
    1124         function feed_activated( $feed_slug ){
     1126        function feed_activated( $feed_slug ) {
    11251127            return isset( $this->registered_feeds[ $this->get_shortened_feed_slug($feed_slug) ] );
    11261128        }
     
    11331135         * @return str|bool The shortened feed slug, or false if the feed is not registered.
    11341136         */
    1135         function get_feed_options( $feed_slug ){
     1137        function get_feed_options( $feed_slug ) {
    11361138            return $this->feed_activated( $feed_slug ) ?
    11371139                    $this->registered_feeds[ $this->get_shortened_feed_slug($feed_slug) ] : false;
  • globalfeed/trunk/readme.txt

    r593074 r790780  
    55Requires at least: 3.3
    66Tested up to: 3.4.1
    7 Stable tag: 0.1.3
     7Stable tag: 0.1.4
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9292== Changelog ==
    9393
     94= 0.1.4 =
     95- Fixed a bug in MB Facebook where Facebook pages could not be loaded.
     96- Fixed a jQuery parsing bug, where geological information in a jQuery stream would corrupt the data.
     97- Upgraded MB Twitter for API 1.1 compatibility and fixed an authorization bug.
     98- Rerouted Facebook and Twitter object requests through GlobalFeed to remove the need for a cross-domain request.
     99
    94100= 0.1.3 =
    95101- Added GlobalFeed option to open GlobalFeed-generated links in a new window.
     
    152158= 0.5 =
    153159*   Better support for 3rd party feeds
    154 
    155 = Winter Season 2012 =
    156 Numerous Social Media APIs require applications to authenticate in order to fetch user
    157 data, such as Facebook, Google+ and coming March 2013: Twitter. At GlobalFeed, we believe that
    158 the need for users to go and create their own applications on these services in order to
    159 get application IDs and secrets is not a positive user experience. That is why GlobalFeed
    160 will be rolling out a webservice based off of MichaelBlouin.ca that will be responsible
    161 for fetching data directly from Social Media sources and will act as a middleman,
    162 making it infinitely quicker and easier for users to access their social media content
    163 from their blog. All users will have to do is give GlobalFeed permission to read
    164 their streams, and GlobalFeed will do the rest.
    165 
    166 For privacy conscious users who would prefer GlobalFeed not have access to their information,
    167 the GlobalFeed plugin will still offer users the option of inputting their own application
    168 information and having their WordPress blog fetch data directly from these services instead
    169 of using the GlobalFeed service.
    170 
    171 If you have a positive or negative opinion or any concerns about this change, please let us know
    172 on our Feature Requests page at: http://globalfeed.michaelblouin.ca/feature-requests
Note: See TracChangeset for help on using the changeset viewer.