ID;
$ac_api_key = get_user_meta($userid, "ac_api_key", true );
$ac_syncid = get_user_meta($userid, "ac_syncid", true );
echo '
';
if ( strlen( $ac_api_key ) == 0 || strlen( $ac_syncid ) == 0 ) {
$connect_url = admin_url( "admin.php?page=atcontent/dashboard.php" );
$img_url = plugins_url( 'assets/logo.png', dirname( __FILE__ ) );
echo '
Connect your account to AtContent and get advanced analytics of your blog
';
return;
}
if ( current_user_can( 'edit_posts' ) ) {
global $wpdb;
$offset = 0;
$limit = 20;
$posts_id = array();
do {
$posts = $wpdb->get_results(
"
SELECT ID, post_title, post_author
FROM {$wpdb->posts}
WHERE post_status = 'publish'
AND post_author = {$userid} AND post_type = 'post'
ORDER BY ID LIMIT {$offset},{$limit}
"
);
foreach ( $posts as $post )
{
$ac_postid = get_post_meta( $post->ID, "ac_postid", true );
if ( strlen( $ac_postid ) > 0 ) {
array_push( $posts_id, $ac_postid );
}
}
$wpdb->flush();
$offset += $limit;
} while ( count( $posts ) > 0 );
$response = atcontent_api_readership( site_url(), json_encode( $posts_id ), $ac_api_key );
?>