static function handle_form()
 {
     if (empty($_POST['action']) || 'manage-escrow' != $_POST['action']) {
         return;
     }
     if (!wp_verify_nonce($_POST['_wpnonce'], 'app-manage-escrow')) {
         return;
     }
     $sanitized_user_meta = scbForms::validate_post_data(self::get_fields());
     foreach ($sanitized_user_meta as $meta_key => $meta_value) {
         update_user_option(get_current_user_id(), $meta_key, $meta_value);
     }
     appthemes_add_notice('saved-escrow-settings', __('Settings Saved.', APP_TD), 'success');
 }
 function update()
 {
     if (!isset($_POST['action']) || 'app-edit-profile' != $_POST['action']) {
         return;
     }
     check_admin_referer('app-edit-profile');
     require ABSPATH . '/wp-admin/includes/user.php';
     $r = edit_user($_POST['user_id']);
     if (is_wp_error($r)) {
         $this->errors = $r;
     } else {
         do_action('personal_options_update', $_POST['user_id']);
         appthemes_add_notice('updated-profile', __('Your profile has been updated.', APP_TD), 'success');
         $redirect_url = add_query_arg(array('updated' => 'true'));
         wp_redirect($redirect_url);
         exit;
     }
 }
Example #3
0
/**
 * Checks permissions to access the WordPress backend.
 *
 * @return void
 */
function cp_security_check()
{
    global $cp_options;
    $cp_access_level = $cp_options->admin_security;
    // if there's no value then give everyone access
    if (empty($cp_access_level)) {
        $cp_access_level = 'read';
    }
    // previous releases had incompatible capability with MU installs
    if ('install_themes' == $cp_access_level) {
        $cp_access_level = 'manage_options';
    }
    $doing_ajax = defined('DOING_AJAX') && DOING_AJAX;
    $doing_admin_post = basename($_SERVER['SCRIPT_FILENAME']) === 'admin-post.php';
    if ($cp_access_level == 'disable' || current_user_can($cp_access_level) || $doing_ajax || $doing_admin_post) {
        return;
    }
    appthemes_add_notice('denied-admin-access', __('Site administrator has blocked your access to the back-office.', APP_TD), 'error');
    wp_redirect(CP_DASHBOARD_URL);
    exit;
}
Example #4
0
 /**
  * Displays an error for the user
  * @param  string $message Message to display
  * @return void
  */
 protected function fail_order($message)
 {
     appthemes_add_notice('error', $message);
 }
Example #5
0
 static function process_actions()
 {
     global $current_user;
     $allowed_actions = array('pause', 'restart', 'delete', 'setSold', 'unsetSold');
     if (!isset($_GET['action']) || !in_array($_GET['action'], $allowed_actions)) {
         return;
     }
     if (!isset($_GET['aid']) || !is_numeric($_GET['aid'])) {
         return;
     }
     $d = trim($_GET['action']);
     $post_id = appthemes_numbers_only($_GET['aid']);
     // make sure ad exist
     $post = get_post($post_id);
     if (!$post || $post->post_type != APP_POST_TYPE) {
         return;
     }
     // make sure author matches
     if ($post->post_author != $current_user->ID) {
         return;
     }
     $expire_time = strtotime(get_post_meta($post->ID, 'cp_sys_expire_date', true));
     $is_expired = current_time('timestamp') > $expire_time && $post->post_status == 'draft';
     $is_pending = $post->post_status == 'pending';
     if ($d == 'pause' && !$is_expired && !$is_pending) {
         wp_update_post(array('ID' => $post->ID, 'post_status' => 'draft'));
         appthemes_add_notice('paused', __('Ad has been paused.', APP_TD), 'success');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     } elseif ($d == 'restart' && !$is_expired && !$is_pending) {
         wp_update_post(array('ID' => $post->ID, 'post_status' => 'publish'));
         appthemes_add_notice('restarted', __('Ad has been published.', APP_TD), 'success');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     } elseif ($d == 'delete') {
         cp_delete_ad_listing($post->ID);
         appthemes_add_notice('deleted', __('Ad has been deleted.', APP_TD), 'success');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     } elseif ($d == 'setSold') {
         update_post_meta($post->ID, 'cp_ad_sold', 'yes');
         appthemes_add_notice('marked-sold', __('Ad has been marked as sold.', APP_TD), 'success');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     } elseif ($d == 'unsetSold') {
         update_post_meta($post->ID, 'cp_ad_sold', 'no');
         appthemes_add_notice('unmarked-sold', __('Ad has been unmarked as sold.', APP_TD), 'success');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     }
 }
Example #6
0
 /**
  * Processing form.
  *
  * @param object $order
  * @param object $checkout
  *
  * return void
  */
 public function process($order, $checkout)
 {
     global $cp_options;
     if (!isset($_POST['action']) || 'edit-listing' !== $_POST['action']) {
         return;
     }
     check_admin_referer($checkout->get_checkout_type());
     $this->category_id = $checkout->get_data('category_id');
     $this->form_id = $checkout->get_data('form_id');
     $this->form_fields = cp_get_custom_form_fields($this->form_id);
     $this->posted_fields = $this->clean_expected_fields();
     $this->errors = $this->validate_fields($this->errors);
     $this->errors = apply_filters('cp_listing_validate_fields', $this->errors);
     $this->update_listing($order, $checkout);
     // set listing as pending if it require moderation
     if ($cp_options->moderate_edited_ads) {
         $listing = $this->get_listing_obj();
         $listing_args = array('ID' => $listing->ID, 'post_status' => 'pending');
         $listing_id = wp_update_post($listing_args);
     }
     if ($this->errors->get_error_codes()) {
         return false;
     }
     // add notice about successful update
     $link = html('a', array('href' => esc_url(CP_DASHBOARD_URL), 'class' => 'no-padding'), __('Return to dashboard.', APP_TD));
     if ($cp_options->moderate_edited_ads) {
         appthemes_add_notice('updated', sprintf(__('Your ad has been successfully updated and awaiting approval. %s', APP_TD), $link), 'success');
     } else {
         appthemes_add_notice('updated', sprintf(__('Your ad has been successfully updated. %s', APP_TD), $link), 'success');
     }
     $checkout->add_data('posted_fields', $this->posted_fields);
     $this->finish_step();
 }