__('ItalyStrap Monster Widgets', 'italystrap'),
// Widget Backend Description.
'description' => __('(Don\'t use this widget because it is in ALPHA version.) Test multiple widgets by ItalyStrap at the same time.', 'italystrap'),
// 'fields' => $this->get_widget_fields( require( ITALYSTRAP_PLUGIN_PATH . 'config/posts.php' ) ),
'control_options' => ['width' => 450],
'widget_options' => ['customize_selective_refresh' => true],
];
/**
* Create Widget
*/
$this->create_widget($args);
}
/**
* Dispay the widget content
*
* @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.
* @return string Return the output
*/
public function widget_render($args, $instance)
{
$output = '';
foreach ($this->get_widget_config() as $widget) {
$_instance = $widget[1] ?? null;
// $args['before_widget'] = sprintf(
// $before_widget,
// 'italystrap_monster-widget-placeholder-' . self::$iterator,
// $this->get_widget_class( $widget[0] )
// );
ob_start();
the_widget('ItalyStrap\\Widget\\' . $widget[0], $_instance, $args);
$output .= ob_get_contents();
ob_end_clean();
self::$iterator++;
}
// $this->query->query( $this->get_query_args( $query_args ) );
// ob_start();
// include $this->get_template_part();
// include \ItalyStrap\Core\get_template( '/templates/content-post.php' );
// wp_reset_postdata();
// $output = ob_get_contents();
// ob_end_clean();
return $output;
}
/**
* Print the Monster widget on the front-end.
*
* @uses $wp_registered_sidebars
* @uses Monster_Widget::$iterator
* @uses Monster_Widget::get_widget_class()
* @uses $this->get_widget_config()
*
* @since 0.1
*/
// public function widget( $args, $instance ) {
// global $wp_registered_sidebars;
// $id = $args['id'];
// $args = $wp_registered_sidebars[$id];
// $before_widget = $args['before_widget'];
// foreach( $this->get_widget_config() as $widget ) {
// $_instance = ( isset( $widget[1] ) ) ? $widget[1] : null;
// $args['before_widget'] = sprintf(
// $before_widget,
// 'italystrap_monster-widget-placeholder-' . self::$iterator,
// $this->get_widget_class( $widget[0] )
// );
// the_widget( 'ItalyStrap\\Widget\\' . $widget[0], $_instance, $args );
// self::$iterator++;
// }
// }
/**
* Widgets (array).
*
* Numerically indexed array of Pre-configured widgets to
* display in every instance of a Monster widget. Each entry
* requires two values:
*
* 0 - The name of the widget's class as registered with register_widget().
* 1 - An associative array representing an instance of the widget.
*
* @uses Monster_Widget::get_text()
*
* This list can be altered by using the `monster-widget-config` filter.
*
* @return array Widget configuration.
* @since 0.1
*/
public function get_widget_config()
{
$widgets = [
// array(
// 'Carousel',
// array(
// 'title' => __( 'Bootstrap Carousel', 'italystrap' ),
// 'ids' => '1,2,3',
// )
// ),
['Posts', ['title' => __('ItalyStrap Posts', 'italystrap')]],
['VCard', ['title' => __('ItalyStrap VCard', 'italystrap')]],
];
return apply_filters('italystrap_monster_widget_config', $widgets);
}
/**
* Get the html class attribute value for a given widget.
*
* @uses $wp_widget_factory
*
* @param string $widget The name of a registered widget class.
* @return string Dynamic class name a given widget.
*
* @since 0.1
*/
public function get_widget_class($widget)
{
global $wp_widget_factory;
$widget_obj = '';
if (isset($wp_widget_factory->widgets[$widget])) {
$widget_obj = $wp_widget_factory->widgets[$widget];
}
if (! is_a($widget_obj, 'WP_Widget')) {
return '';
}
if (! isset($widget_obj->widget_options['classname'])) {
return '';
}
return $widget_obj->widget_options['classname'];
}
/**
* Widget Breaker Text.
*
* Used to populate the Text widget with html designed
* to "break" out of the sidebar.
*
* The "monster-widget-get-text" filter can be used
* to modify the output.
*
* @since 0.1
*/
public function get_text()
{
$html = [];
$html[] = '' . __('Large image: Hand Coded', 'italystrap') . '';
$html[] = '
';
$html[] = '' . __('Large image: linked in a caption', 'italystrap') . '';
$html[] = '