コード例 #1
0
ファイル: widget.php プロジェクト: CherylMuniz/fashion
 function widget($args, $instance)
 {
     global $pib_options;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     $pib_url_of_webpage_widget = $instance['pib_url_of_webpage_widget'];
     //Set URL to home page if button style is "user selects image"
     if (empty($pib_url_of_webpage_widget) && $pib_options['button_style'] == 'user_selects_image') {
         $pib_url_of_webpage_widget = get_home_url();
     }
     $pib_url_of_img_widget = $instance['pib_url_of_img_widget'];
     $pib_description_widget = $instance['pib_description_widget'];
     $count_layout = empty($instance['count_layout']) ? 'none' : $instance['count_layout'];
     $float = empty($instance['float']) ? 'none' : $instance['float'];
     $pib_remove_div = (bool) $instance['remove_div'];
     $base_btn = pib_button_base($pib_url_of_webpage_widget, $pib_url_of_img_widget, $pib_description_widget, $count_layout);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($pib_remove_div) {
         echo $base_btn;
     } else {
         //Surround with div tag
         $float_class = '';
         if ($float == 'left') {
             $float_class = 'pib-float-left';
         } elseif ($float == 'right') {
             $float_class = 'pib-float-right';
         }
         echo '<div class="pin-it-btn-wrapper-widget ' . $float_class . '">' . $base_btn . '</div>';
     }
     echo $after_widget;
 }
コード例 #2
0
ファイル: shortcode.php プロジェクト: CherylMuniz/fashion
function pib_button_shortcode_html($attr)
{
    global $pib_options;
    global $post;
    $postID = $post->ID;
    /*
        For URL, image URL and Description, use in order:
        1) attribute value
        2) custom fields for post
        3) inherit from post: permalink, first image, post title
    */
    $url = $attr['url'];
    if (empty($url)) {
        $url = get_post_meta($postID, 'pib_url_of_webpage', true);
        if (empty($url)) {
            $url = get_permalink($postID);
        }
    }
    $image_url = $attr['image_url'];
    if (empty($image_url)) {
        $image_url = get_post_meta($postID, 'pib_url_of_img', true);
        if (empty($image_url)) {
            //Get url of img and compare width and height
            $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
            $first_img = $matches[1][0];
            $image_url = $first_img;
        }
    }
    $description = $attr['description'];
    if (empty($description)) {
        $description = get_post_meta($postID, 'pib_description', true);
        if (empty($description)) {
            $description = get_the_title($postID);
        }
    }
    $count = empty($attr['count']) ? 'none' : $attr['count'];
    $remove_div = $attr['remove_div'] == 'true';
    $social_buttons = $attr['social_buttons'] == 'true';
    $base_btn = pib_button_base($url, $image_url, $description, $count);
    //Don't wrap with div or use float left/right if using other sharing buttons or "remove div" is checked
    if ($remove_div || $social_buttons) {
        return $base_btn;
    } else {
        //Surround with div tag
        $float_class = '';
        if ($attr['float'] == 'left') {
            $float_class = 'pib-float-left';
        } elseif ($attr['float'] == 'right') {
            $float_class = 'pib-float-right';
        }
        return '<div class="pin-it-btn-wrapper-shortcode ' . $float_class . '">' . $base_btn . '</div>';
    }
}
コード例 #3
0
function pib_button_html()
{
    global $pib_options;
    global $post;
    $postID = $post->ID;
    //Return nothing if sharing disabled on current post
    if (get_post_meta($postID, 'pib_sharing_disabled', 1)) {
        return '';
    }
    //Set post url, image url and description from current post meta
    $post_url = get_post_meta($postID, 'pib_url_of_webpage', true);
    $image_url = get_post_meta($postID, 'pib_url_of_img', true);
    $description = get_post_meta($postID, 'pib_description', true);
    //Use featured image if specified (also not blank and Pro only)
    $featured_img_array = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'full');
    $featured_img_url = $featured_img_array[0];
    if (PIB_IS_PRO && (bool) $pib_options['use_featured_image'] && !empty($featured_img_url)) {
        $image_url = $featured_img_url;
    }
    //Set post url to current post if still blank
    if (empty($post_url)) {
        $post_url = get_permalink($postID);
    }
    //Set image url to first image if still blank
    if (empty($image_url)) {
        //Get url of img and compare width and height
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
        $first_img = $matches[1][0];
        $image_url = $first_img;
    }
    //Set description to post title if still blank
    if (empty($description)) {
        $description = get_the_title($postID);
    }
    $count_layout = $pib_options['count_layout'];
    $base_btn = pib_button_base($post_url, $image_url, $description, $count_layout);
    //Don't wrap with div if using other sharing buttons or "remove div" is checked
    if ((bool) $pib_options['use_other_sharing_buttons'] || (bool) $pib_options['remove_div']) {
        return $base_btn;
    } else {
        //Surround with div tag
        return '<div class="pin-it-btn-wrapper">' . $base_btn . '</div>';
    }
}