mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
New dashboard from mdawaffe. see #5750
git-svn-id: https://develop.svn.wordpress.org/trunk@6705 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+190
-61
@@ -221,9 +221,10 @@ function dynamic_sidebar($index = 1) {
|
||||
|
||||
$did_one = false;
|
||||
foreach ( $sidebars_widgets[$index] as $id ) {
|
||||
$callback = $wp_registered_widgets[$id]['callback'];
|
||||
|
||||
$params = array_merge(array($sidebar), (array) $wp_registered_widgets[$id]['params']);
|
||||
$params = array_merge(
|
||||
array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
|
||||
(array) $wp_registered_widgets[$id]['params']
|
||||
);
|
||||
|
||||
// Substitute HTML id and class attributes into before_widget
|
||||
$classname_ = '';
|
||||
@@ -236,6 +237,10 @@ function dynamic_sidebar($index = 1) {
|
||||
$classname_ = ltrim($classname_, '_');
|
||||
$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
|
||||
|
||||
$params = apply_filters( 'dynamic_sidebar_params', $params );
|
||||
|
||||
$callback = $wp_registered_widgets[$id]['callback'];
|
||||
|
||||
if ( is_callable($callback) ) {
|
||||
call_user_func_array($callback, $params);
|
||||
$did_one = true;
|
||||
@@ -1003,9 +1008,6 @@ function wp_widget_rss($args, $widget_args = 1) {
|
||||
if ( isset($options[$number]['error']) && $options[$number]['error'] )
|
||||
return;
|
||||
|
||||
$num_items = (int) $options[$number]['items'];
|
||||
$show_summary = $options[$number]['show_summary'];
|
||||
if ( empty($num_items) || $num_items < 1 || $num_items > 10 ) $num_items = 10;
|
||||
$url = $options[$number]['url'];
|
||||
while ( strstr($url, 'http') != $url )
|
||||
$url = substr($url, 1);
|
||||
@@ -1032,12 +1034,40 @@ function wp_widget_rss($args, $widget_args = 1) {
|
||||
else
|
||||
$icon = get_option('siteurl').'/wp-includes/images/rss.png';
|
||||
$title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php $title ? print($before_title . $title . $after_title) : null; ?>
|
||||
<?php
|
||||
|
||||
echo $before_widget;
|
||||
echo $before_title . $title . $after_title;
|
||||
|
||||
wp_widget_rss_output( $rss, $options[$number] );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function wp_widget_rss_output( $rss, $args = null ) {
|
||||
if ( is_string( $rss ) ) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
if ( !$rss = fetch_rss($rss) )
|
||||
return;
|
||||
} elseif ( is_array($rss) && isset($rss['url']) ) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
$args = $rss;
|
||||
if ( !$rss = fetch_rss($rss['url']) )
|
||||
return;
|
||||
} elseif ( !is_object($rss) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
$items = (int) $items;
|
||||
if ( $items < 1 || 20 < $items )
|
||||
$items = 10;
|
||||
$show_summary = (int) $show_summary;
|
||||
$show_author = (int) $show_author;
|
||||
$show_date = (int) $show_date;
|
||||
|
||||
if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
|
||||
$rss->items = array_slice($rss->items, 0, $num_items);
|
||||
$rss->items = array_slice($rss->items, 0, $items);
|
||||
echo '<ul>';
|
||||
foreach ($rss->items as $item ) {
|
||||
while ( strstr($item['link'], 'http') != $item['link'] )
|
||||
@@ -1047,21 +1077,56 @@ function wp_widget_rss($args, $widget_args = 1) {
|
||||
if ( empty($title) )
|
||||
$title = __('Untitled');
|
||||
$desc = '';
|
||||
if ( $show_summary ) {
|
||||
$summary = '<div class="rssSummary">' . $item['description'] . '</div>';
|
||||
} else {
|
||||
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
|
||||
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
|
||||
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
|
||||
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
|
||||
|
||||
$summary = '';
|
||||
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
|
||||
$summary = $item['description'];
|
||||
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
|
||||
$summary = $item['summary'];
|
||||
|
||||
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($summary, ENT_QUOTES))));
|
||||
|
||||
if ( $show_summary ) {
|
||||
$desc = '';
|
||||
$summary = wp_specialchars( $summary );
|
||||
$summary = "<div class='rssSummary'>$summary</div>";
|
||||
} else {
|
||||
$summary = '';
|
||||
}
|
||||
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
|
||||
|
||||
$date = '';
|
||||
if ( $show_date ) {
|
||||
if ( isset($item['pubdate']) )
|
||||
$date = $item['pubdate'];
|
||||
elseif ( isset($item['published']) )
|
||||
$date = $item['published'];
|
||||
|
||||
if ( $date ) {
|
||||
if ( $date_stamp = strtotime( $date ) )
|
||||
$date = '<span class="rss-date">' . gmdate( get_option( 'date_format' ), $date_stamp ) . '</span>';
|
||||
else
|
||||
$date = '';
|
||||
}
|
||||
}
|
||||
|
||||
$author = '';
|
||||
if ( $show_author ) {
|
||||
if ( isset($item['dc']['creator']) )
|
||||
$author = ' <cite>' . wp_specialchars( strip_tags( $item['dc']['creator'] ) ) . '</cite>';
|
||||
elseif ( isset($item['author_name']) )
|
||||
$author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>';
|
||||
}
|
||||
|
||||
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
|
||||
}
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function wp_widget_rss_control($widget_args) {
|
||||
@@ -1082,7 +1147,7 @@ function wp_widget_rss_control($widget_args) {
|
||||
if ( isset($option['url']) )
|
||||
$urls[$option['url']] = true;
|
||||
|
||||
if ( !$updated && !empty($_POST['sidebar']) ) {
|
||||
if ( !$updated && 'POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['sidebar']) ) {
|
||||
$sidebar = (string) $_POST['sidebar'];
|
||||
|
||||
$sidebars_widgets = wp_get_sidebars_widgets();
|
||||
@@ -1099,22 +1164,9 @@ function wp_widget_rss_control($widget_args) {
|
||||
}
|
||||
|
||||
foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) {
|
||||
$items = (int) $widget_rss['items'];
|
||||
if ( $items < 1 )
|
||||
$items = 10;
|
||||
$url = sanitize_url(strip_tags(stripslashes($widget_rss['url'])));
|
||||
$title = trim(strip_tags(stripslashes($widget_rss['title'])));
|
||||
|
||||
if ( !isset($urls[$url]) ) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
$rss = fetch_rss($url);
|
||||
$error = false;
|
||||
if ( !is_object($rss) ) {
|
||||
$url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
|
||||
$error = sprintf(__('Error in RSS %1$d'), $widget_number );
|
||||
}
|
||||
}
|
||||
$options[$widget_number] = compact( 'title', 'url', 'items', 'error' );
|
||||
$widget_rss = stripslashes_deep( $widget_rss );
|
||||
$url = sanitize_url(strip_tags($widget_rss['url']));
|
||||
$options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) );
|
||||
}
|
||||
|
||||
update_option('widget_rss', $options);
|
||||
@@ -1127,38 +1179,115 @@ function wp_widget_rss_control($widget_args) {
|
||||
$items = 10;
|
||||
$error = false;
|
||||
$number = '%i%';
|
||||
$show_summary = 0;
|
||||
$show_author = 0;
|
||||
$show_date = 0;
|
||||
} else {
|
||||
$title = attribute_escape($options[$number]['title']);
|
||||
$url = attribute_escape($options[$number]['url']);
|
||||
$items = (int) $options[$number]['items'];
|
||||
if ( $items < 1 )
|
||||
$items = 10;
|
||||
$error = $options[$number]['error'];
|
||||
extract( $options[$number] );
|
||||
}
|
||||
|
||||
wp_widget_rss_form( compact( 'number', 'title', 'url', 'items', 'error', 'show_summary', 'show_author', 'show_date' ) );
|
||||
}
|
||||
|
||||
function wp_widget_rss_form( $args, $inputs = null ) {
|
||||
$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
|
||||
$inputs = wp_parse_args( $inputs, $default_inputs );
|
||||
extract( $args );
|
||||
$number = attribute_escape( $number );
|
||||
$title = attribute_escape( $title );
|
||||
$url = attribute_escape( $url );
|
||||
$items = (int) $items;
|
||||
if ( $items < 1 || 20 < $items )
|
||||
$items = 10;
|
||||
$show_summary = (int) $show_summary;
|
||||
$show_author = (int) $show_author;
|
||||
$show_date = (int) $show_date;
|
||||
|
||||
if ( $inputs['url'] ) :
|
||||
?>
|
||||
<p>
|
||||
<label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?>
|
||||
<input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?>
|
||||
<input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?>
|
||||
<select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
|
||||
<?php
|
||||
for ( $i = 1; $i <= 10; ++$i )
|
||||
echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
|
||||
<p>
|
||||
<label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?>
|
||||
<input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; if ( $inputs['title'] ) : ?>
|
||||
<p>
|
||||
<label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?>
|
||||
<input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; if ( $inputs['items'] ) : ?>
|
||||
<p>
|
||||
<label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?>
|
||||
<select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
|
||||
<?php
|
||||
for ( $i = 1; $i <= 20; ++$i )
|
||||
echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; if ( $inputs['show_summary'] ) : ?>
|
||||
<p>
|
||||
<label for="rss-show-summary-<?php echo $number; ?>">
|
||||
<input id="rss-show-summary-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_summary]" type="checkbox" value="1" <?php if ( $show_summary ) echo 'checked="checked"'; ?>/>
|
||||
<?php _e('Display item content?'); ?>
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; if ( $inputs['show_author'] ) : ?>
|
||||
<p>
|
||||
<label for="rss-show-author-<?php echo $number; ?>">
|
||||
<input id="rss-show-author-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_author]" type="checkbox" value="1" <?php if ( $show_author ) echo 'checked="checked"'; ?>/>
|
||||
<?php _e('Display item author if available?'); ?>
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; if ( $inputs['show_date'] ) : ?>
|
||||
<p>
|
||||
<label for="rss-show-date-<?php echo $number; ?>">
|
||||
<input id="rss-show-date-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_date]" type="checkbox" value="1" <?php if ( $show_date ) echo 'checked="checked"'; ?>/>
|
||||
<?php _e('Display item date?'); ?>
|
||||
</label>
|
||||
</p>
|
||||
<input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
|
||||
<?php
|
||||
endif;
|
||||
foreach ( array_keys($default_inputs) as $input ) :
|
||||
if ( 'hidden' === $inputs[$input] ) :
|
||||
$id = str_replace( '_', '-', $input );
|
||||
?>
|
||||
<input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][<?php echo $input; ?>]" value="<?php echo $$input; ?>" />
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
}
|
||||
|
||||
// Expects unescaped data
|
||||
function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
|
||||
$items = (int) $widget_rss['items'];
|
||||
if ( $items < 1 || 20 < $items )
|
||||
$items = 10;
|
||||
$url = sanitize_url(strip_tags( $widget_rss['url'] ));
|
||||
$title = trim(strip_tags( $widget_rss['title'] ));
|
||||
$show_summary = (int) $widget_rss['show_summary'];
|
||||
$show_author = (int) $widget_rss['show_author'];
|
||||
$show_date = (int) $widget_rss['show_date'];
|
||||
|
||||
if ( $check_feed ) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
$rss = fetch_rss($url);
|
||||
$error = false;
|
||||
$link = '';
|
||||
if ( !is_object($rss) ) {
|
||||
$url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
|
||||
$error = sprintf(__('Error in RSS %1$d'), $widget_number );
|
||||
} else {
|
||||
$link = clean_url(strip_tags($rss->channel['link']));
|
||||
while ( strstr($link, 'http') != $link )
|
||||
$link = substr($link, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
|
||||
}
|
||||
|
||||
function wp_widget_rss_register() {
|
||||
|
||||
Reference in New Issue
Block a user