本文整理汇总了PHP中iis7_supports_permalinks函数的典型用法代码示例。如果您正苦于以下问题:PHP iis7_supports_permalinks函数的具体用法?PHP iis7_supports_permalinks怎么用?PHP iis7_supports_permalinks使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iis7_supports_permalinks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_analyze_page
public function do_analyze_page()
{
$rewrite_rules = $GLOBALS['wp_rewrite']->wp_rewrite_rules();
$rewrite_rules_ui = array();
$public_query_vars = apply_filters('query_vars', $GLOBALS['wp']->public_query_vars);
$rewrite_patterns = array();
// URL prefix
$prefix = '';
if (!got_mod_rewrite() && !iis7_supports_permalinks()) {
$prefix = '/index.php';
}
$url_prefix = get_option('home') . $prefix . '/';
$idx = 0;
if ($rewrite_rules) {
foreach ($rewrite_rules as $pattern => $substitution) {
$idx++;
$rewrite_patterns[$idx] = addslashes($pattern);
$rewrite_rule_ui = array('pattern' => $pattern);
try {
$regex_tree = Monkeyman_Regex::parse($pattern);
} catch (Exception $e) {
$rewrite_rule_ui['error'] = $e;
}
$regex_groups = self::collect_groups($regex_tree);
$rewrite_rule_ui['print'] = self::print_regex($regex_tree, $idx);
$substitution_parts = self::parse_substitution($substitution);
$substitution_parts_ui = array();
foreach ($substitution_parts as $query_var => $query_value) {
$substitution_part_ui = array('query_var' => $query_var, 'query_value' => $query_value);
$query_value_ui = $query_value;
// Replace `$matches[DD]` with URL regex part
// This is so complicated to handle situations where `$query_value` contains multiple `$matches[DD]`
$query_value_replacements = array();
if (preg_match_all('/\\$matches\\[(\\d+)\\]/', $query_value, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[0] as $m_idx => $match) {
$regex_group_idx = $matches[1][$m_idx][0];
$query_value_replacements[$match[1]] = array('replacement' => self::print_regex($regex_groups[$regex_group_idx], $idx, true), 'length' => strlen($match[0]), 'offset' => $match[1]);
}
}
krsort($query_value_replacements);
foreach ($query_value_replacements as $query_value_replacement) {
$query_value_ui = substr_replace($query_value_ui, $query_value_replacement['replacement'], $query_value_replacement['offset'], $query_value_replacement['length']);
}
$substitution_part_ui['query_value_ui'] = $query_value_ui;
// Highlight non-public query vars
$substitution_part_ui['is_public'] = in_array($query_var, $public_query_vars);
$substitution_parts_ui[] = $substitution_part_ui;
}
$rewrite_rule_ui['substitution_parts'] = $substitution_parts_ui;
$rewrite_rules_ui[$idx] = $rewrite_rule_ui;
}
}
wp_localize_script($this->gettext_domain, 'Monkeyman_Rewrite_Analyzer_Regexes', $rewrite_patterns);
$gettext_domain = $this->gettext_domain;
include dirname($this->base_file) . '/ui/rewrite-analyzer.php';
}
示例2: structure
/**
* Update the permalink structure.
*
* ## DESCRIPTION
*
* Updates the post permalink structure.
*
* To regenerate a .htaccess file with WP-CLI, you'll need to add the mod_rewrite module
* to your wp-cli.yml or config.yml. For example:
*
* apache_modules:
* - mod_rewrite
*
* ## OPTIONS
*
* <permastruct>
* : The new permalink structure to apply.
*
* [--category-base=<base>]
* : Set the base for category permalinks, i.e. '/category/'.
*
* [--tag-base=<base>]
* : Set the base for tag permalinks, i.e. '/tag/'.
*
* [--hard]
* : Perform a hard flush - update `.htaccess` rules as well as rewrite rules in database.
*
* ## EXAMPLES
*
* wp rewrite structure '/%year%/%monthnum%/%postname%'
*/
public function structure($args, $assoc_args)
{
global $wp_rewrite;
// copypasta from /wp-admin/options-permalink.php
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$prefix = $blog_prefix = '';
if (!got_mod_rewrite() && !$iis7_permalinks) {
$prefix = '/index.php';
}
if (is_multisite() && !is_subdomain_install() && is_main_site()) {
$blog_prefix = '/blog';
}
$permalink_structure = $args[0] == 'default' ? '' : $args[0];
if (!empty($permalink_structure)) {
$permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
if ($prefix && $blog_prefix) {
$permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
} else {
$permalink_structure = $blog_prefix . $permalink_structure;
}
}
$wp_rewrite->set_permalink_structure($permalink_structure);
// Update category or tag bases
if (isset($assoc_args['category-base'])) {
$category_base = $assoc_args['category-base'];
if (!empty($category_base)) {
$category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
}
$wp_rewrite->set_category_base($category_base);
}
if (isset($assoc_args['tag-base'])) {
$tag_base = $assoc_args['tag-base'];
if (!empty($tag_base)) {
$tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
}
$wp_rewrite->set_tag_base($tag_base);
}
// make sure we detect mod_rewrite if configured in apache_modules in config
self::apache_modules();
// Launch a new process to flush rewrites because core expects flush
// to happen after rewrites are set
$new_assoc_args = array();
if (\WP_CLI\Utils\get_flag_value($assoc_args, 'hard')) {
$new_assoc_args['hard'] = true;
if (!in_array('mod_rewrite', (array) WP_CLI::get_config('apache_modules'))) {
WP_CLI::warning("Regenerating a .htaccess file requires special configuration. See usage docs.");
}
}
$process_run = WP_CLI::launch_self('rewrite flush', array(), $new_assoc_args, true, true, array('apache_modules', WP_CLI::get_config('apache_modules')));
if (!empty($process_run->stderr)) {
// Strip "Warning: "
WP_CLI::warning(substr($process_run->stderr, 9));
}
WP_CLI::success("Rewrite structure set.");
}
示例3: structure
/**
* Update the permalink structure.
*
* ## OPTIONS
*
* <permastruct>
* : The new permalink structure to apply.
*
* [--category-base=<base>]
* : Set the base for category permalinks, i.e. '/category/'.
*
* [--tag-base=<base>]
* : Set the base for tag permalinks, i.e. '/tag/'.
*
* [--hard]
* : Perform a hard flush - update `.htaccess` rules as well as rewrite rules in database.
*
* ## EXAMPLES
*
* wp rewrite structure '/%year%/%monthnum%/%postname%'
*/
public function structure($args, $assoc_args)
{
global $wp_rewrite;
// copypasta from /wp-admin/options-permalink.php
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$prefix = $blog_prefix = '';
if (!got_mod_rewrite() && !$iis7_permalinks) {
$prefix = '/index.php';
}
if (is_multisite() && !is_subdomain_install() && is_main_site()) {
$blog_prefix = '/blog';
}
$permalink_structure = $args[0] == 'default' ? '' : $args[0];
if (!empty($permalink_structure)) {
$permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
if ($prefix && $blog_prefix) {
$permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
} else {
$permalink_structure = $blog_prefix . $permalink_structure;
}
}
$wp_rewrite->set_permalink_structure($permalink_structure);
// Update category or tag bases
if (isset($assoc_args['category-base'])) {
$category_base = $assoc_args['category-base'];
if (!empty($category_base)) {
$category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
}
$wp_rewrite->set_category_base($category_base);
}
if (isset($assoc_args['tag-base'])) {
$tag_base = $assoc_args['tag-base'];
if (!empty($tag_base)) {
$tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
}
$wp_rewrite->set_tag_base($tag_base);
}
// make sure we detect mod_rewrite if configured in apache_modules in config
self::apache_modules();
// Launch a new process to flush rewrites because core expects flush
// to happen after rewrites are set
$new_assoc_args = array();
if (isset($assoc_args['hard'])) {
$new_assoc_args['hard'] = true;
}
\WP_CLI::launch_self('rewrite flush', array(), $new_assoc_args);
WP_CLI::success("Rewrite structure set.");
}
示例4: structure
/**
* Set permalink structure
*
* @param array $args
* @param array $assoc_args
*/
public function structure($args, $assoc_args)
{
if (!count($args) && !count($assoc_args)) {
WP_CLI::line("usage: wp rewrite structure <new-permalink-structure>");
exit;
}
global $wp_rewrite;
// copypasta from /wp-admin/options-permalink.php
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$prefix = $blog_prefix = '';
if (!got_mod_rewrite() && !$iis7_permalinks) {
$prefix = '/index.php';
}
if (is_multisite() && !is_subdomain_install() && is_main_site()) {
$blog_prefix = '/blog';
}
// Update base permastruct if argument is provided
if (isset($args[0])) {
$permalink_structure = $args[0] == 'default' ? '' : $args[0];
if (!empty($permalink_structure)) {
$permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
if ($prefix && $blog_prefix) {
$permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
} else {
$permalink_structure = $blog_prefix . $permalink_structure;
}
}
$wp_rewrite->set_permalink_structure($permalink_structure);
}
// Update category or tag bases
if (isset($assoc_args['category-base'])) {
$category_base = $assoc_args['category-base'];
if (!empty($category_base)) {
$category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
}
$wp_rewrite->set_category_base($category_base);
}
if (isset($assoc_args['tag-base'])) {
$tag_base = $assoc_args['tag-base'];
if (!empty($tag_base)) {
$tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
}
$wp_rewrite->set_tag_base($tag_base);
}
flush_rewrite_rules($hard);
}
示例5: bogo_post_rewrite_rules
function bogo_post_rewrite_rules($post_rewrite)
{
global $wp_rewrite;
$permastruct = $wp_rewrite->permalink_structure;
// from wp-admin/includes/misc.php
$got_rewrite = apply_filters('got_rewrite', apache_mod_loaded('mod_rewrite', true));
$got_url_rewrite = apply_filters('got_url_rewrite', $got_rewrite || $GLOBALS['is_nginx'] || iis7_supports_permalinks());
if (!$got_url_rewrite) {
$permastruct = preg_replace('#^/index\\.php#', '/index.php/%lang%', $permastruct);
} elseif (is_multisite() && !is_subdomain_install() && is_main_site()) {
$permastruct = preg_replace('#^/blog#', '/%lang%/blog', $permastruct);
} else {
$permastruct = preg_replace('#^/#', '/%lang%/', $permastruct);
}
$extra = bogo_generate_rewrite_rules($permastruct, array('ep_mask' => EP_PERMALINK, 'paged' => false));
return array_merge($extra, $post_rewrite);
}
示例6: aletheme_activation_is_config_writable
function aletheme_activation_is_config_writable()
{
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
if ($iis7_permalinks) {
if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
$config_writable = true;
} else {
$config_writable = false;
}
} else {
if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
$config_writable = true;
} else {
$config_writable = false;
}
}
return $config_writable;
}
示例7: modify_permalinks
function modify_permalinks($permalink_structure, $page_structure)
{
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
global $wp_rewrite;
# set the structure
$wp_rewrite->set_permalink_structure($permalink_structure);
$wp_rewrite->page_structure = $page_structure;
# get paths
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
# check if there is a file to rewrite
if ($iis7_permalinks) {
$writable = !file_exists($home_path . 'web.config') && win_is_writable($home_path);
$writable = $writable || win_is_writable($home_path . 'web.config');
} else {
$writable = !file_exists($home_path . '.htaccess') && is_writable($home_path);
$writable = $writable || is_writable($home_path . '.htaccess');
}
# flush the rules
update_option('rewrite_rules', FALSE);
$wp_rewrite->flush_rules($writable);
}
示例8: step_permalinks_save
function step_permalinks_save()
{
global $nxt_rewrite, $current_site, $current_blog;
// Prevent debug notices
$iis7_permalinks = $usingpi = $writable = false;
if (isset($_POST['submit'])) {
check_admin_referer('bpwizard_permalinks');
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
if (isset($_POST['permalink_structure'])) {
$permalink_structure = $_POST['permalink_structure'];
if (!empty($permalink_structure)) {
$permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
}
if (defined('VHOST') && constant('VHOST') == 'no' && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path) {
$permalink_structure = '/blog' . $permalink_structure;
}
$nxt_rewrite->set_permalink_structure($permalink_structure);
}
if (!empty($iis7_permalinks)) {
if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
$writable = true;
}
} else {
if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
$writable = true;
}
}
if ($nxt_rewrite->using_index_permalinks()) {
$usingpi = true;
}
$nxt_rewrite->flush_rules();
if (!empty($iis7_permalinks) || empty($usingpi) && empty($writable)) {
function _bp_core_wizard_step_permalinks_message()
{
global $nxt_rewrite;
?>
<div id="message" class="updated fade"><p>
<?php
_e('Oops, there was a problem creating a configuration file. ', 'buddypress');
if (!empty($iis7_permalinks)) {
if (!empty($permalink_structure) && empty($usingpi) && empty($writable)) {
_e('If your <code>web.config</code> file were <a href="http://codex.nxtclass.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.');
?>
<br /><br />
<textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php
echo esc_html($nxt_rewrite->iis7_url_rewrite_rules());
?>
</textarea>
<?php
} else {
if (!empty($permalink_structure) && empty($usingpi) && !empty($writable)) {
}
}
_e('Permalink structure updated. Remove write access on web.config file now!');
} else {
_e('If your <code>.htaccess</code> file were <a href="http://codex.nxtclass.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.');
?>
<br /><br />
<textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php
echo esc_html($nxt_rewrite->mod_rewrite_rules());
?>
</textarea>
<?php
}
?>
<br /><br />
<?php
if (empty($iis7_permalinks)) {
_e('Paste all these rules into a new <code>.htaccess</code> file in the root of your NXTClass installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress');
}
?>
</p></div>
<?php
}
if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && !empty($_POST['skip-htaccess'])) {
return true;
} else {
add_action('bp_admin_notices', '_bp_core_wizard_step_permalinks_message');
return false;
}
}
return true;
}
return false;
}
示例9: save_file_cache
function save_file_cache()
{
if (iis7_supports_permalinks()) {
return;
}
global $rhc_plugin;
if ('1' == $rhc_plugin->get_option('file_cache', '', true)) {
$content = $this->get_htaccess();
$rules_arr = explode("\n", $content);
} else {
$rules_arr = array();
}
$filename = get_home_path() . '.htaccess';
if (file_exists($filename) && is_writeable($filename)) {
$str = file_get_contents($filename);
if (false === strpos($str, 'BEGIN RHC')) {
$prepend = "# BEGIN RHC\n";
$prepend .= "# END RHC\n";
$str = $prepend . $str;
file_put_contents($filename, $str);
}
}
insert_with_markers($filename, 'RHC', $rules_arr);
}
示例10: check_canonical_url
public function check_canonical_url($requested_url = '', $do_redirect = true)
{
global $wp_query, $post, $is_IIS;
// don't redirect in same cases as WP
if (is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || $is_IIS && !iis7_supports_permalinks()) {
return;
}
// don't redirect mysite.com/?attachment_id= to mysite.com/en/?attachment_id=
if (1 == $this->options['force_lang'] && is_attachment() && isset($_GET['attachment_id'])) {
return;
}
// if the default language code is not hidden and the static front page url contains the page name
// the customizer lands here and the code below would redirect to the list of posts
if (isset($_POST['wp_customize'], $_POST['customized'])) {
return;
}
// don't redirect if we are on a static front page
if ($this->options['redirect_lang'] && isset($this->page_on_front) && is_page($this->page_on_front)) {
return;
}
if (empty($requested_url)) {
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
if (is_single() || is_page()) {
if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type)) {
$language = $this->model->get_post_language((int) $post->ID);
}
} elseif (is_category() || is_tag() || is_tax()) {
$obj = $wp_query->get_queried_object();
if ($this->model->is_translated_taxonomy($obj->taxonomy)) {
$language = $this->model->get_term_language((int) $obj->term_id);
}
} elseif ($wp_query->is_posts_page) {
$obj = $wp_query->get_queried_object();
$language = $this->model->get_post_language((int) $obj->ID);
}
if (empty($language)) {
$language = $this->curlang;
$redirect_url = $requested_url;
} else {
// first get the canonical url evaluated by WP
$redirect_url = !($redirect_url = redirect_canonical($requested_url, false)) ? $requested_url : $redirect_url;
// then get the right language code in url
$redirect_url = $this->options['force_lang'] ? $this->links_model->switch_language_in_link($redirect_url, $language) : $this->links_model->remove_language_from_link($redirect_url);
// works only for default permalinks
}
// allow plugins to change the redirection or even cancel it by setting $redirect_url to false
$redirect_url = apply_filters('pll_check_canonical_url', $redirect_url, $language);
// the language is not correctly set so let's redirect to the correct url for this object
if ($do_redirect && $redirect_url && $requested_url != $redirect_url) {
wp_redirect($redirect_url, 301);
exit;
}
return $redirect_url;
}
示例11: redirect_canonical
/**
* Redirects incoming links to the proper URL based on the site url.
*
* Search engines consider www.somedomain.com and somedomain.com to be two
* different URLs when they both go to the same location. This SEO enhancement
* prevents penalty for duplicate content by redirecting all incoming links to
* one or the other.
*
* Prevents redirection for feeds, trackbacks, searches, comment popup, and
* admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+,
* page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST
* requests.
*
* Will also attempt to find the correct link when a user enters a URL that does
* not exist based on exact WordPress query. Will instead try to parse the URL
* or query in an attempt to figure the correct page to go to.
*
* @since 2.3.0
*
* @global WP_Rewrite $wp_rewrite
* @global bool $is_IIS
* @global WP_Query $wp_query
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $requested_url Optional. The URL that was requested, used to
* figure if redirect is needed.
* @param bool $do_redirect Optional. Redirect to the new URL.
* @return string|void The string of the URL, if redirect needed.
*/
function redirect_canonical($requested_url = null, $do_redirect = true)
{
global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
if (isset($_SERVER['REQUEST_METHOD']) && !in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('GET', 'HEAD'))) {
return;
}
// If we're not in wp-admin and the post has been published and preview nonce
// is non-existent or invalid then no need for preview in query
if (is_preview() && get_query_var('p') && 'publish' == get_post_status(get_query_var('p'))) {
if (!isset($_GET['preview_id']) || !isset($_GET['preview_nonce']) || !wp_verify_nonce($_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'])) {
$wp_query->is_preview = false;
}
}
if (is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || $is_IIS && !iis7_supports_permalinks()) {
return;
}
if (!$requested_url && isset($_SERVER['HTTP_HOST'])) {
// build the URL in the address bar
$requested_url = is_ssl() ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];
$requested_url .= $_SERVER['REQUEST_URI'];
}
$original = @parse_url($requested_url);
if (false === $original) {
return;
}
$redirect = $original;
$redirect_url = false;
// Notice fixing
if (!isset($redirect['path'])) {
$redirect['path'] = '';
}
if (!isset($redirect['query'])) {
$redirect['query'] = '';
}
// If the original URL ended with non-breaking spaces, they were almost
// certainly inserted by accident. Let's remove them, so the reader doesn't
// see a 404 error with no obvious cause.
$redirect['path'] = preg_replace('|(%C2%A0)+$|i', '', $redirect['path']);
// It's not a preview, so remove it from URL
if (get_query_var('preview')) {
$redirect['query'] = remove_query_arg('preview', $redirect['query']);
}
if (is_feed() && ($id = get_query_var('p'))) {
if ($redirect_url = get_post_comments_feed_link($id, get_query_var('feed'))) {
$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url);
$redirect['path'] = parse_url($redirect_url, PHP_URL_PATH);
}
}
if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) {
$vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM {$wpdb->posts} WHERE ID = %d", $id));
if (isset($vars[0]) && ($vars = $vars[0])) {
if ('revision' == $vars->post_type && $vars->post_parent > 0) {
$id = $vars->post_parent;
}
if ($redirect_url = get_permalink($id)) {
$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
}
}
}
// These tests give us a WP-generated permalink
if (is_404()) {
// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
$id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
if ($id && ($redirect_post = get_post($id))) {
$post_type_obj = get_post_type_object($redirect_post->post_type);
if ($post_type_obj->public) {
$redirect_url = get_permalink($redirect_post);
$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
}
}
//.........这里部分代码省略.........
示例12: bps_check_iis_supports_permalinks
function bps_check_iis_supports_permalinks()
{
global $wp_rewrite, $is_IIS, $is_iis7, $current_user;
$user_id = $current_user->ID;
if (current_user_can('manage_options') && $is_IIS && !iis7_supports_permalinks()) {
if (!get_user_meta($user_id, 'bps_ignore_iis_notice')) {
if (esc_html($_SERVER['QUERY_STRING']) == '' && basename(esc_html($_SERVER['REQUEST_URI'])) != 'wp-admin') {
$bps_base = basename(esc_html($_SERVER['REQUEST_URI'])) . '?';
} elseif (esc_html($_SERVER['QUERY_STRING']) == '' && basename(esc_html($_SERVER['REQUEST_URI'])) == 'wp-admin') {
$bps_base = basename(str_replace('wp-admin', 'index.php?', esc_html($_SERVER['REQUEST_URI'])));
} else {
$bps_base = str_replace(admin_url(), '', esc_html($_SERVER['REQUEST_URI'])) . '&';
}
$text = '<div class="update-nag" style="background-color:#ffffe0;font-size:1em;font-weight:bold;padding:2px 5px;margin-top:2px;"><font color="red">' . __('WARNING! BPS has detected that your Server is a Windows IIS Server that does not support htaccess rewriting.', 'bulletproof-security') . '</font><br>' . __('Do NOT activate BulletProof Modes unless you know what you are doing.', 'bulletproof-security') . '<br>' . __('Your Server Type is: ', 'bulletproof-security') . $_SERVER['SERVER_SOFTWARE'] . '<br><a href="http://codex.wordpress.org/Using_Permalinks" target="_blank" title="This link will open in a new browser window.">' . __('WordPress Codex - Using Permalinks - see IIS section', 'bulletproof-security') . '</a><br>' . __('To Dismiss this Notice click the Dismiss Notice button below. To Reset Dismiss Notices click the Reset|Recheck Dismiss Notices button on the Security Status page.', 'bulletproof-security') . '<br><div style="float:left;margin:3px 0px 3px 0px;padding:2px 6px 2px 6px;background-color:#e8e8e8;border:1px solid gray;"><a href="' . $bps_base . 'bps_iis_nag_ignore=0' . '" style="text-decoration:none;font-weight:bold;">' . __('Dismiss Notice', 'bulletproof-security') . '</a></div></div>';
echo $text;
}
}
}
示例13: bps_check_iis_supports_permalinks
function bps_check_iis_supports_permalinks()
{
global $wp_rewrite, $is_IIS, $is_iis7;
if ($is_IIS && !iis7_supports_permalinks()) {
$text = '<br><font color="red"><strong>' . __('WARNING! BPS has detected that your Server is a Windows IIS Server that does not support .htaccess rewriting. Do NOT activate BulletProof Security Modes unless you are absolutely sure you know what you are doing. Your Server Type is: ', 'bulletproof-security') . $_SERVER['SERVER_SOFTWARE'] . '</strong></font><br><strong><a href="http://codex.wordpress.org/Using_Permalinks" target="_blank">' . __(' WordPress Codex - Using Permalinks - see IIS section ', 'bulletproof-security') . '</a></strong><br><strong>' . __('This link will open in a new browser window. You will not be directed away from your WordPress Dashboard.', 'bulletproof-security') . '</strong><br>' . __('To remove this message permanently click ', 'bulletproof-security') . '<strong><a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">' . __('here.', 'bulletproof-security') . '</a></strong><br>';
echo $text;
} else {
echo '';
}
}
示例14: dirname
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once dirname(__FILE__) . '/admin.php';
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to manage options for this site.'));
}
$title = __('Permalink Settings');
$parent_file = 'options-general.php';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . __('Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change — hence the name permalink.') . '</p>' . '<p>' . __('This screen allows you to choose your default permalink structure. You can choose from common settings or create custom URL structures.') . '</p>' . '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'common-settings', 'title' => __('Common Settings'), 'content' => '<p>' . __('Many people choose to use “pretty permalinks,” URLs that contain useful information such as the post title rather than generic post ID numbers. You can choose from any of the permalink formats under Common Settings, or can craft your own if you select Custom Structure.') . '</p>' . '<p>' . __('If you pick an option other than Default, your general URL path with structure tags, terms surrounded by <code>%</code>, will also appear in the custom structure field and your path can be further modified there.') . '</p>' . '<p>' . __('When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes <code>%category%</code> or <code>%tag%</code>.') . '</p>' . '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'custom-structures', 'title' => __('Custom Structures'), 'content' => '<p>' . __('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.') . '</p>' . '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>'));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Settings_Permalinks_Screen" target="_blank">Documentation on Permalinks Settings</a>') . '</p>' . '<p>' . __('<a href="https://codex.wordpress.org/Using_Permalinks" target="_blank">Documentation on Using Permalinks</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
add_filter('admin_head', 'options_permalink_add_js');
$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';
}
if (isset($_POST['permalink_structure']) || isset($_POST['category_base'])) {
check_admin_referer('update-permalink');
if (isset($_POST['permalink_structure'])) {
if (isset($_POST['selection']) && 'custom' != $_POST['selection']) {
$permalink_structure = $_POST['selection'];
} else {
$permalink_structure = $_POST['permalink_structure'];
}
示例15: iis7_save_url_rewrite_rules
/**
* Updates the IIS web.config file with the current rules if it is writable.
* If the permalinks do not require rewrite rules then the rules are deleted from the web.config file.
*
* @since 2.8.0
*
* @global WP_Rewrite $wp_rewrite
*
* @return bool True if web.config was updated successfully
*/
function iis7_save_url_rewrite_rules()
{
if (is_multisite()) {
return;
}
global $wp_rewrite;
$home_path = get_home_path();
$web_config_file = $home_path . 'web.config';
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
if (iis7_supports_permalinks() && (!file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() || win_is_writable($web_config_file))) {
$rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
if (!empty($rule)) {
return iis7_add_rewrite_rule($web_config_file, $rule);
} else {
return iis7_delete_rewrite_rule($web_config_file);
}
}
return false;
}