iis7_rewrite_rule_exists

Definition:
function iis7_rewrite_rule_exists($filename) {}

Check if rewrite rule for WordPress already exists in the IIS 7 configuration file

Parameters

  • string $filename: The file path to the configuration file

Source code

function iis7_rewrite_rule_exists($filename) {

	if ( ! file_exists($filename) )

		return false;

	if ( ! class_exists('DOMDocument') )

		return false;



	$doc = new DOMDocument();

	if ( $doc->load($filename) === false )

		return false;

	$xpath = new DOMXPath($doc);

	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');

	if ( $rules->length == 0 )

		return false;

	else

		return true;

}

1969

iis7_delete_rewrite_rule

Definition:
function iis7_delete_rewrite_rule($filename) {}

Delete WordPress rewrite rule from web.config file if it exists there

Parameters

  • string $filename: Name of the configuration file

Source code

function iis7_delete_rewrite_rule($filename) {

	// If configuration file does not exist then rules also do not exist so there is nothing to delete

	if ( ! file_exists($filename) )

		return true;



	if ( ! class_exists('DOMDocument') )

		return false;



	$doc = new DOMDocument();

	$doc->preserveWhiteSpace = false;



	if ( $doc -> load($filename) === false )

		return false;

	$xpath = new DOMXPath($doc);

	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');

	if ( $rules->length > 0 ) {

		$child = $rules->item(0);

		$parent = $child->parentNode;

		$parent->removeChild($child);

		$doc->formatOutput = true;

		saveDomDocument($doc, $filename);

	}

	return true;

}

1967

iis7_add_rewrite_rule

Definition:
function iis7_add_rewrite_rule($filename, $rewrite_rule) {}

Add WordPress rewrite rule to the IIS 7 configuration file.

Parameters

  • string $filename: The file path to the configuration file
  • string $rewrite_rule: The XML fragment with URL Rewrite rule

Source code

function iis7_add_rewrite_rule($filename, $rewrite_rule) {

	if ( ! class_exists('DOMDocument') )

		return false;



	// If configuration file does not exist then we create one.

	if ( ! file_exists($filename) ) {

		$fp = fopen( $filename, 'w');

		fwrite($fp, '<configuration/>');

		fclose($fp);

	}



	$doc = new DOMDocument();

	$doc->preserveWhiteSpace = false;



	if ( $doc->load($filename) === false )

		return false;



	$xpath = new DOMXPath($doc);



	// First check if the rule already exists as in that case there is no need to re-add it

	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');

	if ( $wordpress_rules->length > 0 )

		return true;



	// Check the XPath to the rewrite rule and create XML nodes if they do not exist

	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');

	if ( $xmlnodes->length > 0 ) {

		$rules_node = $xmlnodes->item(0);

	} else {

		$rules_node = $doc->createElement('rules');



		$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');

		if ( $xmlnodes->length > 0 ) {

			$rewrite_node = $xmlnodes->item(0);

			$rewrite_node->appendChild($rules_node);

		} else {

			$rewrite_node = $doc->createElement('rewrite');

			$rewrite_node->appendChild($rules_node);



			$xmlnodes = $xpath->query('/configuration/system.webServer');

			if ( $xmlnodes->length > 0 ) {

				$system_webServer_node = $xmlnodes->item(0);

				$system_webServer_node->appendChild($rewrite_node);

			} else {

				$system_webServer_node = $doc->createElement('system.webServer');

				$system_webServer_node->appendChild($rewrite_node);



				$xmlnodes = $xpath->query('/configuration');

				if ( $xmlnodes->length > 0 ) {

					$config_node = $xmlnodes->item(0);

					$config_node->appendChild($system_webServer_node);

				} else {

					$config_node = $doc->createElement('configuration');

					$doc->appendChild($config_node);

					$config_node->appendChild($system_webServer_node);

				}

			}

		}

	}



	$rule_fragment = $doc->createDocumentFragment();

	$rule_fragment->appendXML($rewrite_rule);

	$rules_node->appendChild($rule_fragment);



	$doc->encoding = "UTF-8";

	$doc->formatOutput = true;

	saveDomDocument($doc, $filename);



	return true;

}

1965

iframe_header

Definition:
function iframe_header( $title = '', $limit_styles = false ) {}

Generic Iframe header for use with Thickbox

Parameters

  • string $title: Title of the Iframe page.
  • bool $limit_styles: Limit styles to colour-related styles only (unless others are enqueued).

Defined actions

  • admin_xml_ns
    do_action('admin_xml_ns');
  • admin_enqueue_scripts
    do_action('admin_enqueue_scripts', $hook_suffix);
  • admin_print_styles-$hook_suffix
    do_action("admin_print_styles-$hook_suffix");
  • admin_print_styles
    do_action('admin_print_styles');
  • admin_print_scripts-$hook_suffix
    do_action("admin_print_scripts-$hook_suffix");
  • admin_print_scripts
    do_action('admin_print_scripts');
  • admin_head-$hook_suffix
    do_action("admin_head-$hook_suffix");
  • admin_head
    do_action('admin_head');

Source code

function iframe_header( $title = '', $limit_styles = false ) {

	show_admin_bar( false );

	global $hook_suffix, $current_screen, $current_user, $admin_body_class, $wp_locale;

	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);

	$admin_body_class .= ' iframe';



?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>

<head>

<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />

<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> — <?php _e('WordPress'); ?></title>

<?php

wp_enqueue_style( 'global' );

if ( ! $limit_styles )

	wp_enqueue_style( 'wp-admin' );

wp_enqueue_style( 'colors' );

?>

<script type="text/javascript">

//<![CDATA[

addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};

function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}

var userSettings = {

		'url': '<?php echo SITECOOKIEPATH; ?>',

		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',

		'time':'<?php echo time() ?>'

	},

	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',

	pagenow = '<?php echo $current_screen->id; ?>',

	typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',

	adminpage = '<?php echo $admin_body_class; ?>',

	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',

	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',

	isRtl = <?php echo (int) is_rtl(); ?>;

//]]>

</script>

<?php

do_action('admin_enqueue_scripts', $hook_suffix);

do_action("admin_print_styles-$hook_suffix");

do_action('admin_print_styles');

do_action("admin_print_scripts-$hook_suffix");

do_action('admin_print_scripts');

do_action("admin_head-$hook_suffix");

do_action('admin_head');

?>

</head>

<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>  class="no-js <?php echo $admin_body_class; ?>">

<script type="text/javascript">

//<![CDATA[

(function(){

var c = document.body.className;

c = c.replace(/no-js/, 'js');

document.body.className = c;

})();

//]]>

</script>

<?php

}

1963

iframe_footer

Definition:
function iframe_footer() {}

Generic Iframe footer for use with Thickbox

Defined actions

  • admin_footer
    do_action('admin_footer', '');
  • admin_print_footer_scripts
    do_action('admin_print_footer_scripts');

Source code

function iframe_footer() {

	//We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>

	<div class="hidden">

<?php

	do_action('admin_footer', '');

	do_action('admin_print_footer_scripts'); ?>

	</div>

<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>

</body>

</html>

<?php

}

1961