jQuery Pin It Button for Images - Version 0.8

Version Description

  • Released 2013-01-12
  • Feature: Ability to choose transparency level depending on one's needs
  • Added support for default Wordpress align classes, so the plugin doesn't mess up the positioning of the images on screen (in typical cases)
Download this release

Release Info

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

Code changes from version 0.7.1 to 0.8

css/admin.css CHANGED
@@ -22,6 +22,10 @@ table.form-table th {
22
margin-top: 4px;
23
}
24
25
.jpibfi-success-message, .jpibfi-error-message {
26
border: 1px solid;
27
border-radius: 10px;
@@ -66,7 +70,6 @@ table.form-table th {
66
clear:both;
67
}
68
69
-
70
.left-element {
71
max-width:75%;
72
float:left;
22
margin-top: 4px;
23
}
24
25
+ .settings-table select, .settings-table textarea, .settings-table input[type='text'] {
26
+ width: 180px;
27
+ }
28
+
29
.jpibfi-success-message, .jpibfi-error-message {
30
border: 1px solid;
31
border-radius: 10px;
70
clear:both;
71
}
72
73
.left-element {
74
max-width:75%;
75
float:left;
css/style.css CHANGED
@@ -1,6 +1,7 @@
1
.pinit {
2
position:relative;
3
display:inline-block;
4
}
5
6
.pinit .pinit-overlay {
1
.pinit {
2
position:relative;
3
display:inline-block;
4
+ overflow: hidden;
5
}
6
7
.pinit .pinit-overlay {
images/transparency/0.png ADDED
Binary file
images/transparency/0_1.png ADDED
Binary file
images/transparency/0_3.png ADDED
Binary file
images/transparency/0_4.png ADDED
Binary file
images/transparency/0_5.png ADDED
Binary file
images/transparency/0_6.png ADDED
Binary file
images/transparency/0_7.png ADDED
Binary file
images/transparency/0_8.png ADDED
Binary file
images/transparency/0_9.png ADDED
Binary file
images/transparency/1.png ADDED
Binary file
jquery-pin-it-button-for-images.php CHANGED
@@ -4,20 +4,21 @@
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.7.1
8
Author URI: http://profiles.wordpress.org/mrsztuczkens
9
*/
10
11
- if (!empty($_SERVER['SCRIPT_FILENAME']) && 'jquery-pin-it-button-for-images.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Stop! Hammer time!'); //Plugin shouldn't be accessed directly
12
13
- define("JPIBFI_VERSION", "0.7.1");
14
15
if (!class_exists("jQuery_Pin_It_Button_For_Images")) {
16
class jQuery_Pin_It_Button_For_Images {
17
18
- var $admin_basic_options_name = "jptbfi_options";
19
- var $admin_advanced_options_name = "jptbfi_advanced_options";
20
- var $post_metadata_name = "jpibfi_meta";
21
var $description_option_values = array ( '1', '2', '3' );
22
23
//Constructor
@@ -54,11 +55,13 @@
54
'disabled_classes' => 'nopin;wp-smiley',
55
'description_option' => '1',
56
'enabled_classes' => '',
57
- 'compatibility_mode' => $this->description_option_values[0]
58
);
59
60
- $dev_options = get_option( $this->admin_basic_options_name );
61
- $changes_in_db = count( $admin_options ) != count ( $dev_options ); //if arrays aren't of the same length, changes in db needed
62
63
//invalid values need to be corrected and saved in db
64
if ( ! empty( $dev_options ) ) {
@@ -86,6 +89,12 @@
86
else
87
$admin_options[$key] = $option;
88
break;
89
}
90
}
91
} else {
@@ -94,7 +103,7 @@
94
95
//if something changed in the database, we need to save it
96
if ( $changes_in_db )
97
- update_option( $this->admin_basic_options_name, $admin_options );
98
99
return $admin_options;
100
}//End function get_basic_options()
@@ -108,49 +117,45 @@
108
'on_category' => '1'
109
);
110
111
- $dev_options = get_option( $this->admin_advanced_options_name );
112
$changes_in_db = count( $admin_options ) != count ( $dev_options ); //if arrays aren't of the same length, changes in db needed
113
114
- foreach ($admin_options as $setting_name => $setting_value) {
115
if ( array_key_exists( $setting_name, $dev_options ) )
116
$admin_options[$setting_name] = $dev_options[$setting_name];
117
}
118
119
//if something changed in the database, we need to save it
120
if ( $changes_in_db )
121
- update_option( $this->admin_advanced_options_name, $admin_options );
122
return $admin_options;
123
- }//End function get_advanced_options()
124
-
125
-
126
- function add_plugin_to_page() {
127
global $post;
128
$advanced_settings = $this->get_advanced_options();
129
- if ( is_front_page() ) {
130
return $advanced_settings['on_home'] == "1";
131
- } else if ( is_single() ) {
132
- if ( $advanced_settings['on_single'] == "1" ) {
133
- $post_meta = get_post_meta( $post->ID, $this->post_metadata_name, true );
134
- if ( !empty($post_meta) && array_key_exists( 'jpibfi_disable_for_post', $post_meta ) && $post_meta['jpibfi_disable_for_post'] == '1')
135
- return false;
136
- return true;
137
- }
138
- return false;
139
- } else if ( is_page() ) {
140
- if ( $advanced_settings['on_page'] == "1" ) {
141
- $post_meta = get_post_meta( $post->ID, $this->post_metadata_name, true );
142
- if ( !empty($post_meta) && array_key_exists( 'jpibfi_disable_for_post', $post_meta ) && $post_meta['jpibfi_disable_for_post'] == '1')
143
- return false;
144
- return true;
145
- }
146
- return false;
147
- } else if ( is_category() ) {
148
return $advanced_settings['on_category'] == "1";
149
- }
150
return true;
151
}
152
-
153
- //fire it when activating the plugin
154
function init_plugin() {
155
$this->get_basic_options();
156
$this->get_advanced_options();
@@ -158,11 +163,11 @@
158
159
//Adds all necessary scripts
160
function add_plugin_scripts() {
161
- if ( !( $this->add_plugin_to_page() ) )
162
return;
163
164
// Adding my custom js, dependent on jquery
165
- wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/script.js', __FILE__ ), array('jquery'), JPIBFI_VERSION, false );
166
// Registering my custom style
167
wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
168
//Enqueue the style
@@ -170,41 +175,45 @@
170
}
171
172
function footer_action() {
173
- if ( !( $this->add_plugin_to_page() ) )
174
return;
175
176
$dev_options = $this->get_basic_options();
177
?>
178
<script type="text/javascript">
179
jQuery(document).ready(function($) {
180
$('.jpibfi').parent('div').addClass('jpibfi_container');
181
$('<?php echo $dev_options['image_selector'];?>').pinit({disabled_classes:'<?php echo $dev_options['disabled_classes'];?>',
182
- description_option:'<?php echo $dev_options['description_option'];?>'<?php if ( $dev_options['enabled_classes'] ) echo ", enabled_classes:'".$dev_options['enabled_classes']."'";?>});
183
});
184
</script>
185
<?php
186
}
187
188
function print_header_style_action() {
189
- if ( !( $this->add_plugin_to_page() ) )
190
return;
191
192
$dev_options = $this->get_basic_options();
193
?>
194
<style type="text/css">
195
- .pinit .pinit-overlay {
196
- <?php
197
- if ( $dev_options['compatibility_mode'] == '0' )
198
- echo 'background-color: rgba(255,255,255,0.5);';
199
- else
200
- echo "background: url('" . plugins_url('/images/point-five.png', __FILE__) . "') repeat;";
201
- ?>
202
- }</style>
203
<?php
204
}
205
206
function print_hidden_field_script($content) {
207
- if ( ! $this->add_plugin_to_page() )
208
return $content;
209
return "<input class='jpibfi' type='hidden' />" . $content;
210
}
@@ -238,10 +247,16 @@
238
239
//rewrite settings that came from the POST request
240
$dev_options['image_selector'] = sanitize_text_field( $_POST['image_selector'] );
241
- $dev_options['compatibility_mode'] = $_POST['compatibility_mode'] == '1' ? '1' : '0';
242
- $dev_options['disabled_classes'] = $_POST['disabled_classes'];
243
$dev_options['enabled_classes'] = $_POST['enabled_classes'];
244
$dev_options['description_option'] = $_POST['description_option'];
245
246
$advanced_dev_options['on_home'] = $_POST['on_home'] == '1' ? '1' : '0';
247
$advanced_dev_options['on_page'] = $_POST['on_page'] == '1' ? '1' : '0';
@@ -249,8 +264,8 @@
249
$advanced_dev_options['on_category'] = $_POST['on_category'] == '1' ? '1' : '0';
250
251
if ( 0 == count( $errors ) ) { //save only if there are no errors
252
- update_option( $this->admin_basic_options_name, $dev_options );
253
- update_option( $this->admin_advanced_options_name, $advanced_dev_options );
254
?>
255
<p class="jpibfi-success-message"><?php _e( "Settings Updated.", "jpibfi" );?></p>
256
<?php
@@ -272,7 +287,7 @@
272
<tr>
273
<th scope="row"><label for="image_selector">Image selector</label></th>
274
<td>
275
- <input type="text" size="50" id="image_selector" name="image_selector" value="<?php echo esc_attr( $dev_options['image_selector'] );?>" />
276
<p class="description">jQuery selector for all the images that should have the "Pin it" button. Set the value to <a href="#" class="jpibfi_selector_option">div.jpibfi_container img</a> if you want the "Pin it" button to appear only on images in content or <a href="#" class="jpibfi_selector_option">img</a> to appear on all images on site (including sidebar, header and footer). If you know a thing or two about jQuery, you might use your own selector. <a href="http://api.jquery.com/category/selectors/" target="_blank">Click here</a> to read about jQuery selectors.</p>
277
</td>
278
</tr>
@@ -280,7 +295,7 @@
280
<th scope="row"><label for="disabled_classes">Disabled classes</label></th>
281
<td>
282
<div class="left-element">
283
- <textarea rows="3" cols="25" id="disabled_classes" name="disabled_classes" <?php if ( !empty($errors) && array_key_exists( 'disabled_classes', $errors ) ) echo "class='error-border'"; ?>><?php echo esc_attr( $dev_options['disabled_classes'] );?></textarea>
284
</div>
285
<div id="disabled_classes_error" class="error-info" <?php if ( !empty($errors) && array_key_exists( 'disabled_classes', $errors ) ) echo "style='display:block;'"; ?>>
286
Error. Please change this setting and try submitting again.
@@ -292,7 +307,7 @@
292
<th scope="row"><label for="enabled_classes">Enabled classes</label></th>
293
<td>
294
<div class="left-element">
295
- <textarea rows="3" cols="25" id="enabled_classes" name="enabled_classes" <?php if ( !empty($errors) && array_key_exists( 'enabled_classes', $errors ) ) echo "class='error-border'"; ?>><?php echo $dev_options['enabled_classes'];?></textarea>
296
</div>
297
<div id="enabled_classes_error" class="error-info" <?php if ( !empty($errors) && array_key_exists( 'enabled_classes', $errors ) ) echo "style='display:block;'"; ?>>
298
Error. Please change this setting and try submitting again.
@@ -312,10 +327,31 @@
312
</td>
313
</tr>
314
<tr>
315
- <th scope="row"><label>IE7 Compatibility mode</label></th>
316
<td>
317
- <input type="checkbox" id="compatibility_mode" name="compatibility_mode" <?php echo "1" == $dev_options['compatibility_mode'] ? "checked='checked'" : "";?>" value="1" /><label class="chbox-label" for="compatibility_mode"> Compatibility mode</label>
318
- <p class="description">Check this if you want the plugin to work properly on IE7. Without this it doesn't highlight images on IE7.</p>
319
</td>
320
</tr>
321
<tr>
@@ -331,7 +367,7 @@
331
<tr>
332
<th scope="row"></th>
333
<td>
334
- <input id="submit_form" type="submit" style="padding:7px;float:right;" name="update_jQuery_Pin_It_Button_For_Images" value="<?php _e( 'Update Settings', 'jQuery_Pin_It_Button_For_Images' ) ?>" />
335
</td>
336
</tr>
337
</tbody>
@@ -343,7 +379,7 @@
343
344
function print_admin_page_action() {
345
$page = add_options_page( 'jQuery Pin It Button For Images', 'jQuery Pin It Button For Images', 9, basename( __FILE__ ), array( $this, 'print_admin_page' ) );
346
- add_action( 'admin_print_styles-' . $page, array($this, 'add_admin_site_scripts'));
347
}
348
349
function plugin_settings_filter($links) {
@@ -382,7 +418,7 @@
382
function print_meta_box( $post, $metabox ) {
383
wp_nonce_field( plugin_basename( __FILE__ ), 'jpibfi_nonce' );
384
385
- $post_meta = get_post_meta( $post->ID, $this->post_metadata_name, true );
386
if ( isset( $post_meta ) && isset( $post_meta['jpibfi_disable_for_post'] ) && $post_meta['jpibfi_disable_for_post'] == '1' )
387
$checked_message = 'checked="checked"';
388
else
@@ -396,33 +432,46 @@
396
// check if this isn't an auto save
397
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
398
return;
399
- //check user's permissions
400
- if ( !current_user_can( 'edit_post', $post_id ) )
401
- return;
402
// security check = updating possible only using post edit form
403
if ( !wp_verify_nonce( $_POST['jpibfi_nonce'], plugin_basename( __FILE__ ) ) )
404
return;
405
406
$post_meta = array( 'jpibfi_disable_for_post' => '0' );
407
// now store data in custom fields based on checkboxes selected
408
- if ( isset( $_POST['jpibfi_disable_for_post'] ) && $_POST['jpibfi_disable_for_post'] == '1')
409
- $post_meta['jpibfi_disable_for_post'] = '1';
410
- else
411
- $post_meta['jpibfi_disable_for_post'] = '0';
412
- update_post_meta( $post_id, $this->post_metadata_name, $post_meta );
413
}
414
//END POST EDITOR CODE
415
}
416
} //End Class jQuery_Pin_It_Button_For_Images
417
418
- if ( class_exists("jQuery_Pin_It_Button_For_Images") ) {
419
$jptbfi_instance = new jQuery_Pin_It_Button_For_Images();
420
- }
421
422
//Actions and Filters
423
if ( isset($jptbfi_instance) ) {
424
//Register
425
- register_activation_hook(__FILE__, array( &$jptbfi_instance, 'init_plugin' ) );
426
//Actions
427
add_action( 'wp_enqueue_scripts', array( &$jptbfi_instance, 'add_plugin_scripts' ) );
428
add_action( 'admin_menu', array( &$jptbfi_instance, 'print_admin_page_action' ) );
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.8
8
Author URI: http://profiles.wordpress.org/mrsztuczkens
9
*/
10
11
+ if (!empty($_SERVER['SCRIPT_FILENAME']) && 'jquery-pin-it-button-for-images.php' == basename($_SERVER['SCRIPT_FILENAME']))
12
+ die ('Stop! Hammer time!'); //Plugin shouldn't be accessed directly
13
14
+ define("JPIBFI_VERSION", "0.8");
15
16
if (!class_exists("jQuery_Pin_It_Button_For_Images")) {
17
class jQuery_Pin_It_Button_For_Images {
18
19
+ public static $admin_basic_options_name = "jptbfi_options";
20
+ public static $admin_advanced_options_name = "jptbfi_advanced_options";
21
+ public static $post_metadata_name = "jpibfi_meta";
22
var $description_option_values = array ( '1', '2', '3' );
23
24
//Constructor
55
'disabled_classes' => 'nopin;wp-smiley',
56
'description_option' => '1',
57
'enabled_classes' => '',
58
+ 'compatibility_mode' => $this->description_option_values[0],
59
+ 'transparency_value' => '0.5'
60
);
61
62
+ $dev_options = get_option( self::$admin_basic_options_name );
63
+
64
+ $changes_in_db = count( $admin_options ) != count ( $dev_options ); //if arrays aren't of the same length, changes in db needed
65
66
//invalid values need to be corrected and saved in db
67
if ( ! empty( $dev_options ) ) {
89
else
90
$admin_options[$key] = $option;
91
break;
92
+ case "transparency_value":
93
+ if ( !is_numeric( $option ) || ( $option < 0 ) || ( $option > 1 ) )
94
+ $changes_in_db = true;
95
+ else
96
+ $admin_options[$key] = $option;
97
+ break;
98
}
99
}
100
} else {
103
104
//if something changed in the database, we need to save it
105
if ( $changes_in_db )
106
+ update_option( self::$admin_basic_options_name, $admin_options );
107
108
return $admin_options;
109
}//End function get_basic_options()
117
'on_category' => '1'
118
);
119
120
+ $dev_options = get_option( self::$admin_advanced_options_name );
121
$changes_in_db = count( $admin_options ) != count ( $dev_options ); //if arrays aren't of the same length, changes in db needed
122
123
+ foreach ( $admin_options as $setting_name => $setting_value ) {
124
if ( array_key_exists( $setting_name, $dev_options ) )
125
$admin_options[$setting_name] = $dev_options[$setting_name];
126
}
127
128
//if something changed in the database, we need to save it
129
if ( $changes_in_db )
130
+ update_option( self::$admin_advanced_options_name, $admin_options );
131
return $admin_options;
132
+ }
133
+
134
+ //returns false if plugin shouldn't be added to certain post based on metadata, otherwise true
135
+ function add_plugin_to_post( $post_id ){
136
+ $post_meta = get_post_meta( $post_id, self::$post_metadata_name, true );
137
+ if ( !empty($post_meta) && array_key_exists( 'jpibfi_disable_for_post', $post_meta ) && $post_meta['jpibfi_disable_for_post'] == '1')
138
+ return false;
139
+ return true;
140
+ }
141
+
142
+ //Returns true if plugin should be added to a certain page
143
+ function add_plugin() {
144
global $post;
145
$advanced_settings = $this->get_advanced_options();
146
+
147
+ if ( is_front_page() )
148
return $advanced_settings['on_home'] == "1";
149
+ else if ( is_single() )
150
+ return $advanced_settings['on_single'] == "1" ? $this->add_plugin_to_post( $post->ID ) : false;
151
+ else if ( is_page() )
152
+ return $advanced_settings['on_page'] == "1" ? $this->add_plugin_to_post( $post->ID ) : false;
153
+ else if ( is_category() )
154
return $advanced_settings['on_category'] == "1";
155
return true;
156
}
157
+
158
+ //fire it when activating the plugin - add all necessary db entries
159
function init_plugin() {
160
$this->get_basic_options();
161
$this->get_advanced_options();
163
164
//Adds all necessary scripts
165
function add_plugin_scripts() {
166
+ if ( !( $this->add_plugin() ) )
167
return;
168
169
// Adding my custom js, dependent on jquery
170
+ wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/script.min.js', __FILE__ ), array('jquery'), JPIBFI_VERSION, false );
171
// Registering my custom style
172
wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
173
//Enqueue the style
175
}
176
177
function footer_action() {
178
+ if ( !( $this->add_plugin() ) )
179
return;
180
181
$dev_options = $this->get_basic_options();
182
+ $enabled_classes = $dev_options['enabled_classes'] ? ", enabled_classes:'" . $dev_options['enabled_classes'] . "'" : "";
183
+
184
?>
185
<script type="text/javascript">
186
jQuery(document).ready(function($) {
187
$('.jpibfi').parent('div').addClass('jpibfi_container');
188
$('<?php echo $dev_options['image_selector'];?>').pinit({disabled_classes:'<?php echo $dev_options['disabled_classes'];?>',
189
+ description_option:'<?php echo $dev_options['description_option'];?>'<?php echo $enabled_classes;?>});
190
});
191
</script>
192
<?php
193
}
194
195
function print_header_style_action() {
196
+ if ( !( $this->add_plugin() ) )
197
return;
198
199
$dev_options = $this->get_basic_options();
200
+
201
+ if ( $dev_options['compatibility_mode'] == '0' )
202
+ $css = 'background-color: rgba(255, 255, 255, ' . $dev_options['transparency_value']. ');';
203
+ else
204
+ $css = "background: url('" .
205
+ plugins_url( '/images/transparency/'.
206
+ str_replace( '.','_', $dev_options['transparency_value'] ) . '.png', __FILE__) . "') repeat;";
207
+
208
?>
209
<style type="text/css">
210
+ .pinit .pinit-overlay { <?php echo $css; ?> }
211
+ </style>
212
<?php
213
}
214
215
function print_hidden_field_script($content) {
216
+ if ( ! $this->add_plugin() )
217
return $content;
218
return "<input class='jpibfi' type='hidden' />" . $content;
219
}
247
248
//rewrite settings that came from the POST request
249
$dev_options['image_selector'] = sanitize_text_field( $_POST['image_selector'] );
250
+ $dev_options['compatibility_mode'] = $_POST['compatibility_mode'] == '1' ? '1' : '0';
251
+ $dev_options['transparency_value'] =
252
+ $dev_options['compatibility_mode'] =='0' ? $_POST['standard_transparency'] : $_POST['compatibility_transparency'];
253
+ $dev_options['disabled_classes'] = $_POST['disabled_classes'];
254
$dev_options['enabled_classes'] = $_POST['enabled_classes'];
255
$dev_options['description_option'] = $_POST['description_option'];
256
+
257
+ if ($dev_options['compatibility_mode'] =='0')
258
+ if ( !is_numeric( $dev_options['transparency_value'] ) || ( $dev_options['transparency_value'] < 0.0 ) || ( $dev_options['transparency_value'] > 1.0 ) )
259
+ $errors['transparency_value'] = true;
260
261
$advanced_dev_options['on_home'] = $_POST['on_home'] == '1' ? '1' : '0';
262
$advanced_dev_options['on_page'] = $_POST['on_page'] == '1' ? '1' : '0';
264
$advanced_dev_options['on_category'] = $_POST['on_category'] == '1' ? '1' : '0';
265
266
if ( 0 == count( $errors ) ) { //save only if there are no errors
267
+ update_option( self::$admin_basic_options_name, $dev_options );
268
+ update_option( self::$admin_advanced_options_name, $advanced_dev_options );
269
?>
270
<p class="jpibfi-success-message"><?php _e( "Settings Updated.", "jpibfi" );?></p>
271
<?php
287
<tr>
288
<th scope="row"><label for="image_selector">Image selector</label></th>
289
<td>
290
+ <input type="text" id="image_selector" name="image_selector" value="<?php echo esc_attr( $dev_options['image_selector'] );?>" />
291
<p class="description">jQuery selector for all the images that should have the "Pin it" button. Set the value to <a href="#" class="jpibfi_selector_option">div.jpibfi_container img</a> if you want the "Pin it" button to appear only on images in content or <a href="#" class="jpibfi_selector_option">img</a> to appear on all images on site (including sidebar, header and footer). If you know a thing or two about jQuery, you might use your own selector. <a href="http://api.jquery.com/category/selectors/" target="_blank">Click here</a> to read about jQuery selectors.</p>
292
</td>
293
</tr>
295
<th scope="row"><label for="disabled_classes">Disabled classes</label></th>
296
<td>
297
<div class="left-element">
298
+ <textarea id="disabled_classes" name="disabled_classes" <?php if ( !empty($errors) && array_key_exists( 'disabled_classes', $errors ) ) echo "class='error-border'"; ?>><?php echo esc_attr( $dev_options['disabled_classes'] );?></textarea>
299
</div>
300
<div id="disabled_classes_error" class="error-info" <?php if ( !empty($errors) && array_key_exists( 'disabled_classes', $errors ) ) echo "style='display:block;'"; ?>>
301
Error. Please change this setting and try submitting again.
307
<th scope="row"><label for="enabled_classes">Enabled classes</label></th>
308
<td>
309
<div class="left-element">
310
+ <textarea id="enabled_classes" name="enabled_classes" <?php if ( !empty($errors) && array_key_exists( 'enabled_classes', $errors ) ) echo "class='error-border'"; ?>><?php echo $dev_options['enabled_classes'];?></textarea>
311
</div>
312
<div id="enabled_classes_error" class="error-info" <?php if ( !empty($errors) && array_key_exists( 'enabled_classes', $errors ) ) echo "style='display:block;'"; ?>>
313
Error. Please change this setting and try submitting again.
327
</td>
328
</tr>
329
<tr>
330
+ <th scope="row"><label for="compatibility_mode">Transparency</label></th>
331
<td>
332
+ <select name="compatibility_mode" id="compatibility_mode">
333
+ <option value="0" <?php echo "0" == $dev_options['compatibility_mode'] ? "selected='selected'" : "";?>>Standard mode</option>
334
+ <option value="1" <?php echo "1" == $dev_options['compatibility_mode'] ? "selected='selected'" : "";?>>IE7 Compatibility mode</option>
335
+ </select>
336
+ <p id="standard_mode_transparency" <?php echo "1" == $dev_options['compatibility_mode'] ? "style='display:none'" : "";?>>
337
+ <label for="standard_transparency">Choose transparency (between 0.00 and 1.00)</label><br/>
338
+ <input type="text" id="standard_transparency" name="standard_transparency" value="<?php echo $dev_options['transparency_value'];?>" <?php if ( !empty($errors) && array_key_exists( 'transparency_value', $errors ) ) echo "class='error-border'"; ?>/>
339
+ <div id="standard_transparency_error" class="error-info" <?php if ( !empty($errors) && array_key_exists( 'transparency_value', $errors ) ) echo "style='display:block;'"; ?>>
340
+ The number is not valid. Please change the value and try submitting again.
341
+ </div>
342
+ </p>
343
+ <p id="compatibility_mode_transparency" <?php echo "0" == $dev_options['compatibility_mode'] ? "style='display:none'" : "";?>>
344
+ <label for="compatibility_transparency">Choose transparency</label><br/>
345
+ <select name="compatibility_transparency" id="compatibility_transparency">
346
+ <?php for($i = 0; $i <= 1; $i += 0.1): ?>
347
+ <option value="<?php echo $i;?>" <?php if ( round( $i, 1 ) == round( $dev_options['transparency_value'], 1 ) ) echo "selected='selected'"; ?>>
348
+ <?php echo $i;?>
349
+ </option>
350
+ <?php endfor; ?>
351
+ </select>
352
+ </p>
353
+ <!-- miejsce na odpowiedniÄ… zmieniarkÄ™-->
354
+ <p class="description">If you want the plugin to work properly on IE7, meaning the image will become transparent on hover, you need to use IE7 Compatibility mode.</p>
355
</td>
356
</tr>
357
<tr>
367
<tr>
368
<th scope="row"></th>
369
<td>
370
+ <input id="submit_form" type="submit" style="padding:7px; float:right;" name="update_jQuery_Pin_It_Button_For_Images" value="<?php _e( 'Update Settings', 'jQuery_Pin_It_Button_For_Images' ) ?>" />
371
</td>
372
</tr>
373
</tbody>
379
380
function print_admin_page_action() {
381
$page = add_options_page( 'jQuery Pin It Button For Images', 'jQuery Pin It Button For Images', 9, basename( __FILE__ ), array( $this, 'print_admin_page' ) );
382
+ add_action( 'admin_print_styles-' . $page, array($this, 'add_admin_site_scripts' ) );
383
}
384
385
function plugin_settings_filter($links) {
418
function print_meta_box( $post, $metabox ) {
419
wp_nonce_field( plugin_basename( __FILE__ ), 'jpibfi_nonce' );
420
421
+ $post_meta = get_post_meta( $post->ID, self::$post_metadata_name, true );
422
if ( isset( $post_meta ) && isset( $post_meta['jpibfi_disable_for_post'] ) && $post_meta['jpibfi_disable_for_post'] == '1' )
423
$checked_message = 'checked="checked"';
424
else
432
// check if this isn't an auto save
433
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
434
return;
435
// security check = updating possible only using post edit form
436
if ( !wp_verify_nonce( $_POST['jpibfi_nonce'], plugin_basename( __FILE__ ) ) )
437
return;
438
+ //check user's permissions
439
+ if ( !current_user_can( 'edit_post', $post_id ) )
440
+ return;
441
442
$post_meta = array( 'jpibfi_disable_for_post' => '0' );
443
// now store data in custom fields based on checkboxes selected
444
+ $post_meta['jpibfi_disable_for_post'] =
445
+ isset( $_POST['jpibfi_disable_for_post'] ) && $_POST['jpibfi_disable_for_post'] == '1' ? '1' : '0';
446
+
447
+ if ($post_meta['jpibfi_disable_for_post'] == '1')
448
+ update_post_meta( $post_id, self::$post_metadata_name, $post_meta );
449
+ else
450
+ delete_post_meta( $post_id, self::$post_metadata_name );
451
}
452
//END POST EDITOR CODE
453
}
454
} //End Class jQuery_Pin_It_Button_For_Images
455
456
+ if ( class_exists("jQuery_Pin_It_Button_For_Images") )
457
$jptbfi_instance = new jQuery_Pin_It_Button_For_Images();
458
+
459
+ //fire it when the plugin is deleted
460
+ function jpibfi_uninstall_plugin() {
461
+
462
+ //delete all added options
463
+ delete_option(jQuery_Pin_It_Button_For_Images::$admin_basic_options_name);
464
+ delete_option(jQuery_Pin_It_Button_For_Images::$admin_advanced_options_name);
465
+
466
+ //delete added metadata from all posts
467
+ delete_post_meta_by_key(jQuery_Pin_It_Button_For_Images::$post_metadata_name);
468
+ }
469
470
//Actions and Filters
471
if ( isset($jptbfi_instance) ) {
472
//Register
473
+ register_activation_hook( __FILE__, array( &$jptbfi_instance, 'init_plugin' ) );
474
+ register_uninstall_hook( __FILE__, 'jpibfi_uninstall_plugin' );
475
//Actions
476
add_action( 'wp_enqueue_scripts', array( &$jptbfi_instance, 'add_plugin_scripts' ) );
477
add_action( 'admin_menu', array( &$jptbfi_instance, 'print_admin_page_action' ) );
js/admin.js CHANGED
@@ -20,10 +20,37 @@ jQuery(document).ready(function($) {
20
$(areas[i] + "_error").hide();
21
}
22
}
23
24
if (error)
25
e.preventDefault();
26
});
27
28
function is_string_css_class_name(class_name) {
29
var regExp = new RegExp("^-?[_a-zA-Z]+[_a-zA-Z0-9-]*quot;);
20
$(areas[i] + "_error").hide();
21
}
22
}
23
+
24
+ if ($('#compatibility_mode').val() == '0')
25
+ {
26
+ var value = parseFloat($('#standard_transparency').val());
27
+ var regExp = /^((\d+(\.\d+)?)|(\.\d+))\s*#x2F;;
28
+
29
+ if (!regExp.test($('#standard_transparency').val()) || isNaN(value) || value < 0 || value > 1) {
30
+ $('#standard_transparency').addClass('error-border');
31
+ $("#standard_transparency_error").show();
32
+ error = true;
33
+ } else {
34
+ $('#standard_transparency').removeClass('error-border');
35
+ $("#standard_transparency_error").hide();
36
+ }
37
+ }
38
39
if (error)
40
e.preventDefault();
41
});
42
+
43
+ $('#compatibility_mode').change( function() {
44
+ if ($(this).val() == '0') {
45
+ $('#standard_mode_transparency').show();
46
+ $('#compatibility_mode_transparency').hide();
47
+ }
48
+ else {
49
+ $('#standard_mode_transparency').hide();
50
+ $('#compatibility_mode_transparency').show();
51
+ }
52
+
53
+ });
54
55
function is_string_css_class_name(class_name) {
56
var regExp = new RegExp("^-?[_a-zA-Z]+[_a-zA-Z0-9-]*quot;);
js/script.js CHANGED
@@ -5,25 +5,92 @@
5
pinit: function(options) {
6
7
var defaults = {
8
- wrap: '<span class="pinit"/>',
9
pageURL: document.URL,
10
- pageTitle: document.title
11
}
12
- if (options.description_option == 3)
13
- defaults.pageDescription = $('meta[name="description"]').attr('content');
14
-
15
var o = $.extend(defaults, options);
16
var discriminator_classes = o.disabled_classes.split(';');
17
18
if (!(typeof o.enabled_classes === 'undefined')) //variable exists
19
var allowed_classes = o.enabled_classes.split(';');
20
21
- //Iterate over the current set of matched elements
22
return this.each(function(i) {
23
if (!(typeof allowed_classes === 'undefined')) {//variable doesn't exist
24
var has_class = false;
25
for(var c in allowed_classes){
26
- if($(this).hasClass(allowed_classes[c])){
27
has_class = true;
28
break;
29
}
@@ -32,49 +99,8 @@
32
return;
33
}
34
35
- for(var c in discriminator_classes){
36
- if($(this).hasClass(discriminator_classes[c]))
37
- return;
38
- }
39
-
40
//to identify the image when loaded
41
- $(this).attr('indexer', i);
42
-
43
- var e = $(this),
44
- pi_media = e.data('media') ? e.data('media') : e[0].src,
45
- pi_url = o.pageURL,
46
- pi_isvideo = 'false';
47
-
48
- //Pin message depending on settings
49
- var pi_desc;
50
- if (o.description_option == 3)
51
- pi_desc = e.attr('title') ? e.attr('title') : e.attr('alt');
52
- else if (o.description_option == 2)
53
- pi_desc = o.pageDescription;
54
- if (!pi_desc)
55
- pi_desc = o.pageTitle;
56
-
57
- bookmark = 'http://pinterest.com/pin/create/bookmarklet/?media=' + encodeURI(pi_media) + '&url=' + encodeURI(pi_url) + '&is_video=' + encodeURI(pi_isvideo) + '&description=' + encodeURI(pi_desc);
58
-
59
- e.wrap(o.wrap);
60
- e.after('<span class="pinit-overlay" style=" indexer= "' + i + '"><a href="' + bookmark + '" class="pinit-button">Pin It</a></span>');
61
-
62
- $(this).load(function(){
63
- var indexer = $(this).attr("indexer");
64
- $('span[indexer="' + indexer + '"]').css('height', $(this).innerHeight() + 'px');
65
- });
66
-
67
- $('.pinit .pinit-button').on('click', function () {
68
- window.open($(this).attr('href'), 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
69
- return false;
70
- });
71
-
72
- $('.pinit').mouseenter(function () {
73
- $(this).children('.pinit-overlay').fadeIn(200);
74
- }).mouseleave(function () {
75
- $(this).children('.pinit-overlay').fadeOut(200);
76
- });
77
-
78
});
79
}
80
});
5
pinit: function(options) {
6
7
var defaults = {
8
pageURL: document.URL,
9
+ pageTitle: document.title,
10
+ pageDescription: $('meta[name="description"]').attr('content')
11
}
12
+
13
var o = $.extend(defaults, options);
14
var discriminator_classes = o.disabled_classes.split(';');
15
16
if (!(typeof o.enabled_classes === 'undefined')) //variable exists
17
var allowed_classes = o.enabled_classes.split(';');
18
19
+ window.onload = function(){
20
+
21
+ var wpclasses = ['alignnone', 'alignright', 'alignleft'];
22
+
23
+ $("img[data-indexer]").each(function(){
24
+ var image = $(this),
25
+ pi_media = image.data('media') ? image.data('media') : image[0].src,
26
+ pi_url = o.pageURL;
27
+
28
+ //Pin message depending on settings
29
+ var pi_desc;
30
+ if (o.description_option == 3)
31
+ pi_desc = image.attr('title') ? image.attr('title') : image.attr('alt');
32
+ else if (o.description_option == 2)
33
+ pi_desc = o.pageDescription;
34
+ !pi_desc && (pi_desc = o.pageTitle);
35
+
36
+ var indexer = image.attr("data-indexer");
37
+ var bookmark = 'http://pinterest.com/pin/create/bookmarklet/?media=' + encodeURI(pi_media) + '&url=' + encodeURI(pi_url) + '&is_video=' + encodeURI('false') + '&description=' + encodeURI(pi_desc);
38
+
39
+ image.wrap('<span class="pinit" data-indexer="' + indexer + '"/>');
40
+ image.after('<span class="pinit-overlay" data-indexer= "' + indexer + '"><a class="pinit-button" href="' + bookmark + '">Pin It</a></span>');
41
+
42
+ $('span.pinit-overlay[data-indexer="' + indexer + '"]')
43
+ .css({
44
+ height: image.innerHeight() + 'px',
45
+ width: image.innerWidth() + 'px',
46
+ 'margin-right': image.css('margin-right'),
47
+ 'margin-left': image.css('margin-left'),
48
+ 'margin-top': image.css('margin-top'),
49
+ 'margin-bottom': image.css('margin-bottom')
50
+ });
51
+
52
+ for(var i in wpclasses)
53
+ image.hasClass(wpclasses[i]) && $('span.pinit[data-indexer="' + indexer +'"]').addClass(wpclasses[i]);
54
+
55
+ if (image.hasClass('aligncenter')){
56
+ $('span.pinit[data-indexer="' + indexer +'"]')
57
+ .addClass('aligncenter')
58
+ .css('clear', 'both');
59
+ $('span.pinit-overlay[data-indexer="' + indexer + '"]')
60
+ .css({
61
+ "margin-left":"auto",
62
+ "margin-right": "auto",
63
+ left: 0,
64
+ right: 0
65
+ })
66
+ }
67
+
68
+ $('.pinit .pinit-button').on('click', function () {
69
+ window.open($(this).attr('href'), 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
70
+ return false;
71
+ });
72
+
73
+ $('.pinit').mouseenter(function () {
74
+ $(this).children('.pinit-overlay').fadeIn(200);
75
+ }).mouseleave(function () {
76
+ $(this).children('.pinit-overlay').fadeOut(200);
77
+ });
78
+ })
79
+ };
80
+
81
+ //loop over every selected image
82
return this.each(function(i) {
83
+ var e = $(this);
84
+ //check if the image has a discriminator class, if has, then return
85
+ for(var c in discriminator_classes){
86
+ if(e.hasClass(discriminator_classes[c]))
87
+ return;
88
+ }
89
+
90
if (!(typeof allowed_classes === 'undefined')) {//variable doesn't exist
91
var has_class = false;
92
for(var c in allowed_classes){
93
+ if(e.hasClass(allowed_classes[c])){
94
has_class = true;
95
break;
96
}
99
return;
100
}
101
102
//to identify the image when loaded
103
+ e.attr('data-indexer', i);
104
});
105
}
106
});
js/script.min.js ADDED
@@ -0,0 +1 @@
1
+ (function(e){e.fn.extend({pinit:function(t){var n={pageURL:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content")};var r=e.extend(n,t);var i=r.disabled_classes.split(";");if(!(typeof r.enabled_classes==="undefined"))var s=r.enabled_classes.split(";");window.onload=function(){var t=["alignnone","alignright","alignleft"];e("img[data-indexer]").each(function(){var n=e(this),i=n.data("media")?n.data("media"):n[0].src,s=r.pageURL;var u;if(r.description_option==3)u=n.attr("title")?n.attr("title"):n.attr("alt");else if(r.description_option==2)u=r.pageDescription;!u&&(u=r.pageTitle);var a=n.attr("data-indexer");var f="http://pinterest.com/pin/create/bookmarklet/?media="+encodeURI(i)+"&url="+encodeURI(s)+"&is_video="+encodeURI("false")+"&description="+encodeURI(u);n.wrap('<span class="pinit" data-indexer="'+a+'"/>');n.after('<span class="pinit-overlay" data-indexer= "'+a+'"><a class="pinit-button" href="'+f+'">Pin It</a></span>');e('span.pinit-overlay[data-indexer="'+a+'"]').css({height:n.innerHeight()+"px",width:n.innerWidth()+"px","margin-right":n.css("margin-right"),"margin-left":n.css("margin-left"),"margin-top":n.css("margin-top"),"margin-bottom":n.css("margin-bottom")});for(var l in t)n.hasClass(t[l])&&e('span.pinit[data-indexer="'+a+'"]').addClass(t[l]);if(n.hasClass("aligncenter")){e('span.pinit[data-indexer="'+a+'"]').addClass("aligncenter").css("clear","both");e('span.pinit-overlay[data-indexer="'+a+'"]').css({"margin-left":"auto","margin-right":"auto",left:0,right:0})}e(".pinit .pinit-button").on("click",function(){window.open(e(this).attr("href"),"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)})})};return this.each(function(t){var n=e(this);for(var r in i){if(n.hasClass(i[r]))return}if(!(typeof s==="undefined")){var o=false;for(var r in s){if(n.hasClass(s[r])){o=true;break}}if(!o)return}n.attr("data-indexer",t)})}})})(jQuery)
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.0.0
6
Tested up to: 3.5
7
- Stable tag: 0.7.1
8
License: GPLv2 or later
9
10
Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
@@ -19,6 +19,7 @@ The plugin allows you to:
19
* choose which pictures should show the "Pin it" button (all images, post images, images with certain class(es))
20
* choose if you want to show the "Pin it" button on home page, single posts, single pages or category pages
21
* disable showing the button on certain posts and pages (works only on single posts and single pages)
22
23
Once you activate the plugin, it's ready to go with the typical settings - button appears on all images within the body of your posts/pages that aren't marked with "nopin" or "wp-smiley" classes.
24
@@ -62,6 +63,11 @@ Please report them in the plugin's support forum.
62
63
== Changelog ==
64
65
= 0.7.1 =
66
* Released 2012-12-20
67
* Bug related to deleting and quick-editing posts fixed
@@ -82,11 +88,14 @@ Please report them in the plugin's support forum.
82
83
== Upgrade Notice ==
84
85
= 0.7.1 =
86
Critical bug fix, please update.
87
88
= 0.7 =
89
- Additional features and some security enhancments.
90
91
= 0.5 =
92
First version of the plugin.
4
Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
Requires at least: 3.0.0
6
Tested up to: 3.5
7
+ Stable tag: 0.8
8
License: GPLv2 or later
9
10
Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
19
* choose which pictures should show the "Pin it" button (all images, post images, images with certain class(es))
20
* choose if you want to show the "Pin it" button on home page, single posts, single pages or category pages
21
* disable showing the button on certain posts and pages (works only on single posts and single pages)
22
+ * choose transparency level depending on your needs
23
24
Once you activate the plugin, it's ready to go with the typical settings - button appears on all images within the body of your posts/pages that aren't marked with "nopin" or "wp-smiley" classes.
25
63
64
== Changelog ==
65
66
+ = 0.8 =
67
+ * Released 2013-01-12
68
+ * Feature: Ability to choose transparency level depending on one's needs
69
+ * Added support for default Wordpress align classes, so the plugin doesn't mess up the positioning of the images on screen (in typical cases)
70
+
71
= 0.7.1 =
72
* Released 2012-12-20
73
* Bug related to deleting and quick-editing posts fixed
88
89
== Upgrade Notice ==
90
91
+ = 0.8 =
92
+ Additional feature and added support for basic image positioning.
93
+
94
= 0.7.1 =
95
Critical bug fix, please update.
96
97
= 0.7 =
98
+ Additional features and some security enhancements.
99
100
= 0.5 =
101
First version of the plugin.