ID, $user_only_pages ) && ! empty( $registration_settings['engine'] ) && 'others' == $registration_settings['engine'] ) {
if( ! filter_var( $registration_settings['custom_login'], FILTER_VALIDATE_URL ) === FALSE ) {
$redirect_url = $registration_settings['custom_login'];
}
}
}
}
// Redirect
if( ! empty( $redirect_url ) ) {
wp_redirect( $redirect_url );
exit();
}
}
/**
* Output buffer.
*
* @since 1.0.0
* @access public
*/
public function output_buffer() {
if( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
if( ( isset( $_POST['acadp_listing_nonce'] ) && wp_verify_nonce( $_POST['acadp_listing_nonce'], 'acadp_save_listing' ) ) ||
( isset( $_POST['acadp_checkout_nonce'] ) && wp_verify_nonce( $_POST['acadp_checkout_nonce'], 'acadp_process_payment' ) ) ) {
ob_start();
}
}
}
/**
* Add rewrite rules.
*
* @since 1.0.0
* @access public
*/
public function add_rewrites() {
$page_settings = get_option( 'acadp_page_settings' );
$url = home_url();
// Listings Page
$id = $page_settings['listings'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/page/?([0-9]{1,})/?$", 'index.php?page_id='.$id.'&paged=$matches[1]', 'top' );
}
// Single Location Page
$id = $page_settings['location'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_location=$matches[1]&paged=$matches[2]', 'top' );
add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$id.'&acadp_location=$matches[1]', 'top' );
}
// Single Category Page
$id = $page_settings['category'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_category=$matches[1]&paged=$matches[2]', 'top' );
add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$id.'&acadp_category=$matches[1]', 'top' );
}
// User Listings Page
$id = $page_settings['user_listings'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_user=$matches[1]&paged=$matches[2]', 'top' );
add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$id.'&acadp_user=$matches[1]', 'top' );
}
// Listings Edit, Delete (or) Renew Pages
$id = $page_settings['listing_form'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=$matches[1]&acadp_listing=$matches[2]', 'top' );
}
// Remove from Favourites Page
$id = $page_settings['favourite_listings'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=$matches[1]&acadp_listing=$matches[2]', 'top' );
}
// Checkout page
$id = $page_settings['checkout'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/submission/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=submission&acadp_listing=$matches[1]', 'top' );
add_rewrite_rule( "$link/promote/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=promote&acadp_listing=$matches[1]', 'top' );
add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=$matches[1]&acadp_order=$matches[2]', 'top' );
}
// Payment success page
$id = $page_settings['payment_receipt'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/order/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=order&acadp_order=$matches[1]', 'top' );
}
// Payment failure page
$id = $page_settings['payment_failure'];
if( $id > 0 ) {
$link = str_replace( $url, '', get_permalink( $id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/order/([0-9]{1,})/?$", 'index.php?page_id='.$id.'&acadp_action=order&acadp_order=$matches[1]', 'top' );
}
// Rewrite tags
add_rewrite_tag( '%acadp_location%', '([^/]+)' );
add_rewrite_tag( '%acadp_category%', '([^/]+)' );
add_rewrite_tag( '%acadp_user%', '([^/]+)' );
add_rewrite_tag( '%acadp_listing%', '([0-9]{1,})' );
add_rewrite_tag( '%acadp_action%', '([^/]+)' );
add_rewrite_tag( '%acadp_order%', '([0-9]{1,})' );
}
/**
* Flush rewrite rules when it's necessary.
*
* @since 1.0.0
* @access public
*/
public function maybe_flush_rules() {
$rewrite_rules = get_option( 'rewrite_rules' );
if( $rewrite_rules ) {
global $wp_rewrite;
foreach( $rewrite_rules as $rule => $rewrite ) {
$rewrite_rules_array[$rule]['rewrite'] = $rewrite;
}
$rewrite_rules_array = array_reverse( $rewrite_rules_array, true );
$maybe_missing = $wp_rewrite->rewrite_rules();
$missing_rules = false;
foreach( $maybe_missing as $rule => $rewrite ) {
if( ! array_key_exists( $rule, $rewrite_rules_array ) ) {
$missing_rules = true;
break;
}
}
if( true === $missing_rules ) {
flush_rewrite_rules();
}
}
}
/**
* Registers and enqueues the stylesheets for the public-facing side of the site.
*
* @since 1.0.0
* @access public
*/
public function register_enqueue_styles() {
$general_settings = get_option( 'acadp_general_settings' );
$deps = array();
wp_register_style( ACADP_PLUGIN_NAME.'-slick', ACADP_PLUGIN_URL.'public/css/slick.css', array(), '1.6.0', 'all' );
if( isset( $general_settings['load_bootstrap'] ) && in_array( 'css' , $general_settings['load_bootstrap'] ) ) {
wp_register_style( ACADP_PLUGIN_NAME.'-bootstrap', ACADP_PLUGIN_URL.'public/css/acadp-bootstrap.css', array(), '3.3.5', 'all' );
$deps[] = ACADP_PLUGIN_NAME.'-bootstrap';
}
wp_register_style( ACADP_PLUGIN_NAME, ACADP_PLUGIN_URL.'public/css/acadp-public.css', $deps, ACADP_VERSION_NUM, 'all' );
// Enqueue style dependencies
if( is_singular('acadp_listings') ) {
if( ! empty( $general_settings['has_images'] ) ) {
wp_enqueue_style( ACADP_PLUGIN_NAME.'-slick' );
}
wp_enqueue_style( ACADP_PLUGIN_NAME );
}
}
/**
* Registers and enqueues javascript for the public-facing side of the site.
*
* @since 1.0.0
* @access public
*/
public function register_enqueue_scripts() {
$general_settings = get_option( 'acadp_general_settings' );
$map_settings = get_option( 'acadp_map_settings' );
$recaptcha_settings = get_option( 'acadp_recaptcha_settings' );
wp_register_script( ACADP_PLUGIN_NAME.'-slick', ACADP_PLUGIN_URL.'public/js/slick.min.js', array( 'jquery' ), '1.6.0', true );
if( isset( $general_settings['load_bootstrap'] ) && in_array( 'javascript' , $general_settings['load_bootstrap'] ) ) {
wp_register_script( ACADP_PLUGIN_NAME.'-bootstrap', ACADP_PLUGIN_URL.'public/js/bootstrap.min.js', array( 'jquery' ), '3.3.5', true );
}
wp_register_script( ACADP_PLUGIN_NAME.'-validator', ACADP_PLUGIN_URL.'public/js/validator.min.js', array( 'jquery' ), '0.9.0', true );
wp_register_script( ACADP_PLUGIN_NAME, ACADP_PLUGIN_URL.'public/js/acadp-public.js', array( 'jquery' ), ACADP_VERSION_NUM, true );
if( ! empty( $recaptcha_settings['site_key'] ) && ! empty( $recaptcha_settings['forms'] ) ) {
$recaptcha_site_key = $recaptcha_settings['site_key'];
$recaptcha_registration = in_array( 'registration', $recaptcha_settings['forms'] ) ? 1 : 0;
$recaptcha_listing = in_array( 'listing', $recaptcha_settings['forms'] ) ? 1 : 0;
$recaptcha_contact = ! empty( $general_settings['has_contact_form'] ) && in_array( 'contact', $recaptcha_settings['forms'] ) ? 1 : 0;
$recaptcha_report_abuse = ! empty( $general_settings['has_report_abuse'] ) && in_array( 'report_abuse', $recaptcha_settings['forms'] ) ? 1 : 0;
} else {
$recaptcha_site_key = '';
$recaptcha_registration = 0;
$recaptcha_listing = 0;
$recaptcha_contact = 0;
$recaptcha_report_abuse = 0;
}
wp_localize_script( ACADP_PLUGIN_NAME, 'acadp', array(
'is_rtl' => is_rtl(),
'plugin_url' => ACADP_PLUGIN_URL,
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ajax_nonce' => wp_create_nonce( 'acadp_ajax_nonce' ),
'maximum_images_per_listing' => $general_settings['maximum_images_per_listing'],
'zoom_level' => $map_settings['zoom_level'],
'recaptcha_registration' => $recaptcha_registration,
'recaptcha_site_key' => $recaptcha_site_key,
'recaptcha_listing' => $recaptcha_listing,
'recaptcha_contact' => $recaptcha_contact,
'recaptcha_report_abuse' => $recaptcha_report_abuse,
'recaptchas' => array( 'registration' => 0, 'listing' => 0, 'contact' => 0, 'report_abuse' => 0 ),
'recaptcha_invalid_message' => __( "You can't leave Captcha Code empty", 'advanced-classifieds-and-directory-pro' ),
'user_login_alert_message' => __( 'Sorry, you need to login first.', 'advanced-classifieds-and-directory-pro' ),
'upload_limit_alert_message' => __( 'Sorry, you have only %d images pending.', 'advanced-classifieds-and-directory-pro' ),
'delete_label' => __( 'Delete Permanently', 'advanced-classifieds-and-directory-pro' ),
'proceed_to_payment_btn_label' => __( 'Proceed to payment', 'advanced-classifieds-and-directory-pro' ),
'finish_submission_btn_label' => __( 'Finish submission', 'advanced-classifieds-and-directory-pro' )
)
);
$map_api_key = ! empty( $map_settings['api_key'] ) ? '&key='.$map_settings['api_key'] : '';
wp_register_script( ACADP_PLUGIN_NAME.'-google-map', 'https://maps.googleapis.com/maps/api/js?v=3.exp'.$map_api_key, array( ACADP_PLUGIN_NAME ), '', true );
wp_register_script( ACADP_PLUGIN_NAME.'-markerclusterer', ACADP_PLUGIN_URL.'public/js/markerclusterer.js', array( ACADP_PLUGIN_NAME.'-google-map' ), '1.0.0', true );
wp_register_script( ACADP_PLUGIN_NAME."-recaptcha", "https://www.google.com/recaptcha/api.js?onload=acadp_on_recaptcha_load&render=explicit", array( ACADP_PLUGIN_NAME ), '', true );
// Enqueue script dependencies
if( is_singular('acadp_listings') ) {
if( ! empty( $general_settings['has_images'] ) ) {
wp_enqueue_script( ACADP_PLUGIN_NAME.'-slick' );
}
if( wp_script_is( ACADP_PLUGIN_NAME.'-bootstrap', 'registered' ) ) {
wp_enqueue_script( ACADP_PLUGIN_NAME.'-bootstrap' );
}
wp_enqueue_script( ACADP_PLUGIN_NAME.'-validator' );
wp_enqueue_script( ACADP_PLUGIN_NAME );
wp_enqueue_script( ACADP_PLUGIN_NAME.'-google-map' );
if( $recaptcha_contact > 0 || $recaptcha_report_abuse > 0 ) {
wp_enqueue_script( ACADP_PLUGIN_NAME . "-recaptcha" );
}
}
}
/**
* Dequeue scripts.
*
* @since 1.5.6
* @access public
*/
public function dequeue_scripts() {
$page_settings = get_option( 'acadp_page_settings' );
if( ( is_user_logged_in() && is_page( (int) $page_settings['listing_form'] ) ) || is_singular('acadp_listings') ) {
wp_dequeue_script( 'recaptcha' );
}
}
/**
* Override the default post/page title depending on the ACADP view.
*
* @since 1.5.5
* @access public
*
* @param string $title The document title.
* @param string $sep Title separator.
* @param string $seplocation Location of the separator (left or right).
* @return string The filtered title.
*/
public function wp_title( $title, $sep, $seplocation ) {
global $post;
if( ! isset( $post ) ) return $title;
$page_settings = get_option( 'acadp_page_settings' );
$custom_title = '';
$site_name = get_bloginfo( 'name' );
// Get Location page title
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$custom_title = $term->name;
}
}
// Get Category page title
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$custom_title = $term->name;
}
}
// Get User Listings page title
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$custom_title = $user->display_name;
}
}
// ...
if( ! empty( $custom_title ) ) {
$title = ( 'left' == $seplocation ) ? "$site_name $sep $custom_title" : "$custom_title $sep $site_name";
}
return $title;
}
/**
* Override the default post/page title depending on the ACADP view.
*
* @since 1.5.6
* @access public
*
* @param array $title The document title parts.
* @return Filtered title parts.
*/
public function document_title_parts( $title ) {
global $post;
if( ! isset( $post ) ) return $title;
$page_settings = get_option( 'acadp_page_settings' );
// Get Category page title
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$title['title'] = $term->name;
}
}
// Get Location page title
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$title['title'] = $term->name;
}
}
// Get User Listings page title
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$title['title'] = $user->display_name;
}
}
// ...
return $title;
}
/**
* Construct Yoast SEO title for our category, location & user_listings pages.
*
* @since 1.6.1
* @param array $title The Yoast title.
* @return Modified title.
*/
public function wpseo_title( $title ) {
global $post;
if( ! isset( $post ) ) return $title;
$page_settings = get_option( 'acadp_page_settings' );
if( $post->ID != $page_settings['category'] && $post->ID != $page_settings['location'] && $post->ID != $page_settings['user_listings'] ) {
return $title;
}
$wpseo_titles = get_option( 'wpseo_titles' );
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
if( isset( $wpseo_titles['separator'] ) && isset( $sep_options[ $wpseo_titles['separator'] ] ) ) {
$sep = $sep_options[ $wpseo_titles['separator'] ];
} else {
$sep = '-'; // Setting default separator if Admin didn't set it from backed
}
$replacements = array(
'%%sep%%' => $sep,
'%%page%%' => '',
'%%primary_category%%' => '',
'%%sitename%%' => get_bloginfo( 'name' )
);
$title_template = '';
// Category page
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$replacements['%%term_title%%'] = $term->name;
// Get Archive SEO title
if( array_key_exists( 'title-tax-acadp_categories', $wpseo_titles ) ) {
$title_template = $wpseo_titles['title-tax-acadp_categories'];
}
// Get Term SEO title
$meta = get_option( 'wpseo_taxonomy_meta' );
if( array_key_exists( 'acadp_categories', $meta ) ) {
if( array_key_exists( $term->term_id, $meta['acadp_categories'] ) ) {
if( array_key_exists( 'wpseo_title', $meta['acadp_categories'][ $term->term_id ] ) ) {
$title_template = $meta['acadp_categories'][ $term->term_id ]['wpseo_title'];
}
}
}
}
}
// Location page
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$replacements['%%term_title%%'] = $term->name;
// Get Archive SEO title
if( array_key_exists( 'title-tax-acadp_locations', $wpseo_titles ) ) {
$title_template = $wpseo_titles['title-tax-acadp_locations'];
}
// Get Term SEO title
$meta = get_option( 'wpseo_taxonomy_meta' );
if( array_key_exists( 'acadp_locations', $meta ) ) {
if( array_key_exists( $term->term_id, $meta['acadp_locations'] ) ) {
if( array_key_exists( 'wpseo_title', $meta['acadp_locations'][ $term->term_id ] ) ) {
$title_template = $meta['acadp_locations'][ $term->term_id ]['wpseo_title'];
}
}
}
}
}
// User listings page
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$replacements['%%title%%'] = $user->display_name;
// Get Archive SEO title
if( array_key_exists( 'title-page', $wpseo_titles ) ) {
$title_template = $wpseo_titles['title-page'];
}
// Get page meta title
$meta = get_post_meta( $post->ID, '_yoast_wpseo_title', true );
if( ! empty( $meta ) ) {
$title_template = $meta;
}
}
}
// Return
if( ! empty( $title_template ) ) {
$title = strtr( $title_template, $replacements );
}
return $title;
}
/**
* Construct Yoast SEO description for our category, location & user_listings pages.
*
* @since 1.6.1
* @param array $desc The Yoast description.
* @return Modified description.
*/
public function wpseo_metadesc( $desc ) {
global $post;
if( ! isset( $post ) ) return $desc;
$page_settings = get_option( 'acadp_page_settings' );
if( $post->ID != $page_settings['category'] && $post->ID != $page_settings['location'] && $post->ID != $page_settings['user_listings'] ) {
return $desc;
}
$wpseo_titles = get_option( 'wpseo_titles' );
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
if( isset( $wpseo_titles['separator'] ) && isset( $sep_options[ $wpseo_titles['separator'] ] ) ) {
$sep = $sep_options[ $wpseo_titles['separator'] ];
} else {
$sep = '-'; // Setting default separator if Admin didn't set it from backed
}
$replacements = array(
'%%sep%%' => $sep,
'%%page%%' => '',
'%%primary_category%%' => '',
'%%sitename%%' => get_bloginfo( 'name' )
);
$desc_template = '';
// Category page
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$replacements['%%term_title%%'] = $term->name;
// Get Archive SEO desc
if( array_key_exists( 'metadesc-tax-acadp_categories', $wpseo_titles ) ) {
$desc_template = $wpseo_titles['metadesc-tax-acadp_categories'];
}
// Get Term SEO desc
$meta = get_option( 'wpseo_taxonomy_meta' );
if( array_key_exists( 'acadp_categories', $meta ) ) {
if( array_key_exists( $term->term_id, $meta['acadp_categories'] ) ) {
if( array_key_exists( 'wpseo_desc', $meta['acadp_categories'][ $term->term_id ] ) ) {
$desc_template = $meta['acadp_categories'][ $term->term_id ]['wpseo_desc'];
}
}
}
}
}
// Location page
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$replacements['%%term_title%%'] = $term->name;
// Get Archive SEO desc
if( array_key_exists( 'metadesc-tax-acadp_locations', $wpseo_titles ) ) {
$desc_template = $wpseo_titles['metadesc-tax-acadp_locations'];
}
// Get Term SEO desc
$meta = get_option( 'wpseo_taxonomy_meta' );
if( array_key_exists( 'acadp_locations', $meta ) ) {
if( array_key_exists( $term->term_id, $meta['acadp_locations'] ) ) {
if( array_key_exists( 'wpseo_desc', $meta['acadp_locations'][ $term->term_id ] ) ) {
$desc_template = $meta['acadp_locations'][ $term->term_id ]['wpseo_desc'];
}
}
}
}
}
// User listings page
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$replacements['%%title%%'] = $user->display_name;
// Get Archive SEO desc
if( array_key_exists( 'metadesc-page', $wpseo_titles ) ) {
$desc_template = $wpseo_titles['metadesc-page'];
}
// Get page meta desc
$meta = get_post_meta( $post->ID, '_yoast_wpseo_metadesc', true );
if( ! empty( $meta ) ) {
$desc_template = $meta;
}
}
}
// Return
if( ! empty( $desc_template ) ) {
$desc = strtr( $desc_template, $replacements );
}
return $desc;
}
/**
* Override the Yoast SEO canonical URL on our category, location & user_listings pages.
*
* @since 1.6.1
* @param array $url The Yoast canonical URL.
* @return Modified canonical URL.
*/
public function wpseo_canonical( $url ) {
global $post;
if( ! isset( $post ) ) return $url;
$page_settings = get_option( 'acadp_page_settings' );
// Category page
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$url = acadp_get_category_page_link( $term );
}
}
// Location page
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$url = acadp_get_location_page_link( $term );
}
}
// User listings page
if ( $post->ID == $page_settings['user_listings'] ) {
if ( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$url = acadp_get_user_page_link( $user->ID );
}
}
return $url;
}
/**
* Adds the Facebook OG tags and Twitter Cards.
*
* @since 1.0.0
* @access public
*/
public function og_metatags() {
global $post;
if( ! isset( $post ) ) return;
$page_settings = get_option( 'acadp_page_settings' );
$socialshare_settings = get_option( 'acadp_socialshare_settings' );
$page = '';
if( is_singular('acadp_listings') ) {
$page = 'listing';
} else {
if( $page_settings['locations'] == $post->ID ) {
$page = 'locations';
}
if( $page_settings['categories'] == $post->ID ) {
$page = 'categories';
}
if( in_array( $post->ID, array( $page_settings['listings'], $page_settings['user_listings'], $page_settings['location'], $page_settings['category'], $page_settings['search'] ) ) ) {
$page = 'listings';
}
}
if( isset( $socialshare_settings['pages'] ) && in_array( $page, $socialshare_settings['pages'] ) ) {
$title = get_the_title();
// Get Location page title
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$title = $term->name;
}
}
// Get Category page title
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$title = $term->name;
}
}
// Get User Listings page title
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$title = $user->display_name;
}
}
echo '';
echo '';
echo '';
if( 'listing' == $page ) {
if( ! empty( $post->post_content ) ) {
echo '';
}
$images = get_post_meta( $post->ID, 'images', true );
if( ! empty( $images ) ) {
$thumbnail = wp_get_attachment_image_src( $images[0], 'full' );
if( ! empty( $thumbnail ) ) echo '';
}
}
echo '';
echo '';
}
}
/**
* Force Specific Pages to load with the SSL Certificate.
*
* @since 1.0.0
* @access public
*
* @params boolean $force_ssl Whether to force SSL in current page.
* @params int $post_id Page ID.
* @return boolean True to force SSL, false if not.
*/
public function force_ssl_https( $force_ssl, $post_id ) {
$page_settings = get_option( 'acadp_page_settings' );
if( $post_id == ( int ) $page_settings['checkout'] ) {
$gateway_settings = get_option( 'acadp_gateway_settings' );
if( ! empty( $gateway_settings['use_https'] ) ) {
return true;
}
}
return $force_ssl;
}
/**
* Change the current page title if applicable.
*
* @since 1.0.0
* @access public
*
* @params string $title Current page title.
* @return string $title Modified page title.
*/
public function the_title( $title ) {
if( ! in_the_loop() || ! is_main_query() ) {
return $title;
}
if( is_singular('acadp_listings') ) {
return '';
}
global $post;
$page_settings = get_option( 'acadp_page_settings' );
// Change Location page title
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$title = $term->name;
}
}
// Change Category page title
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$title = $term->name;
}
}
// Change User Listings page title
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = acadp_get_user_slug() ) {
$user = get_user_by( 'slug', $slug );
$title = $user->display_name;
}
}
// Change Search page title
if( $post->ID == $page_settings['search'] ) {
if( isset( $_GET['q'] ) && ! empty( $_GET['q'] ) ) {
$title = sprintf( __( 'You have searched for "%s"...', 'advanced-classifieds-and-directory-pro' ), sanitize_text_field( $_GET['q'] ) );
}
}
return $title;
}
/**
* Outputs ACADP child terms dropdown.
*
* @since 1.5.5
* @access public
*/
public function ajax_callback_dropdown_terms() {
check_ajax_referer( 'acadp_ajax_nonce', 'security' );
if( isset( $_POST['taxonomy'] ) && isset( $_POST['parent'] ) ) {
$args = array(
'taxonomy' => sanitize_text_field( $_POST['taxonomy'] ),
'base_term' => 0,
'parent' => (int) $_POST['parent']
);
if( 'acadp_locations' == $args['taxonomy'] ) {
$general_settings = get_option( 'acadp_general_settings' );
$locations_settings = get_option( 'acadp_locations_settings' );
$args['base_term'] = max( 0, $general_settings['base_location'] );
$args['orderby'] = $locations_settings['orderby'];
$args['order'] = $locations_settings['order'];
}
if( 'acadp_categories' == $args['taxonomy'] ) {
$categories_settings = get_option( 'acadp_categories_settings' );
$args['orderby'] = $categories_settings['orderby'];
$args['order'] = $categories_settings['order'];
}
if( isset( $_POST['class'] ) && '' != trim( $_POST['class'] ) ) {
$args['class'] = sanitize_text_field( $_POST['class'] );
}
if( $args['parent'] != $args['base_term'] ) {
ob_start();
acadp_dropdown_terms( $args );
$output = ob_get_clean();
print $output;
}
}
wp_die();
}
/**
* Always use our custom page for ACADP locations and categories.
*
* @since 1.0.0
* @param string $url The term URL.
* @param object $term The term object.
* @param string $taxonomy The taxonomy slug.
* @return string $url Filtered term URL.
*/
public function term_link( $url, $term, $taxonomy ) {
// If ACADP Locations
if ( 'acadp_locations' == $taxonomy ) {
$url = acadp_get_location_page_link( $term );
}
// If ACADP Categories
if ( 'acadp_categories' == $taxonomy ) {
$url = acadp_get_category_page_link( $term );
}
return $url;
}
}