public function get_request_data($subject)
 {
     $subject_data = array('comment_type' => 'comment', 'comment_author' => $subject['ad_contact_name'], 'comment_author_email' => $subject['ad_contact_email'], 'comment_author_url' => $subject['websiteurl'], 'comment_content' => $subject['ad_details']);
     if (isset($subject['ad_id'])) {
         $subject_data['permalink'] = url_showad(intval($subject['ad_id']));
     }
     return $subject_data;
 }
 /**
  * @since 3.0.2
  */
 public function handle_email_verification_link()
 {
     $ad_id = $this->request->get_query_var('awpcp-ad');
     $hash = $this->request->get_query_var('awpcp-hash');
     $ad = AWPCP_Ad::find_by_id($ad_id);
     if (is_null($ad) || !awpcp_verify_email_verification_hash($ad_id, $hash)) {
         wp_redirect(awpcp_get_main_page_url());
         return;
     }
     $this->verify_ad($ad);
     wp_redirect(esc_url_raw(add_query_arg('verified', true, url_showad($ad->ad_id))));
     return;
 }
 private function clear_ad_cache($ad)
 {
     if (is_null($ad) || $ad->disabled) {
         return;
     }
     $args = array('timeout' => 30, 'body' => array('id' => url_showad($ad->ad_id), 'scrape' => true));
     $response = wp_remote_post('https://graph.facebook.com/', $args);
     if ($this->is_successful_response($response)) {
         do_action('awpcp-listing-facebook-cache-cleared', $ad);
     } else {
         $this->schedule_clear_cache_action($ad);
     }
 }
 private function do_facebook_request($listing, $path, $method)
 {
     $primary_image = $this->media->get_ad_primary_image($listing);
     $primary_image_thumbnail_url = $primary_image ? $primary_image->get_url('primary') : '';
     $params = array('link' => url_showad($listing->ad_id), 'name' => $listing->get_title(), 'picture' => $primary_image_thumbnail_url);
     try {
         $response = $this->facebook_config->api_request($path, $method, $params);
     } catch (Exception $e) {
         $message = __("There was an error trying to contact Facebook servers: %s.", 'AWPCP');
         $message = sprintf($message, $e->getMessage());
         throw new AWPCP_Exception($message);
     }
     if (!$response || !isset($response->id)) {
         $message = __('Facebook API returned the following errors: %s.', 'AWPCP');
         $message = sprintf($message, $this->facebook_config->get_last_error()->message);
         throw new AWPCP_Exception($message);
     }
 }
Beispiel #5
0
 protected function process_contact_form()
 {
     global $nameofsite;
     $ad = $this->get_ad();
     $form = array_merge($this->get_posted_data(), array('ad_id' => $ad->ad_id));
     $errors = array();
     if (!$this->validate_posted_data($form, $errors)) {
         return $this->contact_form($form, $errors);
     }
     $ad_title = $ad->get_title();
     $ad_url = url_showad($ad->ad_id);
     $sender_name = stripslashes($form['awpcp_sender_name']);
     $sender_email = stripslashes($form['awpcp_sender_email']);
     $message = awpcp_strip_html_tags(stripslashes($form['awpcp_contact_message']));
     if (get_awpcp_option('usesenderemailinsteadofadmin')) {
         $sender = awpcp_strip_html_tags($sender_name);
         $from = $sender_email;
     } else {
         $sender = $nameofsite;
         $from = awpcp_admin_sender_email_address();
     }
     /* send email to admin */
     if (get_awpcp_option('notify-admin-about-contact-message')) {
         $subject = __('Notification about a response regarding Ad: %s', 'AWPCP');
         $subject = sprintf($subject, $ad_title);
         ob_start();
         include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-admin.tpl.php';
         $admin_body = ob_get_contents();
         ob_end_clean();
         $admin_email = awpcp_admin_recipient_email_address();
         $result = awpcp_process_mail($from, $admin_email, $subject, $admin_body, $sender, $sender_email);
     }
     $subject = sprintf("%s %s: %s", get_awpcp_option('contactformsubjectline'), _x('regarding', 'reply email', 'AWPCP'), $ad_title);
     ob_start();
     include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-user.tpl.php';
     $body = ob_get_contents();
     ob_end_clean();
     $sendtoemail = get_adposteremail($ad->ad_id);
     $result = awpcp_process_mail($from, $sendtoemail, trim($subject), $body, $sender, $sender_email);
     if ($result) {
         $message = __("Your message has been sent.", "AWPCP");
         return $this->render('content', awpcp_print_message($message));
     } else {
         $this->messages[] = __("There was a problem encountered during the attempt to send your message. Please try again and if the problem persists, please contact the system administrator.", "AWPCP");
         return $this->contact_form($form, $errors);
     }
 }
