クラス
Permalink
Sets up URL structure for wishlist page
ソース ソース
ファイル: src/Config/Permalink.php
class Permalink { /** * Registers hook * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return void */ public static function init() { add_action('usces_after_cart_instant', [get_class(), 'makeUrl']); } /** * Builds wishlist page URL from permalink structure * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @return void */ public static function makeUrl() { global $usces; $permalink_structure = get_option('permalink_structure'); if ($usces->use_ssl) { if ($permalink_structure) { $home_perse = parse_url(get_option('home')); $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : ''; $home_path = $home_perse['host'] . $home_perse_path; $ssl_perse = parse_url($usces->options['ssl_url']); $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : ''; $ssl_path = $ssl_perse['host'] . $ssl_perse_path; if ($home_perse_path != $ssl_perse_path) { if (!defined('WCEXWL_PAGE_URL')) { define('WCEXWL_PAGE_URL', $usces->options['ssl_url'] . '/index.php?page_id=' . WCEXWL_POST_ID . '&uscesid=' . $usces->get_uscesid()); } } else { $ssl_plink_wishlist = str_replace('http://', 'https://', str_replace($home_path, $ssl_path, get_page_link(WCEXWL_POST_ID))); if (!defined('WCEXWL_PAGE_URL')) { define('WCEXWL_PAGE_URL', $ssl_plink_wishlist . '?uscesid=' . $usces->get_uscesid()); } } } else { if (!defined('WCEXWL_PAGE_URL')) { define('WCEXWL_PAGE_URL', $usces->options['ssl_url'] . '/?page_id=' . WCEXWL_POST_ID . '&uscesid=' . $usces->get_uscesid()); } } if (!is_admin()) { add_filter('home_url', [get_class(), 'sslPageLink']); } } else { if ($permalink_structure) { if (!defined('WCEXWL_PAGE_URL')) { define('WCEXWL_PAGE_URL', get_page_link(WCEXWL_POST_ID)); } } else { if (!defined('WCEXWL_PAGE_URL')) { define('WCEXWL_PAGE_URL', get_option('home') . '/?page_id=' . WCEXWL_POST_ID); } } } define('ASUMIL_WISHLIST_URL', WCEXWL_PAGE_URL); } /** * SSL page link filter for wishlist page * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $link * @return string */ public static function sslPageLink($link) { $parts = parse_url($link); if (isset($parts['query'])) { parse_str($parts['query'], $query); } if (false !== strpos($link, '/wishlist') || (isset($query['page_id']) && $query['page_id'] == WCEXWL_POST_ID)) { $link = WCEXWL_PAGE_URL; } else { $link = str_replace('https://', 'http://', $link); /** * Filters the SSL wishlist page link * * @param string $link */ $link = apply_filters('wcexwl_filter_ssl_page_link', $link); } return $link; } }
- init — Registers hook
- makeUrl — Builds wishlist page URL from permalink structure
- sslPageLink — SSL page link filter for wishlist page