function id_clear_orphan_comments() { global $wpdb; remove_action('trashed_comment', 'id_comment_trashed', 10); remove_action('wp_set_comment_status', 'id_comment_status', 10, 2); // Get comments with post=0 $offset = 0; // Using direct queries because get_comments() doesn't give access to post_ID=0, or date ranges while ($comments = $wpdb->get_col($wpdb->prepare("SELECT `comment_ID` FROM {$wpdb->comments} WHERE `comment_post_ID` = 0 AND `comment_date_gmt` BETWEEN '2010-07-16 00:00:00' AND '2010-07-23 00:00:00' LIMIT %d, 50", $offset))) { foreach ($comments as $comment) { // Check date wp_delete_comment($comment, true); } $offset += 50; } // Ping ID for a resync $fields = array('sync_type' => 'PDX'); $queue = id_get_queue(); $op = $queue->add('request_resync', $fields, 'id_generic_callback'); $queue->ping(array($op)); add_option('id_pdxsync', time()); add_action('trashed_comment', 'id_comment_trashed', 10); add_action('wp_set_comment_status', 'id_comment_status', 10, 2); }
function id_SETTINGS_user_login() { global $userdata; $goback = remove_query_arg('updated', $_SERVER['REQUEST_URI']); $goback = remove_query_arg('login_msg', $goback); $messages = array(); $fields = id_param('id_remote_fields', array()); $fields['admin'] = current_user_can('manage_options'); $fields['blog_url'] = get_option('siteurl'); $fields['blog_rss'] = get_bloginfo('rss_url'); $fields['blog_title'] = id_get_blog_name(); $fields['blog_sitetype'] = "wordpress"; $fields['rest_service'] = $fields['blog_url'] . '/index.php?id_action=import'; $fields['token'] = id_generate_token($fields); $fields['wp_userID'] = $userdata->ID; $fields['start_import'] = "false"; foreach ($fields as $n => $v) { if (!strlen($v)) { $messages[] = 'Missing field: ' . $n; } } if (!count($messages)) { $queue = id_get_queue(); $queue->create(); $op = $queue->add('user_login', $fields, 'id_process_user_login_callback'); $queue->ping(array($op)); $loginOperation = $queue->operations[0]; $loginResponse = $loginOperation->response; $messages[] = id_coalesce(@$loginResponse->error_msg, "Login successful"); } if (count($messages)) { $msg = implode('<br/>', $messages); $goback = add_query_arg('login_msg', urlencode($msg), $goback); } else { $goback = add_query_arg('updated', 'true', $goback); } wp_redirect($goback); }