Exemplo n.º 1
0
function colabs_handle_property_submit_form()
{
    if (!isset($_POST['property_submit'])) {
        return;
    }
    $actions = array('edit-property', 'new-property', 'relist-property');
    if (empty($_POST['action']) || !in_array($_POST['action'], $actions)) {
        return;
    }
    // if ( !current_user_can( 'can_submit_property' ) )
    //   return;
    $property = colabs_handle_update_property_listing();
    if (!$property) {
        // there are errors, return to current page
        return;
    }
    if ('edit-property' == $_POST['action']) {
        // maybe update property status
        if (_colabs_edited_property_requires_moderation($property)) {
            colabs_update_post_status($property->ID, 'pending');
            // send notification email
            //colabs_edited_property_pending( $property->ID );
        }
        wp_redirect(add_query_arg('update_success', '1', get_permalink($property->ID)));
        exit;
    }
    $args = array('property_id' => $property->ID, 'step ' => colabs_get_next_step());
    if (!empty($_POST['relist'])) {
        $args['property_relist'] = $property->ID;
    }
    if (!empty($_POST['order_id'])) {
        $args['order_id'] = intval($_POST['order_id']);
    }
    // redirect to next step
    wp_redirect(add_query_arg($args, COLABS_SUBMIT_PAGE));
    exit;
}
/*
Template Name: Submit Property Template
*/
### Prevent Caching
nocache_headers();
colabs_auth_redirect_login();
// if ( !current_user_can('can_submit_property') )
//   redirect_profile();
if (empty($params)) {
    $params = array();
}
$property = '';
if ($property_id = get_query_var('property_id')) {
    $property = get_post($property_id);
}
$default_params = array('step' => colabs_get_next_step(), 'property' => $property, 'order_id' => get_query_var('order_id'), 'post_action' => get_query_var('property_relist') ? 'relist-property' : 'new-property', 'form_action' => $_SERVER['REQUEST_URI'], 'submit_text' => __('Next', 'colabsthemes'));
$params = wp_parse_args($params, $default_params);
$step = $params['step'];
$steps = colabs_steps();
if (get_query_var('property_relist')) {
    $title = sprintf(__('Relisting %s', 'colabsthemes'), html('a', array('href' => get_permalink($property->ID)), get_the_title($property->ID)));
} else {
    $title = get_the_title();
}
get_header();
?>


<div class="main-content column col9">
  <?php 
if (have_posts()) {