/** * Returns User Profile Link * @author Howard R <*****@*****.**> * @static * @param int $user_id * @param int $target_id * @return string */ public static function get_profile_link($user_id = '', $target_id = 0) { /** fetch currenr user data if user id is empty **/ if (trim($user_id) == '') { $user_id = self::get_cur_user_id(); } $user_data = self::get_user($user_id); $home_type = wpl_global::get_wp_option('show_on_front', 'posts'); $home_id = wpl_global::get_wp_option('page_on_front', 0); if (!$target_id) { $target_id = wpl_request::getVar('wpltarget', 0); } if ($target_id) { $url = wpl_global::add_qs_var('uid', $user_id, wpl_sef::get_page_link($target_id)); if ($home_type == 'page' and $home_id == $target_id) { $url = wpl_global::add_qs_var('wplview', 'profile_show', $url); } } else { $url = wpl_sef::get_wpl_permalink(true); $nosef = wpl_sef::is_permalink_default(); $wpl_main_page_id = wpl_sef::get_wpl_main_page_id(); if ($nosef or $home_type == 'page' and $home_id == $wpl_main_page_id) { $url = wpl_global::add_qs_var('wplview', 'profile_show', $url); $url = wpl_global::add_qs_var('uid', $user_id, $url); } else { $url .= urlencode($user_data->data->user_login) . '/'; } } return $url; }
/** * * @author Howard <*****@*****.**> * @static * @param type $target_id * @return type */ public static function get_property_listing_link($target_id = 0) { if ($target_id) { $url = wpl_sef::get_page_link($target_id); } else { $url = wpl_sef::get_wpl_permalink(true); } return $url; }
/** * Returns WPL Main rewrite rule * @author Howard R <*****@*****.**> * @static * @return string */ public static function get_main_rewrite_rule() { $main_permalink = wpl_sef::get_wpl_permalink(); $wpl_rules = array(); if (wpl_global::check_multilingual_status()) { $lang_options = wpl_addon_pro::get_wpl_language_options(); $lang_str = '.+'; foreach ($lang_options as $lang_option) { $lang_str .= $lang_option['shortcode'] . '|'; } $lang_str = trim($lang_str, '|.+ '); $wpl_rules[] = array('regex' => '(' . $lang_str . ')/(' . $main_permalink . ')/(.+)$', 'url' => 'index.php?pagename=$matches[2]&wpl_qs=$matches[3]'); $wpl_rules[] = array('regex' => 'language/(' . $lang_str . ')/(' . $main_permalink . ')/(.+)$', 'url' => 'index.php?pagename=$matches[2]&wpl_qs=$matches[3]'); } $wpl_rules[] = array('regex' => '(' . $main_permalink . ')/(.+)$', 'url' => 'index.php?pagename=$matches[1]&wpl_qs=$matches[2]'); /** apply filters (This filter must place after all proccess) **/ _wpl_import('libraries.filters'); @extract(wpl_filters::apply('main_rewrite_rule', array('wpl_rules' => $wpl_rules))); return $wpl_rules; }
/** * Checke proeprty alias and 301 redirect the page to the correct link * @author Howard <*****@*****.**> * @param int $proeprty_id */ public function check_property_link($proeprty_id) { $wpl_qs = urldecode(wpl_global::get_wp_qvar('wpl_qs')); /** check property alias for avoiding duplicate content **/ $called_alias = $wpl_qs; $column = 'alias'; $field_id = wpl_flex::get_dbst_id($column, wpl_property::get_property_kind($proeprty_id)); $field = wpl_flex::get_field($field_id); if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } $property_alias = $proeprty_id . '-' . urldecode(wpl_db::get($column, 'wpl_properties', 'id', $proeprty_id)); if (trim($property_alias) != '' and $called_alias != $property_alias) { $url = wpl_sef::get_wpl_permalink(true) . '/' . urlencode($property_alias); header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); exit; } }
/** * Returns RSS link of property listing * @author Steve A. <*****@*****.**> * @static * @return string|boolean */ public static function get_property_rss_link() { $nosef = wpl_sef::is_permalink_default(); $home_type = wpl_global::get_wp_option('show_on_front', 'posts'); $home_id = wpl_global::get_wp_option('page_on_front', 0); $wpl_main_page_id = wpl_sef::get_wpl_main_page_id(); if ($nosef or $home_type == 'page' and $home_id == $wpl_main_page_id) { $url = wpl_sef::get_wpl_permalink(true); $url = wpl_global::add_qs_var('wplview', 'features', $url); $url = wpl_global::add_qs_var('wpltype', 'rss', $url); } else { $url = wpl_sef::get_wpl_permalink(true) . 'features/rss'; } return $url; }