Pinterest "Pin It" Button - Version 1.1.0

Version Description

  • Added custom CSS area for advanced layout and styling
  • Added checkbox option to remove the button's surrounding <div> tag
  • Button image and style updated to match Pinterest's current embed code
  • Added additional message and link to settings page at top after plugin is activated
  • Changed the way the button click is called to solve pinning issues in Internet Explorer
  • Now using table layout on settings page like WordPress dashboard page (with collapsible boxes)
  • Added mailing list signup form, other links, and rss feed in right column on settings page
Download this release

Release Info

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

Version 1.1.0

css/button-shadow.png ADDED
Binary file
css/pinterest-pin-it-button-admin.css ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
11
+
12
+ .form-table td {
13
+ padding: 1px 10px;
14
+ }
15
+
16
+ .form-table label {
17
+ padding-left: 3px;
18
+ }
19
+ .form-table input[type="checkbox"] {
20
+ margin-right: 5px;
21
+ }
22
+
23
+ .form-table textarea {
24
+ line-height: 1.3em;
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
+ }
37
+
38
+ #other-links ul li {
39
+ font-size: 15px;
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
+ }
53
+
54
+ .pib-right-column {
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;
78
+ font-size:15px;
79
+ padding:7px 10px;
80
+ display:block;
81
+ margin-top:0px;
82
+ font-weight:normal;
83
+ cursor:default !important;
84
+ }
85
+
86
+ .wrap {
87
+ background-position:fixed;
88
+ }
89
+
90
+ /* Mailchimp embedded form */
91
+
92
+ #email-signup {
93
+ /* background-color: #464646; */
94
+ background-color: #999;
95
+ background-image: none;
96
+ border: 0;
97
+ /* color: #ccc; */
98
+ color: #fff;
99
+ margin: 10px 10px 0 0;
100
+ padding: 5px 20px;
101
+ -webkit-border-radius: 3px;
102
+ -moz-border-radius: 3px;
103
+ border-radius: 3px;
104
+ }
105
+
106
+ #email-signup h4 {
107
+ color: #FCF9F9;
108
+ font-size: 18px;
109
+ margin-top: 15px;
110
+ }
111
+
112
+ #email-signup .large-text {
113
+ font-size: 15px;
114
+ }
115
+
116
+ /* Mailchimp original embed CSS at http://cdn-images.mailchimp.com/embedcode/slim-081711.css */
117
+ /* This is the same with some elements removed and some modified */
118
+ #mc_embed_signup form {display:block; position:relative; text-align:left; font: 14px Helvetica,Arial,sans-serif; padding:0}
119
+ #mc_embed_signup input {border:1px solid #999; -webkit-appearance:none;}
120
+ #mc_embed_signup input:focus {border-color:#333;}
121
+ #mc_embed_signup .small-meta {font-size: 11px;}
122
+ #mc_embed_signup .nowrap {white-space:nowrap;}
123
+ #mc_embed_signup .clear {clear:none; display:inline;}
124
+ #mc_embed_signup input.email {display:block; padding:8px 0; margin:0 4% 10px 0; text-indent:5px; width:58%; min-width:130px;}
125
+
126
+ /*
127
+ SUPER CONVERSION BUTTON
128
+
129
+ Conversion buttons made simple:
130
+ http://www.performable.com/buttons/
131
+
132
+ Awesome Button
133
+
134
+ This is a well-enhanced version of the awesome buttons found here:
135
+ http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba
136
+
137
+ Awesome/Red: http://super.hubspot.com/buttons/code/N5XJeFJeRmnC/5L4hyT/
138
+
139
+ ================================================================================ */
140
+
141
+ .awesome,
142
+ .awesome-link,
143
+ .awesome:visited {
144
+ font-family:"helvetica neue",arial,sans-serif !important;
145
+ /* font-family:"lucida grande","lucida sans unicode",arial,sans-serif !important; */
146
+ font-weight:bold !important;
147
+ font-size:18px !important;
148
+ /* font-size:20px !important; */
149
+ line-height:1 !important;
150
+ background: #222 url(button-shadow.png) repeat-x;
151
+ _background: #222 none;
152
+ display: inline-block;
153
+ color: #fff !important;
154
+ text-decoration: none !important;
155
+ margin:0 !important;
156
+ padding:.6em 1.3em .6em !important;
157
+ *padding:.7em 1.4em 1em !important;
158
+ -moz-border-radius: .4em !important;
159
+ -webkit-border-radius: .4em !important;
160
+ border-radius: 5px !important;
161
+ -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
162
+ -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
163
+ box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
164
+ text-shadow: 0 -1px 1px rgba(0,0,0,0.3) !important;
165
+ border: none !important;
166
+ position: relative !important;
167
+ cursor: pointer !important;
168
+ width: auto !important;
169
+ overflow: visible !important;
170
+ vertical-align:baseline !important;
171
+ *vertical-align:middle !important;
172
+ }
173
+
174
+ .awesome:hover {
175
+ -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
176
+ -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
177
+ box-shadow: 0 1px 3px rgba(0,0,0,0.75) !important;
178
+ }
179
+
180
+ 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;}
css/pinterest-pin-it-button.css ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
7
+ margin: 0;
8
+ padding: 0;
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;
16
+ text-indent: -9999em;
17
+ font-size: .01em;
18
+ color: #CD1F1F;
19
+ height: 20px;
20
+ width: 43px;
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
+ */
img/pinit-button-icon-med.png ADDED
Binary file
img/pinit-button-icon-small.png ADDED
Binary file
js/pinterest-pin-it-button-admin.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //jQuery no-conflict mode
2
+ var $j = jQuery.noConflict();
3
+
4
+ //jQuery doc ready
5
+ $j(document).ready(function() {
6
+ //Submit mailchimp form with link button
7
+ $j("#mc-embedded-subscribe-link").click(function(event) {
8
+ event.preventDefault();
9
+ $j("#mc-embedded-subscribe-form").submit();
10
+ });
11
+
12
+ //Enable collapse/expand toggle of admin boxes (like WP dashboard)
13
+ $j(".inside").show();
14
+
15
+ $j(".hndle").toggle(function() {
16
+ $j(this).next(".inside").slideToggle("fast");
17
+ }, function () {
18
+ $j(this).next(".inside").slideToggle("fast");
19
+ });
20
+
21
+ $j(".handlediv").toggle(function() {
22
+ $j(this).next(".hndle").next(".inside").slideToggle("fast");
23
+ }, function() {
24
+ $j(this).next(".hndle").next(".inside").slideToggle("fast");
25
+ });
26
+ });
27
+
28
+ /*$j(document).ready(function() {
29
+ $j(".inside").show();
30
+ //toggle the componenet with class msg_body
31
+ $j(".handlediv").click(function()
32
+ {
33
+ $j(this).next(".inside").slideToggle();
34
+ });
35
+ });
36
+ */
37
+
38
+ /*
39
+ function toggle2(showHideDiv, switchTextDiv) {
40
+ var elementdiv = document.getElementById(showHideDiv);
41
+ var text = document.getElementById(switchTextDiv);
42
+ if(elementdiv.style.display == "block") {
43
+ elementdiv.style.display = "none";
44
+ elementdiv.className+= "handlediv";
45
+ }
46
+ else {
47
+ elementdiv.style.display = "block";
48
+ elementdiv.className+= "handlediv";
49
+ }
50
+ }
51
+ */
js/pinterest-pin-it-button.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //jQuery no-conflict mode
2
+ var $j = jQuery.noConflict();
3
+
4
+ //jQuery doc ready
5
+ $j(function(){
6
+ //Set pin-it button click logic
7
+ $j(".pin-it-btn").click(function(event) {
8
+ event.preventDefault();
9
+ //Use jQuery function to retrieve and execute JavaScript from Pinterest
10
+ $j.getScript("http://assets.pinterest.com/js/pinmarklet.js?r=" + Math.random()*99999999);
11
+ });
12
+ });
13
+
14
+ /* Old JavaScript from Pinterest
15
+ function exec_pinmarklet() {
16
+ var e=document.createElement('script');
17
+ e.setAttribute('type','text/javascript');
18
+ e.setAttribute('charset','UTF-8');
19
+ e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r=' + Math.random()*99999999);
20
+ document.body.appendChild(e);
21
+ }
22
+ */
pinterest-pin-it-button.php ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.0
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
15
+ published by the Free Software Foundation.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+
27
+ //Start session if it doesn't exist
28
+
29
+ if( ! session_id() ) {
30
+ session_start();
31
+ }
32
+
33
+ //Set global variables
34
+
35
+ if ( ! defined( 'PIB_PLUGIN_BASENAME' ) )
36
+ define( 'PIB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
37
+
38
+ define( 'BASE_BTN_HTML', '<a href="javascript:void(0)" class="pin-it-btn" title="Pin It on Pinterest"></a>' );
39
+
40
+ //Plugin install/activation
41
+
42
+ function pib_install() {
43
+ //Deactivate plugin if WP version too low
44
+ if ( version_compare( get_bloginfo( 'version' ), '3.0', '<' ) ) {
45
+ deactivate_plugins( basename( __FILE__ ) );
46
+ }
47
+
48
+ //Setup default settings
49
+ $pib_options = array(
50
+ 'display_home_page' => 0,
51
+ 'display_front_page' => 0,
52
+ 'display_posts' => 1,
53
+ 'display_pages' => 1,
54
+ 'display_archives' => 0,
55
+ 'display_above_content' => 0,
56
+ 'display_below_content' => 1,
57
+ 'display_on_post_excerpts' => 0,
58
+ 'remove_div' => 0,
59
+ 'custom_css' => ''
60
+ );
61
+
62
+ //Save default option values
63
+ update_option( 'pib_options', $pib_options );
64
+
65
+ //Set session variable to display admin notice
66
+ $_SESSION['msg'] = 1;
67
+ }
68
+
69
+ register_activation_hook( __FILE__, 'pib_install' );
70
+
71
+ //Display admin notice to proceed to options
72
+
73
+ function pib_plugin_activate_notice() {
74
+ //Add message to only Plugin Page
75
+ global $current_screen;
76
+
77
+ if ( $current_screen -> parent_base == 'plugins' ) {
78
+ if( $_SESSION['msg'] == 1 ) {
79
+ echo '<div class="updated"><p>' .
80
+ sprintf( __( '<a href="%1$s" class="activate-notice-link">Update Your "Pin It" Button Settings</a>' ),
81
+ 'admin.php?page=' . PIB_PLUGIN_BASENAME ) .
82
+ '</p></div>';
83
+ }
84
+ }
85
+ }
86
+
87
+ add_action('admin_notices', 'pib_plugin_activate_notice');
88
+
89
+ //Destroy session variable when navigate to other page
90
+
91
+ function pib_session_destroy() {
92
+ if ( $current_screen->parent_base != 'plugins' ) {
93
+ session_destroy();
94
+ }
95
+ }
96
+
97
+ add_action('admin_menu', 'pib_session_destroy');
98
+
99
+ /********************
100
+ Public-Only Functions
101
+ ********************/
102
+
103
+ //Add Public CSS/JS
104
+
105
+ function pib_add_public_css_js() {
106
+ wp_enqueue_script( 'jquery' );
107
+
108
+ wp_enqueue_style( 'pinterest-pin-it-button', plugins_url( '/css/pinterest-pin-it-button.css' , __FILE__ ) );
109
+ wp_enqueue_script( 'pinterest-pin-it-button', plugins_url( '/js/pinterest-pin-it-button.js', __FILE__ ), array( 'jquery' ) );
110
+ }
111
+
112
+ add_action( 'wp_enqueue_scripts', 'pib_add_public_css_js' );
113
+
114
+ //Add Custom CSS
115
+
116
+ function pib_add_custom_css() {
117
+ $pib_options = get_option( 'pib_options' );
118
+ $custom_css = trim( $pib_options['custom_css'] );
119
+
120
+ if ( $custom_css != '' ) {
121
+ echo "\n" . '<style type="text/css">' . "\n" . $custom_css . "\n" . '</style>' . "\n";
122
+ }
123
+ }
124
+
125
+ add_action( 'wp_head', 'pib_add_custom_css' );
126
+
127
+ //Button html to render
128
+
129
+ function pib_button_html() {
130
+ $pib_options = get_option( 'pib_options' );
131
+
132
+ //Check that remove surrounding div checkbox is selected
133
+ if ( $pib_options['remove_div'] ) {
134
+ return BASE_BTN_HTML;
135
+ } else {
136
+ //Surround with div tag
137
+ return '<div class="pin-it-btn-wrapper">' . BASE_BTN_HTML . '</div>';
138
+ }
139
+ }
140
+
141
+ //Register shortcode: [pinit]
142
+
143
+ function pib_button_shortcode_html() {
144
+ return '<div class="pin-it-btn-shortcode-wrapper">' . BASE_BTN_HTML . '</div>';
145
+ }
146
+
147
+ add_shortcode( 'pinit', 'pib_button_shortcode_html' );
148
+
149
+ //Render button on pages with regular content
150
+
151
+ function pib_render_btn( $content ) {
152
+ //Load options array
153
+ $pib_options = get_option( 'pib_options' );
154
+
155
+ //Determine if displayed on current page
156
+ if (
157
+ ( is_home() && ( $pib_options['display_home_page'] ) ) ||
158
+ ( is_front_page() && ( $pib_options['display_front_page'] ) ) ||
159
+ ( is_single() && ( $pib_options['display_posts'] ) ) ||
160
+ ( is_page() && ( $pib_options['display_pages'] ) ) ||
161
+ ( is_archive() && ( $pib_options['display_archives'] ) )
162
+ ) {
163
+ if ( $pib_options['display_above_content'] ) {
164
+ $content = pib_button_html() . $content;
165
+ }
166
+
167
+ if ( $pib_options['display_below_content'] ) {
168
+ $content .= pib_button_html();
169
+ }
170
+ }
171
+
172
+ return $content;
173
+ }
174
+
175
+ add_filter( 'the_content', 'pib_render_btn' );
176
+
177
+ //Render button on pages with excerpts if option checked
178
+
179
+ function pib_render_btn_excerpt( $content ) {
180
+ //Load options array
181
+ $pib_options = get_option( 'pib_options' );
182
+
183
+ if ( $pib_options['display_on_post_excerpts'] ) {
184
+ if (
185
+ ( is_home() && ( $pib_options['display_home_page'] ) ) ||
186
+ ( is_front_page() && ( $pib_options['display_front_page'] ) ) ||
187
+ ( is_archive() && ( $pib_options['display_archives'] ) )
188
+ ) {
189
+ if ( $pib_options['display_above_content'] ) {
190
+ $content = pib_button_html() . $content;
191
+ }
192
+
193
+ if ( $pib_options['display_below_content'] ) {
194
+ $content .= pib_button_html();
195
+ }
196
+ }
197
+ }
198
+
199
+ return $content;
200
+ }
201
+
202
+ add_filter( 'the_excerpt', 'pib_render_btn_excerpt' );
203
+
204
+
205
+ /********************
206
+ Admin-Only Functions
207
+ ********************/
208
+
209
+ //Add settings page to admin menu
210
+
211
+ function pib_create_menu() {
212
+ add_menu_page( 'Pin It Button Settings', 'Pin It Button', 'manage_options', __FILE__, 'pib_create_settings_page',
213
+ plugins_url( '/img/pinit-button-icon-small.png', __FILE__ ) );
214
+ }
215
+
216
+ add_action( 'admin_menu', 'pib_create_menu' );
217
+
218
+ //Add Admin CSS/JS
219
+
220
+ function pib_add_admin_css_js() {
221
+ wp_enqueue_script( 'jquery' );
222
+
223
+ wp_enqueue_style( 'pinterest-pin-it-button', plugins_url( '/css/pinterest-pin-it-button-admin.css' , __FILE__ ) );
224
+ wp_enqueue_script( 'pinterest-pin-it-button', plugins_url( '/js/pinterest-pin-it-button-admin.js', __FILE__ ), array( 'jquery' ) );
225
+ }
226
+
227
+ add_action( 'admin_enqueue_scripts', 'pib_add_admin_css_js' );
228
+
229
+
230
+ //Register settings
231
+
232
+ function pib_register_settings() {
233
+ register_setting( 'pib-settings-group', 'pib_options' );
234
+ }
235
+
236
+ add_action( 'admin_init', 'pib_register_settings' );
237
+
238
+ //Create settings page
239
+
240
+ function pib_create_settings_page() {
241
+ //Load options array
242
+ $pib_options = get_option( 'pib_options' );
243
+ $custom_css = trim( $pib_options['custom_css'] );
244
+
245
+ ?>
246
+ <div class="wrap">
247
+
248
+ <a href="http://pinterestplugin.com/" target="_blank"><div id="pinit-button-icon-32" class="icon32"
249
+ style="background: url(<?php echo plugins_url( '/img/pinit-button-icon-med.png', __FILE__ ); ?>) no-repeat;"><br /></div></a>
250
+ <h2>Pinterest "Pin It" Button Settings</h2>
251
+
252
+ <div class="metabox-holder">
253
+ <div class="pib-settings postbox-container">
254
+ <div class="meta-box-sortables ui-sortable">
255
+ <?php settings_errors(); //Display status messages after action ("settings saved", errors) ?>
256
+
257
+ <form method="post" action="options.php">
258
+ <?php settings_fields( 'pib-settings-group' ); ?>
259
+
260
+ <div id="pib-options" class="postbox pib-postbox">
261
+ <!--Collapsable-->
262
+ <div class="handlediv" title="Click to toggle"><br /></div>
263
+ <h3 class="hndle">What types of pages should the button appear on?</h3>
264
+
265
+ <table class="form-table inside">
266
+ <tr valign="top">
267
+ <td>
268
+ <input id="display_home_page" name="pib_options[display_home_page]" type="checkbox"
269
+ <?php if ( $pib_options['display_home_page'] ) echo 'checked="checked"'; ?> />
270
+ <label for="display_home_page">Blog Home Page (or Latest Posts Page)</label>
271
+ </td>
272
+ </tr>
273
+ <tr valign="top">
274
+ <td>
275
+ <input id="display_front_page" name="pib_options[display_front_page]" type="checkbox"
276
+ <?php if ( $pib_options['display_front_page'] ) echo 'checked="checked"'; ?> />
277
+ <label for="display_front_page">Front Page (different from Home Page only if set in Settings > Reading)</label>
278
+ </td>
279
+ </tr>
280
+ <tr valign="top">
281
+ <td>
282
+ <input id="display_posts" name="pib_options[display_posts]" type="checkbox"
283
+ <?php if ( $pib_options['display_posts'] ) echo 'checked="checked"'; ?> />
284
+ <label for="display_posts">Individual Posts</label>
285
+ </td>
286
+ </tr>
287
+ <tr valign="top">
288
+ <td>
289
+ <input id="display_pages" name="pib_options[display_pages]" type="checkbox"
290
+ <?php if ( $pib_options['display_pages'] ) echo 'checked="checked"'; ?> />
291
+ <label for="display_pages">WordPress Static "Pages"</label>
292
+ </td>
293
+ </tr>
294
+ <tr valign="top">
295
+ <td>
296
+ <input id="display_archives" name="pib_options[display_archives]" type="checkbox"
297
+ <?php if ( $pib_options['display_archives'] ) echo 'checked="checked"'; ?> />
298
+ <label for="display_archives">Archives Page (Category, Tag, Author, time-based, etc.)</label>
299
+ </td>
300
+ </tr>
301
+ </table>
302
+ </div>
303
+
304
+ <div id="button-show" class="postbox pib-postbox">
305
+ <div class="handlediv" title="Click to toggle"><br /></div>
306
+ <h3 class="hndle">Where on each page should the button appear?</h3>
307
+
308
+ <table class="form-table inside">
309
+ <tr valign="top">
310
+ <td>
311
+ <input id="display_above_content" name="pib_options[display_above_content]" type="checkbox" <?php if ( $pib_options['display_above_content'] ) echo 'checked="checked"'; ?> />
312
+ <label for="display_above_content">Above Content</label>
313
+ </td>
314
+ </tr>
315
+ <tr valign="top">
316
+ <td>
317
+ <input id="display_below_content" name="pib_options[display_below_content]" type="checkbox" <?php if ( $pib_options['display_below_content'] ) echo 'checked="checked"'; ?> />
318
+ <label for="display_below_content">Below Content</label>
319
+ </td>
320
+ </tr>
321
+ <tr valign="top">
322
+ <td>
323
+ <input id="display_on_post_excerpts" name="pib_options[display_on_post_excerpts]" type="checkbox" <?php if ( $pib_options['display_on_post_excerpts'] ) echo 'checked="checked"'; ?> />
324
+ <label for="display_on_post_excerpts">On Post Excerpts</label>
325
+ </td>
326
+ </tr>
327
+ <tr valign="top">
328
+ <td>
329
+ Use the shortcode <code>[pinit]</code> to display the button within content.<br/>
330
+ Use the function <code><?php echo htmlentities('<?php echo do_shortcode(\'[pinit]\'); ?>'); ?></code>
331
+ to display within template or theme files.
332
+ </td>
333
+ </tr>
334
+ </table>
335
+ </div>
336
+
337
+ <div id="style-options" class="postbox pib-postbox">
338
+ <div class="handlediv" title="Click to toggle"><br /></div>
339
+ <h3 class="hndle">Additional layout and styling options</h3>
340
+
341
+ <table class="form-table inside">
342
+ <tr valign="top">
343
+ <td>
344
+ <label for="custom_css">Custom CSS</label>
345
+ </td>
346
+ </tr>
347
+ <tr valign="top">
348
+ <td>
349
+ <textarea name="pib_options[custom_css]" rows="6" cols="8"><?php echo $custom_css; ?></textarea>
350
+ </td>
351
+ </tr>
352
+ <tr valign="top">
353
+ <td>
354
+ <input id="remove_div" name="pib_options[remove_div]" type="checkbox" <?php if ( $pib_options['remove_div'] ) echo 'checked="checked"'; ?> />
355
+ <label for="remove_div">Remove surrounding <code><?php echo htmlentities('<div class="pin-it-btn-wrapper"></div>'); ?></code> tag</label>
356
+ </td>
357
+ </tr>
358
+ <tr valign="top">
359
+ <td>
360
+ <a href="http://pinterestplugin.com/pin-it-button-custom-css/" target="_blank">See custom CSS examples</a> aligning the button
361
+ with other social sharing plugins.
362
+ </td>
363
+ </tr>
364
+ </table>
365
+ </div>
366
+
367
+ <table class="form-table inside">
368
+ <tr valign="top">
369
+ <td>
370
+ <input name="Submit" type="submit" value="Save Changes" class="button-primary" />
371
+ </td>
372
+ </tr>
373
+ </table>
374
+ </form>
375
+ </div>
376
+ </div>
377
+
378
+ <div class="pib-right-column postbox-container">
379
+ <div class="meta-box-sortables ui-sortable">
380
+ <div id="email-signup">
381
+ <h4>Like This Plugin?</h4>
382
+
383
+ <p class="large-text">
384
+ Join the mailing list to be notified when new features are released.
385
+ </p>
386
+
387
+ <!-- Begin MailChimp Signup Form -->
388
+ <div id="mc_embed_signup">
389
+ <form action="http://pinterestplugin.us1.list-manage.com/subscribe/post?u=bfa8cc8ba2614b0796d33a238&amp;id=80e1043ae4" method="post"
390
+ id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
391
+
392
+ <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
393
+
394
+ <div class="clear">
395
+ <input type="submit" value="Sign Up!" name="subscribe" id="mc-embedded-subscribe" class="awesome large red">
396
+ </div>
397
+ </form>
398
+ </div>
399
+ <!--End mc_embed_signup-->
400
+
401
+ <p>
402
+ No spam. Unsubscribe anytime.
403
+ </p>
404
+ </div>
405
+
406
+ <div id="other-links" class="postbox pib-postbox">
407
+ <div class="handlediv" title="Click to toggle"><br /></div>
408
+ <h3 class="hndle">Other Links</h3>
409
+
410
+ <div class="inside">
411
+ <ul>
412
+ <li><a href="http://pinterestplugin.com/" target="_blank">Official Plugin Site</a></li>
413
+ <li><a href="https://pinterestplugin.uservoice.com/" target="_blank">User Support &amp; Feature Requests</a></li>
414
+ </ul>
415
+ </div>
416
+ </div>
417
+
418
+ <div id="news-links" class="postbox pib-postbox">
419
+ <div class="handlediv" title="Click to toggle"><br /></div>
420
+ <h3 class="hndle">News from PinterestPlugin.com</h3>
421
+
422
+ <div class="inside">
423
+ <?php // Get RSS Feed(s) -- code from http://codex.wordpress.org/Function_Reference/fetch_feed
424
+ include_once(ABSPATH . WPINC . '/feed.php');
425
+
426
+ // Get a SimplePie feed object from the specified feed source.
427
+ $rss = fetch_feed('http://pinterestplugin.com/feed/');
428
+
429
+ if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
430
+ // Figure out how many total items there are, but limit it to 5.
431
+ $maxitems = $rss->get_item_quantity(5);
432
+
433
+ // Build an array of all the items, starting with element 0 (first element).
434
+ $rss_items = $rss->get_items(0, $maxitems);
435
+ endif;
436
+ ?>
437
+
438
+ <ul>
439
+ <?php if ($maxitems == 0) echo '<li>No items.</li>';
440
+ else
441
+ // Loop through each feed item and display each item as a hyperlink.
442
+ foreach ( $rss_items as $item ) : ?>
443
+ <li>
444
+ <a href='<?php echo esc_url( $item->get_permalink() ); ?>'
445
+ title='<?php echo 'Posted ' . $item->get_date('j F Y | g:i a'); ?>'
446
+ target="_blank">
447
+ <?php echo esc_html( $item->get_title() ); ?></a>
448
+ </li>
449
+ <?php endforeach; ?>
450
+ </ul>
451
+ </div>
452
+ </div>
453
+ </div>
454
+ </div>
455
+
456
+ </div>
457
+ </div>
458
+ <?php
459
+ }
460
+
461
+ //Add a link to the settings page to the plugins list
462
+
463
+ function pib_plugin_action_links( $links, $file ) {
464
+ if ( $file != PIB_PLUGIN_BASENAME )
465
+ return $links;
466
+
467
+ $url = admin_url( 'admin.php?page=' . PIB_PLUGIN_BASENAME );
468
+ $settings_link = '<a href="' . esc_attr( $url ) . '">' . esc_html( __( 'Settings') ) . '</a>';
469
+
470
+ array_unshift( $links, $settings_link );
471
+
472
+ return $links;
473
+ }
474
+
475
+ add_filter( 'plugin_action_links', 'pib_plugin_action_links', 10, 2 );
476
+
477
+ ?>
readme.txt ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Pinterest "Pin It" Button ===
2
+ Contributors: pderksen
3
+ Tags: pinterest, pin it, social
4
+ Requires at least: 3.0
5
+ Tested up to: 3.3.1
6
+ Stable tag: trunk
7
+
8
+ Add a Pinterest "Pin It" Button to your posts and pages allowing your readers easily pin your images.
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/)
15
+
16
+ **Pinterest Rate of Referral Now Close to Twitter, Google+** - The Wall Street Journal, Feb 3, 2012 [[link]](http://blogs.wsj.com/tech-europe/2012/02/03/pinterest-rate-of-referral-now-close-to-twitter-google/)
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 *[Pinterestlugin.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
+
46
+ * Use the shortcode `[pinit]` to display the button within content.
47
+ * Use the function `<?php echo do_shortcode('[pinit]'); ?>` to display within template or theme files.
48
+
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
+
56
+ * Go to the [User Support & Feedback Forum](https://pinterestplugin.uservoice.com)
57
+
58
+ == Screenshots ==
59
+
60
+ 1. Settings page
61
+ 2. Button display below a post
62
+ 3. Button display next to other sharing buttons
63
+
64
+ == Changelog ==
65
+
66
+ = 1.1.0 =
67
+
68
+ * Added custom CSS area for advanced layout and styling
69
+ * Added checkbox option to remove the button's surrounding `<div>` tag
70
+ * Button image and style updated to match Pinterest's current embed code
71
+ * Added additional message and link to settings page at top after plugin is activated
72
+ * Changed the way the button click is called to solve pinning issues in Internet Explorer
73
+ * Now using table layout on settings page like WordPress dashboard page (with collapsible boxes)
74
+ * Added mailing list signup form, other links, and rss feed in right column on settings page
75
+
76
+ = 1.0.2 =
77
+
78
+ * Added checkbox option to display/hide on post excerpts
79
+ * "Pin It" links generated by the shortcode should not show up when viewing the post in RSS readers
80
+ * Settings link added to the plugin entry on the plugins page
81
+
82
+ = 1.0.1 =
83
+
84
+ * Added checkbox option to display/hide on "front page" (sometimes different than home page)
85
+
86
+ = 1.0.0 =
87
+
88
+ * Added checkbox options to select what types of pages the button should appear on
89
+ * Display options above and below content are now checkboxes (one or both can be selected)
90
+ * Added shortcode [pinit] to display button within content
91
+ * Settings page is now under main admin menu (was under Settings menu)
92
+ * Added icons to admin menu item and settings page title
93
+
94
+ = 0.1.2 =
95
+ * Moved javascript that fires on button click to a separate file
96
+
97
+ = 0.1.1 =
98
+ * Fixed style sheet reference
99
+
100
+ = 0.1 =
101
+ * Initial release
screenshot-1.png ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //If uninstall/delete not called from WordPress then exit
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
+ exit;
5
+ }
6
+
7
+ //Remove option records from options table
8
+ delete_option( 'pib_options' );
9
+
10
+ //Remove any additional options and custom tables
11
+
12
+ ?>