protected function render($template, $args = array(), $skipouter = false, $is_html = false)
 {
     $html = '';
     $html .= sprintf('<div id="wpbdp-submit-page" class="wpbdp-submit-page businessdirectory-submit businessdirectory wpbdp-page step-%s">', str_replace('_', '-', $this->state->step));
     $html .= sprintf('<h2>%s</h2>', $this->state->editing ? _x('Edit Your Listing', 'templates', 'WPBDM') : _x('Submit A Listing', 'templates', 'WPBDM'));
     if (current_user_can('administrator')) {
         if ($errors = wpbdp_payments_api()->check_config()) {
             foreach ($errors as $error) {
                 $html .= wpbdp_render_msg($error, 'error');
             }
         }
         $html .= wpbdp_render_msg(_x('You are logged in as an administrator. Any payment steps will be skipped.', 'templates', 'WPBDM'));
     }
     if ($this->errors) {
         foreach ($this->errors as &$e) {
             $html .= wpbdp_render_msg($e, 'error');
         }
     }
     if ($this->messages) {
         foreach ($this->messages as &$m) {
             $html .= wpbdp_render_msg($m);
         }
     }
     if (!$is_html) {
         $content = wpbdp_render('submit-listing/' . $template, array_merge(array('_state' => $this->state), $args), false);
     } else {
         $content = $template;
     }
     $html .= $content;
     $html .= '</div>';
     return apply_filters_ref_array('wpbdp_view_submit_listing', array($html, &$this->state));
 }
 private function cancel_subscription()
 {
     $data = $this->decode_subscription_hash(isset($_GET['cancel']) ? $_GET['cancel'] : '');
     if (!$data) {
         return wpbdp_render_msg(_x('Invalid subscription.', 'manage subscriptions', 'WPBDM'), 'error');
     }
     global $wpbdp;
     $unsubscribe_form = $wpbdp->payments->render_unsubscribe_integration($data['category_info'], $data['listing']);
     return wpbdp_render('manage-recurring-cancel', array('listing' => $data['listing'], 'subscription' => $data['category_info'], 'unsubscribe_form' => $unsubscribe_form));
 }
 /**
  * @since 3.5.8
  */
 public function render_billing_information_form(&$payment, $args = array())
 {
     $defaults = array('action' => $this->get_url($payment, 'process'), 'posted' => $payment->get_data('billing-information'), 'errors' => $payment->get_data('validation-errors'));
     $args = wp_parse_args($args, $defaults);
     $args['payment'] = $payment;
     // Clear errors.
     $payment->set_data('billing-information', false);
     $payment->set_data('validation-errors', false);
     $payment->save();
     return wpbdp_render('billing-information-form', $args);
 }
 private function listing_images()
 {
     if (!current_user_can('edit_posts')) {
         return;
     }
     $images = $this->listing->get_images('ids');
     $thumbnail_id = $this->listing->get_thumbnail_id();
     // Current images.
     echo '<h4>' . _x('Current Images', 'templates', 'WPBDM') . '</h4>';
     echo '<div id="no-images-message" style="' . ($images ? 'display: none;' : '') . '">' . _x('There are no images currently attached to the listing.', 'templates', 'WPBDM') . '</div>';
     echo '<div id="wpbdp-uploaded-images" class="cf">';
     foreach ($images as $image_id) {
         echo wpbdp_render('submit-listing/images-single', array('image_id' => $image_id, 'is_thumbnail' => 1 == count($images) || $thumbnail_id == $image_id), false);
     }
     echo '</div>';
     echo wpbdp_render('submit-listing/images-upload-form', array('admin' => true, 'listing_id' => $this->listing->get_id()), false);
 }
 function dispatch()
 {
     $listing_id = intval($_REQUEST['listing_id']);
     if (!wpbdp_user_can('delete', $listing_id)) {
         $html .= wpbdp_render_msg(_x('Please log in to delete the listing.', 'delete listing', 'WPBDM'));
         $html .= wpbdp_render('parts/login-required', array('show_message' => false));
         return $html;
     }
     $listing = WPBDP_Listing::get($listing_id);
     $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';
     if (!$listing) {
         die;
     }
     if ($nonce && wp_verify_nonce($nonce, 'delete listing ' . $listing->get_id())) {
         $listing->delete();
         return wpbdp_render_msg(_x('Your listing has been deleted.', 'delete listing', 'WPBDM'));
     }
     return wpbdp_render('delete-listing-confirm', array('listing' => $listing, 'has_recurring' => $this->has_recurring_fee($listing)));
 }
 private function fee_selection()
 {
     // Cancel renewal?
     if (isset($_POST['cancel-renewal'])) {
         $this->listing->remove_category($this->category->id, true);
         if (!$this->listing->get_categories('all')) {
             $this->listing->delete();
         }
         return wpbdp_render_msg(_x('Your renewal was successfully cancelled.', 'renewal', 'WPBDM'));
     }
     $fees = wpbdp_get_fees_for_category($this->category->id);
     if (isset($_POST['fees']) && isset($_POST['fees'][$this->category->id])) {
         $fee_id = intval($_POST['fees'][$this->category->id]);
         if ($fee = wpbdp_get_fee($fee_id)) {
             $payment = new WPBDP_Payment(array('listing_id' => $this->listing->get_id()));
             $payment->add_item('fee', $fee->amount, sprintf(_x('Fee "%s" renewal for category "%s"', 'listings', 'WPBDM'), $fee->label, wpbdp_get_term_name($this->category->id)), array('fee_id' => $fee_id, 'fee_days' => $fee->days, 'fee_images' => $fee->images), $this->category->id, $fee_id);
             $payment->save();
             $this->category->payment_id = $payment->get_id();
             return $this->checkout();
         }
     }
     return wpbdp_render('renew-listing', array('listing' => $this->listing, 'category' => $this->category, 'fees' => $fees));
 }
 /**
  * Sends the email.
  * @param string $format allowed values are 'html', 'plain' or 'both'
  * @return boolean true on success, false otherwise
  */
 public function send($format = 'both')
 {
     $this->subject = strip_tags($this->subject);
     // TODO: implement 'plain' and 'both'
     $this->prepare_html();
     $this->prepare_plain();
     $this->from = $this->from ? $this->from : sprintf('%s <%s>', get_option('blogname'), get_option('admin_email'));
     $to = $this->to;
     if (!$this->to) {
         return false;
     }
     // Workaround a known WP bug where some headers are ignored if passed inside an array.
     $headers = '';
     foreach ($this->get_headers() as $h => $v) {
         $headers .= $h . ': ' . $v . "\r\n";
     }
     $html = $this->html;
     if ($this->template) {
         if ($html_ = wpbdp_render($this->template, array('subject' => $this->subject, 'body' => $this->html))) {
             $html = $html_;
         }
     }
     return wp_mail($this->to, $this->subject, $html, $headers);
 }
