__('Display a table of upcoming meetings.', '12-step-meeting-list'), ] ); } // front-end display of widget public function widget($args, $instance) { global $tsml_user_interface; $table = tsml_next_meetings($instance); if (empty($table)) { return false; } if (empty($instance['title'])) { $instance['title'] = ''; } if (!empty($instance['css'])) { echo ''; } // don't know how to set this properly $args['before_widget'] = str_replace(' class="', ' class="tsml-widget-upcoming ', $args['before_widget']); $output = $args['before_widget']; if (!empty($instance['title'])) { $output .= $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } $output .= $table; $meetings = tsml_get_meetings(['day' => intval(current_time('w')), 'time' => 'upcoming']); $link = ($tsml_user_interface == 'tsml_ui' || (!count($meetings) && !empty($instance['message']))) ? tsml_meetings_url() : tsml_meetings_url(['tsml-time' => 'upcoming']); $output .= '
' . __('View Moreā¦', '12-step-meeting-list') . '
'; $output .= $args['after_widget']; echo wp_kses($output, [ 'a' => ['href' => [], 'class' => []], 'aside' => ['class' => []], 'div' => ['class' => []], 'h1' => ['class' => []], 'p' => [], 'small' => [], 'span' => ['class' => []], 'style' => ['type' => []], 'table' => ['class' => []], 'tbody' => [], 'td' => ['class' => []], 'th' => ['class' => []], 'thead' => [], 'tr' => ['class' => []], ]); } // backend form public function form($instance) { $title = !empty($instance['title']) ? $instance['title'] : __('Upcoming Meetings', '12-step-meeting-list'); $count = !empty($instance['count']) ? $instance['count'] : 5; $message = !empty($instance['message']) ? $instance['message'] : ''; ?>
>
!empty($new_instance['title']) ? strip_tags($new_instance['title']) : '', 'count' => !empty($new_instance['count']) ? intval($new_instance['count']) : 5, 'css' => !empty($new_instance['css']), 'message' => !empty($new_instance['message']) ? strip_tags($new_instance['message']) : '', ]; } } // app store links widget class TSML_Widget_App_Store extends WP_Widget { // constructor public function __construct() { parent::__construct( 'tsml_widget_app_store', __('App Store', '12-step-meeting-list'), [ 'description' => __('Display links to the Meeting Guide app in the Apple and Android app stores.', '12-step-meeting-list'), ] ); } // backend form public function form($instance) { $title = empty($instance['title']) ? '' : $instance['title']; ?>
>
.tsml-widget-app-store { background-color: transparent; padding: 0; } .tsml-widget-app-store nav { overflow: auto; padding: 0; margin: 0 -7.5px; } .tsml-widget-app-store a { display: inline-block; width: 50%; box-sizing: border-box; padding: 0 7.5px; float: left; } .tsml-widget-app-store img { width: 100%; height: auto; } #tsml .meetings-widgets h3 { margin: 0 0 15px; border-bottom: 1px solid #ddd; padding: 0 0 10px; text-align: center; } #tsml .meetings-widgets-top .tsml-widget-app-store { margin: 0 0 15px; } #tsml .meetings-widgets-bottom .tsml-widget-app-store { margin: 30px 0; } '; } $output .= ' '; $output .= $args['after_widget']; echo wp_kses_post($output); } } // register widgets add_action('widgets_init', function () { register_widget('TSML_Widget_Upcoming'); register_widget('TSML_Widget_App_Store'); });