/** * Renders Bank Transfer Payment Form * * If user will select Bank Transfer as a payment method, this function will render * payment instructions. * * It is executed in third step in [adverts_add] shortcode. * * @param array $data Payment data * @return array */ function adext_bank_transfer_render($data) { $price = $data["price"]; $payment_id = $data["payment_id"]; $atts = array("class" => "adverts-success"); $repl = array("{total}" => adverts_price($price), "{order_number}" => str_pad($payment_id, 6, "0", STR_PAD_LEFT)); $html = str_replace(array_keys($repl), array_values($repl), adverts_config("bank_transfer.custom_text")); $html = apply_filters("adext_bank_transfer_custom_text", $html, $data); return array("result" => 1, "html" => Adverts_Html::build("div", $atts, wpautop($html)), "execute" => null, "execute_id" => ""); }
/** * Customize the email before it will be sent. * * The $mail variable is an array of data that will be used in wp_mail function like this: * wp_mail($mail["to"], $mail["subject"], $mail["message"], $mail["headers"] ); * * This function will do a couple of operations on the data to customize the email * feel free to use only the ones you like. * * @param array $mail Data that will be passed to wp_mail() function. The array has following keys: to, subject, message, headers. * @param int $post_id ID of an Advert * @param Adverts_Form $form Form that was submitted along with its data * @return array Updated $mail data */ function contact_form_email($mail, $post_id, $form) { // get the post $post = get_post($post_id); // Include Advert title in the subject $mail["subject"] = $post->post_title . " - " . $mail["subject"]; // Send all the emails to Administrator $mail["to"] = get_option("admin_email"); // Send a BBC copy of the email to Administrator $mail["headers"][] = "BBC: " . get_option("admin_email"); // Include Advert price and location at the end of message $mail["message"] .= "\r\n---\r\n"; $mail["message"] .= adverts_price(get_post_meta($post_id, "adverts_price", true)) . "\r\n"; $mail["message"] .= get_post_meta($post_id, "adverts_location", true) . "\r\n"; // Allways make sure to return $mail return $mail; }
<?php $listing = get_post($listing_id); ?> <?php if ($listing) { ?> <span> <a href="<?php echo admin_url('edit.php?post_type=advert&page=adverts-extensions&module=payments&adaction=list&edit=' . $listing->ID); ?> "><?php esc_html_e($listing->post_title); ?> </a> <?php echo adverts_price(get_post_meta($listing->ID, "adverts_price", true)); ?> </span> <?php } else { ?> <?php esc_html_e(sprintf(__("Listing [%d] no longer exists.", "adverts"), $listing_id)); ?> <?php } ?> </div> <div class="column" style="width:33%; float: left"> <strong><?php
?> " title="<?php esc_attr_e(get_the_title()); ?> " class="advert-link-wrap"></a> </div> <div class="advert-published "> <span class="advert-date"><?php echo date_i18n(get_option('date_format'), get_post_time('U', false, get_the_ID())); ?> </span> <?php $price = get_post_meta(get_the_ID(), "adverts_price", true); ?> <?php if ($price) { ?> <div class="advert-price"><?php esc_html_e(adverts_price(get_post_meta(get_the_ID(), "adverts_price", true))); ?> </div> <?php } ?> </div> </div>
esc_html_e($item->post_title); ?> </td> <td class=""> <?php esc_html_e(get_post_meta($item->ID, 'adverts_email', true)); ?> </td> <td> <?php echo date_i18n(get_option('date_format'), get_post_time('U', false, $item->ID)); ?> </td> <td class=""> <?php echo adverts_price(get_post_meta($item->ID, '_adverts_payment_total', true)); ?> </td> <td> <?php $post_status = get_post_status_object($item->post_status); ?> <?php esc_html_e($post_status->label); ?> </td> <?php do_action('adext_payment_list_tbody', $item); ?> </tr>
<?php printf(__("by <strong>%s</strong>", "adverts"), get_post_meta($post_id, 'adverts_person', true)); ?> <br/> <?php printf(__('Published: %1$s (%2$s ago)', "adverts"), date_i18n(get_option('date_format'), get_post_time('U', false, $post_id)), human_time_diff(get_post_time('U', false, $post_id), current_time('timestamp'))); ?> </div> </div> <?php if (get_post_meta($post_id, "adverts_price", true)) { ?> <div class="adverts-single-price" style=""> <span class="adverts-price-box"><?php echo adverts_price(get_post_meta($post_id, "adverts_price", true)); ?> </span> </div> <?php } ?> </div> <div class="adverts-grid adverts-grid-closed-top adverts-grid-with-icons adverts-single-grid-details"> <?php $advert_category = get_the_terms($post_id, 'advert_category'); ?> <?php if (!empty($advert_category)) { ?>
/** * Insert custom columns on Adverts list in wp-admin / Classifieds panel. * * @see manage_advert_posts_custom_column action * * @global WP_Post $post * @global type $mode * @param string $column * @param int $post_id */ function adverts_manage_post_columns($column, $post_id) { global $post, $mode; switch ($column) { case 'expires': // Insert expires column $expires = get_post_meta($post_id, '_expiration_date', true); // If expiry date not in DB, then ad never expires if (!$expires) { echo __('Never', 'adverts'); break; } $t_time = date_i18n(__('Y/m/d g:i:s A'), $expires); /* @var string $t_time Post creation date */ $m_time = date_i18n('Y-m-d H:i:s', $expires); /* @var string $m_time Post expiration date */ $time = $expires; /* @var string $time Post expiration timestamp */ $time_diff = current_time('timestamp') - $time; $h_time = mysql2date(__('Y/m/d'), $m_time); if ($time_diff < 0) { $h_text = __('in %s', 'adverts'); } else { $h_text = __('%s ago'); } echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column, $mode) . '</abbr>'; echo '<br />'; echo sprintf($h_text, human_time_diff($time, current_time('timestamp'))); break; case 'price': /* Get the post meta. */ $price = get_post_meta($post_id, 'adverts_price', true); /* If empty then price is not set. */ if (empty($price)) { echo __('None', 'adverts'); } else { echo adverts_price($price); } break; /* Just break out of the switch statement for everything else. */ /* Just break out of the switch statement for everything else. */ default: break; } }
_e("Delete"); ?> </a> | </span> </div> </td> <td class=""> <?php $price = get_post_meta($item->ID, 'adverts_price', true); ?> <?php if ($price) { ?> <?php echo adverts_price($price); ?> <?php } else { ?> <?php _e("Free", "adverts"); ?> <?php } ?> </td> <td class=""> <?php $visible = get_post_meta($item->ID, 'adverts_visible', true); ?>
/** * Adds Listing Type field to Add Advert form. * * This function is applied to "adverts_form_load" filter in Adverts_Form::load() * when Advert form is being loaded. * * @since 1.0 * @see Adverts_Form::load() * * @param array $form * @return array */ function adext_payments_form_load($form) { if ($form["name"] != 'advert' || is_admin()) { return $form; } // do not show payment options when editing Ad. $id = adverts_request("advert_id"); $ad = get_post($id); if (intval($id) && $ad && in_array($ad->post_status, array("publish", "expired"))) { return $form; } $form["field"][] = array("name" => "_listing_information", "type" => "adverts_field_header", "order" => 50, "label" => __('Listing Information', 'adverts')); $opts = array(); $pricings = new WP_Query(array('post_type' => 'adverts-pricing', 'post_status' => 'draft')); foreach ($pricings->posts as $data) { if ($data->post_content) { $post_content = '<br/><small style="padding-left:25px">' . $data->post_content . '</small>'; } else { $post_content = ''; } if (get_post_meta($data->ID, 'adverts_price', true)) { $adverts_price = adverts_price(get_post_meta($data->ID, 'adverts_price', true)); } else { $adverts_price = __("Free", "adverts"); } $text = sprintf(__('<b>%1$s</b> - %2$s for %3$d days.%4$s', 'adverts'), $data->post_title, $adverts_price, get_post_meta($data->ID, 'adverts_visible', true), $post_content); $opts[] = array("value" => $data->ID, "text" => $text); } $form["field"][] = array("name" => "payments_listing_type", "type" => "adverts_field_radio", "label" => __("Listing", "adverts"), "order" => 50, "empty_option" => true, "options" => $opts, "value" => ""); add_filter("adverts_form_bind", "adext_payments_form_bind"); return $form; }