public static function change_custom_menu_url($args = array()) { $site_url = isset($args['site_url']) ? $args['site_url'] : ''; $url = isset($args['url']) ? $args['url'] : ''; if (empty($url)) { $url = SB_Option::get_site_url(); } if (empty($site_url) || $url == $site_url) { return; } $menu_items = self::get_menu_custom_items(); if (!is_array($menu_items)) { return; } foreach ($menu_items as $item) { if ('trang-chu' == $item->post_name || 'home' == $item->post_name) { $item_url = $item->url; $item_url = mb_ereg_replace($url, $site_url, $item_url); SB_Post::update_custom_menu_url($item->ID, $item_url); } } }
public static function change_url($args = array()) { $home_url = ''; $site_url = ''; extract($args, EXTR_OVERWRITE); if (empty($home_url)) { $home_url = $site_url; } if (empty($site_url)) { $site_url = $home_url; } if (empty($site_url) && empty($home_url)) { return; } $url = esc_url(untrailingslashit(SB_Option::get_site_url())); $site_url = esc_url(untrailingslashit($site_url)); if ($url != $site_url) { update_option('siteurl', $site_url); $args = array('url' => $url, 'site_url' => $site_url); SB_Post::change_custom_menu_url($args); SB_Option::change_option_url($args); SB_Option::change_widget_text_url($args); SB_Term::change_meta_url($url, $site_url); add_action('wp_head', array('SB_Core', 'regenerate_htaccess_file')); SB_Post::change_all_url(array('url' => $url, 'site_url' => $site_url)); } else { remove_action('wp_head', array('SB_Core', 'regenerate_htaccess_file')); } $url = esc_url(untrailingslashit(SB_Option::get_home_url())); $home_url = esc_url(untrailingslashit($home_url)); if ($url != $home_url) { update_option('home', $home_url); } }