Exemplo n.º 1
0
 private function sanitize($data)
 {
     if (!isset($data['created']) || !awpcp_is_mysql_date($data['created'])) {
         $data['created'] = awpcp_datetime();
     }
     $data['enabled'] = absint($data['enabled']);
     $data['is_primary'] = absint($data['is_primary']);
     return $data;
 }
Exemplo n.º 2
0
/**
 * If an Ad was passed, calculates Ad End Date from current End Date.
 * If no Ad was passed, calculates Ad End Date as if Ad would have
 * been posted at the current time.
 *
 * TODO: Use the new $ad->calculate_end_date() method.
 */
function awpcp_calculate_ad_end_date($duration, $interval = 'DAY', $ad = null)
{
    $now = awpcp_datetime('timestamp');
    $end_date = is_null($ad) ? $ad->ad_enddate : 0;
    // if the Ad's end date is in the future, use that as starting point
    // for the new end date, else use current date.
    $start_date = $end_date > $now ? $end_date : $now;
    return awpcp_calculate_end_date($duration, $interval, $start_date);
}
 private function days_before_listing_expires($listing)
 {
     $current_time = awpcp_datetime('timestamp');
     $end_date = strtotime($listing->ad_enddate);
     $extended_end_date = awpcp_extend_date_to_end_of_the_day($end_date);
     if ($listing->has_expired()) {
         $time_left = 0;
     } else {
         $time_left = $extended_end_date - $current_time;
     }
     $days_left = $time_left / (24 * 60 * 60);
     if ($days_left == 0 || $days_left >= 1) {
         return floor($days_left);
     } else {
         return __('less than 1', 'AWPCP');
     }
 }
 public function parse_field_posted_data($field, $value)
 {
     $value = stripslashes_deep($value);
     if ($field->field_validation === 'currency') {
         $parsed_value = awpcp_parse_money($value);
     } else {
         if ($field->field_validation == 'url') {
             $parsed_value = awpcp_maybe_add_http_to_url($value);
         } else {
             if ($field->field_input_type == 'date') {
                 $parsed_value = awpcp_datetime('mysql', $value);
             } else {
                 $parsed_value = $value;
             }
         }
     }
     return $parsed_value;
 }
<input id="<?php 
echo esc_attr($html['id']);
?>
" class="inputbox <?php 
echo esc_attr($html['class']);
?>
" type="text" datepicker-placeholder value="<?php 
echo awpcp_datetime('awpcp-date', $value);
?>
">
<input type="hidden" name="<?php 
echo esc_attr($html['name']);
?>
" value="<?php 
echo esc_attr(awpcp_datetime('Y/m/d', $value));
?>
" />
Exemplo n.º 6
0
/**
 * Remove incomplete payment transactions
 */
function awpcp_clean_up_payment_transactions()
{
    $threshold = awpcp_datetime('mysql', current_time('timestamp') - 24 * 60 * 60);
    $transactions = AWPCP_Payment_Transaction::query(array('status' => array(AWPCP_Payment_Transaction::STATUS_NEW, AWPCP_Payment_Transaction::STATUS_OPEN), 'created' => array('<', $threshold)));
    foreach ($transactions as $transaction) {
        $transaction->delete();
    }
}
Exemplo n.º 7
0
 public function renew($end_date = false)
 {
     if ($end_date === false) {
         // if the Ad's end date is in the future, use that as starting point
         // for the new end date, else use current date.
         $end_date = awpcp_datetime('timestamp', $this->ad_enddate);
         $now = awpcp_datetime('timestamp');
         $start_date = $end_date > $now ? $end_date : $now;
         $payment_term = $this->get_payment_term();
         $this->set_end_date($payment_term->calculate_end_date($start_date));
     } else {
         $this->set_end_date($end_date);
     }
     $this->renew_email_sent = false;
     $this->renewed_date = current_time('mysql');
     // if Ad is disabled lets see if we can enable it
     if ($this->disabled && awpcp_should_enable_existing_listing($this)) {
         $this->enable();
     } else {
         if ($this->disabled) {
             $this->clear_disabled_date();
         }
     }
     return true;
 }
