static function can_edit_ad() { global $current_user, $cp_options; if (!isset($_GET['listing_edit']) || $_GET['listing_edit'] != appthemes_numbers_only($_GET['listing_edit'])) { appthemes_add_notice('edit-invalid-id', __('You can not edit this ad. Invalid ID of an ad.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } if (!$cp_options->ad_edit) { appthemes_add_notice('edit-disabled', __('You can not edit this ad. Editing is currently disabled.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } $post = get_post($_GET['listing_edit']); if (!$post) { appthemes_add_notice('edit-invalid-id', __('You can not edit this ad. Invalid ID of an ad.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } if (!$cp_options->moderate_edited_ads && $post->post_status == 'pending') { appthemes_add_notice('edit-pending', __('You can not edit this ad. Ad is not yet approved.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } if ($post->post_type != APP_POST_TYPE) { appthemes_add_notice('edit-invalid-type', __('You can not edit this ad. This is not an ad.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } if ($post->post_author != $current_user->ID) { appthemes_add_notice('edit-invalid-author', __("You can not edit this ad. It's not your ad.", APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } if (cp_is_listing_expired($post->ID)) { appthemes_add_notice('edit-expired', __('You can not edit this ad. Ad is expired.', APP_TD), 'error'); wp_redirect(CP_DASHBOARD_URL); exit; } }
/** * Returns ad listing status name. * * @param int $listing_id (optional) * * @return string */ function cp_get_listing_status_name($listing_id = 0) { global $cp_options; $listing_id = $listing_id ? $listing_id : get_the_ID(); $listing = get_post($listing_id); if (cp_is_listing_expired($listing->ID)) { if ($listing->post_status == 'publish' && !$cp_options->post_prune) { return 'live_expired'; } else { return 'ended'; } } else { if ($listing->post_status == 'draft') { return 'offline'; } else { if ($listing->post_status == 'pending') { if (cp_have_pending_payment($listing->ID)) { return 'pending_payment'; } else { return 'pending_moderation'; } } } } return 'live'; }