public function widget($args, $instance) { // Fetch the (network)button by it's name if (!($button = \PodloveSubscribeButton\Model\Button::get_button_by_name($instance['button']))) { return sprintf(__('Oops. There is no button with the ID "%s".', 'podlove'), $args['button']); } echo $args['before_widget']; echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; echo $button->render(\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'size'), \PodloveSubscribeButton::get_array_value_with_fallback($instance, 'autowidth'), \PodloveSubscribeButton::get_array_value_with_fallback($instance, 'style'), \PodloveSubscribeButton::get_array_value_with_fallback($instance, 'format'), \PodloveSubscribeButton::get_array_value_with_fallback($instance, 'color')); if (strlen($instance['infotext'])) { echo wpautop($instance['infotext']); } echo $args['after_widget']; }
public static function shortcode($args) { if (!$args || !isset($args['button'])) { return __('You need to create a Button first and provide its ID.', 'podlove'); } else { $buttonid = $args['button']; } // Fetch the (network)button by it's name if (!($button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']))) { return sprintf(__('Oops. There is no button with the ID "%s".', 'podlove'), $args['button']); } // Get button styling and options $autowidth = self::interpret_width_attribute(self::get_array_value_with_fallback($args, 'width')); $size = self::get_attribute('size', self::get_array_value_with_fallback($args, 'size')); $style = self::get_attribute('style', self::get_array_value_with_fallback($args, 'style')); $format = self::get_attribute('format', self::get_array_value_with_fallback($args, 'format')); $color = self::get_attribute('color', self::get_array_value_with_fallback($args, 'color')); if (isset($args['language'])) { $language = $args['language']; } else { $language = 'en'; } if (isset($args['color'])) { $color = $args['color']; } else { $color = get_option('podlove_subscribe_button_default_color', '#599677'); } if (isset($args['hide']) && $args['hide'] == 'true') { $hide = TRUE; } else { $hide = FALSE; } // Render button return $button->render($size, $autowidth, $style, $format, $color, $hide, $buttonid, $language); }