Pinterest "Pin It" Button - Version 1.2.0

Version Description

  • Added option to hide button per page/post
  • Added option to hide button per category
  • Added widget to display "Pin It" button
  • Added widget to display "Follow" on Pinterest button
  • Added sharing buttons to settings page to promote plugin
  • Fixed CSS where some blogs weren't displaying the button properly
Download this release

Release Info

Developer pderksen
Plugin Icon 128x128 Pinterest "Pin It" Button
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.2 to 1.2.0

css/pinterest-pin-it-button-admin.css CHANGED
@@ -1,10 +1,5 @@
1
  /* Pinterest Pin It Button Admin CSS */
2
 
3
- .activate-notice-link {
4
- font-size: 15px;
5
- font-weight: bold;
6
- }
7
-
8
  .form-table {
9
  margin-bottom: 10px !important;
10
  }
@@ -18,6 +13,7 @@
18
  }
19
  .form-table input[type="checkbox"] {
20
  margin-right: 5px;
 
21
  }
22
 
23
  .form-table textarea {
@@ -25,12 +21,6 @@
25
  width: 350px;
26
  }
27
 
28
- /*
29
- .postbox-container{
30
- padding-right:0px !important;
31
- }
32
- */
33
-
34
  .pib-postbox {
35
  margin: 10px 10px 0 0;
36
  }
@@ -40,13 +30,6 @@
40
  line-height: 1.2em;
41
  }
42
 
43
- /*
44
- .postbox .inside {
45
- padding-left: 0px !important;
46
- display: block;
47
- }
48
- */
49
-
50
  .pib-settings {
51
  width: 70%;
52
  }
@@ -55,23 +38,6 @@
55
  width: 30%;
56
  }
57
 
