/** * @since 3.0.2 */ function awpcp_listings_api() { if (!isset($GLOBALS['awpcp-listings-api'])) { $GLOBALS['awpcp-listings-api'] = new AWPCP_ListingsAPI(awpcp_listings_metadata(), awpcp_request(), awpcp()->settings); } return $GLOBALS['awpcp-listings-api']; }
public function get_akismet_wrapper() { if ($this->is_akismet_available()) { return new AWPCP_AkismetWrapper(awpcp_request()); } else { return new AWPCP_AkismetWrapperBase(); } }
public function __construct($categories = null, $listings = null, $walker = null, $request = null) { parent::__construct(AWPCP_CAS_LISTINGS_CATEGORIES_MODULE, __('Categories (AWPCP)', 'AWPCP')); if (is_null($categories)) { $this->categories = awpcp_categories_collection(); } else { $this->categories = $categories; } if (is_null($listings)) { $this->listings = awpcp_listings_collection(); } else { $this->listings = $listings; } if (is_null($walker)) { $this->walker = awpcp_content_aware_sidebars_categories_walker($this->id); } else { $this->walker = $walker; } if (is_null($request)) { $this->request = awpcp_request(); } else { $this->request = $request; } }
/** * @since 3.4 */ function awpcp_pointers_manager() { return new AWPCP_PointersManager(awpcp()->js, awpcp()->settings, awpcp_request()); }
private function listing_action($callback) { $listing_id = awpcp_request()->get_ad_id(); if (empty($listing_id)) { awpcp_flash(__('No Ad ID was specified.', 'AWPCP'), 'error'); return $this->redirect('index'); } try { $listing = awpcp_listings_collection()->get($listing_id); } catch (AWPCP_Exception $e) { awpcp_flash(__("The specified Ad doesn't exists.", 'AWPCP'), 'error'); return $this->redirect('index'); } return call_user_func(array($this, $callback), $listing); }
function awpcp_drip_autoresponder() { return new AWPCP_DripAutoresponder(awpcp()->settings, awpcp_request()); }
function awpcp_roles_and_capabilities() { return new AWPCP_RolesAndCapabilities(awpcp()->settings, awpcp_request()); }
function awpcp_renew_listings_admin_page() { return new AWPCP_RenewListingsAdminPage(awpcp_listings_collection(), awpcp_payments_api(), awpcp_request()); }
function awpcp_file_uploader() { return new AWPCP_FileUploader(awpcp_file_types(), awpcp_mime_types(), awpcp_request(), awpcp()->settings); }
function awpcp_meta() { return new AWPCP_Meta(awpcp_page_title_builder(), awpcp_meta_tags_generator(), awpcp_request()); }
function awpcp_drip_autoresponder_ajax_handler() { return new AWPCP_DripAutoresponderAjaxHandler(awpcp()->settings, awpcp_request(), awpcp_ajax_response()); }
function awpcp_update_license_status_request_handler() { return new AWPCP_UpdateLicenseStatusRequestHandler(awpcp_licenses_manager(), awpcp_modules_manager(), awpcp_request()); }
function awpcp_page_name_monitor() { return new AWPCP_PageNameMonitor(awpcp_request(), $GLOBALS['wpdb']); }
function awpcp_save_extra_field_data_step() { global $wpdb; return new AWPCP_SaveExtraFieldDataStep(awpcp_request(), $wpdb); }
function awpcp_user_profile_contact_information_controller() { return new AWPCP_UserProfileContactInformationController(awpcp_request()); }
function awpcp_listing_authorization() { return new AWPCP_ListingAuthorization(awpcp_roles_and_capabilities(), awpcp_request()); }
function awpcp_users_dropdown() { return new AWPCP_UsersDropdown(awpcp_users_collection(), awpcp_request()); }
/** * Bulds WordPress ajax URL using the same domain used in the current request. * * @since 2.0.6 */ function awpcp_ajaxurl($overwrite = false) { static $ajaxurl = false; if ($overwrite || $ajaxurl === false) { $url = admin_url('admin-ajax.php'); $parts = parse_url($url); $ajaxurl = str_replace($parts['host'], awpcp_request()->domain(), $url); } return $ajaxurl; }
function awpcp_extra_form_field($slug) { $extra_field = awpcp_get_extra_field_by_slug(preg_replace('/^awpcp-/', '', $slug)); return new AWPCP_ExtraFormField($slug, $extra_field, awpcp_request()); }
/** * Handles AWPCPSHOWAD shortcode. * * @param $adid An Ad ID. * @param $omitmenu * @param $preview true if the function is used to show an ad just after * it was posted to the website. * @param $send_email if true and $preview=true, a success email will be send * to the admin and poster user. * * @return Show Ad page content. */ function showad($adid = null, $omitmenu = false, $preview = false, $send_email = true, $show_messages = true) { global $wpdb; awpcp_maybe_add_thickbox(); wp_enqueue_script('awpcp-page-show-ad'); $awpcp = awpcp(); $awpcp->js->set('page-show-ad-flag-ad-nonce', wp_create_nonce('flag_ad')); $awpcp->js->localize('page-show-ad', array('flag-confirmation-message' => __('Are you sure you want to flag this ad?', 'AWPCP'), 'flag-success-message' => __('This Ad has been flagged.', 'AWPCP'), 'flag-error-message' => __('An error occurred while trying to flag the Ad.', 'AWPCP'))); $preview = $preview === true || 'preview' == awpcp_array_data('adstatus', '', $_GET); $is_moderator = awpcp_current_user_is_moderator(); $messages = array(); $permastruc = get_option('permalink_structure'); if (!isset($adid) || empty($adid)) { if (isset($_REQUEST['adid']) && !empty($_REQUEST['adid'])) { $adid = $_REQUEST['adid']; } elseif (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $adid = $_REQUEST['id']; } else { if (isset($permastruc) && !empty($permastruc)) { $adid = get_query_var('id'); } else { $adid = 0; } } } $adid = absint($adid); if (!empty($adid)) { // filters to provide alternative method of storing custom // layouts (e.g. can be outside of this plugin's directory) $prefix = 'awpcp_single_ad_template'; if (has_action("{$prefix}_action") || has_filter("{$prefix}_filter")) { do_action("{$prefix}_action"); return apply_filters("{$prefix}_filter"); } else { $results = AWPCP_Ad::query(array('where' => $wpdb->prepare('ad_id = %d', $adid))); if (count($results) === 1) { $ad = array_shift($results); } else { $ad = null; } if (is_null($ad)) { $message = __('Sorry, that listing is not available. Please try browsing or searching existing listings.', 'AWPCP'); return '<div id="classiwrapper">' . awpcp_print_error($message) . '</div><!--close classiwrapper-->'; } if ($ad->user_id > 0 && $ad->user_id == wp_get_current_user()->ID) { $is_ad_owner = true; } else { $is_ad_owner = false; } $content_before_page = apply_filters('awpcp-content-before-listing-page', ''); $content_after_page = apply_filters('awpcp-content-after-listing-page', ''); $output = '<div id="classiwrapper">%s%s<!--awpcp-single-ad-layout-->%s</div><!--close classiwrapper-->'; $output = sprintf($output, $content_before_page, $omitmenu ? '' : awpcp_menu_items(), $content_after_page); if (!$is_moderator && !$is_ad_owner && !$preview && $ad->disabled == 1) { $message = __('The Ad you are trying to view is pending approval. Once the Administrator approves it, it will be active and visible.', 'AWPCP'); return str_replace('<!--awpcp-single-ad-layout-->', awpcp_print_error($message), $output); } if (awpcp_request_param('verified') && $ad->verified) { $messages[] = awpcp_print_message(__('Your email address was successfully verified.', 'AWPCP')); } if ($show_messages && $is_moderator && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the Administrator) and the author can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && !$ad->verified) { $message = __('This Ad is currently disabled until you verify the email address used for the contact information. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } } } $layout = awpcp_get_listing_single_view_layout($ad); $layout = awpcp_do_placeholders($ad, $layout, 'single'); $output = str_replace('<!--awpcp-single-ad-layout-->', join('', $messages) . $layout, $output); $output = apply_filters('awpcp-show-ad', $output, $adid); if (!awpcp_request()->is_bot()) { $ad->visit(); } $ad->save(); } } else { $query = array('limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby')); $output = awpcp_display_listings_in_page($query, 'show-listing'); } return $output; }
function awpcp_get_edit_listing_menu_item() { $listings = awpcp_listings_collection(); $authorization = awpcp_listing_authorization(); $request = awpcp_request(); $settings = awpcp()->settings; try { $listing = $listings->get($request->get_ad_id()); } catch (AWPCP_Exception $e) { $listing = null; } if (is_object($listing) && $authorization->is_current_user_allowed_to_edit_listing($listing)) { $edit_ad_url = awpcp_get_edit_listing_direct_url($listing); } else { if (!$settings->get_option('requireuserregistration')) { $edit_ad_url = awpcp_get_edit_listing_generic_url(); } else { $edit_ad_url = null; } } if (is_null($edit_ad_url)) { return null; } else { $edit_ad_page_name = $settings->get_option('edit-ad-page-name'); return array('url' => $edit_ad_url, 'title' => esc_html($edit_ad_page_name)); } }
function awpcp_users_autocomplete_ajax_handler() { return new AWPCP_UsersAutocompleteAjaxHandler(awpcp_users_collection(), awpcp_request(), awpcp_ajax_response()); }
function awpcp_users_autocomplete() { return new AWPCP_UsersAutocomplete(awpcp_users_collection(), awpcp_request(), awpcp()->js); }
function awpcp_category_shortcode() { return new AWPCP_CategoryShortcode($GLOBALS['wpdb'], awpcp_request()); }
function awpcp_create_captcha($type = 'default') { switch ($type) { case 'recaptcha': $site_key = get_awpcp_option('recaptcha-public-key'); $secret_key = get_awpcp_option('recaptcha-private-key'); return new AWPCP_reCAPTCHA($site_key, $secret_key, awpcp_request()); case 'default': default: $max = get_awpcp_option('math-captcha-max-number'); return new AWPCP_DefaultCAPTCHA($max); } }
function awpcp_form_fields_table_factory() { return new AWPCP_FormFieldsTableFactory(awpcp_request()); }
function awpcp_update_file_status_ajax_handler() { return new AWPCP_UpdateFileStatusAjaxHandler(awpcp_media_api(), awpcp_files_collection(), awpcp_listings_collection(), awpcp_request(), awpcp_ajax_response()); }
function awpcp_upload_listing_media_ajax_handler() { return new AWPCP_UploadListingMediaAjaxHandler(awpcp_listings_collection(), awpcp_file_uploader(), awpcp_new_media_manager(), awpcp_request(), awpcp_ajax_response()); }
function awpcp_update_form_fields_order_ajax_handler() { return new AWPCP_UpdateFormFieldsOrderAjaxHandler(awpcp_form_fields(), awpcp_request(), awpcp_ajax_response()); }
function awpcp_upload_generated_thumbnail_ajax_handler() { return new AWPCP_UploadGeneratedThumbnailAjaxHandler(awpcp_image_resizer(), awpcp_media_api(), awpcp_listings_collection(), awpcp()->settings, awpcp_request(), awpcp_ajax_response()); }