-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed more largo_featured_widget and restructured largo_about_widget #1469
Changes from all commits
6dfc7c1
cb1446a
78464a1
7c83ce0
5eae014
428ff2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,49 +2,105 @@ | |
/* | ||
* About this site | ||
*/ | ||
|
||
/** | ||
* Class largo_about_widget | ||
*/ | ||
class largo_about_widget extends WP_Widget { | ||
|
||
/** | ||
* largo_about_widget constructor. | ||
*/ | ||
function __construct() { | ||
$widget_ops = array( | ||
'classname' => 'largo-about', | ||
'description' => __('Show the site description from your theme options page', 'largo') | ||
'classname' => 'largo-about', | ||
'description' => __( 'Show the site description from your theme options page', 'largo' ) | ||
); | ||
parent::__construct( 'largo-about-widget', __('Largo About Site', 'largo'), $widget_ops); | ||
parent::__construct( 'largo-about-widget', __( 'Largo About Site', 'largo' ), $widget_ops ); | ||
} | ||
|
||
/** | ||
* Echos output for the widget | ||
* | ||
* @param array $args | ||
* @param array $instance | ||
*/ | ||
function widget( $args, $instance ) { | ||
extract( $args ); | ||
|
||
$title = apply_filters('widget_title', empty( $instance['title'] ) ? sprintf( __( 'About %s', 'largo' ), get_bloginfo('name') ) : $instance['title'], $instance, $this->id_base); | ||
$args = wp_parse_args( $args, array( | ||
'before_widget' => '', | ||
'before_title' => '', | ||
'after_title' => '', | ||
'after_widget' => '', | ||
)); | ||
|
||
echo $before_widget; | ||
if ( $title ) | ||
echo $before_title . $title . $after_title; ?> | ||
/* | ||
* Set default title | ||
*/ | ||
$instance = $this->_instance_defaults( $instance ); | ||
|
||
<?php if ( of_get_option( 'site_blurb' ) ) : ?> | ||
<p><?php echo of_get_option( 'site_blurb' ); ?></p> | ||
<?php else: ?> | ||
<p class="error"><strong><?php _e('You have not set a description for your site.</strong> Add a site description by visiting the Largo Theme Options page.', 'largo'); ?></p> | ||
<?php endif; // end about site ?> | ||
echo $args[ 'before_widget' ]; | ||
|
||
<?php | ||
echo $after_widget; | ||
$title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $this->id_base ); | ||
|
||
if ( $title ) { | ||
echo "{$args[ 'before_title' ]}{$title}{$args[ 'after_title' ]}"; | ||
} | ||
|
||
if ( of_get_option( 'site_blurb' ) ) { | ||
echo '<p>' . of_get_option( 'site_blurb' ) . '</p>'; | ||
} else { | ||
$link_title = __( 'The Largo Theme Options page', 'largo' ); | ||
$options_url = site_url( '/wp-admin/themes.php?page=options-framework' ); | ||
$message = sprintf( | ||
__( '%sYou have not set a description for your site.%s Add a site description by visiting %sthe Largo Theme Options page%s.', 'largo' ), | ||
'<strong>','</strong>', | ||
"<a href=\"{$options_url}\" title=\"{$link_title}\">", '</a>' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use tabs for this indentation. |
||
); | ||
echo "<p class=\"error\">{$message}</p>"; | ||
} | ||
|
||
echo $args[ 'after_widget' ]; | ||
} | ||
|
||
function update( $new_instance, $old_instance ) { | ||
$instance = $old_instance; | ||
$instance['title'] = sanitize_text_field( $new_instance['title'] ); | ||
/** | ||
* @param array $new_instance The new widget instance | ||
* @param array $instance The old Widget instance | ||
* | ||
* @return array | ||
*/ | ||
function update( $new_instance, $instance ) { | ||
$new_instance = $this->_instance_defaults( $new_instance ); | ||
$instance[ 'title' ] = sanitize_text_field( $new_instance[ 'title' ] ); | ||
return $instance; | ||
} | ||
|
||
/** | ||
* Display form to allow updating title | ||
* @param array $instance | ||
* @return string Default return is 'noform'. | ||
*/ | ||
function form( $instance ) { | ||
$defaults = array( 'title' => sprintf( __( 'About %s', 'largo' ), get_bloginfo('name') ) ); | ||
$instance = wp_parse_args( (array) $instance, $defaults ); | ||
$instance = wp_parse_args( (array) $instance, $this->_instance_defaults( $instance ) ); | ||
$title_field_id = $this->get_field_id( 'title' ); | ||
$title_field_name = $this->get_field_name( 'title' ); | ||
?> | ||
<p> | ||
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'largo' ); ?>:</label> | ||
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" style="width:90%;" /> | ||
</p> | ||
<?php | ||
<p> | ||
<label for="<?php echo esc_attr( $title_field_id ); ?>"><?php _e( 'Title', 'largo' ); ?>:</label> | ||
<input id="<?php echo esc_attr( $title_field_id ); ?>" name="<?php echo esc_attr( $title_field_name ); ?>" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" style="width:90%;" /> | ||
</p> | ||
<?php | ||
} | ||
|
||
/** | ||
* Returns defaults for an instance, or ensures an instance has a title | ||
* | ||
* @param array $instance The widget instance info | ||
* @return array | ||
*/ | ||
private function _instance_defaults( $instance = array() ) { | ||
return wp_parse_args( $instance, array( | ||
'title' => sprintf( __( 'About %s', 'largo' ), get_bloginfo( 'name' ) ), | ||
)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,23 @@ | |
</div> | ||
|
||
<div class="span6 widget-area" role="complementary"> | ||
<?php if ( ! dynamic_sidebar( 'footer-2' ) ) { | ||
the_widget( 'largo_featured_widget', array( | ||
'term' => 'footer-featured', | ||
'title' => __('In Case You Missed It', 'largo'), | ||
'widget_class' => 'default', | ||
'num_posts' => 2, | ||
'num_sentences' => 2, | ||
'thumb' => 'before' | ||
) | ||
); | ||
} | ||
<?php | ||
|
||
/** | ||
* @see https://github.com/INN/largo/issues/1467 | ||
*/ | ||
// if ( ! dynamic_sidebar( 'footer-2' ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commenting out this specific line prevents the |
||
// the_widget( 'largo_featured_widget', array( | ||
// 'term' => 'footer-featured', | ||
// 'title' => __('In Case You Missed It', 'largo'), | ||
// 'widget_class' => 'default', | ||
// 'num_posts' => 2, | ||
// 'num_sentences' => 2, | ||
// 'thumb' => 'before' | ||
// ) | ||
// ); | ||
// } | ||
|
||
?> | ||
</div> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,21 @@ | |
</div> | ||
|
||
<div class="span3 widget-area" role="complementary"> | ||
<?php if ( ! dynamic_sidebar( 'footer-2' ) ) { | ||
the_widget( 'largo_featured_widget', array( | ||
'term' => 'footer-featured', | ||
'title' => __('In Case You Missed It', 'largo'), | ||
'widget_class' => 'default', | ||
'num_posts' => 2, | ||
'num_sentences' => 2, | ||
'thumb' => 'before' | ||
) | ||
); | ||
} | ||
<?php | ||
/** | ||
* @see https://github.com/INN/largo/issues/1467 | ||
*/ | ||
// if ( ! dynamic_sidebar( 'footer-2' ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commenting out this specific line prevents the |
||
// the_widget( 'largo_featured_widget', array( | ||
// 'term' => 'footer-featured', | ||
// 'title' => __('In Case You Missed It', 'largo'), | ||
// 'widget_class' => 'default', | ||
// 'num_posts' => 2, | ||
// 'num_sentences' => 2, | ||
// 'thumb' => 'before' | ||
// ) | ||
// ); | ||
// } | ||
?> | ||
</div> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of $time_difference being > 86400 seconds (1 day), this results in the output string being:
Can you remove this change from this PR, please?