<?php

// emails are sent in plain text, trailing whitespace are required for proper formatting
echo sprintf(__('Hello %s,', 'AWPCP'), $ad->ad_contact_name);
?>
 

<?php 
$message = __('Your Ad "%s" was recently approved by the admin. You should be able to see the Ad published here: %s.', 'AWPCP');
echo sprintf($message, $ad->get_title(), urldecode(url_showad($ad->ad_id)));
?>
 

<?php 
echo awpcp_get_blog_name();
?>
 
<?php 
echo home_url();
?>
 
 public function get_view_listing_url($listing)
 {
     return url_showad($listing->ad_id);
 }
 public function get_request_data($subject)
 {
     return array('comment_type' => 'comment', 'comment_author' => $subject['awpcp_sender_name'], 'comment_author_email' => $subject['awpcp_sender_email'], 'comment_content' => $subject['awpcp_contact_message'], 'permalink' => url_showad($subject['ad_id']));
 }
_e('Ad Information', 'AWPCP');
?>
 

<?php 
_e("Listing Title", "AWPCP");
?>
: <?php 
echo $ad->get_title();
?>
 
<?php 
_e("Listing URL", "AWPCP");
?>
: <?php 
echo urldecode(url_showad($ad->ad_id));
?>
 
<?php 
_e("Listing ID", "AWPCP");
?>
: <?php 
echo $ad->ad_id;
?>
 
<?php 
_e("Listing Edit Email", "AWPCP");
?>
: <?php 
echo $ad->ad_contact_email;
?>
Beispiel #10
0
/**
 * @since 3.2.1
 */
function awpcp_rel_canonical_url()
{
    global $wp_the_query;
    if (!is_singular()) {
        return false;
    }
    if (!($page_id = $wp_the_query->get_queried_object_id())) {
        return false;
    }
    if ($page_id != awpcp_get_page_id_by_ref('show-ads-page-name')) {
        return false;
    }
    $ad_id = intval(awpcp_request_param('id', ''));
    $ad_id = empty($ad_id) ? intval(get_query_var('id')) : $ad_id;
    if (empty($ad_id)) {
        $url = get_permalink($page_id);
    } else {
        $url = url_showad($ad_id);
    }
    return $url;
}
Beispiel #11
0
 public function get_return_link($ad)
 {
     if (is_admin()) {
         return sprintf('<a href="%1$s">%2$s</a>', $this->get_panel_url(), __('Return to Listings', 'AWPCP'));
     } else {
         return sprintf('<a href="%1$s">%2$s</a>', url_showad($ad->ad_id), __('You can see your Ad here', 'AWPCP'));
     }
 }
Beispiel #12
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;
}
Beispiel #13
0
 protected function render_item_image($item, $instance)
 {
     global $awpcp_imagesurl;
     $show_images = $instance['show-images'] && awpcp_are_images_allowed();
     $image = awpcp_media_api()->get_ad_primary_image($item);
     if (!is_null($image) && $show_images) {
         $image_url = $image->get_url();
     } else {
         if ($instance['show-blank'] && $show_images) {
             $image_url = "{$awpcp_imagesurl}/adhasnoimage.png";
         } else {
             $image_url = '';
         }
     }
     if (empty($image_url)) {
         $html_image = '';
     } else {
         $html_image = sprintf('<a class="awpcp-listings-widget-item-listing-link self" href="%1$s"><img src="%2$s" alt="%3$s" /></a>', url_showad($item->ad_id), $image_url, esc_attr($item->ad_title));
     }
     return apply_filters('awpcp-listings-widget-listing-thumbnail', $html_image, $item);
 }