function colabs_owner_property_expired($post_id, $canceled = false) { $send_expired_email = get_option('colabs_expired_property_email_owner'); if ('true' != $send_expired_email && !$canceled) { return; } $post_info = get_post($post_id); $post_title = stripslashes($post_info->post_title); $post_author = stripslashes(get_the_author_meta('user_login', $post_info->post_author)); $post_author_email = stripslashes(get_the_author_meta('user_email', $post_info->post_author)); $dashurl = trailingslashit(COLABS_DASHBOARD_PAGE); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $mailto = $post_author_email; if ($canceled) { $subject = sprintf(__('[%s] Your Property was Canceled', 'colabsthemes'), $blogname); $message = sprintf(__('Hi %s,', 'colabsthemes'), $post_author) . PHP_EOL . PHP_EOL; $message .= sprintf(__('Your property listing, "%s" was canceled.', 'colabsthemes'), $post_title) . PHP_EOL . PHP_EOL; $message .= __('You can still access your property on your dashboard and submit it again, if you wish.', 'colabsthemes') . PHP_EOL . PHP_EOL; $message .= $dashurl . PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL; } else { $subject = sprintf(__('[%s] Your Property Has Expired', 'colabsthemes'), $blogname); $message = sprintf(__('Hi %s,', 'colabsthemes'), $post_author) . PHP_EOL . PHP_EOL; $message .= sprintf(__('Your property listing, "%s" has expired.', 'colabsthemes'), $post_title) . PHP_EOL . PHP_EOL; if (colabs_allow_relist()) { $message .= __('If you would like to relist your property please go to your Dashboard, click the "relist" link.', 'colabsthemes') . PHP_EOL; $message .= $dashurl . PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL; } } $message .= colabs_email_signature('expired_property'); // ok let's send the email wp_mail($mailto, $subject, $message, _colabs_email_headers()); }
function colabs_property_parse_query($wp_query) { if ($wp_query->is_main_query() && is_page(get_option('colabs_dashboard_page_id'))) { if (get_query_var('order_cancel') || get_query_var('order_status')) { $wp_query->set('tab', 'orders'); } if (get_query_var('order_status')) { $wp_query->set('order_status', array_map('wp_strip_all_tags', get_query_var('order_status'))); } if (get_query_var('order_cancel')) { $order = colabs_get_order(intval(get_query_var('order_cancel'))); if (get_current_user_id() != $order->get_author()) { $wp_query->set('order_cancel_msg', -1); return; } if (COLABS_ORDER_COMPLETED == $order->get_status()) { $wp_query->set('order_cancel_msg', -2); return; } if (!empty($order) && get_query_var('confirm_order_cancel')) { $order->failed(); $wp_query->set('order_cancel_success', 1); } } elseif (get_query_var('property_end') && get_query_var('confirm')) { $property_id = intval(get_query_var('property_end')); $property = get_post($property_id); if ($property->ID != $property_id || $property->post_author != get_current_user_id()) { $wp_query->set('property_action', -1); return; } if (get_query_var('cancel')) { $pending_payment = colabs_get_pending_payment($property_id); $order = colabs_get_order($pending_payment[$property_id]['order_id']); if ($order && !in_array($order->get_status(), array(COLABS_ORDER_ACTIVATED, COLABS_ORDER_COMPLETED))) { $order->failed(); } else { _colabs_end_property($property_id, $cancel = true); } $wp_query->set('property_action', 1); } else { _colabs_end_property($property_id); $wp_query->set('property_action', 2); } // Property delete } elseif (get_query_var('property_delete')) { _colabs_delete_property(get_query_var('property_delete')); // Property mark as sold } elseif (get_query_var('property_marksold')) { $property_id = get_query_var('property_marksold'); update_post_meta($property_id, 'colabs_property_sold', 'true'); $sold_term = get_term_by('slug', 'sold', COLABS_TAX_STATUS); if ($sold_term) { // Save previous property_status into a post meta update_post_meta($property_id, '_colabs_previous_property_status', wp_get_post_terms($property_id, COLABS_TAX_STATUS, array('fields' => 'ids'))); wp_set_post_terms($property_id, $sold_term->term_id, COLABS_TAX_STATUS); } // Property set unsold } elseif (get_query_var('property_unsold')) { $property_id = get_query_var('property_unsold'); update_post_meta($property_id, 'colabs_property_sold', 'false'); $previous_status = get_post_meta($property_id, '_colabs_previous_property_status', true); if ($previous_status) { wp_set_post_terms($property_id, $previous_status, COLABS_TAX_STATUS); } else { $sell_term = get_term_by('slug', 'sell', COLABS_TAX_STATUS); if ($sell_term) { wp_set_post_terms($id, $sell_term->term_id, COLABS_TAX_STATUS); } } } } if ($wp_query->is_main_query() && is_page(get_option('colabs_submit_page_id'))) { if ($wp_query->get('property_relist')) { $property_id = $wp_query->get('property_relist'); // if ( is_user_logged_in() && ! current_user_can('can_submit_property') ) { // wp_redirect( home_url() ); // exit(); // } if (!colabs_allow_relist()) { redirect_myproperties(); } $wp_query->set('property_id', $property_id); } } }
function colabs_handle_new_order() { if (!isset($_POST['action']) || !empty($_POST['goback'])) { return; } if (empty($_POST['ID'])) { return false; } $property = get_post(intval($_POST['ID'])); $property_id = intval($_POST['ID']); if (!empty($_POST['order_id'])) { $order_id = intval($_POST['order_id']); $order = colabs_get_order($order_id); } if (get_option('colabs_cost_to_feature') > 0 && is_sticky($property_id)) { $additional_price = get_option('colabs_cost_to_feature'); } else { $additional_price = 0; } if ('relist-property' == $_POST['action'] && colabs_allow_relist()) { $price = get_option('colabs_property_relisting_cost'); } else { $price = get_option('colabs_property_listing_cost'); } $items = array('_post_type_id' => $property_id, 'price' => $price, 'additional_price' => $additional_price); $new_order = true; if (empty($order)) { $order = Colabs_Order::create($items); colabs_new_order_notify_admin($order); colabs_new_order_notify_owner($order); } else { $new_order = false; } do_action('colabs_create_order', $order, $property); $args = array('order_id' => $order->get_id(), 'property_id' => $property_id); // is the property being relisted? if (!empty($_POST['relist'])) { $args['property_relist'] = $property->ID; } // move form to next step if (!empty($_POST['step'])) { $args['step'] = intval($_POST['step']) + 1; } $args['referer'] = urlencode($_SERVER['REDIRECT_URL']); // redirect to next step wp_redirect(add_query_arg($args, COLABS_SUBMIT_PAGE)); exit; }
$canceled_property = get_post_meta($post->ID, '_colabs_canceled_property', true); if ($canceled_property) { ?> <a class="button button-bold button-green" href="<?php echo add_query_arg(array('property_id' => $post->ID), COLABS_SUBMIT_PAGE); ?> "> <i class="icon-play"></i> <?php _e('Continue', 'colabsthemes'); ?> </a> <?php } else { ?> <?php if (colabs_allow_relist()) { ?> <a class="button button-bold button-red" href="<?php echo add_query_arg(array('property_relist' => $post->ID), COLABS_SUBMIT_PAGE); ?> "> <i class="icon-play"></i> <?php _e('Relist', 'colabsthemes'); ?> </a> <?php } ?> <?php } ?>