예제 #1
0
 /**
  * Get the url for a media attachment for an AJAX request
  */
 public function ajax_media_url()
 {
     if (isset($_POST['attachment_id']) && is_numeric($_POST['attachment_id'])) {
         // determine size to retrieve
         $size = isset($_POST['attachment_size']) ? $_POST['attachment_size'] : 'full';
         // try to get the attachment info
         $src = wp_get_attachment_image_src($_POST['attachment_id'], $size);
         // check it out
         if (is_array($src)) {
             ICE_Ajax::response(true, $src[0], $src[1], $src[2]);
         } else {
             ICE_Ajax::response(false, __('Failed to lookup attachment URL', infinity_text_domain));
         }
     } else {
         ICE_Ajax::response(0, __('No attachment ID received', infinity_text_domain));
     }
 }
예제 #2
0
 /**
  * Switch theme
  *
  * @todo make sure template is a theme which implements the scheme
  */
 public function ajax_switch_theme()
 {
     // check for post id
     if (isset($_POST['template']) && isset($_POST['stylesheet'])) {
         // we are switching here people
         $template = trim($_POST['template']);
         $stylesheet = trim($_POST['stylesheet']);
         // attempt to activate the theme
         // this function does not return a freaking value, come on!!!
         switch_theme($template, $stylesheet);
         // have to assume it worked
         ICE_Ajax::response(true, __('Theme activated', infinity_text_domain));
     } else {
         ICE_Ajax::response(false, __('Theme activation failed', infinity_text_domain));
     }
 }
예제 #3
0
 /**
  * Trash a single post
  */
 public function ajax_post_trash()
 {
     // check for post id
     if (isset($_POST['post_id']) && is_numeric($_POST['post_id'])) {
         // got one
         $post_id = (int) $_POST['post_id'];
         // attempt to trash the post
         if (wp_trash_post($post_id) !== false) {
             ICE_Ajax::response(true, __('Item moved to trash', infinity_text_domain));
         } else {
             ICE_Ajax::response(false, __('Move item to trash failed', infinity_text_domain));
         }
     } else {
         ICE_Ajax::response(false, __('Missing item id', infinity_text_domain));
     }
 }