Example #1
0
 /**
  * WordPress action to perform an ajax edit operation and echo results.
  *
  * @since 1.3
  */
 public static function ajax_edit()
 {
     check_ajax_referer('geo-mashup-edit', 'geo_mashup_nonce');
     unset($_GET['_wpnonce']);
     $status = array('request' => 'ajax-edit', 'code' => 200);
     if (isset($_POST['geo_mashup_object_id'])) {
         $status['object_id'] = $_POST['geo_mashup_object_id'];
     } else {
         $status['code'] = 400;
         $status['message'] = __('No object id posted.', 'GeoMashup');
         $status['object_id'] = '?';
     }
     /** @todo add an option for a user capability check here? */
     if (200 == $status['code'] and !empty($_POST['geo_mashup_ui_manager'])) {
         $ui_manager = GeoMashupUIManager::get_instance($_POST['geo_mashup_ui_manager']);
         $result = $ui_manager->save_posted_object_location($status['object_id']);
         if (is_wp_error($result)) {
             $status['code'] = 500;
             $status['message'] = $result->get_error_message();
         }
     }
     if (200 == $status['code']) {
         if (!empty($_REQUEST['geo_mashup_update_location'])) {
             $status['message'] = __('Location updated.', 'GeoMashup');
         } else {
             if (!empty($_REQUEST['geo_mashup_delete_location'])) {
                 $status['message'] = __('Location deleted.', 'GeoMashup');
             } else {
                 if (!empty($_REQUEST['geo_mashup_add_location'])) {
                     $status['message'] = __('Location added.', 'GeoMashup');
                 }
             }
         }
     }
     echo json_encode(array('status' => $status));
     exit;
 }
 /**
  * Get the single instance of this class.
  * 
  * @since 1.3
  * @uses parent::get_instance()
  *
  * @return GeoMashupPostUIManager The instance.
  */
 public static function get_instance()
 {
     return parent::get_instance('GeoMashupPostUIManager');
 }
 /**
  * Get the single instance of this class.
  * 
  * @since 1.3
  * @uses parent::get_instance()
  *
  * @param string $name The class name, this class by default.
  * @return GeoMashupPostUIManager The instance.
  */
 public static function get_instance($name = __CLASS__)
 {
     return parent::get_instance('GeoMashupPostUIManager');
 }