/** * Return public facing code for the Pinterest Board Widget * * @since 1.0.0 * * @return string */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $board_url = !empty($instance['board_url']) ? $instance['board_url'] : 'http://www.pinterest.com/pinterest/pin-pets/'; $board_size = $instance['board_size']; $custom_sizes = array(); if ($board_size == 'custom') { $custom_sizes = array('width' => !empty($instance['custom_width']) ? $instance['custom_width'] : '', 'height' => !empty($instance['custom_height']) ? $instance['custom_height'] : '', 'board_width' => !empty($instance['custom_board_width']) ? $instance['custom_board_width'] : ''); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $html = '<div class="pw-wrap pw-widget pw-board-widget">' . pw_widget_boards($board_url, '', $board_size, $custom_sizes, 'embedBoard') . '</div>'; do_action('pw_board_widget_before'); echo apply_filters('pw_board_widget_html', $html); do_action('pw_board_widget_after'); echo $after_widget; }
/** * Return public facing code for the Pinterest Profile Widget * * @since 1.0.0 * @modified 1.0.1 * * @return string */ public function widget($args, $instance) { // public facing widget code extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $pin_username = !empty($instance['pin_username']) ? $instance['pin_username'] : '******'; $profile_widget_size = $instance['profile_widget_size']; $custom_sizes = array(); if ($profile_widget_size == 'custom') { $custom_sizes = array('width' => !empty($instance['custom_width']) ? $instance['custom_width'] : '', 'height' => !empty($instance['custom_height']) ? $instance['custom_height'] : '', 'board_width' => !empty($instance['custom_board_width']) ? $instance['custom_board_width'] : ''); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $html = '<div class="pw-wrap pw-widget pw-profile-widget">' . pw_widget_boards($pin_username, '', $profile_widget_size, $custom_sizes, 'embedUser') . '</div>'; do_action('pw_profile_widget_before'); echo apply_filters('pw_profile_widget_html', $html); do_action('pw_profile_widget_after'); echo $after_widget; }
/** * Process and return shortcode for Pinterest Profile Widget * * @since 1.0.0 * @modified 1.0.1 * * @return string */ function pw_profile_widget($attr) { extract(shortcode_atts(array('username' => 'pinterest', 'size' => 'square', 'image_width' => '', 'board_height' => '', 'board_width' => ''), $attr)); $custom_sizes = array(); if ($size == 'custom') { $custom_sizes = array('width' => $image_width, 'height' => $board_height, 'board_width' => $board_width); } $before_html = ''; $html = '<div class="pw-wrap pw-shortcode">' . pw_widget_boards($username, '', $size, $custom_sizes, 'embedUser') . '</div>'; $after_html = ''; $before_html = apply_filters('pw_profile_shortcode_before', $before_html); $html = apply_filters('pw_profile_shortcode_html', $html); $after_html = apply_filters('pw_profile_shortcode_after', $after_html); return $before_html . $html . $after_html; }