58
- /* TODO Using this? */
59
- /*
60
- .typebox {
61
- margin-right:10px;
62
- margin-top:10px;
63
- background-color:#F5F5F5;
64
- background-image:-moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
65
- -moz-border-radius:3px 3px 3px 3px;
66
- -moz-box-shadow:0 1px 0 #FFFFFF inset;
67
- border:#DFDFDF solid 1px;
68
- line-height:1;
69
- margin-bottom:20px;
70
- min-width:255px;
71
- position:relative;
72
- }
73
- */
74
-
75
  .hndle {
76
  color:#464646;
77
  background-color:#F1F1F1;
@@ -181,19 +147,5 @@ a.awesome:active {
181
  top: 1px !important;
182
  }
183
 
184
- .green.awesome,.green.awesome:visited{background-color:#090 !important;}
185
- .green.awesome:hover{background-color:#060 !important;}
186
- .blue.awesome,.blue.awesome:visited{background-color:#3A8CD5 !important;}
187
- .blue.awesome:hover{background-color:#1760AF !important;}
188
- .turquoise.awesome,.turquoise.awesome:visited{background-color:#2daebf !important;}
189
- .turquoise.awesome:hover{background-color:#007d9a !important;}
190
  .red.awesome,.red.awesome:visited{background-color:#CC1100 !important;}
191
  .red.awesome:hover{background-color:#991100 !important;}
192
- .fire.awesome,.fire.awesome:visited{background-color:#FF030D !important;}
193
- .fire.awesome:hover{background-color:#991100 !important;}
194
- .magenta.awesome,.magenta.awesome:visited{background-color:#a9014b !important;}
195
- .magenta.awesome:hover{background-color:#630030 !important;}
196
- .orange.awesome,.orange.awesome:visited{background-color:#ff5c00 !important;}
197
- .orange.awesome:hover{background-color:#d45500 !important;}
198
- .yellow.awesome,.yellow.awesome:visited{background-color:#ffb515 !important;}
199
- .yellow.awesome:hover{background-color:#fc9200 !important;}
1
  /* Pinterest Pin It Button Admin CSS */
2
 
 
 
 
 
 
3
  .form-table {
4
  margin-bottom: 10px !important;
5
  }
13
  }
14
  .form-table input[type="checkbox"] {
15
  margin-right: 5px;
16
+ width: auto;
17
  }
18
 
19
  .form-table textarea {
21
  width: 350px;
22
  }
23
 
 
 
 
 
 
 
24
  .pib-postbox {
25
  margin: 10px 10px 0 0;
26
  }
30
  line-height: 1.2em;
31
  }
32
 
 
 
 
 
 
 
 
33
  .pib-settings {
34
  width: 70%;
35
  }
38
  width: 30%;
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  .hndle {
42
  color:#464646;
43
  background-color:#F1F1F1;
147
  top: 1px !important;
148
  }
149
 
 
 
 
 
 
 
150
  .red.awesome,.red.awesome:visited{background-color:#CC1100 !important;}
151
  .red.awesome:hover{background-color:#991100 !important;}
 
 
 
 
 
 
 
 
css/pinterest-pin-it-button.css CHANGED
@@ -1,6 +1,6 @@
1
- /* Pinterest Pin It Button Public CSS */
2
 
3
- /* DIV surrounding generated iframe */
4
  .pin-it-btn-wrapper,
5
  .pin-it-btn-shortcode-wrapper {
6
  height: 30px;
@@ -9,7 +9,7 @@
9
  }
10
 
11
  /* From Pinterest official html */
12
- .pin-it-btn {
13
  position: absolute;
14
  background: url(http://assets.pinterest.com/images/pinit6.png);
15
  font: 11px Arial, sans-serif;
@@ -21,34 +21,16 @@
21
  background-position: 0 -7px;
22
  }
23
 
24
- .pin-it-btn:hover {
25
  background-position: 0 -28px;
26
  }
27
 
28
- .pin-it-btn:active {
29
  background-position: 0 -49px;
30
  }
31
 
32
- /* Old CSS from Pinterest
33
- /*
34
- .pin-it-btn {
35
- position: relative;
36
- background: url(http://d3io1k5o0zdpqr.cloudfront.net/images/pinit.png);
37
- border: 1px solid #C9C5C5;
38
- border-color: #E8E4E4 #C9C5C5 #C9C5C5;
39
- border-radius: 3px;
40
- -moz-border-radius: 3px;
41
- -webkit-border-radius: 3px;
42
- box-shadow: 0 1px rgba(0,0,0,0.07);
43
- -moz-box-shadow: 0 1px rgba(0,0,0,0.07);
44
- -webkit-box-shadow: 0 1px rgba(0,0,0,0.07);
45
- font: 11px Arial, sans-serif;
46
- text-indent: -9999em;
47
- font-size: .01em;
48
- color: #CD1F1F;
49
- height: 22px;
50
- width: 47px;
51
- background-position: 0 -8px;
52
- display:block;
53
  }
54
- */
1
+ /* Pinterest "Pin It" Button Public CSS */
2
 
3
+ /* DIV surrounding button */
4
  .pin-it-btn-wrapper,
5
  .pin-it-btn-shortcode-wrapper {
6
  height: 30px;
9
  }
10
 
11
  /* From Pinterest official html */
12
+ a.pin-it-btn {
13
  position: absolute;
14
  background: url(http://assets.pinterest.com/images/pinit6.png);
15
  font: 11px Arial, sans-serif;
21
  background-position: 0 -7px;
22
  }
23
 
24
+ a.pin-it-btn:hover {
25
  background-position: 0 -28px;
26
  }
27
 
28
+ a.pin-it-btn:active {
29
  background-position: 0 -49px;
30
  }
31
 
32
+ /* Widgets */
33
+ .pib_widget_button,
34
+ .pib_widget_follow_button {
35
+ clear: both;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
 
inc/admin-pin-it-button-iframe.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <body style="margin: 0; padding: 0;">
3
+
4
+ <a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fpinterestplugin.com&media=http%3A%2F%2Fpinterestplugin.com%2Fwp-content%2Fuploads%2F2012%2F02%2Fpinterest-pin-it-button-wordpress-plugin.jpg&description=Pinterest%20%22Pin%20It%22%20Button%20Plugin%20for%20WordPress"
5
+ class="pin-it-button" count-layout="horizontal">Pin It</a>
6
+ <script type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"></script>
7
+
8
+ </body>
9
+ </html>
pinterest-pin-it-button.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Pinterest "Pin It" Button
4
  Plugin URI: http://pinterestplugin.com/
5
  Description: Add a Pinterest "Pin It" button to your posts and pages.
6
- Version: 1.1.2
7
  Author: Phil Derksen
8
  Author URI: http://pinterestplugin.com/
9
  */
10
 
11
- /* Copyright 2012 Phil Derksen (pderksen@gmail.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
@@ -42,6 +42,7 @@ function pib_install() {
42
 
43
  //Setup default settings
44
  $pib_options = array(
 
45
  'display_home_page' => 1,
46
  'display_front_page' => 0,
47
  'display_posts' => 1,
@@ -56,120 +57,53 @@ function pib_install() {
56
 
57
  //Save default option values
58
  update_option( 'pib_options', $pib_options );
59
- }
60
-
61
- register_activation_hook( __FILE__, 'pib_install' );
62
-
63
-
64
- /********************
65
- Public-Only Functions
66
- ********************/
67
-
68
- //Add Public CSS/JS
69
-
70
- function pib_add_public_css_js() {
71
- wp_enqueue_script( 'jquery' );
72
-
73
- wp_enqueue_style( 'pinterest-pin-it-button', plugins_url( '/css/pinterest-pin-it-button.css' , __FILE__ ) );
74
- wp_enqueue_script( 'pinterest-pin-it-button', plugins_url( '/js/pinterest-pin-it-button.js', __FILE__ ), array( 'jquery' ) );
75
- }
76
-
77
- add_action( 'wp_enqueue_scripts', 'pib_add_public_css_js' );
78
-
79
- //Add Custom CSS
80
-
81
- function pib_add_custom_css() {
82
- $pib_options = get_option( 'pib_options' );
83
- $custom_css = trim( $pib_options['custom_css'] );
84
-
85
- if ( $custom_css != '' ) {
86
- echo "\n" . '<style type="text/css">' . "\n" . $custom_css . "\n" . '</style>' . "\n";
87
- }
88
- }
89
-
90
- add_action( 'wp_head', 'pib_add_custom_css' );
91
-
92
- //Button html to render
93
-
94
- function pib_button_html() {
95
- $pib_options = get_option( 'pib_options' );
96
-
97
- //Check that remove surrounding div checkbox is selected
98
- if ( $pib_options['remove_div'] ) {
99
- return BASE_BTN_HTML;
100
- } else {
101
- //Surround with div tag
102
- return '<div class="pin-it-btn-wrapper">' . BASE_BTN_HTML . '</div>';
103
  }
104
- }
105
-
106
- //Register shortcode: [pinit]
107
-
108
- function pib_button_shortcode_html() {
109
- return '<div class="pin-it-btn-shortcode-wrapper">' . BASE_BTN_HTML . '</div>';
110
- }
111
-
112
- add_shortcode( 'pinit', 'pib_button_shortcode_html' );
113
-
114
- //Render button on pages with regular content
115
-
116
- function pib_render_btn( $content ) {
117
- //Load options array
118
- $pib_options = get_option( 'pib_options' );
119
-
120
- //Determine if displayed on current page
121
- if (
122
- ( is_home() && ( $pib_options['display_home_page'] ) ) ||
123
- ( is_front_page() && ( $pib_options['display_front_page'] ) ) ||
124
- ( is_single() && ( $pib_options['display_posts'] ) ) ||
125
- ( is_page() && ( $pib_options['display_pages'] ) ) ||
126
- ( is_archive() && ( $pib_options['display_archives'] ) )
127
- ) {
128
- if ( $pib_options['display_above_content'] ) {
129
- $content = pib_button_html() . $content;
130
- }
131
-
132
- if ( $pib_options['display_below_content'] ) {
133
- $content .= pib_button_html();
134
- }
135
- }
136
 
137
- return $content;
138
  }
139
 
140
- add_filter( 'the_content', 'pib_render_btn' );
141
 
142
- //Render button on pages with excerpts if option checked
 
 
143
 
144
- function pib_render_btn_excerpt( $content ) {
145
- //Load options array
146
  $pib_options = get_option( 'pib_options' );
147
-
148
- if ( $pib_options['display_on_post_excerpts'] ) {
149
- if (
150
- ( is_home() && ( $pib_options['display_home_page'] ) ) ||
151
- ( is_front_page() && ( $pib_options['display_front_page'] ) ) ||
152
- ( is_archive() && ( $pib_options['display_archives'] ) )
153
- ) {
154
- if ( $pib_options['display_above_content'] ) {
155
- $content = pib_button_html() . $content;
156
- }
157
-
158
- if ( $pib_options['display_below_content'] ) {
159
- $content .= pib_button_html();
160
- }
161
- }
162
- }
163
-
164
- return $content;
165
  }
166
 
167
- add_filter( 'the_excerpt', 'pib_render_btn_excerpt' );
168
-
169
-
170
- /********************
171
- Admin-Only Functions
172
- ********************/
173
 
174
  //Add settings page to admin menu
175
 
@@ -260,7 +194,17 @@ function pib_create_settings_page() {
260
  <td>
261
  <input id="display_archives" name="pib_options[display_archives]" type="checkbox"
262
  <?php if ( $pib_options['display_archives'] ) echo 'checked="checked"'; ?> />
263
- <label for="display_archives">Archives Page (Category, Tag, Author, time-based, etc.)</label>
 
 
 
 
 
 
 
 
 
 
264
  </td>
265
  </tr>
266
  </table>
@@ -339,8 +283,7 @@ function pib_create_settings_page() {
339
  </form>
340
  </div>
341
  </div>
342
-
343
- <div class="pib-right-column postbox-container">
344
  <div class="meta-box-sortables ui-sortable">
345
  <div id="email-signup">
346
  <h4>Like This Plugin?</h4>
@@ -367,6 +310,30 @@ function pib_create_settings_page() {
367
  No spam. Unsubscribe anytime.
368
  </p>
369
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
 
371
  <div id="other-links" class="postbox pib-postbox">
372
  <div class="handlediv" title="Click to toggle"><br /></div>
@@ -374,7 +341,7 @@ function pib_create_settings_page() {
374
 
375
  <div class="inside">
376
  <ul>
377
- <li><a href="http://pinterestplugin.com/" target="_blank">Official Plugin Site</a></li>
378
  <li><a href="https://pinterestplugin.uservoice.com/" target="_blank">User Support &amp; Feature Requests</a></li>
379
  </ul>
380
  </div>
@@ -385,34 +352,7 @@ function pib_create_settings_page() {
385
  <h3 class="hndle">News from PinterestPlugin.com</h3>
386
 
387
  <div class="inside">
388
- <?php // Get RSS Feed(s) -- code from http://codex.wordpress.org/Function_Reference/fetch_feed
389
- include_once(ABSPATH . WPINC . '/feed.php');
390
-
391
- // Get a SimplePie feed object from the specified feed source.
392
- $rss = fetch_feed('http://pinterestplugin.com/feed/');
393
-
394
- if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
395
- // Figure out how many total items there are, but limit it to 5.
396
- $maxitems = $rss->get_item_quantity(5);
397
-
398
- // Build an array of all the items, starting with element 0 (first element).
399
- $rss_items = $rss->get_items(0, $maxitems);
400
- endif;
401
- ?>
402
-
403
- <ul>
404
- <?php if ($maxitems == 0) echo '<li>No items.</li>';
405
- else
406
- // Loop through each feed item and display each item as a hyperlink.
407
- foreach ( $rss_items as $item ) : ?>
408
- <li>
409
- <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
410
- title='<?php echo 'Posted ' . $item->get_date('j F Y | g:i a'); ?>'
411
- target="_blank">
412
- <?php echo esc_html( $item->get_title() ); ?></a>
413
- </li>
414
- <?php endforeach; ?>
415
- </ul>
416
  </div>
417
  </div>
418
  </div>
@@ -423,6 +363,111 @@ function pib_create_settings_page() {
423
  <?php
424
  }
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  //Add a link to the settings page to the plugins list
427
 
428
  function pib_plugin_action_links( $links, $file ) {
@@ -439,4 +484,461 @@ function pib_plugin_action_links( $links, $file ) {
439
 
440
  add_filter( 'plugin_action_links', 'pib_plugin_action_links', 10, 2 );
441
 
442
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Pinterest "Pin It" Button
4
  Plugin URI: http://pinterestplugin.com/
5
  Description: Add a Pinterest "Pin It" button to your posts and pages.
6
+ Version: 1.2.0
7
  Author: Phil Derksen
8
  Author URI: http://pinterestplugin.com/
9
  */
10
 
11
+ /* Copyright 2012 Phil Derksen (phil@pinterestplugin.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
42
 
43
  //Setup default settings
44
  $pib_options = array(
45
+ //'admin_activate_notice' => 0,
46
  'display_home_page' => 1,
47
  'display_front_page' => 0,
48
  'display_posts' => 1,
57
 
58
  //Save default option values
59
  update_option( 'pib_options', $pib_options );
60
+
61
+ //Save default values for page/post meta boxes
62
+ global $wpdb;
63
+ $sql = "SELECT ID
64
+ FROM $wpdb->posts
65
+ WHERE post_type = 'post' || post_type = 'page'";
66
+
67
+ $results = $wpdb->get_results( $sql, ARRAY_A );
68
+
69
+ foreach( $results as $post_id )
70
+ {
71
+ $postid = $post_id['ID'];
72
+ update_post_meta( $postid, 'pib_sharing_enabled', 1 );
73
+ }
74
+
75
+ $category_ids = get_all_category_ids();
76
+ foreach($category_ids as $term_id) {
77
+ $tag_extra_fields[$term_id]['checkbox'] = 1;
78
+ update_option(PIB_CATEGORY_FIELDS, $tag_extra_fields);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
 
81
  }
82
 
83
+ register_activation_hook( __FILE__, 'pib_install' );
84
 
85
+ //Display admin notice only once, then set option to turn off
86
+ //Using saved option instead of session which was causing errors for some
87
+ //TODO Removed until further testing
88
 
89
+ /*
90
+ function pib_plugin_activate_notice() {
91
  $pib_options = get_option( 'pib_options' );
92
+
93
+ if ( !$pib_options['admin_activate_notice'] ) {
94
+ echo '<div class="updated"><p>' .
95
+ '<strong>Your "Pin It" Button is activated!</strong> ' .
96
+ sprintf( __( '<a href="%1$s" class="activate-notice-link">Customize Your Settings</a>' ),
97
+ 'admin.php?page=' . PIB_PLUGIN_BASENAME ) .
98
+ '</p></div>';
99
+
100
+ $pib_options['admin_activate_notice'] = 1;
101
+ update_option( 'pib_options', $pib_options );
102
+ }
 
 
 
 
 
 
 
103
  }
104
 
105
+ add_action('admin_notices', 'pib_plugin_activate_notice');
106
+ */
 
 
 
 
107
 
108
  //Add settings page to admin menu
109
 
194
  <td>
195
  <input id="display_archives" name="pib_options[display_archives]" type="checkbox"
196
  <?php if ( $pib_options['display_archives'] ) echo 'checked="checked"'; ?> />
197
+ <label for="display_archives">Archives (includes Category, Tag, Author and time-based pages)</label>
198
+ </td>
199
+ </tr>
200
+ <tr valign="top">
201
+ <td>
202
+ When editing a post, page or category, scroll down to find the option to hide the "Pin It" button for it.
203
+ </td>
204
+ </tr>
205
+ <tr valign="top">
206
+ <td>
207
+ Go to <a href="<?php echo admin_url( 'widgets.php' ); ?>">Widgets</a> to add a "Pin It" button to the sidebar.
208
  </td>
209
  </tr>
210
  </table>
283
  </form>
284
  </div>
285
  </div>
286
+ <div class="pib-right-column postbox-container">
 
287
  <div class="meta-box-sortables ui-sortable">
288
  <div id="email-signup">
289
  <h4>Like This Plugin?</h4>
310
  No spam. Unsubscribe anytime.
311
  </p>
312
  </div>
313
+
314
+ <div id="promo-buttons" class="postbox pib-postbox">
315
+ <div class="handlediv" title="Click to toggle"><br /></div>
316
+ <h3 class="hndle">Spread the Word!</h3>
317
+
318
+ <div class="inside">
319
+ <p>The more people using this plugin the more we can add to it for you. Just take a sec and share it!</p>
320
+
321
+ <table>
322
+ <tr>
323
+ <td><?php echo pib_share_facebook(); ?></td>
324
+ </tr>
325
+ <tr>
326
+ <td><?php echo pib_share_twitter(); ?></td>
327
+ </tr>
328
+ <tr>
329
+ <td><?php echo pib_share_google_plus(); ?></td>
330
+ </tr>
331
+ <tr>
332
+ <td><?php echo pib_share_pinterest(); ?></td>
333
+ </tr>
334
+ </table>
335
+ </div>
336
+ </div>
337
 
338
  <div id="other-links" class="postbox pib-postbox">
339
  <div class="handlediv" title="Click to toggle"><br /></div>
341
 
342
  <div class="inside">
343
  <ul>
344
+ <li><a href="http://pinterestplugin.com/" target="_blank">Official Site - PinterestPlugin.com</a></li>
345
  <li><a href="https://pinterestplugin.uservoice.com/" target="_blank">User Support &amp; Feature Requests</a></li>
346
  </ul>
347
  </div>
352
  <h3 class="hndle">News from PinterestPlugin.com</h3>
353
 
354
  <div class="inside">
355
+ <? echo pib_rss_news(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  </div>
357
  </div>
358
  </div>
363
  <?php
364
  }
365
 
366
+ //Render rss items from pinterestplugin.com
367
+ //http://codex.wordpress.org/Function_Reference/fetch_feed
368
+ function pib_rss_news() {
369
+ // Get RSS Feed(s)
370
+ include_once(ABSPATH . WPINC . '/feed.php');
371
+
372
+ // Get a SimplePie feed object from the specified feed source.
373
+ $rss = fetch_feed('http://pinterestplugin.com/feed/');
374
+
375
+ if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
376
+ // Figure out how many total items there are, but limit it to 5.
377
+ $maxitems = $rss->get_item_quantity(5);
378
+
379
+ // Build an array of all the items, starting with element 0 (first element).
380
+ $rss_items = $rss->get_items(0, $maxitems);
381
+ endif;
382
+ ?>
383
+
384
+ <ul>
385
+ <?php if ($maxitems == 0) echo '<li>No items.</li>';
386
+ else
387
+ // Loop through each feed item and display each item as a hyperlink.
388
+ foreach ( $rss_items as $item ) : ?>
389
+ <li>
390
+ <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
391
+ title='<?php echo 'Posted ' . $item->get_date('j F Y | g:i a'); ?>'
392
+ target="_blank">
393
+ <?php echo esc_html( $item->get_title() ); ?></a>
394
+ </li>
395
+ <?php endforeach; ?>
396
+ </ul>
397
+
398
+ <?php
399
+ }
400
+
401
+ //Render Facebook Share button
402
+ //http://developers.facebook.com/docs/share/
403
+ function pib_share_facebook() {
404
+ ?>
405
+
406
+ <a name="fb_share" type="button" share_url="http://pinterestplugin.com/" alt="Share on Facebook"></a>
407
+ <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
408
+
409
+ <?php
410
+ }
411
+
412
+ //Render Twitter button
413
+ //https://twitter.com/about/resources/buttons
414
+ function pib_share_twitter() {
415
+ ?>
416
+
417
+ <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://pinterestplugin.com/" data-text="Check out the Pinterest &quot;Pin It&quot; Button Plugin for WordPress" alt="Tweet this!">Tweet</a>
418
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
419
+
420
+ <?php
421
+ }
422
+
423
+ //Render Google +1 button
424
+ //http://www.google.com/intl/en/webmasters/+1/button/index.html
425
+ function pib_share_google_plus() {
426
+ ?>
427
+
428
+ <!-- Place this tag where you want the +1 button to render -->
429
+ <div class="g-plusone" data-size="small" data-annotation="inline" data-href="http://pinterestplugin.com/"></div>
430
+
431
+ <!-- Place this render call where appropriate -->
432
+ <script type="text/javascript">
433
+ (function() {
434
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
435
+ po.src = 'https://apis.google.com/js/plusone.js';
436
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
437
+ })();
438
+ </script>
439
+
440
+ <?php
441
+ }
442
+
443
+ //Render Pin It button
444
+ function pib_share_pinterest() {
445
+ ?>
446
+ <iframe src='<?php echo plugins_url( '/inc/admin-pin-it-button-iframe.html' , __FILE__ ) ?>' scrolling="no" frameborder="0" allowtransparency="true"
447
+ style="border:none; overflow:hidden; width:px; height:20px"></iframe>
448
+ <?php
449
+ }
450
+
451
+ //Render Facebook Like button
452
+ //http://developers.facebook.com/docs/reference/plugins/like/
453
+ //TODO Not using since correct image isn't coming up for now
454
+ function pib_like_facebook() {
455
+ ?>
456
+
457
+ <div id="fb-root"></div>
458
+ <script>(function(d, s, id) {
459
+ var js, fjs = d.getElementsByTagName(s)[0];
460
+ if (d.getElementById(id)) return;
461
+ js = d.createElement(s); js.id = id;
462
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=144056775628952";
463
+ fjs.parentNode.insertBefore(js, fjs);
464
+ }(document, 'script', 'facebook-jssdk'));</script>
465
+
466
+ <div class="fb-like" data-href="http://pinterestplugin.com/" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
467
+
468
+ <?php
469
+ }
470
+
471
  //Add a link to the settings page to the plugins list
472
 
473
  function pib_plugin_action_links( $links, $file ) {
484
 
485
  add_filter( 'plugin_action_links', 'pib_plugin_action_links', 10, 2 );
486
 
487
+ //Adds a meta box to the main column on the Post and Page edit screens
488
+
489
+ function pib_sharing_add_meta_box() {
490
+ add_meta_box( 'pib_sharing_meta','"Pin It" Button Display', 'pib_sharing_meta_box_content', 'page', 'advanced', 'high' );
491
+ add_meta_box( 'pib_sharing_meta','"Pin It" Button Display', 'pib_sharing_meta_box_content', 'post', 'advanced', 'high' );
492
+ }
493
+
494
+ add_action( 'admin_init', 'pib_sharing_add_meta_box' );
495
+
496
+ //Renders the post/page meta box checkbox html
497
+
498
+ function pib_sharing_meta_box_content( $post ) {
499
+ $pib_sharing_checked = get_post_meta( $post->ID, 'pib_sharing_enabled', 1 );
500
+
501
+ if ( $pib_sharing_checked || $pib_sharing_checked == true )
502
+ $pib_sharing_checked = 'checked="checked"';
503
+ else
504
+ $pib_sharing_checked = '';
505
+ ?>
506
+
507
+ <p>
508
+ <input name="pib_enable_post_sharing" id="pib_enable_post_sharing" value="1" <?php echo $pib_sharing_checked; ?> type="checkbox" />
509
+ <label for="pib_enable_post_sharing">Show "Pin It" button on this post/page.</label>
510
+ <p class="description">
511
+ <!-- <span style="font-size: 11px;"> -->
512
+ If checked displays the button for this post/page if <strong>Individual Posts</strong> (for posts) or <strong>WordPress Static "Pages"</strong>
513
+ (for pages) is also checked in <a href='<?php echo 'admin.php?page=' . PIB_PLUGIN_BASENAME ?>'>"Pin It" Button Settings</a>.
514
+ If unchecked the button will always be hidden for this page or post.
515
+ </p>
516
+ <input type="hidden" name="pib_sharing_status_hidden" value="1" />
517
+ </p>
518
+
519
+ <?php
520
+ }
521
+
522
+ //Saves display option for individual post/page
523
+
524
+ function pib_sharing_meta_box_save( $post_id ) {
525
+ if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
526
+ return $post_id;
527
+
528
+ //Record sharing enable
529
+ if ( isset( $_POST['post_type'] ) && ( 'post' == $_POST['post_type'] || 'page' == $_POST['post_type'] ) ) {
530
+ if ( current_user_can( 'edit_post', $post_id ) ) {
531
+ if ( isset( $_POST['pib_sharing_status_hidden'] ) ) {
532
+ if ( isset( $_POST['pib_enable_post_sharing'] ) )
533
+ update_post_meta( $post_id, 'pib_sharing_enabled', 1 );
534
+ else
535
+ delete_post_meta( $post_id, 'pib_sharing_enabled' );
536
+ }
537
+ }
538
+ }
539
+
540
+ return $post_id;
541
+ }
542
+
543
+ add_action( 'save_post', 'pib_sharing_meta_box_save' );
544
+
545
+ //Add Public CSS/JS
546
+
547
+ function pib_add_public_css_js() {
548
+ wp_enqueue_script( 'jquery' );
549
+
550
+ wp_enqueue_style( 'pinterest-pin-it-button', plugins_url( '/css/pinterest-pin-it-button.css' , __FILE__ ) );
551
+ wp_enqueue_script( 'pinterest-pin-it-button', plugins_url( '/js/pinterest-pin-it-button.js', __FILE__ ), array( 'jquery' ) );
552
+ }
553
+
554
+ add_action( 'wp_enqueue_scripts', 'pib_add_public_css_js' );
555
+
556
+ //Add Custom CSS
557
+
558
+ function pib_add_custom_css() {
559
+ $pib_options = get_option( 'pib_options' );
560
+ $custom_css = trim( $pib_options['custom_css'] );
561
+
562
+ if ( $custom_css != '' ) {
563
+ echo "\n" . '<style type="text/css">' . "\n" . $custom_css . "\n" . '</style>' . "\n";
564
+ }
565
+ }
566
+
567
+ add_action( 'wp_head', 'pib_add_custom_css' );
568
+
569
+ //Button html to render
570
+
571
+ function pib_button_html() {
572
+ $pib_options = get_option( 'pib_options' );
573
+
574
+ //Check that remove surrounding div checkbox is selected
575
+ if ( $pib_options['remove_div'] ) {
576
+ return BASE_BTN_HTML;
577
+ } else {
578
+ //Surround with div tag
579
+ return '<div class="pin-it-btn-wrapper">' . BASE_BTN_HTML . '</div>';
580
+ }
581
+ }
582
+
583
+ //Register shortcode: [pinit]
584
+
585
+ function pib_button_shortcode_html() {
586
+ return '<div class="pin-it-btn-shortcode-wrapper">' . BASE_BTN_HTML . '</div>';
587
+ }
588
+
589
+ add_shortcode( 'pinit', 'pib_button_shortcode_html' );
590
+
591
+ //Render button on pages with regular content
592
+
593
+ function pib_render_btn( $content ) {
594
+ //Load options array
595
+ $pib_options = get_option( 'pib_options' );
596
+
597
+
598
+ //Determine if displayed on current page
599
+ if (
600
+ ( is_home() && ( $pib_options['display_home_page'] ) ) ||
601
+ ( is_front_page() && ( $pib_options['display_front_page'] ) )
602
+
603
+ ) {
604
+ if ( $pib_options['display_above_content'] ) {
605
+ $content = pib_button_html() . $content;
606
+ }
607
+
608
+ if ( $pib_options['display_below_content'] ) {
609
+ $content .= pib_button_html();
610
+ }
611
+ }
612
+
613
+ //Determine if displayed on individual post or page from meta value
614
+ if( ( is_single() && ( $pib_options['display_posts'] ) ) ||
615
+ ( is_page() && ( $pib_options['display_pages'] ) )) {
616
+
617
+ global $wpdb;
618
+ $sql = "SELECT post_id
619
+ FROM $wpdb->postmeta
620
+ WHERE meta_key = 'pib_sharing_enabled' AND meta_value = '1'";
621
+
622
+ $results = $wpdb->get_results( $sql, ARRAY_A );
623
+
624
+ foreach( $results as $postid ) {
625
+ $postID = $postid['post_id'];
626
+ if(is_single($postID) || is_page($postID)) {
627
+ if ( $pib_options['display_above_content'] ) {
628
+ $content = pib_button_html() . $content;
629
+ }
630
+
631
+ if ( $pib_options['display_below_content'] ) {
632
+ $content .= pib_button_html();
633
+ }
634
+ }
635
+ }
636
+ }
637
+
638
+ //Determine if displayed on Category on the base of category edit Screen Option
639
+ if( is_archive() && ( $pib_options['display_archives'] ) ) {
640
+
641
+ $tag_extra_fields = get_option(PIB_CATEGORY_FIELDS);
642
+ $category_ids = get_all_category_ids();
643
+ foreach($category_ids as $term_id) {
644
+
645
+ if($tag_extra_fields[$term_id]['checkbox'] == 1) {
646
+
647
+ if(is_category($term_id)) {
648
+ if ( $pib_options['display_above_content'] ) {
649
+ $content = pib_button_html() . $content;
650
+ }
651
+
652
+ if ( $pib_options['display_below_content'] ) {
653
+ $content .= pib_button_html();
654
+ }
655
+ }
656
+ }
657
+ }
658
+ }
659
+
660
+ return $content;
661
+ }
662
+
663
+ add_filter( 'the_content', 'pib_render_btn' );
664
+
665
+
666
+ //Render button on pages with excerpts if option checked
667
+
668
+ function pib_render_btn_excerpt( $content ) {
669
+ //Load options array
670
+ $pib_options = get_option( 'pib_options' );
671
+
672
+ if ( $pib_options['display_on_post_excerpts'] ) {
673
+ if (
674
+ ( is_home() && ( $pib_options['display_home_page'] ) ) ||
675
+ ( is_front_page() && ( $pib_options['display_front_page'] ) )
676
+
677
+ ) {
678
+ if ( $pib_options['display_above_content'] ) {
679
+ $content = pib_button_html() . $content;
680
+ }
681
+
682
+ if ( $pib_options['display_below_content'] ) {
683
+ $content .= pib_button_html();
684
+ }
685
+ }
686
+
687
+
688
+ //Determine if displayed on Category on the base of category edit Screen Option
689
+ if( is_archive() && ( $pib_options['display_archives'] ) ) {
690
+
691
+ $tag_extra_fields = get_option(PIB_CATEGORY_FIELDS);
692
+ $category_ids = get_all_category_ids();
693
+ foreach($category_ids as $term_id) {
694
+
695
+ if($tag_extra_fields[$term_id]['checkbox'] == 1) {
696
+
697
+
698
+ if(is_category($term_id)) {
699
+ if ( $pib_options['display_above_content'] ) {
700
+ $content = pib_button_html() . $content;
701
+ }
702
+
703
+ if ( $pib_options['display_below_content'] ) {
704
+ $content .= pib_button_html();
705
+ }
706
+ }
707
+ }
708
+
709
+ }
710
+ }
711
+ }
712
+ return $content;
713
+ }
714
+
715
+ add_filter( 'the_excerpt', 'pib_render_btn_excerpt' );
716
+
717
+ //Option name
718
+ define('PIB_CATEGORY_FIELDS', 'pib_category_fields_option');
719
+
720
+ //Add Checkbox to Category Edit Screen
721
+ add_action('edit_category_form_fields', 'pib_category_fields');
722
+
723
+ function pib_category_fields($tag) {
724
+ $t_id = $tag->term_id;
725
+ $tag_extra_fields = get_option(PIB_CATEGORY_FIELDS);
726
+
727
+
728
+ if ( $tag_extra_fields[$t_id]['checkbox'] == 1)
729
+ $pib_category_checked = 'checked="checked"';
730
+ else
731
+ $pib_category_checked = '';
732
+ ?>
733
+
734
+ <table class="form-table">
735
+ <tr class="form-field">
736
+ <th scope="row" valign="top">
737
+ <h3>"Pin It" Button Settings</h3>
738
+ </th>
739
+ </tr>
740
+ <tbody>
741
+ <tr class="form-field">
742
+ <th scope="row" valign="top">
743
+ <label for="pib_category_field">Show "Pin It" Button</label>
744
+ </th>
745
+ <td>
746
+ <input name="pib_category_field" id="pib_category_field" type="checkbox" value="1" <?php echo $pib_category_checked; ?>>
747
+ <p class="description">
748
+ If checked displays the button for this category (if <strong>Archives</strong> also checked in
749
+ <a href='<?php echo 'admin.php?page=' . PIB_PLUGIN_BASENAME ?>'>"Pin It" Button Settings</a>).
750
+ If unchecked the button will always be hidden for this category.
751
+ </p>
752
+ </td>
753
+ </tr>
754
+ </tbody>
755
+ </table>
756
+
757
+ <?php
758
+ }
759
+
760
+ // when the form gets submitted, and the category gets updated (in your case the option will get updated with the values of your custom fields above
761
+ add_action('edited_category', 'update_pib_category_fields');
762
+
763
+ function update_pib_category_fields($term_id) {
764
+ if($_POST['taxonomy'] == 'category'):
765
+ $tag_extra_fields = get_option(PIB_CATEGORY_FIELDS);
766
+ $tag_extra_fields[$term_id]['checkbox'] = strip_tags($_POST['pib_category_field']);
767
+
768
+ update_option(PIB_CATEGORY_FIELDS, $tag_extra_fields);
769
+ endif;
770
+ }
771
+
772
+ //Add Pinterest Pin It Button widget to sidebar
773
+
774
+ class Pib_Widget extends WP_Widget {
775
+
776
+ function __construct() {
777
+ $widget_ops = array('classname' => 'pib_widget_button', 'description' => __( 'Add a "Pin It" button to your sidebar with this widget') );
778
+ parent::__construct('pib_button', __('Pinterest - "Pin It" Button'), $widget_ops);
779
+ }
780
+
781
+ function widget( $args, $instance ) {
782
+ extract($args);
783
+
784
+ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
785
+
786
+ echo $before_widget;
787
+ if ( $title )
788
+ echo $before_title . $title . $after_title;
789
+
790
+ echo '<div class="pin-it-btn-wrapper">' . BASE_BTN_HTML . '</div>';
791
+ echo $after_widget;
792
+ }
793
+
794
+ function update( $new_instance, $old_instance ) {
795
+ $instance = $old_instance;
796
+ $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '') );
797
+ $instance['title'] = strip_tags($new_instance['title']);
798
+
799
+ return $instance;
800
+ }
801
+
802
+ function form( $instance ) {
803
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
804
+ $title = strip_tags($instance['title']);
805
+
806
+ ?>
807
+
808
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
809
+ <p>
810
+
811
+ <?php
812
+ }
813
+ }
814
+
815
+ //Add function to the widgets_init hook.
816
+ add_action( 'widgets_init', 'pib_load_widgets' );
817
+
818
+ // Function that register Pin It Button widget.
819
+ function pib_load_widgets() {
820
+ register_widget( 'Pib_Widget' );
821
+ }
822
+
823
+ //Add Pinterest Follow Button Widget to sidebar
824
+
825
+ class Pib_Follow_Button_Widget extends WP_Widget {
826
+
827
+ function __construct() {
828
+ $widget_ops = array('classname' => 'pib_widget_follow_button', 'description' => __( 'Add a Pinterest "Follow" button to your sidebar with this widget') );
829
+ parent::__construct('pib_follow_button', __('Pinterest - "Follow" Button'), $widget_ops);
830
+ }
831
+
832
+ function widget( $args, $instance ) {
833
+ extract($args);
834
+
835
+ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
836
+ $pib_img_option = $instance['pib_follow_button_radio'];
837
+ $pibusername = $instance['pibusername'];
838
+ $newwindow = $instance['newwindow'] ? '1' : '0';
839
+
840
+ echo $before_widget;
841
+ if ( $title )
842
+ echo $before_title . $title . $after_title;
843
+
844
+ if($pib_img_option == 1){
845
+ if($newwindow){
846
+ echo '<a href="http://pinterest.com/'.$pibusername.'/" target="_blank"><img src="http://passets-cdn.pinterest.com/images/follow-on-pinterest-button.png" width="156" height="26" alt="Follow Me on Pinterest" /></a>';
847
+ }
848
+ else{
849
+ echo '<a href="http://pinterest.com/'.$pibusername.'/"><img src="http://passets-cdn.pinterest.com/images/follow-on-pinterest-button.png" width="156" height="26" alt="Follow Me on Pinterest" /></a>';
850
+ }
851
+ }
852
+ elseif($pib_img_option == 2){
853
+ if($newwindow){
854
+ echo'<a href="http://pinterest.com/'.$pibusername.'/" target="_blank"><img src="http://passets-cdn.pinterest.com/images/pinterest-button.png" width="78" height="26" alt="Follow Me on Pinterest" /></a>';
855
+ }
856
+ else {
857
+ echo'<a href="http://pinterest.com/'.$pibusername.'/"><img src="http://passets-cdn.pinterest.com/images/pinterest-button.png" width="78" height="26" alt="Follow Me on Pinterest" /></a>';
858
+ }
859
+ }
860
+ elseif($pib_img_option == 3){
861
+ if($newwindow){
862
+ echo'<a href="http://pinterest.com/'.$pibusername.'/" target="_blank"><img src="http://passets-cdn.pinterest.com/images/big-p-button.png" width="61" height="61" alt="Follow Me on Pinterest" /></a>';
863
+ }
864
+ else {
865
+ echo'<a href="http://pinterest.com/'.$pibusername.'/"><img src="http://passets-cdn.pinterest.com/images/big-p-button.png" width="61" height="61" alt="Follow Me on Pinterest" /></a>';
866
+ }
867
+ }
868
+ elseif($pib_img_option == 4){
869
+ if($newwindow){
870
+ echo'<a href="http://pinterest.com/'.$pibusername.'/" target="_blank"><img src="http://passets-cdn.pinterest.com/images/small-p-button.png" width="16" height="16" alt="Follow Me on Pinterest" /></a>';
871
+ }
872
+ else {
873
+ echo'<a href="http://pinterest.com/'.$pibusername.'/"><img src="http://passets-cdn.pinterest.com/images/small-p-button.png" width="16" height="16" alt="Follow Me on Pinterest" /></a>';
874
+ }
875
+ }
876
+
877
+ echo $after_widget;
878
+ }
879
+
880
+ function update( $new_instance, $old_instance ) {
881
+ $instance = $old_instance;
882
+ $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'pibusername' => '', 'pib_follow_button_radio' => '1') );
883
+ $instance['title'] = strip_tags($new_instance['title']);
884
+ $instance['pibusername'] = strip_tags($new_instance['pibusername']);
885
+ $instance['pib_follow_button_radio'] = strip_tags($new_instance['pib_follow_button_radio']);
886
+ $instance['newwindow'] = !empty($new_instance['newwindow']) ? 1 : 0;
887
+
888
+ return $instance;
889
+ }
890
+
891
+ function form( $instance ) {
892
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'pibusername' => '', 'pib_follow_button_radio' => '1') );
893
+ $title = strip_tags($instance['title']);
894
+ $pibusername = strip_tags($instance['pibusername']);
895
+ $pib_follow_button_radio = $instance['pib_follow_button_radio'];
896
+ $newwindow = isset( $instance['newwindow'] ) ? (bool) $instance['newwindow'] : false;
897
+
898
+ ?>
899
+
900
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
901
+ <p>
902
+
903
+ <p><label for="<?php echo $this->get_field_id('pibusername'); ?>"><?php _e('Pinterest Username:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('pibusername'); ?>" name="<?php echo $this->get_field_name('pibusername'); ?>" type="text" value="<?php echo esc_attr($pibusername); ?>" /></p>
904
+ <p>
905
+
906
+ <p><label>Button image:</label></p>
907
+
908
+ <table>
909
+ <tr>
910
+ <td><input type="radio" <?php if($pib_follow_button_radio == 1){ echo'checked="checked"';} ?> name="<?php echo $this->get_field_name('pib_follow_button_radio'); ?>" id="<?php echo $this->get_field_id('follow-on-pinterest-button'); ?>" value="1" /></td>
911
+ <td><img src="http://passets-cdn.pinterest.com/images/follow-on-pinterest-button.png" width="156" height="26" alt="Follow Me on Pinterest" /></td>
912
+ </tr>
913
+ <tr>
914
+ <td><input type="radio" <?php if($pib_follow_button_radio == 2){ echo'checked="checked"';} ?> name="<?php echo $this->get_field_name('pib_follow_button_radio'); ?>" id="<?php echo $this->get_field_id('pinterest-button'); ?>" value="2"/></td>
915
+ <td><img src="http://passets-cdn.pinterest.com/images/pinterest-button.png" width="78" height="26" alt="Follow Me on Pinterest" /></td>
916
+ </tr>
917
+ <tr>
918
+ <td><input type="radio" <?php if($pib_follow_button_radio == 3){ echo'checked="checked"';} ?> name="<?php echo $this->get_field_name('pib_follow_button_radio'); ?>" id="<?php echo $this->get_field_id('big-p-button'); ?>" value="3"/></td>
919
+ <td><img src="http://passets-cdn.pinterest.com/images/big-p-button.png" width="61" height="61" alt="Follow Me on Pinterest" /></td>
920
+ </tr>
921
+ <tr>
922
+ <td><input type="radio" <?php if($pib_follow_button_radio == 4){ echo'checked="checked"';} ?> name="<?php echo $this->get_field_name('pib_follow_button_radio'); ?>" id="<?php echo $this->get_field_id('small-p-button'); ?>" value="4"/></td>
923
+ <td><img src="http://passets-cdn.pinterest.com/images/small-p-button.png" width="16" height="16" alt="Follow Me on Pinterest" /></td>
924
+ </tr>
925
+ </table>
926
+ <br />
927
+ <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('newwindow'); ?>" name="<?php echo $this->get_field_name('newwindow'); ?>" <?php checked( $newwindow ); ?> />
928
+ <label for="<?php echo $this->get_field_id('newwindow'); ?>"><?php _e( 'Open in a new window' ); ?></label><br />
929
+
930
+ <?php
931
+ }
932
+ }
933
+
934
+ //Add function to the widgets_init hook.
935
+ add_action( 'widgets_init', 'pib_load_follow_button_widget' );
936
+
937
+ // Function that registers Follow Button widget.
938
+ function pib_load_follow_button_widget() {
939
+ register_widget( 'Pib_Follow_Button_Widget' );
940
+ }
941
+
942
+
943
+
944
+ ?>
readme.txt CHANGED
@@ -9,6 +9,26 @@ Add a Pinterest "Pin It" Button to your posts and pages allowing your readers ea
9
 
10
  == Description ==
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  Take advantage of the exploding traffic Pinterest is generating by encouraging your readers to pin your content using this simple "Pin It" button.
13
 
14
  **Pinterest Drives More Traffic Than Google+, YouTube and LinkedIn Combined** - Mashable, Feb 1, 2012 [[link]](http://mashable.com/2012/02/01/pinterest-traffic-study/)
@@ -17,29 +37,28 @@ Take advantage of the exploding traffic Pinterest is generating by encouraging y
17
 
18
  **Pinterest Hits 10 Million U.S. Monthly Uniques Faster Than Any Standalone Site Ever** - TechCrunch, Feb 7, 2012 [[link]](http://techcrunch.com/2012/02/07/pinterest-monthly-uniques/)
19
 
20
- Head to the official plugin site at *[PinterestPlugin.com](http://pinterestplugin.com)* for additional info and updates.
21
-
22
- [Sample Photography Blog](http://bruisesandbandaids.com)
23
 
24
- [User Support & Feature Requests](https://pinterestplugin.uservoice.com)
 
 
25
 
26
- **Features**
27
 
28
- * Display button on various page types: blog home page, front page, posts, pages, archives
29
- * Display button above and/or below content
30
- * Optionally display button on post excerpts
31
- * Display button inside content with a shortcode
32
- * Add custom CSS for fine-tuning button layout and styling
33
 
34
- == Installation ==
35
 
36
- 1. Use the automatic installer in your WordPress admin
37
- 1. Activate the plugin
38
- 1. Configure the plugin by going to **Pin It Button** that appears in your admin menu
39
 
40
- Alertnatively, you can download this plugin, unzip the contents, then FTP upload to the `/wp-content/plugins/` directory.
41
 
42
- == Frequently Asked Questions ==
 
 
 
 
 
43
 
44
  **How do I display the button in places other than above or below the content?**
45
 
@@ -49,7 +68,7 @@ Alertnatively, you can download this plugin, unzip the contents, then FTP upload
49
  **How do I get the "Pin It" button to line up next to my other social sharing icons?**
50
 
51
  * Add custom CSS on the settings screen and optionally remove the surrounding `<div>` tag.
52
- * Start with these [custom CSS examples](http://pinterestplugin.com/pin-it-button-custom-css).
53
 
54
  **I'd like to report a bug or submit a feature request.**
55
 
@@ -63,6 +82,19 @@ Alertnatively, you can download this plugin, unzip the contents, then FTP upload
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  = 1.1.2 =
67
 
68
  * Bug fix: Removed use of session state storing for now as it caused errors for some
@@ -83,13 +115,13 @@ Alertnatively, you can download this plugin, unzip the contents, then FTP upload
83
 
84
  = 1.0.2 =
85
 
86
- * Added checkbox option to display/hide on post excerpts
87
  * "Pin It" links generated by the shortcode should not show up when viewing the post in RSS readers
88
  * Settings link added to the plugin entry on the plugins page
89
 
90
  = 1.0.1 =
91
 
92
- * Added checkbox option to display/hide on "front page" (sometimes different than home page)
93
 
94
  = 1.0.0 =
95
 
9
 
10
  == Description ==
11
 
12
+ Add a Pinterest "Pin It" Button to your posts and pages.
13
+
14
+ **"Pin It" Button Features**
15
+
16
+ * Display on various page types: blog home page, front page, posts, pages, archives
17
+ * Display above and/or below content
18
+ * Optionally display on post excerpts
19
+ * Hide on selected posts and pages
20
+ * Hide on selected categories
21
+ * Display within content with a shortcode
22
+ * Add custom CSS for fine-tuning layout and styling
23
+ * Add "Pin It" button as a sidebar widget
24
+ * Add a "Follow" on Pinterest button as a sidebar widget
25
+
26
+ **Resources**
27
+
28
+ * Official Site: [PinterestPlugin.com](http://pinterestplugin.com)
29
+ * Sample blog using plugin: http://bruisesandbandaids.com
30
+ * [User Support & Feature Requests](https://pinterestplugin.uservoice.com)
31
+
32
  Take advantage of the exploding traffic Pinterest is generating by encouraging your readers to pin your content using this simple "Pin It" button.
33
 
34
  **Pinterest Drives More Traffic Than Google+, YouTube and LinkedIn Combined** - Mashable, Feb 1, 2012 [[link]](http://mashable.com/2012/02/01/pinterest-traffic-study/)
37
 
38
  **Pinterest Hits 10 Million U.S. Monthly Uniques Faster Than Any Standalone Site Ever** - TechCrunch, Feb 7, 2012 [[link]](http://techcrunch.com/2012/02/07/pinterest-monthly-uniques/)
39
 
40
+ == Installation ==
 
 
41
 
42
+ 1. Use the automatic installer in your WordPress admin.
43
+ 1. Activate the plugin.
44
+ 1. Configure the plugin by going to **Pin It Button** that appears in your admin menu .
45
 
46
+ Alernatively, you can download this plugin, unzip the contents, then FTP upload to the `/wp-content/plugins/` directory.
47
 
48
+ Note: If you overwrite the plugin using FTP upload, you may lose some saved settings.
 
 
 
 
49
 
50
+ == Frequently Asked Questions ==
51
 
52
+ **The "Pin It" button is showing up, but clicking it does nothing. What can I try?**
 
 
53
 
54
+ To the best of our knowledge, in order please try the following:
55
 
56
+ * Make sure your browser cache is cleared or test in a different browser.
57
+ * Make sure any WordPress caching is emptied. In W3 Total Cache, make sure Minify mode is set to Manual, not Auto.
58
+ * Disable caching plugins.
59
+ * Disable other social sharing plugins.
60
+ * Disable other plugins one by one until the issue is fixed. If you find an incompatible plugin please let us know.
61
+ * (More solutions added here as they're found.)
62
 
63
  **How do I display the button in places other than above or below the content?**
64
 
68
  **How do I get the "Pin It" button to line up next to my other social sharing icons?**
69
 
70
  * Add custom CSS on the settings screen and optionally remove the surrounding `<div>` tag.
71
+ * See some of our [custom CSS examples](http://pinterestplugin.com/pin-it-button-custom-css).
72
 
73
  **I'd like to report a bug or submit a feature request.**
74
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.2.0 =
86
+
87
+ * Added option to hide button per page/post
88
+ * Added option to hide button per category
89
+ * Added widget to display "Pin It" button
90
+ * Added widget to display "Follow" on Pinterest button
91
+ * Added sharing buttons to settings page to promote plugin
92
+ * Fixed CSS where some blogs weren't displaying the button properly
93
+
94
+ = 1.1.3 =
95
+
96
+ * Added option to hide button on individual posts and pages (on post/page editing screen)
97
+
98
  = 1.1.2 =
99
 
100
  * Bug fix: Removed use of session state storing for now as it caused errors for some
115
 
116
  = 1.0.2 =
117
 
118
+ * Added checkbox option to display/hide button on post excerpts
119
  * "Pin It" links generated by the shortcode should not show up when viewing the post in RSS readers
120
  * Settings link added to the plugin entry on the plugins page
121
 
122
  = 1.0.1 =
123
 
124
+ * Added checkbox option to display/hide button on "front page" (sometimes different than home page)
125
 
126
  = 1.0.0 =
127
 
uninstall.php CHANGED
@@ -1,14 +1,15 @@
1
- <?php
2
- //If uninstall/delete not called from WordPress then exit
3
- if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
- exit;
5
- }
6
-
7
- //Note this will run on manual deactivate, but should not run when upgrading/overwriting plugin
8
-
9
- //Remove option records from options table
10
- delete_option( 'pib_options' );
11
-
12
- //Remove any additional options and custom tables
13
-
14
- ?>
 
1
+ <?php
2
+ //If uninstall/delete not called from WordPress then exit
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
+ exit;
5
+ }
6
+
7
+ //Note this will run on manual deactivate, but should not run when upgrading/overwriting plugin
8
+
9
+ //Remove option records from options table
10
+ delete_option( 'pib_options' );
11
+ delete_option( 'pib_category_fields_option' );
12
+
13
+ //Remove any additional options and custom tables
14
+
15
+ ?>