0 && get_option('readygraph_send_blog_updates') == "true"){ $post_title = get_the_title( $post_id ); $post_url = get_permalink( $post_id ); $post_image = wp_get_attachment_url(get_post_thumbnail_id($post_id)); $post_content = get_post($post_id); $post_excerpt = (isset($post_content->post_excerpt) && (!empty($post_content->post_excerpt))) ? $post_content->post_excerpt : wp_trim_words(strip_tags(strip_shortcodes($post_content->post_content)),500); $url = 'http://readygraph.com/api/v1/post.json/'; if (get_option('readygraph_send_real_time_post_updates')=='true'){ $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'is_realtime'=>1, 'message' => $post_title, 'message_link' => $post_url,'message_excerpt' => $post_excerpt,'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email')))); } else { $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'message' => $post_title, 'message_link' => $post_url,'message_excerpt' => $post_excerpt,'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email')))); } if ( is_wp_error( $response ) ) { $error_message = $response->get_error_message(); } else { } $app_id = get_option('readygraph_application_id'); wp_remote_get( "http://readygraph.com/api/v1/tracking?event=post_created&app_id=$app_id" ); } else{ } } add_action('future_to_publish','al2fb_post_updated_send_email'); add_action('new_to_publish','al2fb_post_updated_send_email'); add_action('draft_to_publish','al2fb_post_updated_send_email'); // add_action( 'publish_post', 'al2fb_post_updated_send_email' ); // add_action( 'publish_page', 'al2fb_post_updated_send_email' ); if(get_option('al2fb_wordpress_sync_users')){} else{ add_action('plugins_loaded', 'rg_al2fb_get_version'); } function rg_al2fb_get_version() { if(get_option('al2fb_wordpress_sync_users') && get_option('al2fb_wordpress_sync_users') == "true") {} else { if(get_option('readygraph_application_id') && strlen(get_option('readygraph_application_id')) > 0){ al2fb_wordpress_sync_users(get_option('readygraph_application_id')); } } } function al2fb_wordpress_sync_users( $app_id ){ global $wpdb; $query = "SELECT email as email, date as user_date FROM {$wpdb->prefix}users "; $al2fb_users = $wpdb->get_results($query); $emails = ""; $dates = ""; $count = 0; $count = mysql_num_rows($al2fb_users); wp_remote_get( "http://readygraph.com/api/v1/tracking?event=wp_user_synced&app_id=$app_id&count=$count" ); foreach($al2fb_users as $user) { $emails .= $user->email . ","; $dates .= $user->user_date . ","; } $url = 'https://readygraph.com/api/v1/wordpress-sync-enduser/'; $response = wp_remote_post($url, array( 'body' => array('app_id' => $app_id, 'email' => rtrim($emails, ", "), 'user_registered' => rtrim($dates, ", ")))); update_option('al2fb_wordpress_sync_users',"true"); remove_action('plugins_loaded', 'rg_al2fb_get_version'); } ?>