Exemplo n.º 8
0
 /**
  * Calculates a date adding this term's duration to the given
  * start date.
  *
  * @param  long $start_date     A timestamp
  * @return string               MySQL date string
  */
 public function calculate_end_date($start_date = null)
 {
     $amount = $this->duration_amount;
     switch ($this->duration_interval) {
         case self::INTERVAL_DAY:
             $interval = 'days';
             $amount = $amount == 0 ? 3650 : $amount;
             break;
         case self::INTERVAL_WEEK:
             $interval = 'weeks';
             $amount = $amount == 0 ? 3520 : $amount;
             break;
         case self::INTERVAL_MONTH:
             $interval = 'months';
             $amount = $amount == 0 ? 31200 : $amount;
             break;
         case self::INTERVAL_YEAR:
             $interval = 'years';
             $amount = $amount == 0 ? 310 : $amount;
             break;
     }
     return awpcp_datetime('mysql', strtotime("+ {$amount} {$interval}", $start_date));
 }
Exemplo n.º 9
0
 public function register_settings($settings)
 {
     $group = $settings->add_group(__('General', 'AWPCP'), 'general-settings', 5);
     // Section: General - Ad Management Panel
     $key = $settings->add_section($group, __('User Ad Management Panel', 'AWPCP'), 'user-panel', 5, array($settings, 'section'));
     $help_text = __('You must have registered users to use this setting. Turning it on will automatically enable "Require Registration" for AWPCP. Make sure you site allows users to register under <wp-settings-link>Settings->General</a>.', 'AWPCP');
     $help_text = str_replace('<wp-settings-link>', sprintf('<a href="%s">', admin_url('options-general.php')), $help_text);
     $settings->add_setting($key, 'enable-user-panel', __('Enable User Ad Management Panel', 'AWPCP'), 'checkbox', 0, $help_text);
     // Section: General - Default
     $key = $settings->add_section($group, __('General Settings', 'AWPCP'), 'default', 9, array($settings, 'section'));
     $settings->add_setting($key, 'activatelanguages', __('Turn on transalation file (POT)', 'AWPCP'), 'checkbox', 0, __("Enable translations. WordPress will look for an AWPCP-&lt;language&gt;.mo file in AWPCP's languages/ directory of the main plugin and premium modules. Example filenames are: AWPCP-en_EN.mo, AWPCP-es_ES.mo. You can generate .mo files using POEdit and the AWPCP.pot or AWPCP-en_EN.po files included with the plugin.", 'AWPCP'));
     $settings->add_setting($key, 'main_page_display', __('Show Ad listings on main page', 'AWPCP'), 'checkbox', 0, __('If unchecked only categories will be displayed', 'AWPCP'));
     $settings->add_setting($key, 'view-categories-columns', __('Category columns in View Categories page', 'AWPCP'), 'select', 2, '', array('options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5)));
     $settings->add_setting($key, 'collapse-categories-columns', __('Collapse Categories', 'AWPCP'), 'checkbox', 0, __('If checked the list of sub-categories will be collapsed by default. Users would have to click the down arrow icon to expand the list and see the sub-categories.', 'AWPCP'));
     $settings->add_setting($key, 'uiwelcome', __('Welcome message in Classified page', 'AWPCP'), 'textarea', __('Looking for a job? Trying to find a date? Looking for an apartment? Browse our classifieds. Have a job to advertise? An apartment to rent? Post a Classified Ad.', 'AWPCP'), __('The welcome text for your classified page on the user side', 'AWPCP'));
     $options = array('admin' => __('Administrator', 'AWPCP'), 'admin,editor' => __('Administrator & Editor', 'AWPCP'));
     $settings->add_setting($key, 'awpcpadminaccesslevel', __('Who can access AWPCP Admin Dashboard', 'AWPCP'), 'radio', 'admin', __('Role of WordPress users who can have admin access to Classifieds.', 'AWPCP'), array('options' => $options));
     $settings->add_setting($key, 'awpcppagefilterswitch', __('Enable page filter', 'AWPCP'), 'checkbox', 1, __('Uncheck this if you need to turn off the AWPCP page filter that prevents AWPCP classifieds children pages from showing up in your wp pages menu (You might need to do this if for example the AWPCP page filter is messing up your page menu. It means you will have to manually exclude the AWPCP children pages from showing in your page list. Some of the pages really should not be visible to your users by default).', 'AWPCP'));
     // Section: General - Date & Time Format
     $label = _x('Date & Time Format', 'settings', 'AWPCP');
     $key = $settings->add_section($group, $label, 'date-time-format', 10, array($settings, 'section_date_time_format'));
     $datetime = current_time('timestamp');
     $options = array('american' => sprintf('<strong>%s</strong>: %s', __('American', 'AWPCP'), awpcp_datetime('m/d/Y h:i:s', $datetime)), 'european' => sprintf('<strong>%s</strong>: %s', __('European', 'AWPCP'), awpcp_datetime('d/m/Y H:i:s', $datetime)), 'custom' => __('Your own.', 'AWPCP'));
     $settings->add_setting($key, 'x-date-time-format', __('Date Time Format', 'AWPCP'), 'radio', 'american', '', array('options' => $options));
     $settings->add_setting($key, 'date-format', _x('Date Format', 'settings', 'AWPCP'), 'textfield', 'm/d/Y', '');
     $settings->add_setting($key, 'time-format', _x('Time Format', 'settings', 'AWPCP'), 'textfield', 'h:i:s', '');
     $example = sprintf('<strong>%s</strong>: <span example>%s</span>', _x('Example output', 'settings', 'AWPCP'), awpcp_datetime('awpcp'));
     $description = _x('Full date/time output with any strings you wish to add. <date> and <time> are placeholders for date and time strings using the formats specified in the Date Format and Time Format settings above.', 'settings', 'AWPCP');
     $settings->add_setting($key, 'date-time-format', _x('Full Display String', 'settings', 'AWPCP'), 'textfield', '<date> at <time>', esc_html($description) . '<br/>' . $example);
     // Section: General - Currency Format
     $key = $settings->add_section($group, __('Currency Format', 'AWPCP'), 'currency-format', 10, array($settings, 'section'));
     $settings->add_setting($key, 'currency-code', __('Currency code', 'AWPCP'), 'textfield', $settings->get_option('displaycurrencycode', 'USD'), __("Prices in listings pages and payment pages will be displayed using this currency. The currency symbol will be generated based on this code, but if the plugin doesn't know the symbol for your currency, it will use an uppercase version of the code itself.", 'AWPCP'));
     $settings->add_setting($key, 'currency-symbol', __('Currency symbol', 'AWPCP'), 'textfield', '', __("Use this setting to overwrite the currency symbol shown in listings pages. If empty, the plugin will attempt to show one of the standard symbols for the selected currency code, but if the plugin doesn't know the symbol for your currency, it will use an uppercase version of the currency code.", 'AWPCP'));
     $settings->add_setting($key, 'thousands-separator', __('Thousands separator', 'AWPCP'), 'textfield', _x(',', 'This translation is deprecated. Please go to the Settings section to change the thousands separator.', 'AWPCP'), '');
     $settings->add_setting($key, 'decimal-separator', __('Separator for the decimal point', 'AWPCP'), 'textfield', _x('.', 'This translation is deprecated. Please go to the Settings section to change the decimal separator.', 'AWPCP'), '');
     $settings->add_setting($key, 'show-decimals', __('Show decimals in price', 'AWPCP'), 'checkbox', 1, _x('Uncheck to show prices without decimals. The value will be rounded.', 'settings', 'AWPCP'));
     $settings->add_setting($key, 'show-currency-symbol', __('Show currency symbol', 'AWPCP'), 'radio', 'show-currency-symbol-on-left', __('The currency symbol can be configured by changing the currency code in the settings above.', 'AWPCP'), array('options' => array('show-currency-symbol-on-left' => __('Show currency symbol on left', 'AWPCP'), 'show-currency-symbol-on-right' => __('Show currency symbol on right', 'AWPCP'), 'do-not-show-currency-symbol' => __("Don't show currency symbol", 'AWPCP'))));
     $settings->add_setting($key, 'include-space-between-currency-symbol-and-amount', __('Include a space between the currency symbol and the amount', 'AWPCP'), 'checkbox', 1, '');
     // Section: General - Terms of Service
     $key = $settings->add_section($group, __('Terms of Service', 'AWPCP'), 'terms-of-service', 11, array($settings, 'section'));
     $settings->add_setting($key, 'requiredtos', __('Display and require Terms of Service', 'AWPCP'), 'checkbox', 1, __('Display and require Terms of Service', 'AWPCP'));
     $settings->add_setting($key, 'tos', __('Terms of Service', 'AWPCP'), 'textarea', __('Terms of service go here...', 'AWPCP'), __('Terms of Service for posting Ads. Put in text or an URL starting with http. If you use an URL, the text box will be replaced by a link to the appropriate Terms of Service page', 'AWPCP'));
     // Section: General - Anti-SPAM
     $key = $settings->add_section($group, __('Anti-SPAM', 'AWPCP'), 'anti-spam', 10, array($settings, 'section'));
     $options = array('recaptcha' => __('reCAPTCHA (recommended)', 'AWPCP'), 'math' => __('Math', 'AWPCP'));
     if (!$settings->option_exists('useakismet')) {
         $is_akismet_installed = function_exists('akismet_init');
         $is_akismet_key_set = strlen(get_option('wordpress_api_key')) > 0;
         $use_akismet_default_value = $is_akismet_installed && $is_akismet_key_set;
     } else {
         $use_akismet_default_value = $settings->get_option('useakismet');
     }
     $settings->add_setting($key, 'useakismet', __('Use Akismet', 'AWPCP'), 'checkbox', $use_akismet_default_value, __('Use Akismet for Posting Ads/Contact Responses (strong anti-spam).', 'AWPCP'));
     $settings->add_setting($key, 'captcha-enabled', __('Enable CAPTCHA', 'AWPCP'), 'checkbox', $settings->get_option('contactformcheckhuman', 1), __('A CAPTCHA is a program to ensure only humans are posting Ads to your website. Using a CAPTCHA will reduce the SPAM and prevent bots from posting on your website. If checked, an additional form field will be added to the Place Ad and Reply to Ad forms.', 'AWPCP'));
     $settings->add_setting($key, 'captcha-provider', __('Type of CAPTCHA', 'AWPCP'), 'select', 'math', __('reCAPTCHA: Uses distorted images that only humans should be able to read (recommended).', 'AWPCP') . '<br/>' . __('Math: Asks user to solve a simple arithmetic operation.', 'AWPCP'), array('options' => $options));
     $settings->add_setting($key, 'math-captcha-max-number', __('Max number used in Math CAPTCHA', 'AWPCP'), 'textfield', $settings->get_option('contactformcheckhumanhighnumval', 10), __('Highest number used in aithmetic operation.', 'AWPCP'));
     $link = sprintf('<a href="%1$s">%1$s</a>', 'https://www.google.com/recaptcha/admin');
     $help_text = sprintf(__('You can get an API key from %s.', 'AWPCP'), $link);
     $settings->add_setting($key, 'recaptcha-public-key', __('reCAPTCHA Site Key', 'AWPCP'), 'textfield', '', $help_text);
     $settings->add_setting($key, 'recaptcha-private-key', __('reCAPTCHA Secret Key', 'AWPCP'), 'textfield', '', $help_text);
     // Section: SEO Settings
     $key = $settings->add_section($group, __('SEO Settings', 'AWPCP'), 'seo-settings', 10, array($settings, 'section'));
     $settings->add_setting($key, 'seofriendlyurls', __('Turn on Search Engine Friendly URLs', 'AWPCP'), 'checkbox', 0, __('Turn on Search Engine Friendly URLs? (SEO Mode)', 'AWPCP'));
 }
Exemplo n.º 10
0
 /**
  * ------------------------------------------------------------------------
  * Migrate Media Information
  */
 public function ajax_migrate_media_information()
 {
     global $wpdb;
     $mime_types = awpcp_mime_types();
     if (!awpcp_table_exists(AWPCP_TABLE_ADPHOTOS)) {
         return $this->ajax_response(0, 0);
     }
     $cursor = get_option('awpcp-migrate-media-information-cursor', 0);
     $total = $this->count_pending_images($cursor);
     $sql = 'SELECT * FROM ' . AWPCP_TABLE_ADPHOTOS . ' ';
     $sql .= 'WHERE ad_id > %d ORDER BY key_id LIMIT 0, 100';
     $results = $wpdb->get_results($wpdb->prepare($sql, $cursor));
     $uploads = awpcp_setup_uploads_dir();
     $uploads = array_shift($uploads);
     foreach ($results as $image) {
         $cursor = $image->ad_id;
         $filename = awpcp_get_image_url($image->image_name);
         if (empty($filename)) {
             continue;
         }
         $path = str_replace(AWPCPUPLOADURL, $uploads, $filename);
         $mime_type = $mime_types->get_file_mime_type($path);
         $entry = array('ad_id' => $image->ad_id, 'path' => $image->image_name, 'name' => $image->image_name, 'mime_type' => strtolower($mime_type), 'enabled' => !$image->disabled, 'is_primary' => $image->is_primary, 'created' => awpcp_datetime());
         $wpdb->insert(AWPCP_TABLE_MEDIA, $entry);
     }
     update_option('awpcp-migrate-media-information-cursor', $cursor);
     $remaining = $this->count_pending_images($cursor);
     if (0 === $remaining) {
         // TODO: do this in the next version upgrade
         // $wpdb->query( 'DROP TABLE ' . AWPCP_TABLE_ADPHOTOS );
         delete_option('awpcp-migrate-media-information');
         $this->update_pending_upgrades_status();
     }
     return $this->ajax_response($total, $remaining);
 }
Exemplo n.º 11
0
 /**
  * @since 3.0.2
  */
 public function send_verification_email($ad)
 {
     $mail = new AWPCP_Email();
     $mail->to[] = awpcp_format_email_address($ad->ad_contact_email, $ad->ad_contact_name);
     $mail->subject = sprintf(__('Verify the email address used for Ad "%s"', 'AWPCP'), $ad->get_title());
     $verification_link = awpcp_get_email_verification_url($ad->ad_id);
     $template = AWPCP_DIR . '/frontend/templates/email-ad-awaiting-verification.tpl.php';
     $mail->prepare($template, array('contact_name' => $ad->ad_contact_name, 'ad_title' => $ad->get_title(), 'verification_link' => $verification_link));
     if ($mail->send()) {
         $emails_sent = intval(awpcp_get_ad_meta($ad->ad_id, 'verification_emails_sent', true));
         awpcp_update_ad_meta($ad->ad_id, 'verification_email_sent_at', awpcp_datetime());
         awpcp_update_ad_meta($ad->ad_id, 'verification_emails_sent', $emails_sent + 1);
     }
 }
Exemplo n.º 12
0
function awpcp_set_datetime_date($datetime, $date)
{
    $base_timestamp = strtotime($datetime);
    $base_year_month_day_timestamp = strtotime(date('Y-m-d', strtotime($datetime)));
    $time_of_the_day_in_seconds = $base_timestamp - $base_year_month_day_timestamp;
    $target_year_month_day_timestamp = strtotime(date('Y-m-d', strtotime($date)));
    $new_datetime_timestamp = $target_year_month_day_timestamp + $time_of_the_day_in_seconds;
    return awpcp_datetime('mysql', $new_datetime_timestamp);
}
Exemplo n.º 13
0
 public function delay($seconds)
 {
     $this->set_metadata('delay_time', $seconds);
     $this->task->status = self::TASK_STATUS_DELAYED;
     $this->task->execute_after = awpcp_datetime('mysql', current_time('timestamp') + $seconds);
 }
Exemplo n.º 14
0
 public function get_listing_metadata()
 {
     $metadata = array('http://ogp.me/ns#type' => 'article', 'http://ogp.me/ns#url' => $this->properties['url'], 'http://ogp.me/ns#title' => $this->properties['title'], 'http://ogp.me/ns#description' => htmlspecialchars($this->properties['description'], ENT_QUOTES, get_bloginfo('charset')), 'http://ogp.me/ns/article#published_time' => awpcp_datetime('c', $this->properties['published-time']), 'http://ogp.me/ns/article#modified_time' => awpcp_datetime('c', $this->properties['modified-time']));
     foreach ($this->properties['images'] as $k => $image) {
         $metadata['http://ogp.me/ns#image'] = $image;
         break;
     }
     if (empty($this->properties['images'])) {
         $metadata['http://ogp.me/ns#image'] = AWPCP_URL . '/resources/images/adhasnoimage.png';
     }
     return $metadata;
 }
?>
" />
    </span>
    <span>
        <label for="<?php 
echo esc_attr($html['base-id']);
?>
-to"><?php 
echo esc_html(__('To', 'awpcp-extra-fields'));
?>
</label>
        <input id="<?php 
echo esc_attr($html['base-id']);
?>
-to" class="inputbox <?php 
echo esc_attr($html['class']);
?>
" type="text" datepicker-placeholder value="<?php 
echo esc_attr($to_date ? awpcp_datetime('awpcp-date', $to_date) : '');
?>
">
        <input type="hidden" name="<?php 
echo esc_attr($html['name']);
?>
-to" value="<?php 
echo esc_attr($to_date ? awpcp_datetime('Y/m/d', $to_date) : '');
?>
" />
    </span>
</span>
Exemplo n.º 16
0
 public function save_details_step($transaction, $errors = array())
 {
     global $wpdb, $hasextrafieldsmodule;
     $data = $this->get_posted_details($_POST, $transaction);
     $characters = $this->get_characters_allowed($data['ad_id'], $transaction);
     $errors = array();
     $payment_term = awpcp_payments_api()->get_transaction_payment_term($transaction);
     if (!$this->validate_details($data, false, $payment_term, $errors)) {
         return $this->details_step_form($transaction, $data, $errors);
     }
     $now = current_time('mysql');
     if ($transaction->get('ad-id')) {
         $ad = AWPCP_Ad::find_by_id($transaction->get('ad-id'));
     } else {
         $ad = new AWPCP_Ad();
         $totals = $transaction->get_totals();
         $ad->adterm_id = $transaction->get('payment-term-id');
         $ad->payment_term_type = $transaction->get('payment-term-type');
         $ad->ad_transaction_id = $transaction->id;
         $ad->ad_fee_paid = $totals['money'];
         $ad->ad_key = AWPCP_Ad::generate_key();
         $timestamp = awpcp_datetime('timestamp', $now);
         $payment_term = $ad->get_payment_term();
         $ad->set_start_date($now);
         $ad->set_end_date($payment_term->calculate_end_date($timestamp));
         $ad->ad_postdate = $now;
         $ad->disabled = true;
         $ad->payment_status = 'Unpaid';
     }
     if (!$transaction->get('ad-id') || $this->verify_preview_hash($ad)) {
         $ad->user_id = $data['user_id'];
         $ad->ad_category_id = $data['ad_category'];
         $ad->ad_category_parent_id = get_cat_parent_ID($data['ad_category']);
         $ad->ad_title = $this->prepare_ad_title($data['ad_title'], $characters['characters_allowed_in_title']);
         $ad->ad_details = $this->prepare_ad_details($data['ad_details'], $characters['characters_allowed']);
         $ad->ad_contact_name = $data['ad_contact_name'];
         $ad->ad_contact_phone = $data['ad_contact_phone'];
         $ad->ad_contact_email = $data['ad_contact_email'];
         $ad->websiteurl = $data['websiteurl'];
         $ad->ad_item_price = $data['ad_item_price'] * 100;
         $ad->is_featured_ad = $data['is_featured_ad'];
         $ad->ad_last_updated = $now;
         $ad->posterip = awpcp_getip();
         if (!$ad->save()) {
             $errors[] = __('There was an unexpected error trying to save your Ad details. Please try again or contact an administrator.', 'AWPCP');
             return $this->details_step_form($transaction, $data, $errors);
         }
         $regions_allowed = $this->get_regions_allowed($ad->ad_id, $transaction);
         awpcp_basic_regions_api()->update_ad_regions($ad, $data['regions'], $regions_allowed);
         $transaction->set('ad-id', $ad->ad_id);
         do_action('awpcp-save-ad-details', $ad, $transaction);
         $transaction->save();
     }
     if (awpcp_post_param('preview-hash', false)) {
         return $this->preview_step();
     } else {
         if ($this->should_show_upload_files_step($ad)) {
             return $this->upload_images_step();
         } else {
             if ((bool) get_awpcp_option('pay-before-place-ad')) {
                 return $this->finish_step();
             } else {
                 if ((bool) get_awpcp_option('show-ad-preview-before-payment')) {
                     return $this->preview_step();
                 } else {
                     return $this->checkout_step();
                 }
             }
         }
     }
 }
Exemplo n.º 17
0
/**
 * @since 3.0
 */
function awpcp_do_placeholder_legacy_dates($ad, $placeholder)
{
    $replacements['ad_startdate'] = awpcp_datetime('awpcp-date', $ad->ad_startdate);
    $replacements['ad_postdate'] = awpcp_datetime('awpcp-date', $ad->ad_postdate);
    $replacements['awpcpadpostdate'] = sprintf('%s<br/>', $replacements['ad_postdate']);
    return $replacements[$placeholder];
}
        <p class="awpcp-form-spacer">
            <label for="end-date"><?php 
    echo esc_html(_x('End Date', 'ad details form', 'AWPCP'));
    echo $required['end-date'] ? '*' : '';
    ?>
</label>
            <?php 
    $date = awpcp_datetime('awpcp-date', $form['end_date']);
    ?>
            <input class="inputbox" id="end-date" type="text" size="50" datepicker-placeholder value="<?php 
    echo awpcp_esc_attr($date);
    ?>
" />
            <input type="hidden" name="end_date" value="<?php 
    echo esc_attr(awpcp_datetime('Y/m/d', $form['end_date']));
    ?>
" />
            <?php 
    echo awpcp_form_error('end_date', $errors);
    ?>
        </p>

        <?php 
}
?>

        <h3><?php 
echo esc_html(__('Add Details and Contact Information', 'AWPCP'));
?>
</h3>
Exemplo n.º 19
0
function awpcp_get_ad_share_info($id)
{
    global $wpdb;
    $ad = AWPCP_Ad::find_by_id($id);
    $info = array();
    if (is_null($ad)) {
        return null;
    }
    $info['url'] = url_showad($id);
    $info['title'] = stripslashes($ad->ad_title);
    $info['description'] = strip_tags(stripslashes($ad->ad_details));
    $info['description'] = str_replace("\n", " ", $info['description']);
    if (awpcp_utf8_strlen($info['description']) > 300) {
        $info['description'] = awpcp_utf8_substr($info['description'], 0, 300) . '...';
    }
    $info['images'] = array();
    $info['published-time'] = awpcp_datetime('Y-m-d', $ad->ad_postdate);
    $info['modified-time'] = awpcp_datetime('Y-m-d', $ad->ad_last_updated);
    $images = awpcp_media_api()->find_by_ad_id($ad->ad_id, array('enabled' => true));
    foreach ($images as $image) {
        $info['images'][] = $image->get_url('large');
    }
    return $info;
}