=' ) ) {
parent::__construct( false, __( 'Jalali Date Archives', 'wp-parsidate' ),
'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
} else {
parent::WP_Widget( false, __( 'Jalali Date Archives', 'wp-parsidate' ),
'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
}
}
/**
* Outputs the settings update form.
*
* @param array $instance Current settings.
*
* @return void Default return is 'noform'.
* @since 2.8.0
*
*/
public function form( $instance ) {
global $wpp_settings;
$type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
$instance['parsidate_archive_title'] = isset( $instance['parsidate_archive_title'] ) ? strip_tags( $instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
$instance['parsidate_archive_count'] = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : 0;
$instance['parsidate_archive_list'] = isset( $instance['parsidate_archive_list'] ) ? $instance['parsidate_archive_list'] : 0;
?>
:
/>
/>
" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.',
'wp-parsidate' ) . "";
}
}
/**
* Updates a particular instance of a widget.
*
* This function should check that `$new_instance` is set correctly. The newly-calculated
* value of `$instance` should be returned. If false is returned, the instance won't be
* saved/updated.
*
* @param array $new_instance New settings for this instance as input by the user via
* WP_Widget::form().
* @param array $old_instance Old settings for this instance.
*
* @return array Settings to save or bool false to cancel saving.
* @since 2.8.0
*
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['parsidate_archive_title'] = isset( $new_instance['parsidate_archive_title'] ) ? strip_tags( $new_instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
$instance['parsidate_archive_count'] = isset( $new_instance['parsidate_archive_count'] ) ? $new_instance['parsidate_archive_count'] : 0;
$instance['parsidate_archive_list'] = isset( $new_instance['parsidate_archive_list'] ) ? $new_instance['parsidate_archive_list'] : 0;
$instance['parsidate_archive_type'] = isset( $new_instance['parsidate_archive_type'] ) ? $new_instance['parsidate_archive_type'] : 'monthly';
return $instance;
}
/**
* Echoes the widget content.
*
* Subclasses should override this function to generate their widget code.
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance The settings for the particular instance of the widget.
*
* @since 2.8.0
*
*/
public function widget( $args, $instance ) {
if ( ! wpp_is_active( 'conv_permalinks' ) ) {
return;
}
$type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
$title = isset( $instance['parsidate_archive_title'] ) ? $instance['parsidate_archive_title'] : __( 'Jalali Date Archives', 'wp-parsidate' );
$post_count = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : false;
$ddl_style = isset( $instance['parsidate_archive_list'] ) && $instance['parsidate_archive_list'];
echo $args['before_widget'];
if ( ! empty( $instance['parsidate_archive_title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title',
$instance['parsidate_archive_title'] ) . $args['after_title'];
}
if ( $ddl_style ) {
echo "';
} else {
echo '';
wpp_get_archives( "type=$type&show_post_count=$post_count" );
echo '
';
}
echo $args['after_widget'];
}
}