Beispiel #1
0
 function ajax_csv_import()
 {
     global $wpbdp;
     if (!current_user_can('administrator')) {
         die;
     }
     $import_id = !empty($_POST['import_id']) ? $_POST['import_id'] : 0;
     if (!$import_id) {
         die;
     }
     $res = new WPBDP_Ajax_Response();
     try {
         $import = new WPBDP_CSV_Import($import_id);
     } catch (Exception $e) {
         if ($import) {
             $import->cleanup();
         }
         $res->send_error($e->getMessage());
     }
     if (!empty($_POST['cleanup'])) {
         $import->cleanup();
         $res->send();
     }
     $wpbdp->_importing_csv = true;
     $wpbdp->_importing_csv_no_email = (bool) $import->get_setting('disable-email-notifications');
     $import->do_work();
     unset($wpbdp->_importing_csv);
     unset($wpbdp->_importing_csv_no_email);
     $res->add('done', $import->done());
     $res->add('progress', $import->get_progress('n'));
     $res->add('total', $import->get_import_rows_count());
     $res->add('imported', $import->get_imported_rows_count());
     $res->add('rejected', $import->get_rejected_rows_count());
     if ($import->done()) {
         $res->add('warnings', $import->get_errors());
         $import->cleanup();
     }
     $res->send();
 }
 public function ajax_listing_submit_image_delete()
 {
     $res = new WPBDP_Ajax_Response();
     $image_id = intval($_REQUEST['image_id']);
     if (!$image_id) {
         $res->send_error();
     }
     $state_id = isset($_REQUEST['state_id']) ? $_REQUEST['state_id'] : '';
     if ($state_id) {
         require_once WPBDP_PATH . 'core/view-submit-listing.php';
         if (!$state_id) {
             $res->send_error();
         }
         $state = WPBDP_Listing_Submit_State::get($state_id);
         if (!$state || !in_array($image_id, $state->images)) {
             $res->send_error();
         }
         wpbdp_array_remove_value($state->images, $image_id);
         $state->save();
     }
     wp_delete_attachment($image_id, true);
     $res->add('imageId', $image_id);
     $res->send();
 }
Beispiel #3
0
 function ajax_dismiss_license_warning()
 {
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     $module = isset($_POST['module']) ? $_POST['module'] : '';
     $res = new WPBDP_Ajax_Response();
     if (!wp_verify_nonce($nonce, 'dismiss warning')) {
         $res->send_error();
     }
     $data = get_transient('wpbdp-license-check-data');
     if (!is_array($data['warning-dismissed'])) {
         $data['warning-dismissed'] = array();
     }
     if (!in_array($module, $data['warning-dismissed'], true)) {
         $data['warning-dismissed'][] = $module;
     }
     set_transient('wpbdp-license-check-data', $data, 1 * WEEK_IN_SECONDS);
     $res->send();
 }
 public function ajax_listing_change_fee()
 {
     global $wpdb;
     $response = new WPBDP_Ajax_Response();
     if (!current_user_can('administrator')) {
         $response->send_error();
     }
     $fee_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpbdp_listing_fees WHERE id = %d", isset($_POST['renewal']) ? $_POST['renewal'] : 0));
     if (!$fee_info) {
         $response->send_error();
     }
     $listing = WPBDP_Listing::get($fee_info->listing_id);
     $category = $listing->get_category_info($fee_info->category_id);
     if (!$listing || !$category || 'pending' == $category->status) {
         $response->send_error();
     }
     $response->add('html', wpbdp_render_page(WPBDP_PATH . 'admin/templates/listing-change-fee.tpl.php', array('category' => $category, 'listing' => $listing, 'fees' => wpbdp_get_fees_for_category($fee_info->category_id))));
     $response->send();
 }