Skip to content
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

Closed
wants to merge 6 commits into from
15 changes: 6 additions & 9 deletions inc/post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function largo_modified_time( $echo=true, $post=null ) {

/**
* Given a time, if it was less than 24 hours ago return how many hours ago that was, otherwise return the 'F j, Y' formatted date
* @param int $modified the Unix timestamp for the modified date
* @param int $time the Unix timestamp for the modified date
* @return string HTML for the either "x hours ago" or the submitted date, formatted
* @since 0.5.5
* @see https://secure.php.net/manual/en/function.date.php
Expand All @@ -51,15 +51,12 @@ function largo_modified_time( $echo=true, $post=null ) {
function largo_time_diff( $time ) {
$time_difference = current_time( 'timestamp' ) - $time;

if ( $time_difference < 86400 ) {
$output = sprintf( __( '<span class="time-ago">%s ago</span>', 'largo' ),
human_time_diff( $time, current_time( 'timestamp' ) )
);
} else {
$output = date( 'F j, Y', $time );
}
$time = $time_difference < 86400
? human_time_diff( $time, current_time( 'timestamp' ) )
: date( 'F j, Y', $time );

return sprintf( __( '<span class="time-ago">%s ago</span>', 'largo' ), $time );
Copy link
Collaborator

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:

<span class="time-ago">August 23, 2017 ago</span>

Can you remove this change from this PR, please?


return $output;
}

/**
Expand Down
106 changes: 81 additions & 25 deletions inc/widgets/largo-about.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
Copy link
Collaborator

Choose a reason for hiding this comment

The 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' ) ),
));
}
}
28 changes: 17 additions & 11 deletions partials/footer-widget-3col-default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting out this specific line prevents the footer-2 sidebar from displaying, since calling dynamic_sidebar( 'footer-2' ) is what causes that sidebar to be displayed. It may be best to comment out only the lines within the conditional, as you did in partials/footer-widget-3col-equal.php in this PR.

// 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>

Expand Down
21 changes: 12 additions & 9 deletions partials/footer-widget-3col-equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

<div class="span4 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'
)
);
/**
* @see https://github.com/INN/largo/issues/1467
*/
// 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>
Expand Down
26 changes: 15 additions & 11 deletions partials/footer-widget-4col.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting out this specific line prevents the footer-2 sidebar from displaying, since calling dynamic_sidebar( 'footer-2' ) is what causes that sidebar to be displayed. It may be best to comment out only the lines within the conditional, as you did in partials/footer-widget-3col-equal.php in this PR.

// 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>

Expand Down
19 changes: 11 additions & 8 deletions partials/sidebar-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
);
}

the_widget( 'largo_featured_widget', array(
'term' => 'sidebar-featured',
'title' => __('We Recommend', 'largo'),
'widget_class' => 'default',
'num_posts' => 5,
'num_sentences' => 2
)
);
/**
* @see https://github.com/INN/largo/issues/1467
*/
//the_widget( 'largo_featured_widget', array(
// 'term' => 'sidebar-featured',
// 'title' => __('We Recommend', 'largo'),
// 'widget_class' => 'default',
// 'num_posts' => 5,
// 'num_sentences' => 2
// )
//);