Pinterest "Pin It" Button - Version 2.0.9

Version Description

  • April 22, 2015 =

  • Updated calls to add_query_arg to prevent any possible XSS attacks.

  • Fixed bug with button showing up on WooCommerce Products.

  • Added option to always enqueue scripts & styles (enabled by default).

  • Tested up to WordPress 4.2.

Download this release

Release Info

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

Code changes from version 2.0.8 to 2.0.9

class-pinterest-pin-it-button.php CHANGED
@@ -28,7 +28,7 @@ class Pinterest_Pin_It_Button {
28
  * and README.txt changelog
29
  **************************************/
30
 
31
- protected $version = '2.0.8';
32
 
33
  /**
34
  * Unique identifier for your plugin.
@@ -78,7 +78,13 @@ class Pinterest_Pin_It_Button {
78
 
79
  // Load plugin text domain
80
  add_action( 'plugins_loaded', array( $this, 'plugin_textdomain' ) );
81
-
 
 
 
 
 
 
82
  // Run our upgrade checks first and update our version option.
83
  if( ! get_option( 'pib_upgrade_has_run' ) ) {
84
  add_action( 'init', array( $this, 'upgrade_plugin' ), 0 );
@@ -95,8 +101,8 @@ class Pinterest_Pin_It_Button {
95
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
96
 
97
  // Enqueue public style and scripts.
98
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
99
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
100
 
101
  // Add admin notice after plugin activation. Also check if should be hidden.
102
  add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
@@ -116,6 +122,30 @@ class Pinterest_Pin_It_Button {
116
 
117
  // Check WP version
118
  add_action( 'admin_init', array( $this, 'check_wp_version' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
  /**
@@ -280,13 +310,10 @@ class Pinterest_Pin_It_Button {
280
  public function enqueue_styles() {
281
  global $pib_options;
282
 
283
- if( ! in_array( 'no_buttons', pib_render_button() ) ) {
284
- // Check to see if setting to disable is true first.
285
- if ( empty( $pib_options['disable_css'] ) ) {
286
- wp_enqueue_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'css/public.css', __FILE__ ), array(), $this->version );
287
- }
288
  }
289
-
290
  }
291
 
292
  /**
@@ -297,13 +324,11 @@ class Pinterest_Pin_It_Button {
297
  public function enqueue_scripts() {
298
  global $pib_options;
299
 
300
- if( ! in_array( 'no_buttons', pib_render_button() ) ) {
301
- // If this option is empty then it means we can load the pinit.js, otherwise do not load it
302
- if( empty( $pib_options['no_pinit_js'] ) ) {
303
- // Enqueue Pinterest JS plugin boilerplate style. Don't tack on plugin version.
304
- // We DO NOT include the plugin slug here. This is so that this can be uniform across all of our plugins
305
- wp_enqueue_script( 'pinterest-pinit-js', '//assets.pinterest.com/js/pinit.js', array(), null, true );
306
- }
307
  }
308
  }
309
 
@@ -431,7 +456,7 @@ class Pinterest_Pin_It_Button {
431
  * @return array $links Amended plugin action links.
432
  */
433
  public function settings_link( $links ) {
434
- $setting_link = sprintf( '<a href="%s">%s</a>', add_query_arg( 'page', $this->plugin_slug, admin_url( 'admin.php' ) ), __( 'Settings', 'pib' ) );
435
  array_unshift( $links, $setting_link );
436
 
437
  return $links;
28
  * and README.txt changelog
29
  **************************************/
30
 
31
+ protected $version = '2.0.9';
32
 
33
  /**
34
  * Unique identifier for your plugin.
78
 
79
  // Load plugin text domain
80
  add_action( 'plugins_loaded', array( $this, 'plugin_textdomain' ) );
81
+
82
+ $old = get_option( 'pib_version' );
83
+
84
+ if( version_compare( $old, $this->version, '<' ) ) {
85
+ delete_option( 'pib_upgrade_has_run' );
86
+ }
87
+
88
  // Run our upgrade checks first and update our version option.
89
  if( ! get_option( 'pib_upgrade_has_run' ) ) {
90
  add_action( 'init', array( $this, 'upgrade_plugin' ), 0 );
101
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
102
 
103
  // Enqueue public style and scripts.
104
+ add_action( 'init', array( $this, 'enqueue_styles' ) );
105
+ add_action( 'init', array( $this, 'enqueue_scripts' ) );
106
 
107
  // Add admin notice after plugin activation. Also check if should be hidden.
108
  add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
122
 
123
  // Check WP version
124
  add_action( 'admin_init', array( $this, 'check_wp_version' ) );
125
+
126
+ // Load scripts when posts load so we know if we need to include them or not
127
+ add_filter( 'the_posts', array( $this, 'load_scripts' ) );
128
+ }
129
+
130
+ function load_scripts( $posts ) {
131
+
132
+ if ( empty( $posts ) ) {
133
+ return $posts;
134
+ }
135
+
136
+ foreach ( $posts as $post ) {
137
+ if ( ! in_array( 'no_buttons', pib_render_button( $post ) ) ) {
138
+ // Load CSS
139
+ wp_enqueue_style( $this->plugin_slug . '-plugin-styles' );
140
+
141
+ // Load JS
142
+ wp_enqueue_script( 'pinterest-pinit-js' );
143
+
144
+ break;
145
+ }
146
+ }
147
+
148
+ return $posts;
149
  }
150
 
151
  /**
310
  public function enqueue_styles() {
311
  global $pib_options;
312
 
313
+ // Check to see if setting to disable is true first.
314
+ if ( empty( $pib_options['disable_css'] ) ) {
315
+ wp_register_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'css/public.css', __FILE__ ), array(), $this->version );
 
 
316
  }
 
317
  }
318
 
319
  /**
324
  public function enqueue_scripts() {
325
  global $pib_options;
326
 
327
+ // If this option is empty then it means we can load the pinit.js, otherwise do not load it
328
+ if( empty( $pib_options['no_pinit_js'] ) ) {
329
+ // Enqueue Pinterest JS plugin boilerplate style. Don't tack on plugin version.
330
+ // We DO NOT include the plugin slug here. This is so that this can be uniform across all of our plugins
331
+ wp_register_script( 'pinterest-pinit-js', '//assets.pinterest.com/js/pinit.js', array(), null, true );
 
 
332
  }
333
  }
334
 
456
  * @return array $links Amended plugin action links.
457
  */
458
  public function settings_link( $links ) {
459
+ $setting_link = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( 'page', $this->plugin_slug, admin_url( 'admin.php' ) ) ), __( 'Settings', 'pib' ) );
460
  array_unshift( $links, $setting_link );
461
 
462
  return $links;
includes/misc-functions.php CHANGED
@@ -40,11 +40,11 @@ function pib_ga_campaign_url( $base_url, $source, $medium, $campaign ) {
40
  // $source is always 'pib_lite_2' for Pit It Button Lite 2.x
41
  // $medium examples: 'sidebar_link', 'banner_image'
42
 
43
- $url = add_query_arg( array(
44
  'utm_source' => $source,
45
  'utm_medium' => $medium,
46
  'utm_campaign' => $campaign
47
- ), $base_url );
48
 
49
  return $url;
50
  }
@@ -79,14 +79,14 @@ function pib_rss_news() {
79
  <?php
80
  // Loop through each feed item and display each item as a hyperlink.
81
  foreach ( $rss_items as $item ): ?>
82
- <?php $post_url = add_query_arg( array(
83
 
84
  // Google Analytics campaign URL
85
  'utm_source' => 'pib_lite_2',
86
  'utm_medium' => 'sidebar_link',
87
  'utm_campaign' => 'blog_post_link'
88
 
89
- ), esc_url( $item->get_permalink() ) ); ?>
90
 
91
  <li>
92
  <div class="dashicons dashicons-arrow-right-alt2"></div>
@@ -150,9 +150,14 @@ function pib_is_wc_rich_pins_active() {
150
  *
151
  * @return boolean
152
  */
153
- function pib_render_button() {
154
- global $pib_options, $post;
155
 
 
 
 
 
 
156
  $return = array();
157
 
158
  //Determine if button displayed on current page from main admin settings
40
  // $source is always 'pib_lite_2' for Pit It Button Lite 2.x
41
  // $medium examples: 'sidebar_link', 'banner_image'
42
 
43
+ $url = esc_url( add_query_arg( array(
44
  'utm_source' => $source,
45
  'utm_medium' => $medium,
46
  'utm_campaign' => $campaign
47
+ ), $base_url ) );
48
 
49
  return $url;
50
  }
79
  <?php
80
  // Loop through each feed item and display each item as a hyperlink.
81
  foreach ( $rss_items as $item ): ?>
82
+ <?php $post_url = esc_url( add_query_arg( array(
83
 
84
  // Google Analytics campaign URL
85
  'utm_source' => 'pib_lite_2',
86
  'utm_medium' => 'sidebar_link',
87
  'utm_campaign' => 'blog_post_link'
88
 
89
+ ), $item->get_permalink() ) ); ?>
90
 
91
  <li>
92
  <div class="dashicons dashicons-arrow-right-alt2"></div>
150
  *
151
  * @return boolean
152
  */
153
+ function pib_render_button( $post = null ) {
154
+ global $pib_options;
155
 
156
+ // If $post parameter is not sent then we load the global $post object
157
+ if( $post === null ) {
158
+ global $post;
159
+ }
160
+
161
  $return = array();
162
 
163
  //Determine if button displayed on current page from main admin settings
includes/register-settings.php CHANGED
@@ -85,7 +85,8 @@ function pib_register_settings() {
85
  'uninstall_save_settings' => array(
86
  'id' => 'uninstall_save_settings',
87
  'name' => __( 'Save Settings', 'pib' ),
88
- 'desc' => __( 'Save your settings when uninstalling this plugin. Useful when upgrading or re-installing.', 'pib' ),
 
89
  'type' => 'checkbox'
90
  )
91
  ),
@@ -125,7 +126,7 @@ function pib_register_settings() {
125
  'id' => 'custom_css',
126
  'name' => __( 'Custom CSS', 'pib' ),
127
  'desc' => __( 'Custom CSS can be used to override other CSS style rules.', 'pib' ) . '<br />' .
128
- sprintf( __( 'Visit the <a href="%s">Help Section</a> for CSS override examples.', 'pib' ), add_query_arg( 'page', PIB_PLUGIN_SLUG . '_help', admin_url( 'admin.php' ) ) ),
129
  'type' => 'textarea'
130
  ),
131
  'remove_div' => array(
@@ -136,20 +137,27 @@ function pib_register_settings() {
136
  ),
137
  'disable_css' => array(
138
  'id' => 'disable_css',
139
- 'name' => __( 'Disable CSS File Reference', 'pib' ),
140
- 'desc' => __( 'Advanced. Will prevent the plugin\'s CSS file from being referenced. Custom CSS above will still be included.', 'pib' ),
141
  'type' => 'checkbox'
142
  )
143
  ),
144
 
145
  /* Advanced Settings */
146
  'advanced' => array(
 
 
 
 
 
 
 
147
  'no_pinit_js' => array(
148
  'id' => 'no_pinit_js',
149
  'name' => __( 'Disable <code>pinit.js</code>', 'pib' ),
150
- 'desc' => __( 'Disable output of <code>pinit.js</code>, the JavaScript file for all widgets from Pinterest.', 'pib' ) .
151
- '<p class="description">' . __( 'Check this option if you have <code>pinit.js</code> referenced in another plugin, widget or your theme. ' .
152
- 'Ouputting <code>pinit.js</code> more than once on a page can cause conflicts.', 'pib' ) . '</p>',
153
  'type' => 'checkbox'
154
  )
155
  )
@@ -274,7 +282,8 @@ function pib_get_settings_field_args( $option, $section ) {
274
  'section' => $section,
275
  'size' => isset( $option['size'] ) ? $option['size'] : null,
276
  'options' => isset( $option['options'] ) ? $option['options'] : '',
277
- 'std' => isset( $option['std'] ) ? $option['std'] : ''
 
278
  );
279
 
280
  // Link label to input using 'label_for' argument if text, textarea, password, select, or variations of.
@@ -523,6 +532,7 @@ function pib_get_settings() {
523
  $general['button_type'] = 'user_selects_image';
524
  $general['count_layout'] = 'none';
525
  $general['uninstall_save_settings'] = 1;
 
526
 
527
  update_option( 'pib_settings_general', $general );
528
 
85
  'uninstall_save_settings' => array(
86
  'id' => 'uninstall_save_settings',
87
  'name' => __( 'Save Settings', 'pib' ),
88
+ 'desc' => __( 'Save your settings when uninstalling this plugin.', 'pib' ) . '<br/>' .
89
+ '<p class="description">' . __( 'Useful when upgrading or re-installing.', 'pib' ) . '</p>',
90
  'type' => 'checkbox'
91
  )
92
  ),
126
  'id' => 'custom_css',
127
  'name' => __( 'Custom CSS', 'pib' ),
128
  'desc' => __( 'Custom CSS can be used to override other CSS style rules.', 'pib' ) . '<br />' .
129
+ sprintf( __( 'Visit the <a href="%s">Help Section</a> for CSS override examples.', 'pib' ), esc_url( add_query_arg( 'page', PIB_PLUGIN_SLUG . '_help', admin_url( 'admin.php' ) ) ) ),
130
  'type' => 'textarea'
131
  ),
132
  'remove_div' => array(
137
  ),
138
  'disable_css' => array(
139
  'id' => 'disable_css',
140
+ 'name' => __( 'Disable Plugin CSS', 'pib' ),
141
+ 'desc' => __( 'If this option is checked, this plugin\'s CSS file will not be referenced. The custom CSS above will still be included.', 'pib' ),
142
  'type' => 'checkbox'
143
  )
144
  ),
145
 
146
  /* Advanced Settings */
147
  'advanced' => array(
148
+ 'always_enqueue' => array(
149
+ 'id' => 'always_enqueue',
150
+ 'name' => __( 'Always Enqueue Scripts & Styles', 'pib' ),
151
+ 'desc' => __( 'Enqueue this plugin\'s scripts and styles on every post and page.', 'pib' ) . '<br/>' .
152
+ '<p class="description">' . __( 'Useful if using shortcodes in widgets or other non-standard locations.', 'pib' ) . '</p>',
153
+ 'type' => 'checkbox'
154
+ ),
155
  'no_pinit_js' => array(
156
  'id' => 'no_pinit_js',
157
  'name' => __( 'Disable <code>pinit.js</code>', 'pib' ),
158
+ 'desc' => __( 'Disable output of <code>pinit.js</code>, the JavaScript file for all widgets from Pinterest.', 'pib' ) . '<br/>' .
159
+ '<p class="description">' . __( 'Check this option if you have <code>pinit.js</code> referenced in another plugin, widget or your theme. ' .
160
+ 'Ouputting <code>pinit.js</code> more than once on a page can cause conflicts.', 'pib' ) . '</p>',
161
  'type' => 'checkbox'
162
  )
163
  )
282
  'section' => $section,
283
  'size' => isset( $option['size'] ) ? $option['size'] : null,
284
  'options' => isset( $option['options'] ) ? $option['options'] : '',
285
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
286
+ 'product' => isset( $option['product'] ) ? $option['product'] : '',
287
  );
288
 
289
  // Link label to input using 'label_for' argument if text, textarea, password, select, or variations of.
532
  $general['button_type'] = 'user_selects_image';
533
  $general['count_layout'] = 'none';
534
  $general['uninstall_save_settings'] = 1;
535
+ $general['always_enqueue'] = 1;
536
 
537
  update_option( 'pib_settings_general', $general );
538
 
includes/upgrade-plugin.php CHANGED
@@ -20,12 +20,6 @@ if ( ! get_option( 'pib_version' ) ) {
20
  add_option( 'pib_old_version', get_option( 'pib_version' ) );
21
  }
22
 
23
- // If this option exists then the plugin is before version 2.0.0
24
- if ( get_option( 'pib_options' ) ) {
25
- add_option( 'pib_old_version', '1.4.3' );
26
- update_option( 'pib_upgrade_has_run', 1 );
27
- }
28
-
29
  // Only if the old version is less than the new version do we run our upgrade code.
30
  if ( version_compare( get_option( 'pib_old_version' ), $this->version, '<' ) ) {
31
  // need to update pib_upgrade_has_run so that we don;t load the defaults in too
@@ -46,8 +40,9 @@ function pib_do_all_upgrades() {
46
  $current_version = get_option( 'pib_old_version' );
47
 
48
  // if less than version 2 then upgrade
49
- if ( version_compare( $current_version, '2.0.0', '<' ))
50
- pib_v2_upgrade();
 
51
 
52
  delete_option( 'pib_old_version' );
53
 
@@ -58,57 +53,13 @@ function pib_do_all_upgrades() {
58
  *
59
  * @since 2.0.0
60
  */
61
- function pib_v2_upgrade() {
62
- // Add code here to transfer all the options to new tab layout
63
-
64
- // Need to decipher which Post Visibility settings to update so we will use an array
65
- $page_placement = array( 'display_above_content', 'display_below_content', 'display_on_post_excerpts' );
66
 
67
- if ( get_option('pib_options' ) ) {
68
- $old_options = get_option( 'pib_options' );
69
-
70
- // get the new options so we can update them accordingly
71
- $general_options = get_option( 'pib_settings_general' );
72
- $post_visibility_options = get_option( 'pib_settings_post_visibility' );
73
- $style_options = get_option( 'pib_settings_styles' );
74
-
75
- // Do I need to add the new options here if they don't exist?
76
-
77
- foreach ($old_options as $key => $value) {
78
-
79
- if ( 'custom_css' == $key || 'remove_div' == $key ) {
80
- // Add to styles settings
81
- $style_options[$key] = $value;
82
-
83
- } else if ( ! ( false === strrpos( $key, 'display' ) ) ) {
84
- // Add to Post Visibility settings
85
-
86
- // With the new options we have these setup as nested arrays so we need to check which one we are adding to
87
- if ( in_array( $key, $page_placement ) ) {
88
- $post_visibility_options['post_page_placement'][$key] = $value;
89
- } else {
90
- $post_visibility_options['post_page_types'][$key] = $value;
91
- }
92
-
93
- } else {
94
- // Add to General Settings
95
- // we are changing 'button_style' to 'button_type' going forward
96
- if( 'button_style' == $key ) {
97
- $general_options['button_type'] = $value;
98
- } else {
99
- $general_options[$key] = $value;
100
- }
101
- }
102
-
103
- // add update options here
104
- update_option( 'pib_settings_general', $general_options );
105
- update_option( 'pib_settings_post_visibility', $post_visibility_options );
106
- update_option( 'pib_settings_styles', $style_options );
107
 
108
- // Delete old options
109
- delete_option( 'pib_options' );
110
- delete_option( 'pib_hide_pointer' );
111
- }
112
- }
113
  }
114
  pib_do_all_upgrades();
20
  add_option( 'pib_old_version', get_option( 'pib_version' ) );
21
  }
22
 
 
 
 
 
 
 
23
  // Only if the old version is less than the new version do we run our upgrade code.
24
  if ( version_compare( get_option( 'pib_old_version' ), $this->version, '<' ) ) {
25
  // need to update pib_upgrade_has_run so that we don;t load the defaults in too
40
  $current_version = get_option( 'pib_old_version' );
41
 
42
  // if less than version 2 then upgrade
43
+ if ( version_compare( $current_version, '2.0.9', '<' ) ) {
44
+ pib_v209_upgrade();
45
+ }
46
 
47
  delete_option( 'pib_old_version' );
48
 
53
  *
54
  * @since 2.0.0
55
  */
56
+ function pib_v209_upgrade() {
 
 
 
 
57
 
58
+ $advanced_options = get_option( 'pib_settings_advanced' );
59
+
60
+ $advanced_options['always_enqueue'] = 1;
61
+
62
+ update_option( 'pib_settings_general', $advanced_options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
 
 
 
 
 
64
  }
65
  pib_do_all_upgrades();
includes/widgets.php CHANGED
@@ -36,6 +36,19 @@ class PIB_Widget extends WP_Widget {
36
  // Widen widget admin area.
37
  array( 'width' => 400 )
38
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  /**
36
  // Widen widget admin area.
37
  array( 'width' => 400 )
38
  );
39
+
40
+ if ( is_active_widget( false, false, $this->id_base ) ) {
41
+ // Call action to load CSS for widget
42
+ add_action( 'wp_enqueue_scripts', array( $this, 'pib_widget_add_styles' ) );
43
+
44
+ // Load JS
45
+ wp_enqueue_script( 'pinterest-pinit-js' );
46
+ }
47
+ }
48
+
49
+ function pib_widget_add_styles() {
50
+ // Load CSS
51
+ wp_enqueue_style( 'pinterest-pin-it-button-plugin-styles' );
52
  }
53
 
54
  /**
pinterest-pin-it-button.php CHANGED
@@ -7,13 +7,13 @@
7
  * @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
8
  * @license GPL-2.0+
9
  * @link http://pinplugins.com
10
- * @copyright 2011-2014 Phil Derksen
11
  *
12
  * @wordpress-plugin
13
  * Plugin Name: Pinterest "Pin It" Button Lite
14
  * Plugin URI: http://pinplugins.com/pin-it-button-pro/
15
  * Description: Add a Pinterest "Pin It" Button to your site and get your visitors to start pinning your awesome content!
16
- * Version: 2.0.8
17
  * Author: Phil Derksen
18
  * Author URI: http://philderksen.com
19
  * License: GPL-2.0+
7
  * @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
8
  * @license GPL-2.0+
9
  * @link http://pinplugins.com
10
+ * @copyright 2012-2015 Phil Derksen
11
  *
12
  * @wordpress-plugin
13
  * Plugin Name: Pinterest "Pin It" Button Lite
14
  * Plugin URI: http://pinplugins.com/pin-it-button-pro/
15
  * Description: Add a Pinterest "Pin It" Button to your site and get your visitors to start pinning your awesome content!
16
+ * Version: 2.0.9
17
  * Author: Phil Derksen
18
  * Author URI: http://philderksen.com
19
  * License: GPL-2.0+
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Pinterest "Pin It" Button ===
2
  Contributors: pderksen, nickyoung87
3
  Tags: pinterest, pin it button, social, social media, image, images, photo, photos, pinterest pin it button, pin it, social button
4
- Requires at least: 3.8.5
5
- Tested up to: 4.1
6
- Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -66,7 +66,7 @@ This plugin (as well as the Pro version) is in full compliance with the [officia
66
 
67
  This plugin utilizes the code output from the [official "Pin It" button widget builder](http://business.pinterest.com/widget-builder/#do_pin_it_button).
68
 
69
- [Follow this project on Github](https://github.com/pderksen/WP-Pinterest-Pin-It-Button).
70
 
71
  == Installation ==
72
 
@@ -122,6 +122,13 @@ CSS styling and shortcode help available within the plugin admin.
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
 
125
  = 2.0.8 =
126
 
127
  * Tested up to WordPress 4.1.
1
  === Pinterest "Pin It" Button ===
2
  Contributors: pderksen, nickyoung87
3
  Tags: pinterest, pin it button, social, social media, image, images, photo, photos, pinterest pin it button, pin it, social button
4
+ Requires at least: 3.9.3
5
+ Tested up to: 4.2
6
+ Stable tag: 2.0.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
66
 
67
  This plugin utilizes the code output from the [official "Pin It" button widget builder](http://business.pinterest.com/widget-builder/#do_pin_it_button).
68
 
69
+ [Follow this project on Github](https://github.com/pderksen/WP-Pinterest-Pin-It-Button)
70
 
71
  == Installation ==
72
 
122
 
123
  == Changelog ==
124
 
125
+ = 2.0.9 - April 22, 2015 =
126
+
127
+ * Updated calls to add_query_arg to prevent any possible XSS attacks.
128
+ * Fixed bug with button showing up on WooCommerce Products.
129
+ * Added option to always enqueue scripts & styles (enabled by default).
130
+ * Tested up to WordPress 4.2.
131
+
132
  = 2.0.8 =
133
 
134
  * Tested up to WordPress 4.1.
views/admin-help.php CHANGED
@@ -209,11 +209,11 @@ if ( ! defined( 'ABSPATH' ) ) {
209
 
210
  <p>
211
  <?php printf( __( 'Need more widgets? Check out our free <a href="%s">Pinterest Widgets</a> plugin.', 'pib' ),
212
- add_query_arg( array(
213
  'tab' => 'search',
214
  'type' => 'term',
215
  's' => urlencode('pinterest widgets')
216
- ), admin_url( 'plugin-install.php' ) )
217
  ); ?>
218
  </p>
219
  <p>
209
 
210
  <p>
211
  <?php printf( __( 'Need more widgets? Check out our free <a href="%s">Pinterest Widgets</a> plugin.', 'pib' ),
212
+ esc_url( add_query_arg( array(
213
  'tab' => 'search',
214
  'type' => 'term',
215
  's' => urlencode('pinterest widgets')
216
+ ), admin_url( 'plugin-install.php' ) ) )
217
  ); ?>
218
  </p>
219
  <p>
views/admin-install-notice.php CHANGED
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
25
  <div id="pib-install-notice" class="updated">
26
  <p>
27
  <?php echo $this->get_plugin_title() . __( ' is now installed.', 'pib' ); ?>
28
- <a href="<?php echo add_query_arg( 'page', $this->plugin_slug, admin_url( 'admin.php' ) ); ?>" class="button-primary"><?php _e( 'Setup your Pin It button now', 'pib' ); ?></a>
29
- <a href="<?php echo add_query_arg( 'pib-dismiss-install-nag', 1 ); ?>" class="button-secondary"><?php _e( 'Hide this', 'pib' ); ?></a>
30
  </p>
31
  </div>
25
  <div id="pib-install-notice" class="updated">
26
  <p>
27
  <?php echo $this->get_plugin_title() . __( ' is now installed.', 'pib' ); ?>
28
+ <a href="<?php echo esc_url( add_query_arg( 'page', $this->plugin_slug, admin_url( 'admin.php' ) ) ); ?>" class="button-primary"><?php _e( 'Setup your Pin It button now', 'pib' ); ?></a>
29
+ <a href="<?php echo esc_url( add_query_arg( 'pib-dismiss-install-nag', 1 ) ); ?>" class="button-secondary"><?php _e( 'Hide this', 'pib' ); ?></a>
30
  </p>
31
  </div>
views/admin-sidebar.php CHANGED
@@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
30
  <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Use with custom post types', 'pib' ); ?></li>
31
 
32
  <?php if ( pib_is_woo_commerce_active() ): ?>
33
- <div class="dashicons dashicons-yes"></div> <?php _e( 'WooCommerce support', 'pib' ); ?></li>
34
  <?php endif; ?>
35
 
36
  <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Automatic updates & email support', 'pib' ); ?></li>
@@ -45,11 +45,6 @@ if ( ! defined( 'ABSPATH' ) ) {
45
  class="button-primary button-large" target="_blank">
46
  <?php _e( 'Upgrade to Pro Now', 'pib' ); ?></a>
47
  </div>
48
-
49
- <!-- Black Friday 2014 Promo -->
50
- <div class="centered">
51
- <h3>Use the Black Friday discount code <span style="color:red;">BF2014</span> to get 30% off any license. Expires Friday, Dec. 5.</h3>
52
- </div>
53
  </div>
54
  </div>
55
  </div>
@@ -111,11 +106,11 @@ if ( ! defined( 'ABSPATH' ) ) {
111
  <div class="postbox">
112
  <div class="inside">
113
  <p>
114
- <?php _e( 'Now accepting 5-star reviews! It only takes seconds and means a lot.', 'pib' ); ?>
115
  </p>
116
  <div class="centered">
117
- <a href="http://wordpress.org/support/view/plugin-reviews/pinterest-pin-it-button" class="button-primary" target="_blank">
118
- <?php _e( 'Rate this Plugin Now', 'pib' ); ?></a>
119
  </div>
120
  </div>
121
  </div>
@@ -127,13 +122,13 @@ if ( ! defined( 'ABSPATH' ) ) {
127
  <ul>
128
  <li>
129
  <div class="dashicons dashicons-arrow-right-alt2"></div>
130
- <a href="<?php echo add_query_arg( 'page', PIB_PLUGIN_SLUG . '_help', admin_url( 'admin.php' ) ); ?>">
131
  <?php _e( 'Shortcode & CSS Help', 'pib' ); ?></a>
132
  </li>
133
  <li>
134
  <div class="dashicons dashicons-arrow-right-alt2"></div>
135
- <a href="http://wordpress.org/support/plugin/pinterest-pin-it-button" target="_blank">
136
- <?php _e( 'Community Support Forums', 'pib' ); ?></a>
137
  </li>
138
  <li>
139
  <div class="dashicons dashicons-arrow-right-alt2"></div>
30
  <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Use with custom post types', 'pib' ); ?></li>
31
 
32
  <?php if ( pib_is_woo_commerce_active() ): ?>
33
+ <li><div class="dashicons dashicons-yes"></div> <?php _e( 'WooCommerce support', 'pib' ); ?></li>
34
  <?php endif; ?>
35
 
36
  <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Automatic updates & email support', 'pib' ); ?></li>
45
  class="button-primary button-large" target="_blank">
46
  <?php _e( 'Upgrade to Pro Now', 'pib' ); ?></a>
47
  </div>
 
 
 
 
 
48
  </div>
49
  </div>
50
  </div>
106
  <div class="postbox">
107
  <div class="inside">
108
  <p>
109
+ <?php _e( 'Your review helps more folks find our plugin. Thanks so much!', 'pib' ); ?>
110
  </p>
111
  <div class="centered">
112
+ <a href="https://wordpress.org/support/view/plugin-reviews/pinterest-pin-it-button#postform" class="button-primary" target="_blank">
113
+ <?php _e( 'Review this Plugin Now', 'pib' ); ?></a>
114
  </div>
115
  </div>
116
  </div>
122
  <ul>
123
  <li>
124
  <div class="dashicons dashicons-arrow-right-alt2"></div>
125
+ <a href="<?php echo esc_url( add_query_arg( 'page', PIB_PLUGIN_SLUG . '_help', admin_url( 'admin.php' ) ) ); ?>">
126
  <?php _e( 'Shortcode & CSS Help', 'pib' ); ?></a>
127
  </li>
128
  <li>
129
  <div class="dashicons dashicons-arrow-right-alt2"></div>
130
+ <a href="https://wordpress.org/support/plugin/pinterest-pin-it-button" target="_blank">
131
+ <?php _e( 'Community support forums', 'pib' ); ?></a>
132
  </li>
133
  <li>
134
  <div class="dashicons dashicons-arrow-right-alt2"></div>
views/admin.php CHANGED
@@ -31,13 +31,13 @@ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
31
  <h2><img src="<?php echo PIB_PLUGIN_URL; ?>assets/pinterest-icon-32.png" style="vertical-align: bottom;" /> <?php echo esc_html( get_admin_page_title() ); ?></h2>
32
 
33
  <h2 class="nav-tab-wrapper">
34
- <a href="<?php echo add_query_arg( 'tab', 'general', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
35
  <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>"><?php _e( 'General', 'pib' ); ?></a>
36
- <a href="<?php echo add_query_arg( 'tab', 'post_visibility', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
37
  <?php echo $active_tab == 'post_visibility' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Post Visibility', 'pib' ); ?></a>
38
- <a href="<?php echo add_query_arg( 'tab', 'styles', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
39
  <?php echo $active_tab == 'styles' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Styles', 'pib' ); ?></a>
40
- <a href="<?php echo add_query_arg( 'tab', 'advanced', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
41
  <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Advanced', 'pib' ); ?></a>
42
  </h2>
43
 
31
  <h2><img src="<?php echo PIB_PLUGIN_URL; ?>assets/pinterest-icon-32.png" style="vertical-align: bottom;" /> <?php echo esc_html( get_admin_page_title() ); ?></h2>
32
 
33
  <h2 class="nav-tab-wrapper">
34
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'general', remove_query_arg( 'settings-updated' ) ) ); ?>" class="nav-tab
35
  <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>"><?php _e( 'General', 'pib' ); ?></a>
36
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'post_visibility', remove_query_arg( 'settings-updated' ) ) ); ?>" class="nav-tab
37
  <?php echo $active_tab == 'post_visibility' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Post Visibility', 'pib' ); ?></a>
38
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'styles', remove_query_arg( 'settings-updated' ) ) ); ?>" class="nav-tab
39
  <?php echo $active_tab == 'styles' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Styles', 'pib' ); ?></a>
40
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'advanced', remove_query_arg( 'settings-updated' ) ) ); ?>" class="nav-tab
41
  <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Advanced', 'pib' ); ?></a>
42
  </h2>
43
 
views/post-meta-display.php CHANGED
@@ -32,7 +32,7 @@ $pib_description = get_post_meta( $post->ID, 'pib_description', true);
32
  <?php if ( $pib_options['button_type'] == 'user_selects_image' ): ?>
33
  <p>
34
  <strong style="color: red;"><?php _e( 'The below settings will not take affects unless the button type is changed. ', 'pib' ); ?></strong>
35
- <?php echo sprintf( '<a href="%s">%s</a>', add_query_arg( 'page', PIB_PLUGIN_SLUG, admin_url( 'admin.php' ) ), __( 'Go to "Pin It" Button Settings', 'pib' ) ); ?>
36
  </p>
37
  <?php endif; ?>
38
  <p>
32
  <?php if ( $pib_options['button_type'] == 'user_selects_image' ): ?>
33
  <p>
34
  <strong style="color: red;"><?php _e( 'The below settings will not take affects unless the button type is changed. ', 'pib' ); ?></strong>
35
+ <?php echo sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( 'page', PIB_PLUGIN_SLUG, admin_url( 'admin.php' ) ), __( 'Go to "Pin It" Button Settings', 'pib' ) ) ); ?>
36
  </p>
37
  <?php endif; ?>
38
  <p>
views/public.php CHANGED
@@ -247,8 +247,13 @@ function pib_render_content( $content ) {
247
  global $pib_options;
248
  global $post;
249
 
250
- if( ! is_main_query() )
251
  return $content;
 
 
 
 
 
252
 
253
  //Determine if button displayed on current page from main admin settings
254
  if ( in_array( 'button', pib_render_button() ) ) {
247
  global $pib_options;
248
  global $post;
249
 
250
+ if( ! is_main_query() ) {
251
  return $content;
252
+ }
253
+
254
+ if( ! ( get_post_type_object( get_post_type( $post->ID ) )->_builtin ) ) {
255
+ return $content;
256
+ }
257
 
258
  //Determine if button displayed on current page from main admin settings
259
  if ( in_array( 'button', pib_render_button() ) ) {