Strip lines that contain only whitespace down to newlines.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6025 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-09-03 23:19:20 +00:00
parent d38d018ce9
commit 87c4f3a17f
16 changed files with 111 additions and 111 deletions

View File

@ -1,17 +1,17 @@
<?php
class JeromesKeyword_Import {
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import Jerome&#8217;s Keywords').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
}
function footer() {
echo '</div>';
}
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! This imports tags from an existing Jerome&#8217;s Keywords installation into this blog using the new WordPress native tagging structure.').'</p>';
@ -28,18 +28,18 @@ class JeromesKeyword_Import {
echo '</form>';
echo '</div>';
}
function dispatch () {
if ( empty( $_GET['step'] ) ) {
$step = 0;
} else {
$step = (int) $_GET['step'];
}
// load the header
$this->header();
switch ( $step ) {
case 0 :
$this->greet();
@ -68,18 +68,18 @@ class JeromesKeyword_Import {
$this->done();
break;
}
// load the footer
$this->footer();
}
function check_V1_post_keyword ( $precheck = true ) {
global $wpdb;
echo '<div class="narrow">';
echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
// import Jerome's Keywords tags
$qry = "SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'";
$metakeys = $wpdb->get_results($qry);
@ -89,9 +89,9 @@ class JeromesKeyword_Import {
} else {
$count = count($metakeys);
echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
echo '<ul>';
foreach ($metakeys as $post_meta) {
if ($post_meta->meta_value != '') {
$post_keys = explode(',', $post_meta->meta_value);
@ -109,25 +109,25 @@ class JeromesKeyword_Import {
delete_post_meta($post_meta->post_id, 'keywords');
}
}
echo '</ul>';
}
echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 2:6).'" method="post">';
wp_nonce_field('import-jkw');
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
echo '</form>';
echo '</div>';
}
function check_V2_post_keyword ( $precheck = true ) {
global $wpdb;
echo '<div class="narrow">';
echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
// import Jerome's Keywords tags
$tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
$qry = "SELECT post_id, tag_name FROM $tablename";
@ -139,12 +139,12 @@ class JeromesKeyword_Import {
else {
$count = count($metakeys);
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
echo '<ul>';
foreach($metakeys as $post_meta) {
$keyword = addslashes(trim($post_meta->tag_name));
if ($keyword != ''){
echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
if( !$precheck ){
@ -152,43 +152,43 @@ class JeromesKeyword_Import {
}
}
}
echo '</ul>';
}
echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 4:5).'" method="post">';
wp_nonce_field('import-jkw');
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
echo '</form>';
echo '</div>';
}
function cleanup_V2_import ( ) {
global $wpdb;
/* options from V2.0a (jeromes-keywords.php) */
$options = array(
'version' => '2.0', // keywords options version
'keywords_table' => 'jkeywords', // table where keywords/tags are stored
'query_varname' => 'tag', // HTTP var name used for tag searches
'template' => 'keywords.php', // template file to use for displaying tag queries
'meta_always_include' => '', // meta keywords to always include
'meta_includecats' => 'default', // default' => include cats in meta keywords only for home page
// all' => includes cats on every page, none' => never included
'meta_autoheader' => '1', // automatically output meta keywords in header
'search_strict' => '1', // returns only exact tag matches if true
'use_feed_cats' => '1', // insert tags into feeds as categories
/* post tag options */
'post_linkformat' => '', // post tag format (initialized to $link_localsearch)
'post_tagseparator' => ', ', // tag separator character(s)
'post_includecats' => '0', // include categories in post's tag list
'post_notagstext' => 'none', // text to display if no tags found
/* tag cloud options */
'cloud_linkformat' => '', // post tag format (initialized to $link_tagcloud)
'cloud_tagseparator' => ' ', // tag separator character(s)
@ -199,39 +199,39 @@ class JeromesKeyword_Import {
'cloud_scalemax' => '0', // maximum value for count scaling (no scaling if zero)
'cloud_scalemin' => '0' // minimum value for count scaling
);
$tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
$wpdb->query('DROP TABLE IF EXISTS ' . $tablename);
foreach($options as $optname => $optval) {
delete_option('jkeywords_' . $optname);
}
$this->done();
}
function done ( ) {
echo '<div class="narrow">';
echo '<p><h3>'.__('Import Complete!').'</h3></p>';
echo '</div>';
}
function JeromesKeyword_Import ( ) {
// Nothing.
}
}
// create the import object
$jkw_import = new JeromesKeyword_Import();
// add it to the import page!
register_importer('jkw', 'Jerome&#8217;s Keywords', __('Import Jerome&#8217;s Keywords into the new native tagging structure.'), array($jkw_import, 'dispatch'));
?>

View File

@ -31,7 +31,7 @@ class UTW_Import {
} else {
$step = (int) $_GET['step'];
}
if ( $step > 1 )
check_admin_referer('import-utw');

View File

@ -97,7 +97,7 @@ function insert_with_markers( $filename, $marker, $insertion ) {
function save_mod_rewrite_rules() {
global $wp_rewrite;
$home_path = get_home_path();
$htaccess_file = $home_path.'.htaccess';
@ -109,7 +109,7 @@ function save_mod_rewrite_rules() {
return insert_with_markers( $htaccess_file, 'WordPress', $rules );
}
}
return false;
}

View File

@ -615,7 +615,7 @@ function upgrade_230() {
$name = $wpdb->escape($category->cat_name);
$slug = sanitize_title($name);
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
$term_group = $exists[0]->term_group;

View File

@ -127,7 +127,7 @@ class AtomServer {
if(strlen($path) == 0 || $path == '/') {
$this->redirect($this->get_service_url());
}
// dispatch
foreach($this->selectors as $regex => $funcs) {
if(preg_match($regex, $path, $matches)) {
@ -220,17 +220,17 @@ EOD;
}
$entry = array_pop($parser->feed->entries);
log_app('Received entry:', print_r($entry,true));
$catnames = array();
foreach($entry->categories as $cat)
array_push($catnames, $cat["term"]);
$wp_cats = get_categories(array('hide_empty' => false));
$post_category = array();
foreach($wp_cats as $cat) {
if(in_array($cat->cat_name, $catnames))
array_push($post_category, $cat->cat_ID);
@ -252,7 +252,7 @@ EOD;
$pubtimes = $this->get_publish_time($entry);
$post_date = $pubtimes[0];
$post_date_gmt = $pubtimes[1];
if ( isset( $_SERVER['HTTP_SLUG'] ) )
$post_name = $_SERVER['HTTP_SLUG'];
@ -1113,21 +1113,21 @@ EOD;
}
function rfc3339_str2time($str) {
$match = false;
if(!preg_match("/(\d{4}-\d{2}-\d{2})T(\d{2}\:\d{2}\:\d{2})\.?\d{0,3}(Z|[+-]+\d{2}\:\d{2})/", $str, $match))
return false;
if($match[3] == 'Z')
$match[3] == '+0000';
return strtotime($match[1] . " " . $match[2] . " " . $match[3]);
}
function get_publish_time($entry) {
$pubtime = $this->rfc3339_str2time($entry->published);
if(!$pubtime) {
return array(current_time('mysql'),current_time('mysql',1));
} else {

View File

@ -47,7 +47,7 @@ class AtomParser {
var $current;
function AtomParser() {
$this->feed = new AtomFeed();
$this->current = null;
$this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
@ -87,7 +87,7 @@ class AtomParser {
$fp = fopen($this->FILE, "r");
while ($data = fread($fp, 4096)) {
if($this->debug) $this->content .= $data;
if(!xml_parse($parser, $data, feof($fp))) {
trigger_error(sprintf(__('XML error: %s at line %d')."\n",
xml_error_string(xml_get_error_code($xml_parser)),

View File

@ -8,7 +8,7 @@ function get_bookmark($bookmark_id, $output = OBJECT, $filter = 'raw') {
$link->link_category = array_unique( wp_get_object_terms($link_id, 'link_category', 'fields=ids') );
$link = sanitize_bookmark($link, $filter);
if ( $output == OBJECT ) {
return $link;
} elseif ( $output == ARRAY_A ) {

View File

@ -186,10 +186,10 @@ function get_tag_feed_link($tag_id, $feed = 'rss2') {
$tag_id = (int) $tag_id;
$tag = get_tag($tag_id);
if ( empty($tag) || is_wp_error($tag) )
return false;
$permalink_structure = get_option('permalink_structure');
if ( '' == $permalink_structure ) {

View File

@ -406,7 +406,7 @@ function gzip_compression() {
if ( ( ini_get( 'zlib.output_compression' ) == 'On' || ini_get( 'zlib.output_compression_level' ) > 0 ) || ini_get( 'output_handler' ) == 'ob_gzhandler' ) {
return false;
}
if ( extension_loaded( 'zlib' ) ) {
ob_start( 'ob_gzhandler' );
}

View File

@ -147,7 +147,7 @@ function get_bloginfo($show = '', $filter = 'raw') {
strpos($show, 'directory') === false &&
strpos($show, 'home') === false)
$url = false;
if ( 'display' == $filter ) {
if ( $url )
$output = apply_filters('bloginfo_url', $output, $show);

View File

@ -286,7 +286,7 @@ function register_deactivation_hook($file, $function) {
function _wp_filter_build_unique_id($tag, $function, $priority = 10)
{
global $wp_filter;
// If function then just skip all of the tests and not overwrite the following.
// Static Calling
if( is_string($function) )

View File

@ -421,7 +421,7 @@ class WP_Query {
$array_keys = array('category__in', 'category__not_in', 'category__and',
'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and');
foreach ( $array_keys as $key ) {
if ( !isset($array[$key]))
$array[$key] = array();

View File

@ -827,11 +827,11 @@ if ( !function_exists('wp_rss') ) :
function wp_rss( $url, $num_items = -1 ) {
if ( $rss = fetch_rss( $url ) ) {
echo '<ul>';
if ( $num_items !== -1 ) {
$rss->items = array_slice( $rss->items, 0, $num_items );
}
foreach ( $rss->items as $item ) {
printf(
'<li><a href="%1$s" title="%2$s">%3$s</a></li>',
@ -840,7 +840,7 @@ function wp_rss( $url, $num_items = -1 ) {
htmlentities( $item['title'] )
);
}
echo '</ul>';
} else {
_e( 'An error has occurred, which probably means the feed is down. Try again later.' );

View File

@ -8,7 +8,7 @@ function wp_version_check() {
global $wp_version;
$php_version = phpversion();
$current = get_option( 'update_core' );
$locale = get_locale();
@ -35,11 +35,11 @@ function wp_version_check() {
while ( !feof( $fs ) )
$response .= fgets( $fs, 1160 ); // One TCP-IP packet
fclose( $fs );
$response = explode("\r\n\r\n", $response, 2);
$body = trim( $response[1] );
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
$new_option->response = $returns[0];

View File

@ -606,11 +606,11 @@ function wp_widget_text_register() {
function wp_widget_categories($args, $number = 1) {
extract($args);
$options = get_option('widget_categories');
$c = $options[$number]['count'] ? '1' : '0';
$h = $options[$number]['hierarchical'] ? '1' : '0';
$d = $options[$number]['dropdown'] ? '1' : '0';
$title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title'];
echo $before_widget;
@ -646,60 +646,60 @@ function wp_widget_categories($args, $number = 1) {
function wp_widget_categories_control( $number ) {
$options = $newoptions = get_option('widget_categories');
if ( !is_array( $options ) ) {
$options = $newoptions = get_option( 'widget_categories' );
}
if ( $_POST['categories-submit-' . $number] ) {
$newoptions[$number]['count'] = isset($_POST['categories-count-' . $number]);
$newoptions[$number]['hierarchical'] = isset($_POST['categories-hierarchical-' . $number]);
$newoptions[$number]['dropdown'] = isset($_POST['categories-dropdown-' . $number]);
$newoptions[$number]['title'] = strip_tags(stripslashes($_POST['categories-title-' . $number]));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_categories', $options);
}
$title = attribute_escape( $options[$number]['title'] );
?>
<p><label for="categories-title-<?php echo $number; ?>">
<?php _e( 'Title:' ); ?> <input style="width:300px" id="categories-title-<?php echo $number; ?>" name="categories-title-<?php echo $number; ?>" type="text" value="<?php echo $title; ?>" />
</label></p>
<p><label for="categories-dropdown-<?php echo $number; ?>">
<input type="checkbox" class="checkbox" id="categories-dropdown-<?php echo $number; ?>" name="categories-dropdown-<?php echo $number; ?>"<?php echo $options[$number]['dropdown'] ? ' checked="checked"' : ''; ?> /> <?php _e( 'Show as dropdown' ); ?>
</label></p>
<p><label for="categories-count-<?php echo $number; ?>">
<input type="checkbox" class="checkbox" id="categories-count-<?php echo $number; ?>" name="categories-count-<?php echo $number; ?>"<?php echo $options[$number]['count'] ? ' checked="checked"' : ''; ?> /> <?php _e( 'Show post counts' ); ?>
</label></p>
<p><label for="categories-hierarchical-<?php echo $number; ?>">
<input type="checkbox" class="checkbox" id="categories-hierarchical-<?php echo $number; ?>" name="categories-hierarchical-<?php echo $number; ?>"<?php echo $options[$number]['hierarchical'] ? ' checked="checked"' : ''; ?> /> <?php _e( 'Show hierarchy' ); ?>
</label></p>
<input type="hidden" id="categories-submit-<?php echo $number; ?>" name="categories-submit-<?php echo $number; ?>" value="1" />
<?php
}
function wp_widget_categories_setup() {
$options = $newoptions = get_option( 'widget_categories' );
if ( isset( $_POST['categories-number-submit'] ) ) {
$number = (int) $_POST['categories-number'];
if ( $number > 9 ) {
$number = 9;
} elseif ( $number < 1 ) {
$number = 1;
}
$newoptions['number'] = $number;
}
if ( $newoptions != $options ) {
$options = $newoptions;
update_option( 'widget_categories', $options );
@ -770,27 +770,27 @@ function wp_widget_categories_register() {
if ( !isset($options['number']) )
$options = wp_widget_categories_upgrade();
$number = (int) $options['number'];
if ( $number > 9 ) {
$number = 9;
} elseif ( $number < 1 ) {
$number = 1;
}
$dims = array( 'width' => 350, 'height' => 170 );
$class = array( 'classname' => 'widget_catgories' );
for ( $i = 1; $i <= 9; $i++ ) {
$name = sprintf( __( 'Categories %d' ), $i );
$id = 'categories-' . $i;
$widget_callback = ( $i <= $number ) ? 'wp_widget_categories' : '';
$control_callback = ( $i <= $number ) ? 'wp_widget_categories_control' : '';
wp_register_sidebar_widget( $id, $name, $widget_callback, $class, $i );
wp_register_widget_control( $id, $name, $control_callback, $dims, $i );
}
add_action( 'sidebar_admin_setup', 'wp_widget_categories_setup' );
add_action( 'sidebar_admin_page', 'wp_widget_categories_page' );
}
@ -985,7 +985,7 @@ function wp_widget_rss($args, $number = 1) {
} else {
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
}
echo $after_widget;
}
@ -1079,37 +1079,37 @@ function wp_widgets_init() {
return;
$GLOBALS['wp_register_widget_defaults'] = true;
$dims90 = array( 'height' => 90, 'width' => 300 );
$dims100 = array( 'height' => 100, 'width' => 300 );
$dims150 = array( 'height' => 150, 'width' => 300 );
$class = array('classname' => 'widget_pages');
wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $class);
wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims150);
$class['classname'] = 'widget_calendar';
wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $class);
wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control', $dims90);
$class['classname'] = 'widget_archives';
wp_register_sidebar_widget('archives', __('Archives'), 'wp_widget_archives', $class);
wp_register_widget_control('archives', __('Archives'), 'wp_widget_archives_control', $dims100);
$class['classname'] = 'widget_links';
wp_register_sidebar_widget('links', __('Links'), 'wp_widget_links', $class);
$class['classname'] = 'widget_meta';
wp_register_sidebar_widget('meta', __('Meta'), 'wp_widget_meta', $class);
wp_register_widget_control('meta', __('Meta'), 'wp_widget_meta_control', $dims90);
$class['classname'] = 'widget_search';
wp_register_sidebar_widget('search', __('Search'), 'wp_widget_search', $class);
$class['classname'] = 'widget_recent_entries';
wp_register_sidebar_widget('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries', $class);
wp_register_widget_control('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries_control', $dims90);
wp_widget_categories_register();
wp_widget_text_register();
wp_widget_rss_register();

View File

@ -42,7 +42,7 @@ if ( empty( $_SERVER['REQUEST_URI'] ) ) {
$_SERVER['REQUEST_URI'] = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')) . '/';
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
// Append the query string if it exists and isn't null
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];