public static function AjaxMassTitleTools() { $action = @$_POST['act']; $start = (int) @$_POST['start']; $all_posts = wp_count_posts('post'); $total = $all_posts->publish + $all_posts->draft + $all_posts->pending + $all_posts->future + $all_posts->private + $all_posts->trash; switch ($action) { case 'capitalize': $c = GFontsDB::ModifyCapitalizeUpperLowerTitlesLimited('capitalize', $start, 5); break; case 'upperfirst': $c = GFontsDB::ModifyCapitalizeUpperLowerTitlesLimited('upfirst', $start, 5); break; case 'upper': $c = GFontsDB::ModifyCapitalizeUpperLowerTitlesLimited('upper', $start, 5); break; case 'lower': $c = GFontsDB::ModifyCapitalizeUpperLowerTitlesLimited('lower', $start, 5); break; } $response = array('result' => 0, 'start' => (int) $c, 'message' => sprintf(__('Finished %d of %d (%d%%)', self::PLUGIN_SLUG), $c, $total, $c * 100 / $total), 'finished' => $c >= $total ? 1 : 0); echo json_encode($response); die; }