function upgrade_all() { global $wp_current_db_version, $wp_db_version; $wp_current_db_version = __get_option('db_version'); // We are up-to-date. Nothing to do. if ($wp_db_version == $wp_current_db_version) { return; } // If the version is not set in the DB, try to guess the version. if (empty($wp_current_db_version)) { $wp_current_db_version = 0; // If the template option exists, we have 1.5. $template = __get_option('template'); if (!empty($template)) { $wp_current_db_version = 2541; } } populate_options(); if ($wp_current_db_version < 2541) { upgrade_100(); upgrade_101(); upgrade_110(); upgrade_130(); } if ($wp_current_db_version < 3308) { upgrade_160(); } save_mod_rewrite_rules(); update_option('db_version', $wp_db_version); }
function upgrade_all() { populate_options(); upgrade_100(); upgrade_101(); upgrade_110(); upgrade_130(); save_mod_rewrite_rules(); }
function upgrade_all() { populate_options(); //在admin-schema.php中 upgrade_100(); upgrade_101(); upgrade_110(); upgrade_130(); save_mod_rewrite_rules(); }
public function __construct($id, $sources) { $this->id = $id; $this->label = __('Экспорт в YML', 'woocommerce'); $this->sources = $sources; add_filter('woocommerce_settings_tabs_array', array($this, 'add_settings_page'), 20); add_action('woocommerce_settings_' . $this->id, array($this, 'output')); add_action('woocommerce_settings_save_' . $this->id, array($this, 'save')); add_action('woocommerce_admin_field_filter_settings', array($this, 'show_filter_settings')); add_action('woocommerce_admin_field_yml_head', array($this, 'show_head')); add_action('woocommerce_update_option_filter_settings', array($this, 'save_filter_settings')); if ($_GET['tab'] == $this->id) { wp_register_style($this->id . 'Stylesheet', plugins_url('/style.css', __FILE__)); wp_enqueue_style($this->id . 'Stylesheet'); wp_register_script($this->id . 'script', plugins_url('/script.js', __FILE__)); wp_enqueue_script($this->id . 'script'); } if (isset($_GET['tab']) && $_GET['tab'] == $this->id and isset($_REQUEST['save'])) { save_mod_rewrite_rules(); } }
/** * Remove rewrite rules and then recreate rewrite rules. * * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' * exists, it will be called. * * @since 2.0.1 * @access public * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ function flush_rules($hard = true) { delete_option('rewrite_rules'); $this->wp_rewrite_rules(); if ($hard && function_exists('save_mod_rewrite_rules')) { save_mod_rewrite_rules(); } if ($hard && function_exists('iis7_save_url_rewrite_rules')) { iis7_save_url_rewrite_rules(); } }
/** * Remove rewrite rules and then recreate rewrite rules. * * Calls {@link HQ_Rewrite::hq_rewrite_rules()} after removing the * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' * exists, it will be called. * * @since 0.0.1 * @access public * * @staticvar bool $do_hard_later * * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ public function flush_rules($hard = true) { static $do_hard_later = null; // Prevent this action from running before everyone has registered their rewrites if (!did_action('hq_loaded')) { add_action('hq_loaded', array($this, 'flush_rules')); $do_hard_later = isset($do_hard_later) ? $do_hard_later || $hard : $hard; return; } if (isset($do_hard_later)) { $hard = $do_hard_later; unset($do_hard_later); } delete_option('rewrite_rules'); $this->hq_rewrite_rules(); /** * Filter whether a "hard" rewrite rule flush should be performed when requested. * * A "hard" flush updates .htaccess (Apache) or web.config (IIS). * * @since 0.0.1 * * @param bool $hard Whether to flush rewrite rules "hard". Default true. */ if (!$hard || !apply_filters('flush_rewrite_rules_hard', true)) { return; } if (function_exists('save_mod_rewrite_rules')) { save_mod_rewrite_rules(); } if (function_exists('iis7_save_url_rewrite_rules')) { iis7_save_url_rewrite_rules(); } }
/** * save_rewrite_rules() * * @return bool $success **/ function save_rewrite_rules() { if (!isset($GLOBALS['wp_rewrite'])) { $GLOBALS['wp_rewrite'] = new WP_Rewrite(); } if (!function_exists('save_mod_rewrite_rules') || !function_exists('get_home_path')) { include_once ABSPATH . 'wp-admin/includes/admin.php'; } if (!get_option('permalink_structure') || !intval(get_option('blog_public'))) { remove_filter('mod_rewrite_rules', array($this, 'rewrite_rules')); } return save_mod_rewrite_rules() && get_option('permalink_structure') && intval(get_option('blog_public')); }
function flush_rules() { generate_page_rewrite_rules(); delete_option('rewrite_rules'); $this->wp_rewrite_rules(); if ( function_exists('save_mod_rewrite_rules') ) save_mod_rewrite_rules(); }
function set_permalink_structure($str) { global $wp_rewrite; $wp_rewrite->set_permalink_structure($str); save_mod_rewrite_rules(); }
function generate_page_rewrite_rules() { global $wpdb; //get pages in order of hierarchy, i.e. children after parents $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE post_status = 'static'")); //now reverse it, because we need parents after children for rewrite rules to work properly $posts = array_reverse($posts, true); $page_rewrite_rules = array(); if ($posts) { foreach ($posts as $id => $post) { // URI => page name $uri = get_page_uri($id); $page_rewrite_rules[$uri] = $post; } update_option('page_uris', $page_rewrite_rules); save_mod_rewrite_rules(); } }
} if ($option == 'blogdescription' || $option == 'blogname') { if (current_user_can('unfiltered_html') == false) { $value = wp_filter_post_kses($value); } } if (update_option($option, $value)) { $any_changed++; } } } if ($any_changed) { // If siteurl or home changed, reset cookies. if (get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home) { // If home changed, write rewrite rules to new location. save_mod_rewrite_rules(); // Get currently logged in user and password. get_currentuserinfo(); // Clear cookies for old paths. wp_clearcookie(); // Set cookies for new paths. wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl')); } //$message = sprintf(__('%d setting(s) saved... '), $any_changed); } $referred = remove_query_arg('updated', $_SERVER['HTTP_REFERER']); $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); wp_redirect($goback); break; default:
function flush_rules() { delete_option('rewrite_rules'); $this->wp_rewrite_rules(); if (function_exists('save_mod_rewrite_rules')) { save_mod_rewrite_rules(); } }
public static function regenerate_htaccess_file() { if (!function_exists('save_mod_rewrite_rules')) { if (!function_exists('mysql2date')) { require ABSPATH . '/wp-includes/functions.php'; } if (!function_exists('get_home_path')) { require ABSPATH . '/wp-admin/includes/file.php'; } require ABSPATH . '/wp-admin/includes/misc.php'; } global $is_nginx, $wp_rewrite; $home_path = get_home_path(); $htaccess_file = $home_path . '.htaccess'; if (file_exists($htaccess_file)) { unlink($htaccess_file); } $home_path = get_home_path(); $iis7_permalinks = iis7_supports_permalinks(); $prefix = $blog_prefix = ''; if (!got_url_rewrite()) { $prefix = '/index.php'; } if (is_multisite() && !is_subdomain_install() && is_main_site()) { $blog_prefix = '/blog'; } $permalink_structure = get_option('permalink_structure'); $category_base = get_option('category_base'); $tag_base = get_option('tag_base'); $update_required = false; if ($iis7_permalinks) { if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) { $writable = true; } else { $writable = false; } } elseif ($is_nginx) { $writable = false; } else { if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) { $writable = true; } else { $writable = false; $existing_rules = array_filter(extract_from_markers($home_path . '.htaccess', 'WordPress')); $new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules())); $update_required = $new_rules !== $existing_rules; } } if ($wp_rewrite->using_index_permalinks()) { $usingpi = true; } else { $usingpi = false; } flush_rewrite_rules(); save_mod_rewrite_rules(); }
/** * Remove rewrite rules and then recreate rewrite rules. * * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' * exists, it will be called. * * @since 2.0.1 * @access public */ function flush_rules() { delete_transient('rewrite_rules'); $this->wp_rewrite_rules(); if ( function_exists('save_mod_rewrite_rules') ) save_mod_rewrite_rules(); if ( function_exists('iis7_save_url_rewrite_rules') ) iis7_save_url_rewrite_rules(); }
private function flush_rewrite_rules() { // We have to deal with the fact that the procedures used call get_option, which could be looking at the wrong table prefix, or have the wrong thing cached global $updraftplus_addons_migrator; if (!empty($updraftplus_addons_migrator->new_blogid)) { switch_to_blog($updraftplus_addons_migrator->new_blogid); } foreach (array('permalink_structure', 'rewrite_rules', 'page_on_front') as $opt) { add_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt)); } global $wp_rewrite; $wp_rewrite->init(); // Don't do this: it will cause rules created by plugins that weren't active at the start of the restore run to be lost # flush_rewrite_rules(true); if (function_exists('save_mod_rewrite_rules')) { save_mod_rewrite_rules(); } if (function_exists('iis7_save_url_rewrite_rules')) { iis7_save_url_rewrite_rules(); } foreach (array('permalink_structure', 'rewrite_rules', 'page_on_front') as $opt) { remove_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt)); } if (!empty($updraftplus_addons_migrator->new_blogid)) { restore_current_blog(); } }
function generate_page_rewrite_rules() { global $wpdb; $posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_status = 'static' ORDER BY post_parent DESC"); $page_rewrite_rules = array(); if ($posts) { foreach ($posts as $post) { // URI => page name $uri = get_page_uri($post->ID); $page_rewrite_rules[$uri] = $post->post_name; } update_option('page_uris', $page_rewrite_rules); save_mod_rewrite_rules(); } }
/** * Remove rewrite rules and then recreate rewrite rules. * * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' * exists, it will be called. * * @since 2.0.1 * @access public * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ public function flush_rules($hard = true) { delete_option('rewrite_rules'); $this->wp_rewrite_rules(); /** * Filter whether a "hard" rewrite rule flush should be performed when requested. * * A "hard" flush updates .htaccess (Apache) or web.config (IIS). * * @since 3.7.0 * * @param bool $hard Whether to flush rewrite rules "hard". Default true. */ if (!$hard || !apply_filters('flush_rewrite_rules_hard', true)) { return; } if (function_exists('save_mod_rewrite_rules')) { save_mod_rewrite_rules(); } if (function_exists('iis7_save_url_rewrite_rules')) { iis7_save_url_rewrite_rules(); } }