"fql.multiquery","queries"=>$query,'access_token'=>$atoken); $result = $fb->api($query); $comments = $result; if (!is_array($comments)) { print_r('No response from facebook.com'); return; } $ncomms = sizeof($comments[0]['fql_result_set']); $dcomms = $ncomms < $fbc_options['dashNumComments'] ? $ncomms : $fbc_options['dashNumComments']; if ($ncomms == 0) { echo "
Administer Comments

" .'No Comments!'; } else { // $ncomms = $ncomms < 10 ? $ncomms : 10; $htmlout = // using the old api to make calling from js easier // the new graph api method is much cleaner, but it causes problems in opera // since it returns a value, which opera then prompts the user to open or save "
" ."
Administer Comments

" // should probably change this to class so that it validates .'
'; $parity = ''; $users = $comments[1]['fql_result_set']; $comments = $comments[0]['fql_result_set']; for ($i=0,$par=0;$i<$dcomms;$i++,$par++) { // for people who use the same app id for more than one site, // only return results unique to this xid if ( strncmp($comments[$i]['xid'],$fbc_options['xid'],15) ) { $par--; continue; } // find matching user for ($j=0;$j'. $users[$index]['name'] .''; } // make pretty $commenttext = $comments[$i]['text']; $order = array("\r\n", "\n", "\r"); $replace = '
'; // Processes \r\n's first so they aren't converted twice. $commenttext = str_replace($order, $replace, $commenttext); // url of post/page on which comment was made $post_id = substr($comments[$i]['xid'],20); $commenturl = get_permalink($post_id); // make pretty alternations $parity = ($par&1) ? "comment byuser comment-author-admin odd alt thread-odd thread-alt depth-1 comment-item approved": "comment byuser comment-author-admin even thread-even depth-1 comment-item approved"; $imgurl = $users[$index]['pic_square']; // what will be written to the dashboard widget $htmlout .= '
'. ''. '
'. '

From '. ''.$username.' on '. ''.get_post($post_id)->post_title.' '.date('d M Y',$comments[$i]['time']).' [Pending]'. '

'.$commenttext.'

delete '. "

"; } $htmlout .= '
'; print_r($htmlout); } } // Create the function used in the action hook function fbcomments_add_dashboard_widgets() { global $fbc_options; if ($fbc_options['showDBWidget'] == true) wp_add_dashboard_widget('dashboard_widget', 'Recent Facebook comments', 'fbcomments_dashboard_widget_function'); } /********************************** Page recent comments widget **********************************/ /* add styles before wp_head is loaded see: http://bit.ly/igYFYu */ function conditionally_add_scripts_and_styles($posts){ if (empty($posts)) return $posts; // enqueue here wp_enqueue_style('fbc_rc_widgets-style', FBCOMMENTS_CSS_WIDGETS); return $posts; } /** * Recent_Comments widget class * * @since 3.0.0 */ class FBCRC_Widget extends WP_Widget { /** constructor */ function FBCRC_Widget() { $widget_ops = array( 'description' => __('The most recent Facebook comments.') ); parent::WP_Widget(false, $name = 'Recent Facebook Comments', $widget_ops); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', $instance['title']); global $fbc_options; $atoken = $fbc_options['accessToken']; $fb = fbComments_getFbApi(); /* select post_id, fromid, time, text, post_fbid from comment where object_id in (select comments_fbid from link_stat where url="http://developers.facebook.com/blog/post/472")' */ $commentsq = "SELECT fromid, text, id, time, username, xid, object_id ". "FROM comment WHERE xid IN (SELECT xid FROM comments_info WHERE app_id={$fbc_options['appId']})". "ORDER BY time desc"; // $commurl = urlencode(''); // $commentsq = "SELECT fromid, text, id, time, username, xid, post_id, post_fbid, object_id ". // "FROM comment ". // "WHERE (xid IN (SELECT xid FROM comments_info WHERE app_id={$fbc_options['appId']})) ". // "OR object_id IN (SELECT comments_fbid FROM link_stat WHERE url='$commurl') ". // "ORDER BY time desc"; // $commentsq = "SELECT post_id, fromid, time, text, post_fbid ". // 'FROM comment'. // "ORDER BY time desc"; $usersq = "SELECT id, name, url, pic_square FROM profile ". "WHERE id IN (SELECT fromid FROM #comments)"; $query = '{ "comments": "' . $commentsq . '", "users": "' . $usersq . '" }'; $query = array("method"=>"fql.multiquery","queries"=>$query,'access_token'=>$atoken); $comments = $fb->api($query); if ( ! $number = (int) $instance['number'] ) $number = 5; else if ( $number < 1 ) $number = 1; $ncomms = sizeof($comments[0]['fql_result_set']); // if no comments, display no comments; otherwise display the greater of $ncomms and $number comments $ncomms = $ncomms == 0 ? 0 : ($ncomms < $number ? $ncomms : $number); $output = ''; // print everything out echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo $output; echo $after_widget; } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = (int) $new_instance['number']; $instance['word_count'] = (int) $new_instance['word_count']; if ( isset($new_instance['show_avatar']) ) $instance['show_avatar'] = 1; else $instance['show_avatar'] = 0; return $instance; } /** @see WP_Widget::form */ function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'show_avatar' => true ) ); $title = isset($instance['title']) ? esc_attr($instance['title']) : 'Recent Comments'; $number = isset($instance['number']) ? absint($instance['number']) : 5; $word_count = isset($instance['word_count']) ? absint($instance['word_count']) : 50; ?>

id="get_field_id( 'show_avatar' ); ?>" name="get_field_name( 'show_avatar' ); ?>" />