+ wp_ob_end_flush_all();
+ flush();
+}
+
+function wp_doc_link_parse( $content ) {
+ if ( !is_string( $content ) || empty( $content ) )
+ return array();
+
+ if ( !function_exists('token_get_all') )
+ return array();
+
+ $tokens = token_get_all( $content );
+ $functions = array();
+ $ignore_functions = array();
+ for ( $t = 0, $count = count( $tokens ); $t < $count; $t++ ) {
+ if ( !is_array( $tokens[$t] ) ) continue;
+ if ( T_STRING == $tokens[$t][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
+ // If it's a function or class defined locally, there's not going to be any docs available
+ if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
+ $ignore_functions[] = $tokens[$t][1];
+ }
+ // Add this to our stack of unique references
+ $functions[] = $tokens[$t][1];
+ }
+ }
+
+ $functions = array_unique( $functions );
+ sort( $functions );
+ $ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
+ $ignore_functions = array_unique( $ignore_functions );
+
+ $out = array();
+ foreach ( $functions as $function ) {
+ if ( in_array( $function, $ignore_functions ) )
+ continue;
+ $out[] = $function;
+ }
+
+ return $out;
+}
+
+/**
+ * Saves option for number of rows when listing posts, pages, comments, etc.
+ *
+ * @since 2.8
+**/
+function set_screen_options() {
+
+ if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
+ check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
+
+ if ( !$user = wp_get_current_user() )
+ return;
+ $option = $_POST['wp_screen_options']['option'];
+ $value = $_POST['wp_screen_options']['value'];
+
+ if ( $option != sanitize_key( $option ) )
+ return;
+
+ $map_option = $option;
+ $type = str_replace('edit_', '', $map_option);
+ $type = str_replace('_per_page', '', $type);
+ if ( in_array( $type, get_taxonomies() ) )
+ $map_option = 'edit_tags_per_page';
+ elseif ( in_array( $type, get_post_types() ) )
+ $map_option = 'edit_per_page';
+ else
+ $option = str_replace('-', '_', $option);
+
+ switch ( $map_option ) {
+ case 'edit_per_page':
+ case 'users_per_page':
+ case 'edit_comments_per_page':
+ case 'upload_per_page':
+ case 'edit_tags_per_page':
+ case 'plugins_per_page':
+ // Network admin
+ case 'sites_network_per_page':
+ case 'users_network_per_page':
+ case 'site_users_network_per_page':
+ case 'plugins_network_per_page':
+ case 'themes_network_per_page':
+ case 'site_themes_network_per_page':
+ $value = (int) $value;
+ if ( $value < 1 || $value > 999 )
+ return;
+ break;
+ default:
+ $value = apply_filters('set-screen-option', false, $option, $value);
+ if ( false === $value )
+ return;
+ break;
+ }
+
+ update_user_meta($user->ID, $option, $value);
+ wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
+ exit;
+ }
+}
+
+/**
+ * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file
+ *
+ * @since 2.8.0
+ *
+ * @return bool
+ * @param string $filename The file path to the configuration file
+ */
+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;
+}
+
+/**
+ * Delete WordPress rewrite rule from web.config file if it exists there
+ *
+ * @since 2.8.0
+ *
+ * @param string $filename Name of the configuration file
+ * @return bool
+ */
+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;