function _wpbdp_render_excerpt()
{
    global $post;
    static $counter = 0;
    $sticky_status = wpbdp_listings_api()->get_sticky_status($post->ID);
    $html = '';
    $html .= sprintf('<div id="wpbdp-listing-%d" class="wpbdp-listing excerpt wpbdp-listing-excerpt %s %s %s cf">', $post->ID, $sticky_status, $counter & 1 ? 'odd' : 'even', apply_filters('wpbdp_excerpt_view_css', '', $post->ID));
    $html .= wpbdp_capture_action('wpbdp_before_excerpt_view', $post->ID);
    $d = WPBDP_ListingFieldDisplayItem::prepare_set($post->ID, 'excerpt');
    $listing_fields = implode('', WPBDP_ListingFieldDisplayItem::walk_set('html', $d->fields));
    $social_fields = implode('', WPBDP_ListingFieldDisplayItem::walk_set('html', $d->social));
    $vars = array('is_sticky' => $sticky_status == 'sticky', 'thumbnail' => wpbdp_get_option('allow-images') && wpbdp_get_option('show-thumbnail') ? wpbdp_listing_thumbnail(null, 'link=listing&class=wpbdmthumbs wpbdp-excerpt-thumbnail') : '', 'title' => get_the_title(), 'listing_fields' => apply_filters('wpbdp_excerpt_listing_fields', $listing_fields, $post->ID), 'fields' => $d->fields, 'listing_id' => $post->ID);
    $vars = apply_filters('wpbdp_listing_template_vars', $vars, $post->ID);
    $vars = apply_filters('wpbdp_excerpt_template_vars', $vars, $post->ID);
    $html .= wpbdp_render('businessdirectory-excerpt', $vars, true);
    $social_fields = apply_filters('wpbdp_excerpt_social_fields', $social_fields, $post->ID);
    if ($social_fields) {
        $html .= '<div class="social-fields cf">' . $social_fields . '</div>';
    }
    $html .= wpbdp_capture_action('wpbdp_after_excerpt_view', $post->ID);
    $html .= wpbdp_render('parts/listing-buttons', array('listing_id' => $post->ID, 'view' => 'excerpt'), false);
    $html .= '</div>';
    $counter++;
    return $html;
}
        </form>
    <?php 
} else {
    ?>
        <p><?php 
    printf(_x('You are about to renew your listing "%s" publication inside category "%s".', 'templates', 'WPBDM'), esc_html($listing->get_title()), esc_html(wpbdp_get_term_name($category->id)));
    ?>
</p>
        <p><?php 
    _ex('Please select a fee option or click "Do not renew my listing" to cancel your renewal.', 'WPBDM');
    ?>
</p>

        <form id="wpbdp-renewlisting-form" method="POST" action="">
        <?php 
    echo wpbdp_render('parts/category-fee-selection', array('category' => get_term($category->id, WPBDP_CATEGORY_TAX), 'category_fees' => $fees, 'current_fee' => $category->fee_id, 'multiple_categories' => false), false);
    ?>
        <input type="submit" class="submit" name="submit" value="<?php 
    _ex('Continue', 'templates', 'WPBDM');
    ?>
" />

        <div class="do-not-renew-listing">
            <div class="header"><?php 
    _ex('Cancel Listing Renewal', 'renewal', 'WPBDM');
    ?>
</div>
            <input type="submit" class="submit" name="cancel-renewal" value="<?php 
    _ex('Do not renew my listing', 'templates', 'WPBDM');
    ?>
" />
Beispiel #10
0
 /**
  * Renders an invoice table for a given payment.
  * @param $payment WPBDP_Payment
  * @return string HTML output.
  * @since 3.4
  */
 public function render_invoice(&$payment)
 {
     return wpbdp_render('payment/payment_items', array('payment' => $payment), false);
 }
 public function ajax_listing_submit_image_upload()
 {
     $res = new WPBDP_Ajax_Response();
     $listing_id = 0;
     $state_id = 0;
     $state = null;
     if (isset($_REQUEST['state_id'])) {
         require_once WPBDP_PATH . 'core/view-submit-listing.php';
         $state_id = trim($_REQUEST['state_id']);
         $state = WPBDP_Listing_Submit_State::get($state_id);
         if (!$state) {
             $res->send_error();
         }
     } else {
         $listing_id = intval($_REQUEST['listing_id']);
         if (!$listing_id) {
             $res->send_error();
         }
     }
     $content_range = null;
     $size = null;
     if (isset($_SERVER['HTTP_CONTENT_RANGE'])) {
         $content_range = preg_split('/[^0-9]+/', $_SERVER['HTTP_CONTENT_RANGE']);
         $size = $content_range ? $content_range[3] : null;
     }
     $attachments = array();
     $files = wpbdp_flatten_files_array(isset($_FILES['images']) ? $_FILES['images'] : array());
     $errors = array();
     foreach ($files as $i => $file) {
         $image_error = '';
         $attachment_id = wpbdp_media_upload($file, true, true, array('image' => true, 'min-size' => intval(wpbdp_get_option('image-min-filesize')) * 1024, 'max-size' => intval(wpbdp_get_option('image-max-filesize')) * 1024, 'min-width' => wpbdp_get_option('image-min-width'), 'min-height' => wpbdp_get_option('image-min-height')), $image_error);
         // TODO: handle errors.
         if ($image_error) {
             $errors[$file['name']] = $image_error;
         } else {
             $attachments[] = $attachment_id;
         }
     }
     $html = '';
     foreach ($attachments as $attachment_id) {
         if ($state) {
             $state->images[] = $attachment_id;
         }
         $html .= wpbdp_render('submit-listing/images-single', array('image_id' => $attachment_id, 'state_id' => $state ? $state->id : ''), false);
     }
     if ($listing_id) {
         $listing = WPBDP_Listing::get($listing_id);
         $listing->set_images($attachments, true);
     } elseif ($state) {
         $state->save();
     }
     if ($errors) {
         $error_msg = '';
         foreach ($errors as $fname => $error) {
             $error_msg .= sprintf('&#149; %s: %s', $fname, $error) . '<br />';
         }
         $res->add('uploadErrors', $error_msg);
     }
     $res->add('attachmentIds', $attachments);
     $res->add('html', $html);
     $res->send();
 }
Beispiel #12
0
" />

    <h4><?php 
_ex('Current Images', 'templates', 'WPBDM');
?>
</h4>
    <div id="no-images-message" style="<?php 
echo $images ? 'display: none;' : '';
?>
"><?php 
_ex('There are no images currently attached to your listing.', 'templates', 'WPBDM');
?>
</div>
    <div id="wpbdp-uploaded-images" class="cf">
    <?php 
foreach ($images as $image_id) {
    echo wpbdp_render('submit-listing/images-single', array('image_id' => $image_id, 'is_thumbnail' => 1 == count($images) || $thumbnail_id == $image_id, 'state_id' => $_state->id), false);
}
?>
    </div>

    <?php 
echo wpbdp_render('submit-listing/images-upload-form', array('slots' => $image_slots, 'slots_available' => $image_slots_remaining, 'max_file_size' => $image_max_file_size, 'state_id' => $_state->id), false);
?>

    <input type="submit" class="submit" name="finish" value="<?php 
_ex('Continue', 'templates', 'WPBDM');
?>
" />      
</form>
Beispiel #13
0
 public function search()
 {
     $_REQUEST = stripslashes_deep($_REQUEST);
     $search_args = array();
     $results = array();
     if (isset($_GET['dosrch'])) {
         $search_args['q'] = wpbdp_getv($_GET, 'q', null);
         $search_args['fields'] = array();
         // standard search fields
         $search_args['extra'] = array();
         // search fields added by plugins
         foreach (wpbdp_getv($_GET, 'listingfields', array()) as $field_id => $field_search) {
             $search_args['fields'][] = array('field_id' => $field_id, 'q' => $field_search);
         }
         foreach (wpbdp_getv($_GET, '_x', array()) as $label => $field) {
             $search_args['extra'][$label] = $field;
         }
         $listings_api = wpbdp_listings_api();
         if ($search_args['q'] && !$search_args['fields'] && !$search_args['extra']) {
             $results = $listings_api->quick_search($search_args['q']);
         } else {
             $results = $listings_api->search($search_args);
         }
     }
     $form_fields = wpbdp_get_form_fields(array('display_flags' => 'search', 'validators' => '-email'));
     $fields = '';
     foreach ($form_fields as &$field) {
         $field_value = isset($_REQUEST['listingfields']) && isset($_REQUEST['listingfields'][$field->get_id()]) ? $field->convert_input($_REQUEST['listingfields'][$field->get_id()]) : $field->convert_input(null);
         $fields .= $field->render($field_value, 'search');
     }
     $args = array('post_type' => WPBDP_POST_TYPE, 'posts_per_page' => wpbdp_get_option('listings-per-page') > 0 ? wpbdp_get_option('listings-per-page') : -1, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'post__in' => $results ? $results : array(0), 'orderby' => wpbdp_get_option('listings-order-by', 'date'), 'order' => wpbdp_get_option('listings-sort', 'ASC'));
     $args = apply_filters('wpbdp_search_query_posts_args', $args, $search_args);
     query_posts($args);
     wpbdp_push_query($GLOBALS['wp_query']);
     $html = wpbdp_render('search', array('fields' => $fields, 'searching' => isset($_GET['dosrch']) ? true : false, 'show_form' => !isset($_GET['dosrch']) || wpbdp_get_option('show-search-form-in-results')), false);
     wp_reset_query();
     wpbdp_pop_query();
     return $html;
 }
echo $_state->step_number . ' - ';
_ex('Fee/Upgrade Selection', 'templates', 'WPBDM');
?>
</h3>

<form id="wpbdp-listing-form-fees" class="wpbdp-listing-form" method="POST" action="">
	<input type="hidden" name="_state" value="<?php 
echo $_state->id;
?>
" />

	<?php 
foreach ($fee_selection as &$f) {
    ?>
		<?php 
    echo wpbdp_render('parts/category-fee-selection', array('category' => $f['term'], 'multiple_categories' => count($fee_selection) > 1, 'current_fee' => $f['fee_id'], 'category_fees' => $f['options']));
    ?>
	<?php 
}
?>

<?php 
if ($upgrade_option) {
    ?>
<div class="upgrade-to-featured-option">
	<b><?php 
    echo sprintf(_x('Would you like to upgrade your listing to "%s" for %s more?', 'templates', 'WPBDM'), esc_attr($upgrade_option->name), wpbdp_get_option('currency-symbol') . ' ' . $upgrade_option->cost);
    ?>
</b>	
	<p class="description"><?php 
    echo esc_html($upgrade_option->description);
 public function render_form($listing_id = 0, $validation_errors = array())
 {
     if (!$listing_id || !apply_filters('wpbdp_show_contact_form', wpbdp_get_option('show-contact-form'), $listing_id)) {
         return '';
     }
     $html = '';
     $html .= '<div class="contact-form">';
     if (!$_POST) {
         $html .= '<input type="button" class="wpbdp-show-on-mobile send-message-button" value="' . _x('Contact listing owner', 'templates', 'WPBDM') . '" />';
         $html .= '<div class="wpbdp-hide-on-mobile contact-form-wrapper">';
     }
     $html .= '<h3>' . _x('Send Message to listing owner', 'templates', 'WPBDM') . '</h3>';
     $form = '';
     if (!$this->can_submit($listing_id, $error_msg)) {
         $form = wpbdp_render_msg($error_msg);
     } else {
         $form = wpbdp_render('listing-contactform', array('validation_errors' => $validation_errors, 'listing_id' => $listing_id, 'current_user' => is_user_logged_in() ? wp_get_current_user() : null, 'recaptcha' => wpbdp_get_option('recaptcha-on') ? wpbdp_recaptcha('wpbdp-contact-form-recaptcha') : '', false));
     }
     $html .= $form;
     if (!$_POST) {
         $html .= '</div>';
     }
     $html .= '</div>';
     return $html;
 }
    if ($is_tag) {
        ?>
                <?php 
        echo sprintf(_x('Listings tagged: %s', 'templates', 'WPBDM'), $title);
        ?>
            <?php 
    } else {
        ?>
                <?php 
        echo $title;
        ?>
            <?php 
    }
    ?>
        </h2>
    <?php 
}
?>

    <?php 
do_action('wpbdp_before_category_page', $category);
?>
    <?php 
echo apply_filters('wpbdp_category_page_listings', wpbdp_render('businessdirectory-listings', array('excludebuttons' => true)), $category);
?>
    <?php 
do_action('wpbdp_after_category_page', $category);
?>

</div>
 private function upgrade_selection()
 {
     $sticky_info = $this->upgrades_api->get_info($this->listing->get_id());
     return wpbdp_render('listing-upgradetosticky', array('listing' => $this->listing, 'featured_level' => $sticky_info->upgrade), false);
 }
Beispiel #18
0
    ?>
    
    <h3><?php 
    _ex('Search Results', 'search', 'WPBDM');
    ?>
</h3>    

    <?php 
    do_action('wpbdp_before_search_results');
    ?>
    <div class="search-results">
    <?php 
    if (have_posts()) {
        ?>
        <?php 
        echo wpbdp_render('businessdirectory-listings');
        ?>
    <?php 
    } else {
        ?>
        <?php 
        _ex("No listings found.", 'templates', "WPBDM");
        ?>
        <br />
        <?php 
        echo sprintf('<a href="%s">%s</a>.', wpbdp_get_page_link('main'), _x('Return to directory', 'templates', 'WPBDM'));
        ?>
    
    <?php 
    }
    ?>