function wp_ozh_yourls_reset_url() { check_ajax_referer('yourls'); $post_id = (int) $_POST['yourls_post_id']; $old_shorturl = $_POST['yourls_shorturl']; delete_post_meta($post_id, 'yourls_shorturl'); $shorturl = wp_ozh_yourls_geturl($post_id); if ($shorturl) { $result = "New short URL generated: <a href='{$shorturl}'>{$shorturl}</a>"; update_post_meta($post_id, 'yourls_shorturl', $shorturl); } else { $result = "Bleh. Could not generate short URL. Maybe the URL shortening service is down? Please try again later!"; } $x = new WP_AJAX_Response(array('data' => $result, 'supplemental' => array('old_shorturl' => $old_shorturl, 'shorturl' => $shorturl))); $x->send(); die('1'); }
$x = new WP_Ajax_Response(array('what' => 'cat', 'id' => $cat->term_id, 'position' => -1, 'data' => _cat_row($cat, $level, $cat_full_name), 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__('Category <a href="#%s">%s</a> added'), "cat-{$cat->term_id}", $cat_full_name)))); $x->send(); break; case 'add-link-cat': // From Blogroll -> Categories check_ajax_referer('add-link-category'); if (!current_user_can('manage_categories')) { die('-1'); } if ('' === trim($_POST['name'])) { $x = new WP_Ajax_Response(array('what' => 'link-cat', 'id' => new WP_Error('name', __('You did not enter a category name.')))); $x->send(); } $r = wp_insert_term($_POST['name'], 'link_category', $_POST); if (is_wp_error($r)) { $x = new WP_AJAX_Response(array('what' => 'link-cat', 'id' => $r)); $x->send(); } extract($r, EXTR_SKIP); if (!($link_cat = link_cat_row($term_id))) { die('0'); } $x = new WP_Ajax_Response(array('what' => 'link-cat', 'id' => $term_id, 'position' => -1, 'data' => $link_cat)); $x->send(); break; case 'add-tag': // From Manage->Tags check_ajax_referer('add-tag'); if (!current_user_can('manage_categories')) { die('-1'); }
static function delete_revisions() { //Add nonce check check_admin_referer('revision-control-delete'); if (empty($_POST['revisions'])) { $x = new WP_AJAX_Response(); $x->add(array('data' => -1)); $x->send(); return; } $revisions = stripslashes($_POST['revisions']); $revisions = explode(',', $revisions); $revisions = array_map('intval', $revisions); $deleted = array(); foreach ($revisions as $revision_id) { $revision = get_post($revision_id); if (wp_is_post_revision($revision) && !wp_is_post_autosave($revision) && current_user_can('delete_post', $revision->post_parent)) { if (wp_delete_post_revision($revision_id)) { $deleted[] = $revision_id; } } } $x = new WP_AJAX_Response(); $x->add(array('data' => 1, 'supplemental' => array('revisions' => implode(',', $deleted)))); $x->send(); }