jQuery Pin It Button for Images - Version 0.9.9

Version Description

  • Released 2013-04-04
  • Bug fixed: showing "Pin it" button on categories and archives even though they are unchecked in the settings
  • New feature: possibility to set minimum image size that triggers the "Pin it" button to show up
  • New feature: option to always link the image to its post/page url, instead of linking to the url the user is currently visiting
  • Improvement: you now can set "Site title" as the default description of the pin
Download this release

Release Info

Developer mrsztuczkens
Plugin Icon wp plugin jQuery Pin It Button for Images
Version 0.9.9
Comparing to
See all releases

Code changes from version 0.9.5 to 0.9.9

index.php CHANGED
@@ -1,3 +1,2 @@
1
<?php
2
- /* Let The Force Be With You */
3
- ?>
1
<?php
2
+ /* Let The Force Be With You */
jpibfi-admin.php CHANGED
@@ -4,8 +4,8 @@ if ( ! function_exists( 'add_action' ) ) {
4
exit;
5
}
6
7
- require_once( "jpibfi-validation.php" );
8
- require_once( "jpibfi-constants.php" );
9
10
function jpibfi_conditional( $condition, $true_value = "", $false_value = "", $echo = true) {
11
if ( $condition ) {
@@ -16,7 +16,6 @@ function jpibfi_conditional( $condition, $true_value = "", $false_value = "", $e
16
if ( $echo )
17
echo $false_value;
18
return $false_value;
19
-
20
}
21
22
//Prints out the admin page
@@ -29,7 +28,9 @@ function jpibfi_print_admin_page() {
29
'enabled_classes' => false,
30
'custom_image_height' => false,
31
'custom_image_width' => false,
32
- 'transparency_value' => false
33
);
34
?>
35
@@ -45,8 +46,10 @@ function jpibfi_print_admin_page() {
45
46
$errors['disabled_classes'] = ! jpibfi_contains_css_class_names_or_empty( $_POST['disabled_classes'] );
47
$errors['enabled_classes'] = ! jpibfi_contains_css_class_names_or_empty( $_POST['enabled_classes'] );
48
- $errors['custom_image_height'] = ! jpibfi_is_numeric_or_empty( $_POST['custom_image_height'] );
49
- $errors['custom_image_width'] = ! jpibfi_is_numeric_or_empty( $_POST['custom_image_width'] );
50
51
//rewrite settings that came from the POST request
52
$dev_options['image_selector'] = sanitize_text_field( $_POST['image_selector'] );
@@ -56,20 +59,25 @@ function jpibfi_print_admin_page() {
56
$dev_options['disabled_classes'] = $_POST['disabled_classes'];
57
$dev_options['enabled_classes'] = $_POST['enabled_classes'];
58
$dev_options['description_option'] = $_POST['description_option'];
59
60
- $dev_options['use_custom_image'] = $_POST['use_custom_image'] == "1" ? "1" : "0";
61
$dev_options['custom_image_url'] = $_POST['custom_image_url'];
62
$dev_options['custom_image_height'] = $_POST['custom_image_height'];
63
$dev_options['custom_image_width'] = $_POST['custom_image_width'];
64
65
66
if ( $dev_options['compatibility_mode'] == '0' )
67
$errors['transparency_value'] = ! is_numeric( $dev_options['transparency_value'] ) || ( $dev_options['transparency_value'] < 0.0 ) || ( $dev_options['transparency_value'] > 1.0 );
68
69
- $advanced_dev_options['on_home'] = $_POST['on_home'] == '1' ? '1' : '0';
70
- $advanced_dev_options['on_page'] = $_POST['on_page'] == '1' ? '1' : '0';
71
- $advanced_dev_options['on_single'] = $_POST['on_single'] == '1' ? '1' : '0';
72
- $advanced_dev_options['on_category'] = $_POST['on_category'] == '1' ? '1' : '0';
73
74
$any_errors = false;
75
foreach ( $errors as $value )
@@ -100,10 +108,16 @@ function jpibfi_print_admin_page() {
100
The given transparency error is not valid. Please change the value and try submitting again.
101
</div>
102
<div id="custom_image_height_error" class="<?php jpibfi_conditional( $errors["custom_image_height"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
103
- Custom image height must be either blank or a number.
104
</div>
105
<div id="custom_image_width_error" class="<?php jpibfi_conditional( $errors["custom_image_width"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
106
- Custom image width must be either blank or a number.
107
</div>
108
</div>
109
@@ -157,11 +171,30 @@ function jpibfi_print_admin_page() {
157
<input type="checkbox" id="on_single" name="on_single" <?php checked( "1", $advanced_dev_options['on_single'] ); ?> value="1" />
158
<label for="on_single"> Single posts</label><br />
159
<input type="checkbox" id="on_category" name="on_category" <?php checked( "1", $advanced_dev_options['on_category'] ); ?> value="1" />
160
- <label for="on_category"> Category pages</label>
161
162
<p class="description">Check on which pages you want the Pinterest button to show up.</p>
163
</td>
164
</tr>
165
</tbody>
166
</table>
167
<h3>Visual settings</h3>
@@ -174,12 +207,21 @@ function jpibfi_print_admin_page() {
174
<select id="description_option" name="description_option">
175
<option value="1" <?php selected ( "1", $dev_options['description_option'] ); ?>>Page title</option>
176
<option value="2" <?php selected ( "2", $dev_options['description_option'] ); ?>>Page description</option>
177
- <option value="3" <?php selected ( "3", $dev_options['description_option'] ); ?>>Picture title or alt attributes</option>
178
</select>
179
180
<p class="description">From where the Pinterest message should be taken.</p>
181
</td>
182
</tr>
183
<tr>
184
<th scope="row"><label for="compatibility_mode">Transparency</label></th>
185
<td>
@@ -216,7 +258,7 @@ function jpibfi_print_admin_page() {
216
<label class="chbox-label" for="use_custom_image">Use custom image</label>
217
</p>
218
219
- <input id="upload-image" type='button' class='button' value='Upload an image using media library'/></br>
220
221
<p>
222
<label for="custom_image_url">URL address of the image</label>
@@ -225,13 +267,13 @@ function jpibfi_print_admin_page() {
225
226
<p>
227
<label for="custom_image_height">Height</label>
228
- <input type="number" min="1" step="1" id="custom_image_height" name="custom_image_height" value="<?php echo $dev_options["custom_image_height"]; ?>"
229
class="jpibfi-admin-number <?php jpibfi_conditional( $errors['custom_image_height'], "error-border"); ?>" /> px
230
</p>
231
232
<p>
233
<label for="custom_image_width">Width</label>
234
- <input type="number" min="1" step="1" id="custom_image_width" name="custom_image_width" value="<?php echo $dev_options["custom_image_width"]; ?>"
235
class="jpibfi-admin-number <?php jpibfi_conditional( $errors['custom_image_width'], "error-border" ); ?>" /> px
236
</p>
237
4
exit;
5
}
6
7
+ //require_once( "jpibfi-validation.php" );
8
+ //require_once( "jpibfi-constants.php" );
9
10
function jpibfi_conditional( $condition, $true_value = "", $false_value = "", $echo = true) {
11
if ( $condition ) {
16
if ( $echo )
17
echo $false_value;
18
return $false_value;
19
}
20
21
//Prints out the admin page
28
'enabled_classes' => false,
29
'custom_image_height' => false,
30
'custom_image_width' => false,
31
+ 'transparency_value' => false,
32
+ 'min_image_height' => false,
33
+ 'min_image_width' => false
34
);
35
?>
36
46
47
$errors['disabled_classes'] = ! jpibfi_contains_css_class_names_or_empty( $_POST['disabled_classes'] );
48
$errors['enabled_classes'] = ! jpibfi_contains_css_class_names_or_empty( $_POST['enabled_classes'] );
49
+ $errors['custom_image_height'] = ! jpibfi_is_numeric_and_more_or_equal_to_zero( $_POST['custom_image_height'] );
50
+ $errors['custom_image_width'] = ! jpibfi_is_numeric_and_more_or_equal_to_zero( $_POST['custom_image_width'] );
51
+ $errors['min_image_height'] = ! jpibfi_is_numeric_and_more_or_equal_to_zero( $_POST['min_image_height'] );
52
+ $errors['min_image_width'] = ! jpibfi_is_numeric_and_more_or_equal_to_zero( $_POST['min_image_width'] );
53
54
//rewrite settings that came from the POST request
55
$dev_options['image_selector'] = sanitize_text_field( $_POST['image_selector'] );
59
$dev_options['disabled_classes'] = $_POST['disabled_classes'];
60
$dev_options['enabled_classes'] = $_POST['enabled_classes'];
61
$dev_options['description_option'] = $_POST['description_option'];
62
+ $dev_options['min_image_height'] = $_POST['min_image_height'];
63
+ $dev_options['min_image_width'] = $_POST['min_image_width'];
64
+ $dev_options['use_custom_image'] = ( isset( $_POST['use_custom_image'] ) && $_POST['use_custom_image'] == "1" ) ? "1" : "0";
65
66
$dev_options['custom_image_url'] = $_POST['custom_image_url'];
67
$dev_options['custom_image_height'] = $_POST['custom_image_height'];
68
$dev_options['custom_image_width'] = $_POST['custom_image_width'];
69
70
+ $dev_options['use_post_url'] = ( isset($_POST['use_post_url']) && $_POST['use_post_url'] == "1" ) ? "1" : "0";
71
+
72
73
if ( $dev_options['compatibility_mode'] == '0' )
74
$errors['transparency_value'] = ! is_numeric( $dev_options['transparency_value'] ) || ( $dev_options['transparency_value'] < 0.0 ) || ( $dev_options['transparency_value'] > 1.0 );
75
76
+ $advanced_dev_options['on_home'] = ( isset( $_POST['on_home'] ) && $_POST['on_home'] == '1' ) ? '1' : '0';
77
+ $advanced_dev_options['on_page'] = ( isset( $_POST['on_page'] ) && $_POST['on_page']== '1' ) ? '1' : '0';
78
+ $advanced_dev_options['on_single'] = ( isset( $_POST['on_single'] ) && $_POST['on_single'] == '1' ) ? '1' : '0';
79
+ $advanced_dev_options['on_category'] = ( isset( $_POST['on_category'] ) && $_POST['on_category'] == '1' ) ? '1' : '0';
80
+ $advanced_dev_options['on_blog'] = ( isset( $_POST['on_blog'] ) && $_POST['on_blog'] == '1' ) ? '1' : '0';
81
82
$any_errors = false;
83
foreach ( $errors as $value )
108
The given transparency error is not valid. Please change the value and try submitting again.
109
</div>
110
<div id="custom_image_height_error" class="<?php jpibfi_conditional( $errors["custom_image_height"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
111
+ Custom image height must be a number larger than or equal to zero.
112
</div>
113
<div id="custom_image_width_error" class="<?php jpibfi_conditional( $errors["custom_image_width"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
114
+ Custom image width must be a number larger than or equal to zero.
115
+ </div>
116
+ <div id="min_image_height_error" class="<?php jpibfi_conditional( $errors["min_image_height"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
117
+ Minimum image height must be a number larger than or equal to zero.
118
+ </div>
119
+ <div id="min_image_width_error" class="<?php jpibfi_conditional( $errors["min_image_width"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
120
+ Minimum image width must be a number larger than or equal to zero.
121
</div>
122
</div>
123
171
<input type="checkbox" id="on_single" name="on_single" <?php checked( "1", $advanced_dev_options['on_single'] ); ?> value="1" />
172
<label for="on_single"> Single posts</label><br />
173
<input type="checkbox" id="on_category" name="on_category" <?php checked( "1", $advanced_dev_options['on_category'] ); ?> value="1" />
174
+ <label for="on_category"> Category and archive pages</label><br />
175
+ <input type="checkbox" id="on_blog" name="on_blog" <?php checked( "1", $advanced_dev_options['on_blog'] ); ?> value="1" />
176
+ <label for="on_blog"> Blog pages</label>
177
178
<p class="description">Check on which pages you want the Pinterest button to show up.</p>
179
</td>
180
</tr>
181
+ <tr>
182
+ <th scope="row"><label>Minimum resolution that should trigger the "Pin it" button to show up</label></th>
183
+ <td>
184
+ <p>
185
+ <label for="min_image_height">Height</label>
186
+ <input type="number" min="0" step="1" id="min_image_height" name="min_image_height" value="<?php echo $dev_options["min_image_height"]; ?>"
187
+ class="jpibfi-admin-number <?php jpibfi_conditional( $errors['min_image_height'], "error-border"); ?>" /> px
188
+ </p>
189
+
190
+ <p>
191
+ <label for="min_image_width">Width</label>
192
+ <input type="number" min="0" step="1" id="min_image_width" name="min_image_width" value="<?php echo $dev_options["min_image_width"]; ?>"
193
+ class="jpibfi-admin-number <?php jpibfi_conditional( $errors['min_image_width'], "error-border" ); ?>" /> px
194
+ </p>
195
+ <p class="description">If you'd like the "Pin it" button to not show up on small images (e.g. social media icons), just set the appropriate values above. The default value (0,0) causes the "Pin it" button to show on every eligible image.</p>
196
+ </td>
197
+ </tr>
198
</tbody>
199
</table>
200
<h3>Visual settings</h3>
207
<select id="description_option" name="description_option">
208
<option value="1" <?php selected ( "1", $dev_options['description_option'] ); ?>>Page title</option>
209
<option value="2" <?php selected ( "2", $dev_options['description_option'] ); ?>>Page description</option>
210
+ <option value="3" <?php selected ( "3", $dev_options['description_option'] ); ?>>Picture title or (if title not available) alt attribute</option>
211
+ <option value="4" <?php selected ( "4", $dev_options['description_option'] ); ?>>Site title (Settings->General)</option>
212
</select>
213
214
<p class="description">From where the Pinterest message should be taken.</p>
215
</td>
216
</tr>
217
+ <tr>
218
+ <th scope="row"><label for="use_post_url">Linked page</label></th>
219
+ <td>
220
+ <input type="checkbox" id="use_post_url" name="use_post_url" value="1" <?php checked( "1", $dev_options["use_post_url"] ); ?> />
221
+ <label class="chbox-label" for="use_post_url">Always link to individual post page</label>
222
+ <p class="description">Experimental feature. When checked, the link on Pinterest will always point to the individual page with the image, even when the image was pinned on an archive page, category page or homepage. If false, the link will point to the URL the user is currently on.</p>
223
+ </td>
224
+ </tr>
225
<tr>
226
<th scope="row"><label for="compatibility_mode">Transparency</label></th>
227
<td>
258
<label class="chbox-label" for="use_custom_image">Use custom image</label>
259
</p>
260
261
+ <input id="upload-image" type='button' class='button' value='Upload an image using media library' /><br />
262
263
<p>
264
<label for="custom_image_url">URL address of the image</label>
267
268
<p>
269
<label for="custom_image_height">Height</label>
270
+ <input type="number" min="0" step="1" id="custom_image_height" name="custom_image_height" value="<?php echo $dev_options["custom_image_height"]; ?>"
271
class="jpibfi-admin-number <?php jpibfi_conditional( $errors['custom_image_height'], "error-border"); ?>" /> px
272
</p>
273
274
<p>
275
<label for="custom_image_width">Width</label>
276
+ <input type="number" min="0" step="1" id="custom_image_width" name="custom_image_width" value="<?php echo $dev_options["custom_image_width"]; ?>"
277
class="jpibfi-admin-number <?php jpibfi_conditional( $errors['custom_image_width'], "error-border" ); ?>" /> px
278
</p>
279
jpibfi-constants.php CHANGED
@@ -5,7 +5,7 @@ if ( ! function_exists( 'add_action' ) ) {
5
exit;
6
}
7
8
- define( "JPIBFI_VERSION", "0.9.5" );
9
define( "JPIBFI_BASIC_OPTIONS", "jptbfi_options" );
10
define( "JPIBFI_ADVANCED_OPTIONS", "jptbfi_advanced_options" );
11
define( "JPIBFI_METADATA", "jpibfi_meta");
@@ -15,4 +15,4 @@ define( "JPIBFI_IMAGE_URL", plugins_url( '/images/pinit-button.png', __FILE__ )
15
define( "JPIBFI_IMAGE_WIDTH", 65 );
16
define( "JPIBFI_IMAGE_HEIGHT", 41 );
17
18
- define( "JPIBFI_PREVIEW_IMAGE_ID", "jpibfi_preview_image" );
5
exit;
6
}
7
8
+ define( "JPIBFI_VERSION", "0.9.9" );
9
define( "JPIBFI_BASIC_OPTIONS", "jptbfi_options" );
10
define( "JPIBFI_ADVANCED_OPTIONS", "jptbfi_advanced_options" );
11
define( "JPIBFI_METADATA", "jpibfi_meta");
15
define( "JPIBFI_IMAGE_WIDTH", 65 );
16
define( "JPIBFI_IMAGE_HEIGHT", 41 );
17
18
+ define( "JPIBFI_PREVIEW_IMAGE_ID", "jpibfi_preview_image" );
jpibfi-validation.php CHANGED
@@ -13,11 +13,11 @@ function jpibfi_contains_css_class_names_or_empty( $str ) {
13
if ( strlen( $str ) == 0 )
14
return true;
15
16
- $names = explode( ";", $str );
17
$only_css_class_names = true;
18
19
foreach ( $names as $name ) {
20
- if ( false == jpibfi_is_string_css_class_name( $name ) ) {
21
$only_css_class_names = false;
22
break;
23
}
@@ -25,6 +25,6 @@ function jpibfi_contains_css_class_names_or_empty( $str ) {
25
return $only_css_class_names;
26
}
27
28
- function jpibfi_is_numeric_or_empty( $str ) {
29
- return ( is_numeric( $str ) || "" === $str );
30
}
13
if ( strlen( $str ) == 0 )
14
return true;
15
16
+ $names = explode( ";", $str );
17
$only_css_class_names = true;
18
19
foreach ( $names as $name ) {
20
+ if ( ! jpibfi_is_string_css_class_name( $name ) ) {
21
$only_css_class_names = false;
22
break;
23
}
25
return $only_css_class_names;
26
}
27
28
+ function jpibfi_is_numeric_and_more_or_equal_to_zero( $str ) {
29
+ return ( is_numeric( $str ) && $str >= 0 );
30
}
jquery-pin-it-button-for-images.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: jQuery Pin It Button For Images
4
Plugin URI: http://wordpress.org/extend/plugins/jquery-pin-it-button-for-images/
5
Description: Highlights images on hover and adds a "Pin It" button over them for easy pinning.
6
Author: Marcin Skrzypiec
7
- Version: 0.9.5
8
Author URI: http://profiles.wordpress.org/mrsztuczkens
9
*/
10
@@ -17,23 +17,24 @@ require_once( "jpibfi-constants.php" );
17
require_once( "jpibfi-validation.php" );
18
require_once( "jpibfi-admin.php" );
19
20
- $jpbfi_description_option_values = array( '1', '2', '3' );
21
22
//Returns an array of basic admin options, updates settings if necessary
23
function jpibfi_get_basic_options() {
24
- global $jpbfi_description_option_values;
25
26
$admin_options = array(
27
'image_selector' => 'div.jpibfi_container img',
28
'disabled_classes' => 'nopin;wp-smiley',
29
- 'description_option' => $jpbfi_description_option_values[0],
30
'enabled_classes' => '',
31
'compatibility_mode' => '0',
32
'transparency_value' => '0.5',
33
'use_custom_image' => '0',
34
'custom_image_url' => '',
35
- 'custom_image_height' => '',
36
- 'custom_image_width' => ''
37
);
38
39
$dev_options = get_option( JPIBFI_BASIC_OPTIONS );
@@ -56,13 +57,14 @@ function jpibfi_get_basic_options() {
56
$changes_in_db = true;
57
break;
58
case "description_option":
59
- if ( in_array( $option, $jpbfi_description_option_values ) )
60
- $admin_options[$key] = $option;
61
- else
62
- $changes_in_db = true;
63
break;
64
case "compatibility_mode": //0 or 1 values
65
case "use_custom_image":
66
if ( strcmp( $option, '0' ) != 0 && strcmp( $option, '1' ) != 0 ) //invalid value in database
67
$changes_in_db = true;
68
else
@@ -76,7 +78,9 @@ function jpibfi_get_basic_options() {
76
break;
77
case "custom_image_width": //numeric value or empty
78
case "custom_image_height":
79
- if ( jpibfi_is_numeric_or_empty( $option ) )
80
$admin_options[$key] = $option;
81
else
82
$changes_in_db = true;
@@ -87,7 +91,6 @@ function jpibfi_get_basic_options() {
87
else {
88
$changes_in_db = true;
89
}
90
-
91
//if something changed in the database, we need to save it
92
if ( $changes_in_db )
93
update_option( JPIBFI_BASIC_OPTIONS, $admin_options );
@@ -102,15 +105,18 @@ function jpibfi_get_advanced_options() {
102
'on_home' => '1',
103
'on_single' => '1',
104
'on_page' => '1',
105
- 'on_category' => '1'
106
);
107
108
$dev_options = get_option( JPIBFI_ADVANCED_OPTIONS );
109
- $changes_in_db = count( $admin_options ) != count( $dev_options ); //if arrays aren't of the same length, changes in db needed
110
111
- foreach ( $admin_options as $setting_name => $setting_value ) {
112
- if ( array_key_exists( $setting_name, $dev_options ) )
113
- $admin_options[$setting_name] = $dev_options[$setting_name];
114
}
115
116
//if something changed in the database, we need to save it
@@ -127,6 +133,17 @@ function jpibfi_add_plugin_to_post( $post_id ) {
127
return true;
128
}
129
130
//Returns true if plugin should be added to a certain page
131
function jpibfi_add_plugin() {
132
if ( is_admin() )
@@ -141,8 +158,10 @@ function jpibfi_add_plugin() {
141
return $advanced_settings['on_single'] == "1" ? jpibfi_add_plugin_to_post( $post->ID ) : false;
142
else if ( is_page() )
143
return $advanced_settings['on_page'] == "1" ? jpibfi_add_plugin_to_post( $post->ID ) : false;
144
- else if ( is_category() )
145
return $advanced_settings['on_category'] == "1";
146
return true;
147
}
148
@@ -161,12 +180,16 @@ function jpibfi_add_plugin_scripts() {
161
162
$dev_options = jpibfi_get_basic_options();
163
$parameters_array = array(
164
- 'image_selector' => $dev_options['image_selector'],
165
- 'disabled_classes' => $dev_options['disabled_classes'],
166
- 'enabled_classes' => $dev_options['enabled_classes'],
167
- 'description_option' => $dev_options['description_option']
168
);
169
- wp_localize_script('jquery-pin-it-button-script', 'jpibfi_options', $parameters_array);
170
171
wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
172
wp_enqueue_style( 'jquery-pin-it-button-style' );
@@ -183,7 +206,7 @@ function jpibfi_print_header_style_action() {
183
else
184
$css = "background: url('" .
185
plugins_url( '/images/transparency/' .
186
- str_replace( '.', '_', $dev_options['transparency_value'] ) . '.png', __FILE__ ) . "') repeat;";
187
188
if ( $dev_options['use_custom_image'] == "1" ) {
189
$width = $dev_options['custom_image_width'];
@@ -211,7 +234,8 @@ function jpibfi_print_header_style_action() {
211
function jpibfi_print_hidden_field_script( $content ) {
212
if ( ! jpibfi_add_plugin() )
213
return $content;
214
- return "<input class='jpibfi' type='hidden' />" . $content;
215
}
216
217
//ADMIN PAGE CODE
@@ -219,7 +243,6 @@ function jpibfi_print_hidden_field_script( $content ) {
219
//add admin scripts
220
function jpibfi_add_admin_site_scripts() {
221
222
- wp_enqueue_style( 'thickbox' );
223
wp_register_style( 'jquery-pin-it-button-admin-style', plugins_url( '/css/admin.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
224
wp_enqueue_style( 'jquery-pin-it-button-admin-style' );
225
wp_enqueue_script( 'jquery-pin-it-button-admin-script', plugins_url( '/js/admin.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
@@ -239,7 +262,10 @@ function jpibfi_add_admin_site_scripts() {
239
'image_selector' => '#' . JPIBFI_PREVIEW_IMAGE_ID,
240
'disabled_classes' => "",
241
'enabled_classes' => "",
242
- 'description_option' => 3
243
);
244
wp_localize_script('jquery-pin-it-button-script', 'jpibfi_options', $parameters_array);
245
@@ -248,7 +274,7 @@ function jpibfi_add_admin_site_scripts() {
248
}
249
250
function jpibfi_print_admin_page_action() {
251
- $page = add_options_page( 'jQuery Pin It Button For Images', 'jQuery Pin It Button For Images', 9, basename( __FILE__ ), 'jpibfi_print_admin_page' );
252
add_action( 'admin_print_styles-' . $page, 'jpibfi_add_admin_site_scripts' );
253
}
254
@@ -290,13 +316,10 @@ function jpibfi_print_meta_box( $post, $metabox ) {
290
wp_nonce_field( plugin_basename( __FILE__ ), 'jpibfi_nonce' );
291
292
$post_meta = get_post_meta( $post->ID, JPIBFI_METADATA, true );
293
- if ( isset( $post_meta ) && isset( $post_meta['jpibfi_disable_for_post'] ) && $post_meta['jpibfi_disable_for_post'] == '1' )
294
- $checked_message = 'checked="checked"';
295
- else
296
- $checked_message = '';
297
298
echo '<input type="checkbox" id="jpibfi_disable_for_post" name="jpibfi_disable_for_post" value="1"'
299
- . $checked_message . ' /><label for="jpibfi_disable_for_post"> Disable "Pin it" button for this post (works only on single pages/posts)</label><br />';
300
}
301
302
function jpibfi_save_meta_data( $post_id ) {
@@ -305,7 +328,7 @@ function jpibfi_save_meta_data( $post_id ) {
305
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
306
return;
307
// security check = updating possible only using post edit form
308
- if ( ! wp_verify_nonce( $_POST['jpibfi_nonce'], plugin_basename( __FILE__ ) ) )
309
return;
310
//check user's permissions
311
if ( ! current_user_can( 'edit_post', $post_id ) )
@@ -349,6 +372,4 @@ function jpibfi_uninstall_plugin() {
349
//Filters
350
$plugin = plugin_basename( __FILE__ );
351
add_filter( "plugin_action_links_$plugin", 'jpibfi_plugin_settings_filter' );
352
- add_filter( "the_content", 'jpibfi_print_hidden_field_script' );
353
-
354
- ?>
4
Plugin URI: http://wordpress.org/extend/plugins/jquery-pin-it-button-for-images/
5
Description: Highlights images on hover and adds a "Pin It" button over them for easy pinning.
6
Author: Marcin Skrzypiec
7
+ Version: 0.9.9
8
Author URI: http://profiles.wordpress.org/mrsztuczkens
9
*/
10
17
require_once( "jpibfi-validation.php" );
18
require_once( "jpibfi-admin.php" );
19
20
21
//Returns an array of basic admin options, updates settings if necessary
22
function jpibfi_get_basic_options() {
23
24
$admin_options = array(
25
'image_selector' => 'div.jpibfi_container img',
26
'disabled_classes' => 'nopin;wp-smiley',
27
+ 'description_option' => 1,
28
'enabled_classes' => '',
29
'compatibility_mode' => '0',
30
'transparency_value' => '0.5',
31
'use_custom_image' => '0',
32
'custom_image_url' => '',
33
+ 'custom_image_height' => '0',
34
+ 'custom_image_width' => '0',
35
+ 'use_post_url' => '0',
36
+ 'min_image_height' => '0',
37
+ 'min_image_width' => '0'
38
);
39
40
$dev_options = get_option( JPIBFI_BASIC_OPTIONS );
57
$changes_in_db = true;
58
break;
59
case "description_option":
60
+ if ( in_array( $option, array( '1', '2', '3', '4' ) ) )
61
+ $admin_options[$key] = $option;
62
+ else
63
+ $changes_in_db = true;
64
break;
65
case "compatibility_mode": //0 or 1 values
66
case "use_custom_image":
67
+ case "use_post_url":
68
if ( strcmp( $option, '0' ) != 0 && strcmp( $option, '1' ) != 0 ) //invalid value in database
69
$changes_in_db = true;
70
else
78
break;
79
case "custom_image_width": //numeric value or empty
80
case "custom_image_height":
81
+ case "min_image_width":
82
+ case "min_image_height":
83
+ if ( jpibfi_is_numeric_and_more_or_equal_to_zero( $option ) )
84
$admin_options[$key] = $option;
85
else
86
$changes_in_db = true;
91
else {
92
$changes_in_db = true;
93
}
94
//if something changed in the database, we need to save it
95
if ( $changes_in_db )
96
update_option( JPIBFI_BASIC_OPTIONS, $admin_options );
105
'on_home' => '1',
106
'on_single' => '1',
107
'on_page' => '1',
108
+ 'on_category' => '1',
109
+ 'on_blog' => '1'
110
);
111
112
$dev_options = get_option( JPIBFI_ADVANCED_OPTIONS );
113
+ $changes_in_db = ! $dev_options || count( $admin_options ) != count( $dev_options ); //if arrays aren't of the same length, changes in db needed
114
115
+ if ( !empty( $dev_options ) ) {
116
+ foreach ( $admin_options as $setting_name => $setting_value ) {
117
+ if ( array_key_exists( $setting_name, $dev_options ) )
118
+ $admin_options[$setting_name] = $dev_options[$setting_name];
119
+ }
120
}
121
122
//if something changed in the database, we need to save it
133
return true;
134
}
135
136
+ /*
137
+ * function copied from https://gist.github.com/wesbos/1189639
138
+ */
139
+ function jpibfi_is_blog_page() {
140
+ global $post;
141
+
142
+ $post_type = get_post_type( $post );
143
+
144
+ return ( ( is_home() || is_archive() || is_single() ) && ( $post_type == 'post' ) );
145
+ }
146
+
147
//Returns true if plugin should be added to a certain page
148
function jpibfi_add_plugin() {
149
if ( is_admin() )
158
return $advanced_settings['on_single'] == "1" ? jpibfi_add_plugin_to_post( $post->ID ) : false;
159
else if ( is_page() )
160
return $advanced_settings['on_page'] == "1" ? jpibfi_add_plugin_to_post( $post->ID ) : false;
161
+ else if ( is_category() || is_archive() )
162
return $advanced_settings['on_category'] == "1";
163
+ else if ( jpibfi_is_blog_page() )
164
+ return $advanced_settings['on_blog'] == "1";
165
return true;
166
}
167
180
181
$dev_options = jpibfi_get_basic_options();
182
$parameters_array = array(
183
+ 'image_selector' => $dev_options['image_selector'],
184
+ 'disabled_classes' => $dev_options['disabled_classes'],
185
+ 'enabled_classes' => $dev_options['enabled_classes'],
186
+ 'description_option'=> $dev_options['description_option'],
187
+ 'use_post_url' => $dev_options['use_post_url'],
188
+ 'min_image_height' => $dev_options['min_image_height'],
189
+ 'min_image_width' => $dev_options['min_image_width'],
190
+ 'site_title' => get_bloginfo( 'name', 'display' )
191
);
192
+ wp_localize_script( 'jquery-pin-it-button-script', 'jpibfi_options', $parameters_array );
193
194
wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
195
wp_enqueue_style( 'jquery-pin-it-button-style' );
206
else
207
$css = "background: url('" .
208
plugins_url( '/images/transparency/' .
209
+ str_replace( '.', '_', $dev_options['transparency_value'] ) . '.png', __FILE__ ) . "') repeat;";
210
211
if ( $dev_options['use_custom_image'] == "1" ) {
212
$width = $dev_options['custom_image_width'];
234
function jpibfi_print_hidden_field_script( $content ) {
235
if ( ! jpibfi_add_plugin() )
236
return $content;
237
+ global $post;
238
+ return "<input class='jpibfi' type='hidden' data-jpibfi-url='". get_permalink( $post->ID ) . "'/>" . $content;
239
}
240
241
//ADMIN PAGE CODE
243
//add admin scripts
244
function jpibfi_add_admin_site_scripts() {
245
246
wp_register_style( 'jquery-pin-it-button-admin-style', plugins_url( '/css/admin.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
247
wp_enqueue_style( 'jquery-pin-it-button-admin-style' );
248
wp_enqueue_script( 'jquery-pin-it-button-admin-script', plugins_url( '/js/admin.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
262
'image_selector' => '#' . JPIBFI_PREVIEW_IMAGE_ID,
263
'disabled_classes' => "",
264
'enabled_classes' => "",
265
+ 'description_option' => 3,
266
+ 'use_post_url' => 1,
267
+ 'min_image_height' => '0',
268
+ 'min_image_width' => '0'
269
);
270
wp_localize_script('jquery-pin-it-button-script', 'jpibfi_options', $parameters_array);
271
274
}
275
276
function jpibfi_print_admin_page_action() {
277
+ $page = add_options_page( 'jQuery Pin It Button For Images', 'jQuery Pin It Button For Images', 'manage_options', basename( __FILE__ ), 'jpibfi_print_admin_page' );
278
add_action( 'admin_print_styles-' . $page, 'jpibfi_add_admin_site_scripts' );
279
}
280
316
wp_nonce_field( plugin_basename( __FILE__ ), 'jpibfi_nonce' );
317
318
$post_meta = get_post_meta( $post->ID, JPIBFI_METADATA, true );
319
+ $checked = isset( $post_meta ) && isset( $post_meta['jpibfi_disable_for_post'] ) && $post_meta['jpibfi_disable_for_post'] == '1';
320
321
echo '<input type="checkbox" id="jpibfi_disable_for_post" name="jpibfi_disable_for_post" value="1"'
322
+ . checked( $checked, true, false ) . ' /><label for="jpibfi_disable_for_post"> Disable "Pin it" button for this post (works only on single pages/posts)</label><br />';
323
}
324
325
function jpibfi_save_meta_data( $post_id ) {
328
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
329
return;
330
// security check = updating possible only using post edit form
331
+ if ( !isset( $_POST['jpibfi_nonce'] ) || ! wp_verify_nonce( $_POST['jpibfi_nonce'], plugin_basename( __FILE__ ) ) )
332
return;
333
//check user's permissions
334
if ( ! current_user_can( 'edit_post', $post_id ) )
372
//Filters
373
$plugin = plugin_basename( __FILE__ );
374
add_filter( "plugin_action_links_$plugin", 'jpibfi_plugin_settings_filter' );
375
+ add_filter( "the_content", 'jpibfi_print_hidden_field_script' );
js/admin.js CHANGED
@@ -8,7 +8,7 @@ jQuery(document).ready(function($) {
8
$('#submit_form').click(function(e){
9
var error = false;
10
11
- var areas = ["#disabled_classes", "#enabled_classes"];
12
for (var i = 0; i < areas.length; i++) {
13
if ( !contains_css_class_names_or_empty( $(areas[i]).val() ) ) {
14
$(areas[i]).addClass('error-border');
@@ -36,10 +36,10 @@ jQuery(document).ready(function($) {
36
}
37
}
38
39
- var number_values = ['#custom_image_width', '#custom_image_height']
40
for (var i = 0; i < number_values.length; i++) {
41
var field = $(number_values[i]);
42
- if ( !contains_number_or_empty(field.val()) ) {
43
field.addClass('error-border');
44
$(number_values[i] + "_error").show();
45
error = true;
@@ -89,7 +89,7 @@ jQuery(document).ready(function($) {
89
return only_css_class_names;
90
}
91
92
- function contains_number_or_empty(value){
93
- return value.length == 0 || /^(\d+)\s*#x2F;.test(value);
94
}
95
});
8
$('#submit_form').click(function(e){
9
var error = false;
10
11
+ var areas = ["#disabled_classes", "#enabled_classes"];
12
for (var i = 0; i < areas.length; i++) {
13
if ( !contains_css_class_names_or_empty( $(areas[i]).val() ) ) {
14
$(areas[i]).addClass('error-border');
36
}
37
}
38
39
+ var number_values = ['#custom_image_width', '#custom_image_height', '#min_image_width', '#min_image_height']
40
for (var i = 0; i < number_values.length; i++) {
41
var field = $(number_values[i]);
42
+ if ( !contains_number_larger_or_equal_to_zero(field.val()) ) {
43
field.addClass('error-border');
44
$(number_values[i] + "_error").show();
45
error = true;
89
return only_css_class_names;
90
}
91
92
+ function contains_number_larger_or_equal_to_zero(value){
93
+ return /^(\d+)\s*#x2F;.test(value) && value >= 0;
94
}
95
});
js/script.js CHANGED
@@ -2,37 +2,41 @@
2
3
$(document).ready( function() {
4
var o = {
5
- pageURL : document.URL,
6
- pageTitle : document.title,
7
- pageDescription: $('meta[name="description"]').attr('content'),
8
- image_selector: jpibfi_options.image_selector,
9
- disabled_classes: jpibfi_options.disabled_classes,
10
- enabled_classes: jpibfi_options.enabled_classes,
11
- description_option: jpibfi_options.description_option
12
}
13
14
- var discriminator_classes = o.disabled_classes.split(';');
15
- var allowed_classes = o.enabled_classes.split(';');
16
17
$('.jpibfi').closest('div').addClass('jpibfi_container');
18
19
- $(o.image_selector).each(function (i) {
20
var e = $(this);
21
22
//check if the image has a discriminator class, if has, then return
23
- if ( discriminator_classes[0].length > 0 ) {
24
- for (var c in discriminator_classes) {
25
- if (e.hasClass(discriminator_classes[c]))
26
return;
27
}
28
}
29
//check allowed classes
30
- if ( allowed_classes[0].length > 0 ) {
31
- var has_allowed_class = false;
32
- for (var z = 0; ( z < allowed_classes.length ) && !has_allowed_class; z++ )
33
- has_allowed_class = e.hasClass(allowed_classes[z]);
34
35
- if (!has_allowed_class)
36
return;
37
}
38
@@ -42,47 +46,70 @@
42
43
function jpibfiAddElements() {
44
45
var wpclasses = ['alignnone', 'alignright', 'alignleft'];
46
47
$("img[data-indexer]").each(function () {
48
- var image = $(this),
49
- pi_url = o.pageURL;
50
51
- //Pin message depending on settings
52
- var pi_desc;
53
- if (o.description_option == 3)
54
- pi_desc = image.attr('title') ? image.attr('title') : image.attr('alt');
55
- else if (o.description_option == 2)
56
- pi_desc = o.pageDescription;
57
- !pi_desc && (pi_desc = o.pageTitle);
58
59
- var indexer = image.attr("data-indexer"),
60
- bookmark = 'http://pinterest.com/pin/create/bookmarklet/?url=' + encodeURI(pi_url) + '&is_video=' + encodeURI('false') + '&description=' + encodeURI(pi_desc);
61
62
- image.wrap('<div class="pinit" data-indexer="' + indexer + '"/>');
63
- image.after('<span class="pinit-overlay" data-indexer= "' + indexer + '"><a class="pinit-button" href="' + bookmark + '" data-indexer= "' + indexer + '">Pin It</a></span>');
64
65
- var overlay = $('.pinit-overlay[data-indexer="' + indexer + '"]')
66
.css({
67
height :this.clientHeight + 'px',
68
width :this.clientWidth + 'px',
69
- 'margin-right' :image.css('margin-right'),
70
- 'margin-left' :image.css('margin-left'),
71
- 'margin-top' :image.css('margin-top'),
72
- 'margin-bottom':image.css('margin-bottom')
73
});
74
75
for (var i in wpclasses) {
76
- image.hasClass(wpclasses[i]) && $('.pinit[data-indexer="' + indexer + '"]').addClass(wpclasses[i]);
77
- image.hasClass(wpclasses[i]) && overlay.addClass(wpclasses[i]);
78
}
79
80
- if (image.hasClass('aligncenter')) {
81
$('.pinit[data-indexer="' + indexer + '"]')
82
.addClass('aligncenter')
83
.css('clear', 'both');
84
85
- overlay.css({
86
'margin-left' :"auto",
87
'margin-right':"auto",
88
left :0,
@@ -92,9 +119,9 @@
92
93
$('.pinit .pinit-button').click( function () {
94
var index = $(this).attr("data-indexer");
95
- var image = $('img[data-indexer="' + index+ '"]');
96
- var url = $(this).attr('href') + "&media=" + encodeURI ( image.data('media') ? image.data('media') : image[0].src );
97
- window.open(url, 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
98
return false;
99
});
100
@@ -111,12 +138,12 @@
111
$("img[data-indexer]").unwrap();
112
}
113
114
- window.onload = jpibfiAddElements;
115
116
- window.onresize = function() {
117
jpibfiRemoveElements();
118
jpibfiAddElements();
119
- }
120
121
})
122
2
3
$(document).ready( function() {
4
var o = {
5
+ pageUrl : document.URL,
6
+ pageTitle : document.title,
7
+ pageDescription : $('meta[name="description"]').attr('content'),
8
+ siteTitle : jpibfi_options.site_title,
9
+ imageSelector : jpibfi_options.image_selector,
10
+ disabledClasses : jpibfi_options.disabled_classes,
11
+ enabledClasses : jpibfi_options.enabled_classes,
12
+ descriptionOption : jpibfi_options.description_option,
13
+ usePostUrl : jpibfi_options.use_post_url == "1",
14
+ minImageHeight : jpibfi_options.min_image_height,
15
+ minImageWidth : jpibfi_options.min_image_width
16
}
17
18
+ var discriminatorClasses = o.disabledClasses.split(';');
19
+ var allowedClasses = o.enabledClasses.split(';');
20
21
$('.jpibfi').closest('div').addClass('jpibfi_container');
22
23
+ $(o.imageSelector).each(function (i) {
24
var e = $(this);
25
26
//check if the image has a discriminator class, if has, then return
27
+ if ( discriminatorClasses[0].length > 0 ) {
28
+ for (var discriminatorClass in discriminatorClasses) {
29
+ if (e.hasClass(discriminatorClasses[discriminatorClass]))
30
return;
31
}
32
}
33
//check allowed classes
34
+ if ( allowedClasses[0].length > 0 ) {
35
+ var hasAllowedClass = false;
36
+ for (var z = 0; ( z < allowedClasses.length ) && !hasAllowedClass; z++ )
37
+ hasAllowedClass = e.hasClass(allowedClasses[z]);
38
39
+ if (!hasAllowedClass)
40
return;
41
}
42
46
47
function jpibfiAddElements() {
48
49
+ //selector = selector ? selector : "img[data-indexer]";
50
var wpclasses = ['alignnone', 'alignright', 'alignleft'];
51
52
$("img[data-indexer]").each(function () {
53
+ var $image = $(this);
54
55
+ if ( this.clientWidth < o.minImageWidth || this.clientHeight < o.minImageHeight ) {
56
+ $image.removeAttr( 'data-indexer' );
57
+ return;
58
+ }
59
60
+ var bookmarkUrl = "";
61
+ if ( o.usePostUrl ) {
62
+ var $inputWithUrl = $image.closest("div.jpibfi_container").children("input.jpibfi").first();
63
+ if ($inputWithUrl.length != 0)
64
+ bookmarkUrl = $inputWithUrl.attr("data-jpibfi-url");
65
+ }
66
+ if ( bookmarkUrl.length == 0 )
67
+ bookmarkUrl = o.pageUrl;
68
+
69
+ var bookmarkDescription;
70
+ switch (o.descriptionOption) {
71
+ case '3':
72
+ bookmarkDescription = $image.attr('title') ? $image.attr('title') : $image.attr('alt');
73
+ break;
74
+ case '2':
75
+ bookmarkDescription = o.pageDescription;
76
+ break;
77
+ case '4':
78
+ bookmarkDescription = o.siteTitle;
79
+ break;
80
+ }
81
+ if ( !bookmarkDescription )
82
+ bookmarkDescription = o.pageTitle;
83
84
+ var indexer = $image.attr("data-indexer"),
85
+ bookmark = 'http://pinterest.com/pin/create/bookmarklet/?url=' + encodeURI(bookmarkUrl) + '&is_video=' + encodeURI('false') + '&description=' + encodeURI(bookmarkDescription);
86
87
+ $image.wrap('<div class="pinit" data-indexer="' + indexer + '"/>');
88
+ $image.after('<span class="pinit-overlay" data-indexer= "' + indexer + '"><a class="pinit-button" href="' + bookmark + '" data-indexer= "' + indexer + '">Pin It</a></span>');
89
+
90
+ var $overlay = $('.pinit-overlay[data-indexer="' + indexer + '"]')
91
.css({
92
height :this.clientHeight + 'px',
93
width :this.clientWidth + 'px',
94
+ 'margin-right' :$image.css('margin-right'),
95
+ 'margin-left' :$image.css('margin-left'),
96
+ 'margin-top' :$image.css('margin-top'),
97
+ 'margin-bottom':$image.css('margin-bottom')
98
});
99
100
for (var i in wpclasses) {
101
+ if ( $image.hasClass(wpclasses[i]) ) {
102
+ $('.pinit[data-indexer="' + indexer + '"]').addClass(wpclasses[i]);
103
+ $overlay.addClass(wpclasses[i]);
104
+ }
105
}
106
107
+ if ($image.hasClass('aligncenter')) {
108
$('.pinit[data-indexer="' + indexer + '"]')
109
.addClass('aligncenter')
110
.css('clear', 'both');
111
112
+ $overlay.css({
113
'margin-left' :"auto",
114
'margin-right':"auto",
115
left :0,
119
120
$('.pinit .pinit-button').click( function () {
121
var index = $(this).attr("data-indexer");
122
+ var $image = $('img[data-indexer="' + index+ '"]');
123
+ var imageUrl = $(this).attr('href') + "&media=" + encodeURI ( $image.data('media') ? $image.data('media') : $image[0].src );
124
+ window.open(imageUrl, 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
125
return false;
126
});
127
138
$("img[data-indexer]").unwrap();
139
}
140
141
+ $(window).load( jpibfiAddElements );
142
143
+ $(window).resize ( function() {
144
jpibfiRemoveElements();
145
jpibfiAddElements();
146
+ });
147
148
})
149
js/script.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){e(document).ready(function(){function i(){var n=["alignnone","alignright","alignleft"];e("img[data-indexer]").each(function(){var r=e(this),i=t.pageURL;var s;if(t.description_option==3)s=r.attr("title")?r.attr("title"):r.attr("alt");else if(t.description_option==2)s=t.pageDescription;!s&&(s=t.pageTitle);var u=r.attr("data-indexer"),a="http://pinterest.com/pin/create/bookmarklet/?url="+encodeURI(i)+"&is_video="+encodeURI("false")+"&description="+encodeURI(s);r.wrap('<div class="pinit" data-indexer="'+u+'"/>');r.after('<span class="pinit-overlay" data-indexer= "'+u+'"><a class="pinit-button" href="'+a+'" data-indexer= "'+u+'">Pin It</a></span>');var f=e('.pinit-overlay[data-indexer="'+u+'"]').css({height:this.clientHeight+"px",width:this.clientWidth+"px","margin-right":r.css("margin-right"),"margin-left":r.css("margin-left"),"margin-top":r.css("margin-top"),"margin-bottom":r.css("margin-bottom")});for(var l in n){r.hasClass(n[l])&&e('.pinit[data-indexer="'+u+'"]').addClass(n[l]);r.hasClass(n[l])&&f.addClass(n[l])}if(r.hasClass("aligncenter")){e('.pinit[data-indexer="'+u+'"]').addClass("aligncenter").css("clear","both");f.css({"margin-left":"auto","margin-right":"auto",left:0,right:0})}e(".pinit .pinit-button").click(function(){var t=e(this).attr("data-indexer");var n=e('img[data-indexer="'+t+'"]');var r=e(this).attr("href")+"&media="+encodeURI(n.data("media")?n.data("media"):n[0].src);window.open(r,"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1");return false});e(".pinit").mouseenter(function(){e(this).children(".pinit-overlay").fadeIn(200)}).mouseleave(function(){e(this).children(".pinit-overlay").fadeOut(200)})})}function s(){e("span.pinit-overlay").remove();e("img[data-indexer]").unwrap()}var t={pageURL:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content"),image_selector:jpibfi_options.image_selector,disabled_classes:jpibfi_options.disabled_classes,enabled_classes:jpibfi_options.enabled_classes,description_option:jpibfi_options.description_option};var n=t.disabled_classes.split(";");var r=t.enabled_classes.split(";");e(".jpibfi").closest("div").addClass("jpibfi_container");e(t.image_selector).each(function(t){var i=e(this);if(n[0].length>0){for(var s in n){if(i.hasClass(n[s]))return}}if(r[0].length>0){var o=false;for(var u=0;u<r.length&&!o;u++)o=i.hasClass(r[u]);if(!o)return}i.attr("data-indexer",t)});window.onload=i;window.onresize=function(){s();i()}})})(jQuery)
1
+ (function(e){e(document).ready(function(){function i(){var n=["alignnone","alignright","alignleft"];e("img[data-indexer]").each(function(){var r=e(this);if(this.clientWidth<t.minImageWidth||this.clientHeight<t.minImageHeight){r.removeAttr("data-indexer");return}var i="";if(t.usePostUrl){var s=r.closest("div.jpibfi_container").children("input.jpibfi").first();if(s.length!=0)i=s.attr("data-jpibfi-url")}if(i.length==0)i=t.pageUrl;var u;switch(t.descriptionOption){case"3":u=r.attr("title")?r.attr("title"):r.attr("alt");break;case"2":u=t.pageDescription;break;case"4":u=t.siteTitle;break}if(!u)u=t.pageTitle;var a=r.attr("data-indexer"),f="http://pinterest.com/pin/create/bookmarklet/?url="+encodeURI(i)+"&is_video="+encodeURI("false")+"&description="+encodeURI(u);r.wrap('<div class="pinit" data-indexer="'+a+'"/>');r.after('<span class="pinit-overlay" data-indexer= "'+a+'"><a class="pinit-button" href="'+f+'" data-indexer= "'+a+'">Pin It</a></span>');var l=e('.pinit-overlay[data-indexer="'+a+'"]').css({height:this.clientHeight+"px",width:this.clientWidth+"px","margin-right":r.css("margin-right"),"margin-left":r.css("margin-left"),"margin-top":r.css("margin-top"),"margin-bottom":r.css("margin-bottom")});for(var c in n){if(r.hasClass(n[c])){e('.pinit[data-indexer="'+a+'"]').addClass(n[c]);l.addClass(n[c])}}if(r.hasClass("aligncenter")){e('.pinit[data-indexer="'+a+'"]').addClass("aligncenter").css("clear","both");l.css({"margin-left":"auto","margin-right":"auto",left:0,right:0})}e(".pinit .pinit-button").click(function(){var t=e(this).attr("data-indexer");var n=e('img[data-indexer="'+t+'"]');var r=e(this).attr("href")+"&media="+encodeURI(n.data("media")?n.data("media"):n[0].src);window.open(r,"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1");return false});e(".pinit").mouseenter(function(){e(this).children(".pinit-overlay").fadeIn(200)}).mouseleave(function(){e(this).children(".pinit-overlay").fadeOut(200)})})}function s(){e("span.pinit-overlay").remove();e("img[data-indexer]").unwrap()}var t={pageUrl:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content"),siteTitle:jpibfi_options.site_title,imageSelector:jpibfi_options.image_selector,disabledClasses:jpibfi_options.disabled_classes,enabledClasses:jpibfi_options.enabled_classes,descriptionOption:jpibfi_options.description_option,usePostUrl:jpibfi_options.use_post_url=="1",minImageHeight:jpibfi_options.min_image_height,minImageWidth:jpibfi_options.min_image_width};var n=t.disabledClasses.split(";");var r=t.enabledClasses.split(";");e(".jpibfi").closest("div").addClass("jpibfi_container");e(t.imageSelector).each(function(t){var i=e(this);if(n[0].length>0){for(var s in n){if(i.hasClass(n[s]))return}}if(r[0].length>0){var o=false;for(var u=0;u<r.length&&!o;u++)o=i.hasClass(r[u]);if(!o)return}i.attr("data-indexer",t)});e(window).load(i);e(window).resize(function(){s();i()})})})(jQuery)
readme.txt CHANGED
@@ -1,5 +1,5 @@
1
=== jQuery Pin It Button For Images ===
2
- Contributors: mrsztuczkens
3
Donate link: http://bit.ly/Uw2mEP
4
Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
Requires at least: 3.3.0
@@ -69,6 +69,13 @@ Please report them in the plugin's support forum on Wordpress.org.
69
70
== Changelog ==
71
72
= 0.9.5 =
73
* Released 2013-03-04
74
* Fixed some issues with image sizing and responsive themes
@@ -115,6 +122,9 @@ Please report them in the plugin's support forum on Wordpress.org.
115
116
== Upgrade Notice ==
117
118
= 0.9.5 =
119
Few minor bug fixes and tweaks
120
1
=== jQuery Pin It Button For Images ===
2
+ Contributors: mrsztuczkens, redearthdesign
3
Donate link: http://bit.ly/Uw2mEP
4
Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
Requires at least: 3.3.0
69
70
== Changelog ==
71
72
+ = 0.9.9 =
73
+ * Released 2013-04-04
74
+ * Bug fixed: showing "Pin it" button on categories and archives even though they are unchecked in the settings
75
+ * New feature: possibility to set minimum image size that triggers the "Pin it" button to show up
76
+ * New feature: option to always link the image to its post/page url, instead of linking to the url the user is currently visiting
77
+ * Improvement: you now can set "Site title" as the default description of the pin
78
+
79
= 0.9.5 =
80
* Released 2013-03-04
81
* Fixed some issues with image sizing and responsive themes
122
123
== Upgrade Notice ==
124
125
+ = 0.9.9 =
126
+ A minor bug fixed and two new features (minimum image size among them) added.
127
+
128
= 0.9.5 =
129
Few minor bug fixes and tweaks
130
screenshot-1.jpg DELETED
Binary file
screenshot-2.jpg DELETED
Binary file
screenshot-3.jpg DELETED
Binary file
screenshot-4.jpg DELETED
Binary file