jQuery Pin It Button for Images - Version 0.9.5

Version Description

  • Released 2013-03-04
  • Fixed some issues with image sizing and responsive themes
  • Code refactoring
  • Added preview in the settings panel
  • New feature: adding images using media library
Download this release

Release Info

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

Code changes from version 0.9.2 to 0.9.5

css/admin.css CHANGED
@@ -1,21 +1,23 @@
1
- table.form-table th {
2
- font-weight:bold;
3
- }
4
-
5
.settings-table {
6
- background-color:#E7E7E7;
7
- border:1px solid #B1B1B1;
8
- border-radius:20px;
9
padding:20px;
10
- width:60%;
11
}
12
13
.settings-table th {
14
- font-weight:bold;
15
vertical-align:top;
16
text-align:left;
17
padding:0px 10px;
18
- width:150px;
19
}
20
21
.settings-table p {
@@ -27,11 +29,11 @@ table.form-table th {
27
}
28
29
.jpibfi-success-message, .jpibfi-error-message {
30
- border: 1px solid;
31
border-radius: 10px;
32
- margin: 10px 0px;
33
- padding:10px;
34
- width: 55%;
35
}
36
37
.jpibfi-success-message {
@@ -47,34 +49,38 @@ table.form-table th {
47
.settings-table .error-border {
48
border: 2px solid #ff8387;
49
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
50
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
51
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
52
}
53
54
- .error-info {
55
border: 1px solid #eed3d7;;
56
-webkit-border-radius: 4px;
57
- -moz-border-radius: 4px;
58
- border-radius: 4px;
59
background-color: #f2dede;
60
color: #b94a48;
61
padding: 8px 14px;
62
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
63
- float:left;
64
- display:none;
65
- margin-left: 5px;
66
- max-width:45%;
67
}
68
69
- .error-info :after,.description {
70
- clear:both;
71
}
72
73
- .left-element {
74
- max-width:75%;
75
- float:left;
76
}
77
78
- label.chbox-label {
79
padding-left: 5px;
80
}
1
.settings-table {
2
padding:20px;
3
+ width:100%;
4
+ border-collapse: collapse
5
+ }
6
+
7
+ .settings-table td {
8
+ padding-bottom: 20px;
9
}
10
11
.settings-table th {
12
vertical-align:top;
13
+ font-weight: normal;
14
text-align:left;
15
padding:0px 10px;
16
+ width:200px;
17
+ }
18
+
19
+ .settings-table th label{
20
+ font-weight:bold;
21
}
22
23
.settings-table p {
29
}
30
31
.jpibfi-success-message, .jpibfi-error-message {
32
+ border: 1px solid;
33
border-radius: 10px;
34
+ margin: 10px 0px;
35
+ padding:10px;
36
+ width: 90%;
37
}
38
39
.jpibfi-success-message {
49
.settings-table .error-border {
50
border: 2px solid #ff8387;
51
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
52
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
53
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
54
}
55
56
+ #errors_div div {
57
border: 1px solid #eed3d7;;
58
-webkit-border-radius: 4px;
59
+ -moz-border-radius: 4px;
60
+ border-radius: 4px;
61
background-color: #f2dede;
62
color: #b94a48;
63
padding: 8px 14px;
64
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
65
}
66
67
+ .jpibfi-visible {
68
+ display: block;
69
}
70
71
+ .jpibfi-hidden {
72
+ display: none;
73
}
74
75
+ #errors_div div :after,.description {
76
+ clear:both;
77
+ }
78
+
79
+ input[type="checkbox"] ~ label {
80
padding-left: 5px;
81
+ }
82
+
83
+ .jpibfi-admin-number {
84
+ width: 60px;
85
+ text-align: right;
86
}
css/style.css CHANGED
@@ -1,25 +1,26 @@
1
.pinit {
2
- position:relative;
3
- display:inline-block;
4
- overflow: hidden;
5
}
6
7
.pinit .pinit-overlay {
8
- position:absolute;
9
- top:0;
10
- left:0;
11
- width:100%;
12
- height:100%;
13
- z-index:200;
14
- display:none;
15
text-align:left;
16
}
17
18
.pinit .pinit-overlay a {
19
- position:relative;
20
- top:0%;
21
- left:0%;
22
- margin:20px 0 0 20px;
23
- display:block;
24
- text-indent:-9999em;
25
}
1
.pinit {
2
+ position:relative;
3
+ display:inline-block;
4
+ overflow: hidden;
5
+ max-width: 100%;
6
}
7
8
.pinit .pinit-overlay {
9
+ position:absolute;
10
+ top:0;
11
+ left:0;
12
+ width:100%;
13
+ height:100%;
14
+ z-index:200;
15
+ display:none;
16
text-align:left;
17
}
18
19
.pinit .pinit-overlay a {
20
+ position:relative;
21
+ top:0%;
22
+ left:0%;
23
+ margin:20px 0 0 20px;
24
+ display:block;
25
+ text-indent:-9999em;
26
}
images/image_preview.jpg ADDED
Binary file
jpibfi-admin.php CHANGED
@@ -5,51 +5,48 @@ if ( ! function_exists( 'add_action' ) ) {
5
}
6
7
require_once( "jpibfi-validation.php" );
8
9
- //HTML HELPERS
10
-
11
- function jpibfi_print_error_class( $error_array, $field_name ) {
12
- if ( ! empty( $error_array ) && array_key_exists( $field_name, $error_array ) )
13
- echo "class='error-border'";
14
- }
15
16
- function jpibfi_print_error_div( $div_id, $error_array, $field_name, $message ) {
17
- $display_message = "";
18
- if ( ! empty( $error_array ) && array_key_exists( $field_name, $error_array ) )
19
- $display_message = "style='display:block;'";
20
- printf( '<div id="%s" class="error-info" %s>%s</div>', $div_id, $display_message, $message );
21
}
22
23
- //END HTML HELPERS
24
-
25
//Prints out the admin page
26
function jpibfi_print_admin_page() {
27
- global $jpibfi_admin_basic_options_name;
28
- global $jpibfi_admin_advanced_options_name;
29
30
$dev_options = jpibfi_get_basic_options();
31
$advanced_dev_options = jpibfi_get_advanced_options();
32
33
- $errors = array();
34
35
if ( isset( $_POST['update_jQuery_Pin_It_Button_For_Images'] ) ) {
36
//security check
37
if ( ! wp_verify_nonce( $_POST['jpibfi_nonce'], 'jpibfi_admin_settings' ) )
38
die( 'Security alert' );
39
40
-
41
-
42
- if ( ! jpibfi_contains_css_class_names_or_empty( $_POST['disabled_classes'] ) )
43
- $errors['disabled_classes'] = true;
44
-
45
- if ( ! jpibfi_contains_css_class_names_or_empty( $_POST['enabled_classes'] ) )
46
- $errors['enabled_classes'] = true;
47
-
48
- if ( ! jpibfi_is_numeric_or_empty( $_POST['custom_image_height'] ) )
49
- $errors['custom_image_height'] = true;
50
-
51
- if ( ! jpibfi_is_numeric_or_empty( $_POST['custom_image_width'] ) )
52
- $errors['custom_image_width'] = true;
53
54
//rewrite settings that came from the POST request
55
$dev_options['image_selector'] = sanitize_text_field( $_POST['image_selector'] );
@@ -67,19 +64,22 @@ function jpibfi_print_admin_page() {
67
68
69
if ( $dev_options['compatibility_mode'] == '0' )
70
- if ( ! is_numeric( $dev_options['transparency_value'] ) || ( $dev_options['transparency_value'] < 0.0 ) || ( $dev_options['transparency_value'] > 1.0 ) )
71
- $errors['transparency_value'] = true;
72
73
$advanced_dev_options['on_home'] = $_POST['on_home'] == '1' ? '1' : '0';
74
$advanced_dev_options['on_page'] = $_POST['on_page'] == '1' ? '1' : '0';
75
$advanced_dev_options['on_single'] = $_POST['on_single'] == '1' ? '1' : '0';
76
$advanced_dev_options['on_category'] = $_POST['on_category'] == '1' ? '1' : '0';
77
78
- if ( 0 == count( $errors ) ) { //save only if there are no errors
79
- update_option( $jpibfi_admin_basic_options_name, $dev_options );
80
- update_option( $jpibfi_admin_advanced_options_name, $advanced_dev_options );
81
?>
82
- <p class="jpibfi-success-message"><?php _e( "Settings Updated.", "jpibfi" );?></p>
83
<?php
84
}
85
else { //otherwise inform that there are some errors
@@ -89,12 +89,28 @@ function jpibfi_print_admin_page() {
89
}
90
}
91
?>
92
- <div class="wrap">
93
- <h2>jQuery Pin It Button For Images</h2>
94
95
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
96
<?php wp_nonce_field( "jpibfi_admin_settings", 'jpibfi_nonce' ); ?>
97
- <h3>Plugin settings</h3>
98
99
<table class="settings-table">
100
<tbody>
@@ -106,10 +122,8 @@ function jpibfi_print_admin_page() {
106
107
<p class="description">jQuery selector for all the images that should have the "Pin it" button. Set
108
the value to <a href="#" class="jpibfi_selector_option">div.jpibfi_container img</a> if you want
109
- the "Pin it" button to appear only on images in content or
110
- <a href="#" class="jpibfi_selector_option">img</a>
111
- to appear on all images on site (including sidebar, header and footer). If you know a thing or
112
- two about jQuery, you might use your own selector.
113
<a href="http://api.jquery.com/category/selectors/" target="_blank">Click here</a> to read
114
about jQuery selectors.</p>
115
</td>
@@ -117,45 +131,50 @@ function jpibfi_print_admin_page() {
117
<tr>
118
<th scope="row"><label for="disabled_classes">Disabled classes</label></th>
119
<td>
120
- <div class="left-element">
121
- <textarea id="disabled_classes"
122
- name="disabled_classes" <?php jpibfi_print_error_class( $errors, 'disabled_classes' ); ?>><?php echo esc_attr( $dev_options['disabled_classes'] );?></textarea>
123
- </div>
124
- <?php jpibfi_print_error_div( "disabled_classes_error", $errors, "disabled_classes",
125
- "Error. Please change this setting and try submitting again." ); ?>
126
127
- <p class="description">Pictures with these CSS classes won't show the "Pin it" button. Please
128
- separate multiple classes with semicolons. Spaces are not accepted.</p>
129
</td>
130
</tr>
131
<tr>
132
<th scope="row"><label for="enabled_classes">Enabled classes</label></th>
133
<td>
134
- <div class="left-element">
135
- <textarea id="enabled_classes"
136
- name="enabled_classes" <?php jpibfi_print_error_class( $errors, 'enabled_classes' ); ?>><?php echo $dev_options['enabled_classes'];?></textarea>
137
- </div>
138
- <?php jpibfi_print_error_div( "enabled_classes_error", $errors, "enabled_classes",
139
- "Error. Please change this setting and try submitting again." ); ?>
140
-
141
<p class="description">Pictures with these CSS classes will show the "Pin it" button. Please
142
separate multiple classes with semicolons. If this field is empty, images with any (besides
143
disabled ones) classes will show the Pin It button.</p>
144
</td>
145
</tr>
146
<tr>
147
<th scope="row"><label for="description_option">Description source</label></th>
148
<td>
149
<select id="description_option" name="description_option">
150
- <option value="1" <?php if ( "1" == $dev_options['description_option'] ) echo "selected='selected'"; ?>>
151
- Page title
152
- </option>
153
- <option value="2" <?php if ( "2" == $dev_options['description_option'] ) echo "selected='selected'"; ?>>
154
- Page description
155
- </option>
156
- <option value="3" <?php if ( "3" == $dev_options['description_option'] ) echo "selected='selected'"; ?>>
157
- Picture title or alt attributes
158
- </option>
159
</select>
160
161
<p class="description">From where the Pinterest message should be taken.</p>
@@ -165,31 +184,23 @@ function jpibfi_print_admin_page() {
165
<th scope="row"><label for="compatibility_mode">Transparency</label></th>
166
<td>
167
<select name="compatibility_mode" id="compatibility_mode">
168
- <option value="0" <?php echo "0" == $dev_options['compatibility_mode'] ? "selected='selected'" : "";?>>
169
- Standard mode
170
- </option>
171
- <option value="1" <?php echo "1" == $dev_options['compatibility_mode'] ? "selected='selected'" : "";?>>
172
- IE7 Compatibility mode
173
- </option>
174
</select>
175
176
- <p id="standard_mode_transparency" <?php echo "1" == $dev_options['compatibility_mode'] ? "style='display:none'" : "";?>>
177
<label for="standard_transparency">Choose transparency (between 0.00 and 1.00)</label><br />
178
- <input type="text" id="standard_transparency" name="standard_transparency"
179
- value="<?php echo $dev_options['transparency_value'];?>" <?php jpibfi_print_error_class( $errors, 'transparency_value' ); ?>/>
180
-
181
- <?php jpibfi_print_error_div( "standard_transparency_error", $errors, "transparency_value",
182
- "The number is not valid. Please change the value and try submitting again." ); ?>
183
-
184
</p>
185
186
- <p id="compatibility_mode_transparency" <?php echo "0" == $dev_options['compatibility_mode'] ? "style='display:none'" : "";?>>
187
<label for="compatibility_transparency">Choose transparency</label><br />
188
<select name="compatibility_transparency" id="compatibility_transparency">
189
<?php for ( $i = 0; $i <= 1; $i += 0.1 ): ?>
190
- <option value="<?php echo $i;?>" <?php if ( round( $i, 1 ) == round( $dev_options['transparency_value'], 1 ) ) echo "selected='selected'"; ?>>
191
- <?php echo $i;?>
192
- </option>
193
<?php endfor; ?>
194
</select>
195
</p>
@@ -198,57 +209,56 @@ function jpibfi_print_admin_page() {
198
</td>
199
</tr>
200
<tr>
201
- <th scope="row"><label>Use custom Pinterest button</label></th>
202
<td>
203
- <input type="checkbox" id="use_custom_image" name="use_custom_image" value="1" <?php echo "1" == $dev_options["use_custom_image"] ? "checked='checked'" : "" ?> />
204
- <label class="chbox-label" for="use_custom_image">Use custom image</label><br />
205
206
- <p><label for="custom_image_url">URL address of the image</label><br />
207
- <input type="text" id="custom_image_url" name="custom_image_url" value="<?php echo $dev_options["custom_image_url"]; ?>" />
208
</p>
209
210
- <div class="left-element" style="clear:both;">
211
- <label for="custom_image_height">Height of the image (in pixels)</label><br />
212
- <input type="text" id="custom_image_height" name="custom_image_height" value="<?php echo $dev_options["custom_image_height"]; ?>"
213
- <?php jpibfi_print_error_class( $errors, 'custom_image_height' ); ?> />
214
- </div>
215
- <?php jpibfi_print_error_div( "custom_image_height_error", $errors, "custom_image_height",
216
- "Must be either blank or a number" ); ?>
217
218
- <div class="left-element" style="clear:both;">
219
- <label for="custom_image_width">Width of the image (in pixels)</label><br />
220
- <input type="text" id="custom_image_width" name="custom_image_width" value="<?php echo $dev_options["custom_image_width"]; ?>"
221
- <?php jpibfi_print_error_class( $errors, 'custom_image_width' ); ?> />
222
- </div>
223
- <?php jpibfi_print_error_div( "custom_image_width_error", $errors, "custom_image_width",
224
- "Must be either blank or a number" ); ?>
225
226
- <p class="description">Check the
227
- <b>Use custom image</b> checkbox, specify image's URL, height and width to use your own Pinterest button design.
228
</p>
229
</td>
230
</tr>
231
<tr>
232
- <th scope="row"><label>On which pages the "Pin it" button should be shown</label></th>
233
<td>
234
- <input type="checkbox" id="on_home"
235
- name="on_home" <?php echo "1" == $advanced_dev_options['on_home'] ? "checked='checked'" : "";?> value="1" /><label class="chbox-label" for="on_home"> Home page</label><br />
236
- <input type="checkbox" id="on_page"
237
- name="on_page" <?php echo "1" == $advanced_dev_options['on_page'] ? "checked='checked'" : "";?> value="1" /><label class="chbox-label" for="on_page"> Pages</label><br />
238
- <input type="checkbox" id="on_single"
239
- name="on_single" <?php echo "1" == $advanced_dev_options['on_single'] ? "checked='checked'" : "";?> value="1" /><label class="chbox-label" for="on_single"> Single posts</label><br />
240
- <input type="checkbox" id="on_category"
241
- name="on_category" <?php echo "1" == $advanced_dev_options['on_category'] ? "checked='checked'" : "";?> value="1" /><label class="chbox-label" for="on_category"> Category pages</label>
242
-
243
- <p class="description">Check on which pages you want the Pinterest button to show up.</p>
244
</td>
245
</tr>
246
<tr>
247
<th scope="row"></th>
248
<td>
249
- <input id="submit_form" type="submit" style="padding:7px; float:right;"
250
- name="update_jQuery_Pin_It_Button_For_Images"
251
- value="<?php _e( 'Update Settings', 'jQuery_Pin_It_Button_For_Images' ) ?>" />
252
</td>
253
</tr>
254
</tbody>
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 ) {
12
+ if ( $echo )
13
+ echo $true_value;
14
+ return $true_value;
15
+ }
16
+ if ( $echo )
17
+ echo $false_value;
18
+ return $false_value;
19
20
}
21
22
//Prints out the admin page
23
function jpibfi_print_admin_page() {
24
25
$dev_options = jpibfi_get_basic_options();
26
$advanced_dev_options = jpibfi_get_advanced_options();
27
+ $errors = array(
28
+ 'disabled_classes' => false,
29
+ 'enabled_classes' => false,
30
+ 'custom_image_height' => false,
31
+ 'custom_image_width' => false,
32
+ 'transparency_value' => false
33
+ );
34
+ ?>
35
+
36
+ <div class="wrap" id="top_anchor">
37
+ <h2>jQuery Pin It Button For Images</h2>
38
39
+ <?php
40
41
if ( isset( $_POST['update_jQuery_Pin_It_Button_For_Images'] ) ) {
42
//security check
43
if ( ! wp_verify_nonce( $_POST['jpibfi_nonce'], 'jpibfi_admin_settings' ) )
44
die( 'Security alert' );
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'] );
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 )
76
+ $any_errors = $any_errors || $value;
77
+
78
+ if ( ! $any_errors ) { //save only if there are no errors
79
+ update_option( JPIBFI_BASIC_OPTIONS, $dev_options );
80
+ update_option( JPIBFI_ADVANCED_OPTIONS, $advanced_dev_options );
81
?>
82
+ <p class='jpibfi-success-message'><?php _e( "Settings Updated.", "jpibfi" );?></p>
83
<?php
84
}
85
else { //otherwise inform that there are some errors
89
}
90
}
91
?>
92
+ <div id="errors_div">
93
+ <div id="disabled_classes_error" class="<?php jpibfi_conditional( $errors["disabled_classes"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
94
+ Disabled classes setting error. Please change it and try submitting again.
95
+ </div>
96
+ <div id="enabled_classes_error" class="<?php jpibfi_conditional( $errors["enabled_classes"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
97
+ Enabled classes setting error. Please change it and try submitting again.
98
+ </div>
99
+ <div id="standard_transparency_error" class="<?php jpibfi_conditional( $errors["transparency_value"], "jpibfi-visible", "jpibfi-hidden" ); ?>">
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
110
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
111
<?php wp_nonce_field( "jpibfi_admin_settings", 'jpibfi_nonce' ); ?>
112
+ <h3>Which images should be pinned</h3>
113
+ <hr/>
114
115
<table class="settings-table">
116
<tbody>
122
123
<p class="description">jQuery selector for all the images that should have the "Pin it" button. Set
124
the value to <a href="#" class="jpibfi_selector_option">div.jpibfi_container img</a> if you want
125
+ the "Pin it" button to appear only on images in content or <a href="#" class="jpibfi_selector_option">img</a>
126
+ 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.
127
<a href="http://api.jquery.com/category/selectors/" target="_blank">Click here</a> to read
128
about jQuery selectors.</p>
129
</td>
131
<tr>
132
<th scope="row"><label for="disabled_classes">Disabled classes</label></th>
133
<td>
134
+ <textarea id="disabled_classes" name="disabled_classes" <?php jpibfi_conditional( $errors["disabled_classes"], "class='error-border'" ); ?>
135
+ ><?php echo esc_attr( $dev_options['disabled_classes'] );?></textarea>
136
137
+ <p class="description">Pictures with these CSS classes won't show the "Pin it" button. Please separate multiple classes with semicolons. Spaces are not accepted.</p>
138
</td>
139
</tr>
140
<tr>
141
<th scope="row"><label for="enabled_classes">Enabled classes</label></th>
142
<td>
143
+ <textarea id="enabled_classes" name="enabled_classes" <?php jpibfi_conditional( $errors["enabled_classes"], "class='error-border'" ); ?>
144
+ ><?php echo esc_attr( $dev_options['enabled_classes'] );?></textarea>
145
<p class="description">Pictures with these CSS classes will show the "Pin it" button. Please
146
separate multiple classes with semicolons. If this field is empty, images with any (besides
147
disabled ones) classes will show the Pin It button.</p>
148
</td>
149
</tr>
150
+ <tr>
151
+ <th scope="row"><label>On which pages the "Pin it" button should be shown</label></th>
152
+ <td>
153
+ <input type="checkbox" id="on_home" name="on_home" <?php checked( "1", $advanced_dev_options['on_home'] ); ?> value="1" />
154
+ <label for="on_home"> Home page</label><br />
155
+ <input type="checkbox" id="on_page" name="on_page" <?php checked( "1", $advanced_dev_options['on_page'] ); ?> value="1" />
156
+ <label for="on_page"> Pages</label><br />
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>
168
+ <hr/>
169
+ <table class="settings-table">
170
+ <tbody>
171
<tr>
172
<th scope="row"><label for="description_option">Description source</label></th>
173
<td>
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>
184
<th scope="row"><label for="compatibility_mode">Transparency</label></th>
185
<td>
186
<select name="compatibility_mode" id="compatibility_mode">
187
+ <option value="0" <?php selected( "0", $dev_options['compatibility_mode'] ); ?>>Standard mode</option>
188
+ <option value="1" <?php selected( "1", $dev_options['compatibility_mode'] ); ?>>IE7 Compatibility mode</option>
189
</select>
190
191
+ <p id="standard_mode_transparency" <?php echo jpibfi_conditional( "1" == $dev_options['compatibility_mode'], "style='display:none'" );?>>
192
<label for="standard_transparency">Choose transparency (between 0.00 and 1.00)</label><br />
193
+ <input type="number" min="0" max="1" step="0.01" id="standard_transparency" name="standard_transparency"
194
+ value="<?php echo $dev_options['transparency_value'];?>" <?php jpibfi_conditional( $errors["transparency_value"], "class='error-border'" ); ?>/>
195
</p>
196
197
+ <p id="compatibility_mode_transparency" <?php jpibfi_conditional( "0" == $dev_options['compatibility_mode'], "style='display:none'" ); ?>>
198
<label for="compatibility_transparency">Choose transparency</label><br />
199
<select name="compatibility_transparency" id="compatibility_transparency">
200
<?php for ( $i = 0; $i <= 1; $i += 0.1 ): ?>
201
+ <option value="<?php echo $i;?>" <?php selected( round( $i, 1 ), round( $dev_options['transparency_value'], 1 ) ); ?>>
202
+ <?php echo $i;?>
203
+ </option>
204
<?php endfor; ?>
205
</select>
206
</p>
209
</td>
210
</tr>
211
<tr>
212
+ <th scope="row"><label>Custom "Pin It" button</label></th>
213
<td>
214
+ <p>
215
+ <input type="checkbox" id="use_custom_image" name="use_custom_image" value="1" <?php checked( "1", $dev_options["use_custom_image"] ); ?> />
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>
223
+ <input type="url" id="custom_image_url" name="custom_image_url" value="<?php echo $dev_options["custom_image_url"]; ?>" style="width: 100%;" />
224
</p>
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
238
+ <p class="description">
239
+ Check the <b>Use custom image</b> checkbox, specify image's URL, height and width to use your own Pinterest button design. You can just upload an image using Wordpress media library if you wish.
240
</p>
241
</td>
242
</tr>
243
<tr>
244
+ <th scope="row"><label>Preview</label></th>
245
<td>
246
+ <img src="<?php echo plugins_url( '/images/image_preview.jpg', __FILE__ ); ?>" id="<?php echo JPIBFI_PREVIEW_IMAGE_ID; ?>"
247
+ alt="This is a preview"/>
248
+ <p class="description">Make sure you reload the settings page (click the proper link in Settings section) once again after saving the settings to make preview work properly.</p>
249
+ </td>
250
+ </tr>
251
+ <tr>
252
+ <th scope="row"><label>Donate</label></th>
253
+ <td>
254
+ <a href="http://bit.ly/Uw2mEP" target="_blank" rel="nofollow" class="button"><b>Donate</b></a>
255
+ <p class="description">If you like the plugin and would like to support its author, please donate.</p>
256
</td>
257
</tr>
258
<tr>
259
<th scope="row"></th>
260
<td>
261
+ <?php submit_button( null, 'primary', "update_jQuery_Pin_It_Button_For_Images", true, array( 'id' => 'submit_form' ) ); ?>
262
</td>
263
</tr>
264
</tbody>
jpibfi-constants.php ADDED
@@ -0,0 +1,18 @@
1
+ <?php
2
+
3
+ if ( ! function_exists( 'add_action' ) ) {
4
+ echo "Hi there! I'm just a plugin, not much I can do when called directly.";
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");
12
+
13
+ //DEFAULT PIN BUTTON IMAGE
14
+ 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" );
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.2
8
Author URI: http://profiles.wordpress.org/mrsztuczkens
9
*/
10
@@ -13,20 +13,15 @@ if ( ! function_exists( 'add_action' ) ) {
13
exit;
14
}
15
16
- define( "JPIBFI_VERSION", "0.9.2" );
17
-
18
require_once( "jpibfi-validation.php" );
19
require_once( "jpibfi-admin.php" );
20
21
$jpbfi_description_option_values = array( '1', '2', '3' );
22
- $jpibfi_admin_basic_options_name = "jptbfi_options";
23
- $jpibfi_admin_advanced_options_name = "jptbfi_advanced_options";
24
- $jpibfi_post_metadata_name = "jpibfi_meta";
25
-
26
27
//Returns an array of basic admin options, updates settings if necessary
28
function jpibfi_get_basic_options() {
29
- global $jpibfi_admin_basic_options_name, $jpbfi_description_option_values;
30
31
$admin_options = array(
32
'image_selector' => 'div.jpibfi_container img',
@@ -41,7 +36,7 @@ function jpibfi_get_basic_options() {
41
'custom_image_width' => ''
42
);
43
44
- $dev_options = get_option( $jpibfi_admin_basic_options_name );
45
46
$changes_in_db = count( $admin_options ) != count( $dev_options ); //if arrays aren't of the same length, changes in db needed
47
@@ -95,16 +90,13 @@ function jpibfi_get_basic_options() {
95
96
//if something changed in the database, we need to save it
97
if ( $changes_in_db )
98
- update_option( $jpibfi_admin_basic_options_name, $admin_options );
99
100
return $admin_options;
101
}
102
103
- //End function jpibfi_get_basic_options()
104
-
105
//Returns an array of advanced admin options, updates settings if necessary
106
function jpibfi_get_advanced_options() {
107
- global $jpibfi_admin_advanced_options_name;
108
109
$admin_options = array(
110
'on_home' => '1',
@@ -113,7 +105,7 @@ function jpibfi_get_advanced_options() {
113
'on_category' => '1'
114
);
115
116
- $dev_options = get_option( $jpibfi_admin_advanced_options_name );
117
$changes_in_db = count( $admin_options ) != count( $dev_options ); //if arrays aren't of the same length, changes in db needed
118
119
foreach ( $admin_options as $setting_name => $setting_value ) {
@@ -123,16 +115,13 @@ function jpibfi_get_advanced_options() {
123
124
//if something changed in the database, we need to save it
125
if ( $changes_in_db )
126
- update_option( $jpibfi_admin_advanced_options_name, $admin_options );
127
return $admin_options;
128
}
129
- //
130
-
131
132
//returns false if plugin shouldn't be added to certain post based on metadata, otherwise true
133
function jpibfi_add_plugin_to_post( $post_id ) {
134
- global $jpibfi_post_metadata_name;
135
- $post_meta = get_post_meta( $post_id, $jpibfi_post_metadata_name, true );
136
if ( ! empty( $post_meta ) && array_key_exists( 'jpibfi_disable_for_post', $post_meta ) && $post_meta['jpibfi_disable_for_post'] == '1' )
137
return false;
138
return true;
@@ -140,6 +129,9 @@ function jpibfi_add_plugin_to_post( $post_id ) {
140
141
//Returns true if plugin should be added to a certain page
142
function jpibfi_add_plugin() {
143
global $post;
144
$advanced_settings = jpibfi_get_advanced_options();
145
@@ -164,34 +156,20 @@ function jpibfi_init_plugin() {
164
function jpibfi_add_plugin_scripts() {
165
if ( ! ( jpibfi_add_plugin() ) )
166
return;
167
- // Adding my custom js, dependent on jquery
168
- wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/script.min.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
169
- // Registering my custom style
170
- wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
171
- //Enqueue the style
172
- wp_enqueue_style( 'jquery-pin-it-button-style' );
173
- }
174
175
- function jpibfi_footer_action() {
176
- if ( !jpibfi_add_plugin() )
177
- return;
178
179
$dev_options = jpibfi_get_basic_options();
180
- $enabled_classes = $dev_options['enabled_classes'] ? ", enabled_classes:'" . $dev_options['enabled_classes'] . "'" : "";
181
182
- ?>
183
- <script type="text/javascript">
184
- jQuery(document).ready(function ($) {
185
- $('.jpibfi').parent('div').addClass('jpibfi_container');
186
- jpibfi_pinit({
187
- image_selector:'<?php echo $dev_options['image_selector'];?>',
188
- disabled_classes:'<?php echo $dev_options['disabled_classes'];?>',
189
- description_option:'<?php echo $dev_options['description_option'];?>'
190
- <?php echo $enabled_classes;?>
191
- });
192
- });
193
- </script>
194
- <?php
195
}
196
197
function jpibfi_print_header_style_action() {
@@ -213,9 +191,9 @@ function jpibfi_print_header_style_action() {
213
$url = $dev_options['custom_image_url'];
214
}
215
else {
216
- $width = 65;
217
- $height = 41;
218
- $url = plugins_url( '/images/pinit-button.png', __FILE__ );
219
}
220
221
?>
@@ -240,15 +218,34 @@ function jpibfi_print_hidden_field_script( $content ) {
240
241
//add admin scripts
242
function jpibfi_add_admin_site_scripts() {
243
wp_register_style( 'jquery-pin-it-button-admin-style', plugins_url( '/css/admin.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
244
wp_enqueue_style( 'jquery-pin-it-button-admin-style' );
245
- wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/admin.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
246
- }
247
248
249
250
251
- //End function print_admin_page()
252
253
function jpibfi_print_admin_page_action() {
254
$page = add_options_page( 'jQuery Pin It Button For Images', 'jQuery Pin It Button For Images', 9, basename( __FILE__ ), 'jpibfi_print_admin_page' );
@@ -289,11 +286,10 @@ function jpibfi_add_meta_box() {
289
290
// display the metabox
291
function jpibfi_print_meta_box( $post, $metabox ) {
292
- global $jpibfi_post_metadata_name;
293
294
wp_nonce_field( plugin_basename( __FILE__ ), 'jpibfi_nonce' );
295
296
- $post_meta = get_post_meta( $post->ID, $jpibfi_post_metadata_name, true );
297
if ( isset( $post_meta ) && isset( $post_meta['jpibfi_disable_for_post'] ) && $post_meta['jpibfi_disable_for_post'] == '1' )
298
$checked_message = 'checked="checked"';
299
else
@@ -304,7 +300,6 @@ function jpibfi_print_meta_box( $post, $metabox ) {
304
}
305
306
function jpibfi_save_meta_data( $post_id ) {
307
- global $jpibfi_post_metadata_name;
308
309
// check if this isn't an auto save
310
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
@@ -322,23 +317,22 @@ function jpibfi_save_meta_data( $post_id ) {
322
isset( $_POST['jpibfi_disable_for_post'] ) && $_POST['jpibfi_disable_for_post'] == '1' ? '1' : '0';
323
324
if ( $post_meta['jpibfi_disable_for_post'] == '1' )
325
- update_post_meta( $post_id, $jpibfi_post_metadata_name, $post_meta );
326
else
327
- delete_post_meta( $post_id, $jpibfi_post_metadata_name );
328
}
329
330
//END POST EDITOR CODE
331
332
//fire it when the plugin is deleted
333
function jpibfi_uninstall_plugin() {
334
- global $jpibfi_admin_basic_options_name, $jpibfi_admin_advanced_options_name, $jpibfi_post_metadata_name;
335
336
//delete all added options
337
- delete_option( $jpibfi_admin_basic_options_name );
338
- delete_option( $jpibfi_admin_advanced_options_name );
339
340
//delete added metadata from all posts
341
- delete_post_meta_by_key( $jpibfi_post_metadata_name );
342
}
343
344
//Actions and Filters
@@ -348,7 +342,6 @@ function jpibfi_uninstall_plugin() {
348
//Actions
349
add_action( 'wp_enqueue_scripts', 'jpibfi_add_plugin_scripts' );
350
add_action( 'admin_menu', 'jpibfi_print_admin_page_action' );
351
- add_action( 'wp_footer', 'jpibfi_footer_action' );
352
add_action( 'wp_head', 'jpibfi_print_header_style_action' );
353
add_action( 'add_meta_boxes', 'jpibfi_add_meta_box' );
354
add_action( 'save_post', 'jpibfi_save_meta_data' );
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
13
exit;
14
}
15
16
+ 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',
36
'custom_image_width' => ''
37
);
38
39
+ $dev_options = get_option( JPIBFI_BASIC_OPTIONS );
40
41
$changes_in_db = count( $admin_options ) != count( $dev_options ); //if arrays aren't of the same length, changes in db needed
42
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 );
94
95
return $admin_options;
96
}
97
98
//Returns an array of advanced admin options, updates settings if necessary
99
function jpibfi_get_advanced_options() {
100
101
$admin_options = array(
102
'on_home' => '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 ) {
115
116
//if something changed in the database, we need to save it
117
if ( $changes_in_db )
118
+ update_option( JPIBFI_ADVANCED_OPTIONS, $admin_options );
119
return $admin_options;
120
}
121
122
//returns false if plugin shouldn't be added to certain post based on metadata, otherwise true
123
function jpibfi_add_plugin_to_post( $post_id ) {
124
+ $post_meta = get_post_meta( $post_id, JPIBFI_METADATA, true );
125
if ( ! empty( $post_meta ) && array_key_exists( 'jpibfi_disable_for_post', $post_meta ) && $post_meta['jpibfi_disable_for_post'] == '1' )
126
return false;
127
return true;
129
130
//Returns true if plugin should be added to a certain page
131
function jpibfi_add_plugin() {
132
+ if ( is_admin() )
133
+ return true;
134
+
135
global $post;
136
$advanced_settings = jpibfi_get_advanced_options();
137
156
function jpibfi_add_plugin_scripts() {
157
if ( ! ( jpibfi_add_plugin() ) )
158
return;
159
160
+ wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/script.min.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
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' );
173
}
174
175
function jpibfi_print_header_style_action() {
191
$url = $dev_options['custom_image_url'];
192
}
193
else {
194
+ $width = JPIBFI_IMAGE_WIDTH;
195
+ $height = JPIBFI_IMAGE_WIDTH;
196
+ $url = JPIBFI_IMAGE_URL;
197
}
198
199
?>
218
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 );
226
227
+ if ( function_exists( "wp_enqueue_media") ) {
228
+ wp_enqueue_media();
229
+ wp_enqueue_script( 'jpibfi-upload-new', plugins_url( '/js/upload-button-new.js', __FILE__ ), array(), JPIBFI_VERSION, false );
230
+ } else {
231
+ wp_enqueue_script( 'jpibfi-upload-old', plugins_url( '/js/upload-button-old.js', __FILE__ ), array('thickbox', 'media-upload' ), JPIBFI_VERSION, false );
232
+ }
233
234
+ //for preview purposes
235
+ jpibfi_print_header_style_action();
236
+ wp_enqueue_script( 'jquery-pin-it-button-script', plugins_url( '/js/script.min.js', __FILE__ ), array( 'jquery' ), JPIBFI_VERSION, false );
237
238
+ $parameters_array = array(
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
246
+ wp_register_style( 'jquery-pin-it-button-style', plugins_url( '/css/style.css', __FILE__ ), array(), JPIBFI_VERSION, 'all' );
247
+ wp_enqueue_style( 'jquery-pin-it-button-style' );
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' );
286
287
// display the metabox
288
function jpibfi_print_meta_box( $post, $metabox ) {
289
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
300
}
301
302
function jpibfi_save_meta_data( $post_id ) {
303
304
// check if this isn't an auto save
305
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
317
isset( $_POST['jpibfi_disable_for_post'] ) && $_POST['jpibfi_disable_for_post'] == '1' ? '1' : '0';
318
319
if ( $post_meta['jpibfi_disable_for_post'] == '1' )
320
+ update_post_meta( $post_id, JPIBFI_METADATA, $post_meta );
321
else
322
+ delete_post_meta( $post_id, JPIBFI_METADATA );
323
}
324
325
//END POST EDITOR CODE
326
327
//fire it when the plugin is deleted
328
function jpibfi_uninstall_plugin() {
329
330
//delete all added options
331
+ delete_option( JPIBFI_BASIC_OPTIONS );
332
+ delete_option( JPIBFI_ADVANCED_OPTIONS );
333
334
//delete added metadata from all posts
335
+ delete_post_meta_by_key( JPIBFI_METADATA );
336
}
337
338
//Actions and Filters
342
//Actions
343
add_action( 'wp_enqueue_scripts', 'jpibfi_add_plugin_scripts' );
344
add_action( 'admin_menu', 'jpibfi_print_admin_page_action' );
345
add_action( 'wp_head', 'jpibfi_print_header_style_action' );
346
add_action( 'add_meta_boxes', 'jpibfi_add_meta_box' );
347
add_action( 'save_post', 'jpibfi_save_meta_data' );
js/admin.js CHANGED
@@ -49,11 +49,14 @@ jQuery(document).ready(function($) {
49
}
50
}
51
52
- if (error)
53
e.preventDefault();
54
});
55
56
- $('#compatibility_mode').change( function() {
57
if ($(this).val() == '0') {
58
$('#standard_mode_transparency').show();
59
$('#compatibility_mode_transparency').hide();
@@ -86,7 +89,7 @@ jQuery(document).ready(function($) {
86
return only_css_class_names;
87
}
88
89
- function contains_number_or_empty(value){
90
- return value.length == 0 || /^(\d+)\s*#x2F;.test(value);
91
- }
92
});
49
}
50
}
51
52
+ if (error) {
53
e.preventDefault();
54
+ location.hash = "#top_anchor";
55
+ }
56
+
57
});
58
59
+ $('#compatibility_mode').change( function() {
60
if ($(this).val() == '0') {
61
$('#standard_mode_transparency').show();
62
$('#compatibility_mode_transparency').hide();
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
});
js/script.js CHANGED
@@ -1,107 +1,123 @@
1
- function jpibfi_pinit(options) {
2
- var $ = jQuery;
3
-
4
- var defaults = {
5
- pageURL : document.URL,
6
- pageTitle : document.title,
7
- pageDescription: $('meta[name="description"]').attr('content')
8
- }
9
-
10
- var o = $.extend(defaults, options);
11
- var discriminator_classes = o.disabled_classes.split(';');
12
13
- if (!(typeof o.enabled_classes === 'undefined')) //variable exists
14
var allowed_classes = o.enabled_classes.split(';');
15
16
- $(o.image_selector).each(function (i) {
17
- var e = $(this);
18
- //check if the image has a discriminator class, if has, then return
19
- for (var c in discriminator_classes) {
20
- if (e.hasClass(discriminator_classes[c]))
21
- return;
22
- }
23
24
- if (!(typeof allowed_classes === 'undefined')) {//variable doesn't exist
25
- var has_class = false;
26
- for (var c in allowed_classes) {
27
- if (e.hasClass(allowed_classes[c])) {
28
- has_class = true;
29
- break;
30
}
31
}
32
- if (!has_class)
33
- return;
34
- }
35
36
- //to identify the image when loaded
37
- e.attr('data-indexer', i);
38
- });
39
-
40
- window.onload = function () {
41
-
42
- var wpclasses = ['alignnone', 'alignright', 'alignleft'];
43
-
44
- $("img[data-indexer]").each(function () {
45
- var image = $(this),
46
- pi_url = o.pageURL;
47
-
48
- //Pin message depending on settings
49
- var pi_desc;
50
- if (o.description_option == 3)
51
- pi_desc = image.attr('title') ? image.attr('title') : image.attr('alt');
52
- else if (o.description_option == 2)
53
- pi_desc = o.pageDescription;
54
- !pi_desc && (pi_desc = o.pageTitle);
55
-
56
- var indexer = image.attr("data-indexer"),
57
- bookmark = 'http://pinterest.com/pin/create/bookmarklet/?url=' + encodeURI(pi_url) + '&is_video=' + encodeURI('false') + '&description=' + encodeURI(pi_desc),
58
- height = this.clientHeight,
59
- width = this.clientWidth;
60
-
61
- image.wrap('<div class="pinit" data-indexer="' + indexer + '"/>');
62
- image.after('<span class="pinit-overlay" data-indexer= "' + indexer + '"><a class="pinit-button" href="' + bookmark + '" data-indexer= "' + indexer + '">Pin It</a></span>');
63
- image.attr('height', height + 'px').attr('width', width + 'px');
64
-
65
- $('span.pinit-overlay[data-indexer="' + indexer + '"]')
66
- .css({
67
- height :height + 'px',
68
- width :width + '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]) && $('span.pinit[data-indexer="' + indexer + '"]').addClass(wpclasses[i]);
77
-
78
- if (image.hasClass('aligncenter')) {
79
- $('.pinit[data-indexer="' + indexer + '"]')
80
- .addClass('aligncenter')
81
- .css('clear', 'both');
82
- $('span.pinit-overlay[data-indexer="' + indexer + '"]')
83
.css({
84
- "margin-left" :"auto",
85
- "margin-right":"auto",
86
- left :0,
87
- right :0
88
- })
89
- }
90
91
- $('.pinit .pinit-button').click( function () {
92
- var index = $(this).attr("data-indexer");
93
- var image = $('img[data-indexer="' + index+ '"]');
94
- var url = $(this).attr('href') + "&media=" + encodeURI ( image.data('media') ? image.data('media') : image[0].src );
95
- window.open(url, 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
96
- return false;
97
- });
98
-
99
- $('.pinit').mouseenter(function () {
100
- $(this).children('.pinit-overlay').fadeIn(200);
101
- }).mouseleave(function () {
102
- $(this).children('.pinit-overlay').fadeOut(200);
103
- });
104
- })
105
- };
106
- }
107
1
+ (function($){
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
+
39
+ //to identify the image when loaded
40
+ e.attr('data-indexer', i);
41
+ });
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,
89
+ right :0
90
+ })
91
+ }
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
+
101
+ $('.pinit').mouseenter(function () {
102
+ $(this).children('.pinit-overlay').fadeIn(200);
103
+ }).mouseleave(function () {
104
+ $(this).children('.pinit-overlay').fadeOut(200);
105
+ });
106
+ })
107
+ };
108
+
109
+ function jpibfiRemoveElements() {
110
+ $("span.pinit-overlay").remove();
111
+ $("img[data-indexer]").unwrap();
112
+ }
113
+
114
+ window.onload = jpibfiAddElements;
115
+
116
+ window.onresize = function() {
117
+ jpibfiRemoveElements();
118
+ jpibfiAddElements();
119
+ }
120
121
+ })
122
123
+ })(jQuery);
js/script.min.js CHANGED
@@ -1 +1 @@
1
- function jpibfi_pinit(e){var t=jQuery;var n={pageURL:document.URL,pageTitle:document.title,pageDescription:t('meta[name="description"]').attr("content")};var r=t.extend(n,e);var i=r.disabled_classes.split(";");if(!(typeof r.enabled_classes==="undefined"))var s=r.enabled_classes.split(";");t(r.image_selector).each(function(e){var n=t(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",e)});window.onload=function(){var e=["alignnone","alignright","alignleft"];t("img[data-indexer]").each(function(){var n=t(this),i=r.pageURL;var s;if(r.description_option==3)s=n.attr("title")?n.attr("title"):n.attr("alt");else if(r.description_option==2)s=r.pageDescription;!s&&(s=r.pageTitle);var u=n.attr("data-indexer"),a="http://pinterest.com/pin/create/bookmarklet/?url="+encodeURI(i)+"&is_video="+encodeURI("false")+"&description="+encodeURI(s),f=this.clientHeight,l=this.clientWidth;n.wrap('<div class="pinit" data-indexer="'+u+'"/>');n.after('<span class="pinit-overlay" data-indexer= "'+u+'"><a class="pinit-button" href="'+a+'" data-indexer= "'+u+'">Pin It</a></span>');n.attr("height",f+"px").attr("width",l+"px");t('span.pinit-overlay[data-indexer="'+u+'"]').css({height:f+"px",width:l+"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 c in e)n.hasClass(e[c])&&t('span.pinit[data-indexer="'+u+'"]').addClass(e[c]);if(n.hasClass("aligncenter")){t('.pinit[data-indexer="'+u+'"]').addClass("aligncenter").css("clear","both");t('span.pinit-overlay[data-indexer="'+u+'"]').css({"margin-left":"auto","margin-right":"auto",left:0,right:0})}t(".pinit .pinit-button").click(function(){var e=t(this).attr("data-indexer");var n=t('img[data-indexer="'+e+'"]');var r=t(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});t(".pinit").mouseenter(function(){t(this).children(".pinit-overlay").fadeIn(200)}).mouseleave(function(){t(this).children(".pinit-overlay").fadeOut(200)})})}}
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)
js/upload-button-new.js ADDED
@@ -0,0 +1,38 @@
1
+ jQuery(document).ready(function($) {
2
+
3
+ //Uploading media using new media uploader (Wordpress 3.5+)
4
+
5
+ var file_frame;
6
+
7
+ $('#upload-image').click(function(e) {
8
+ e.preventDefault();
9
+
10
+ // If the media frame already exists, reopen it.
11
+ if ( file_frame ) {
12
+ file_frame.open();
13
+ return;
14
+ }
15
+
16
+ // Create the media frame.
17
+ file_frame = wp.media.frames.file_frame = wp.media({
18
+ title: 'Select your custom "Pin It" button',
19
+ button: {
20
+ text: 'Use as "Pin It" button'
21
+ },
22
+ multiple: false // Set to true to allow multiple files to be selected
23
+ });
24
+
25
+ // When an image is selected, run a callback.
26
+ file_frame.on( 'select', function() {
27
+ // We set multiple to false so only get one image from the uploader
28
+ var image = file_frame.state().get('selection').first().toJSON();
29
+
30
+ $("#custom_image_url").val(image.url);
31
+ $("#custom_image_width").val(image.width);
32
+ $("#custom_image_height").val(image.height);
33
+ });
34
+
35
+ file_frame.open();
36
+ });
37
+
38
+ });
js/upload-button-old.js ADDED
@@ -0,0 +1,25 @@
1
+ jQuery(document).ready(function($) {
2
+
3
+ //Uploading media using old media uploader
4
+
5
+ $('#upload-image').click(function() {
6
+
7
+ tb_show('Choose an image and click "Insert into post"', 'media-upload.php?referer=jpibfi&type=image&TB_iframe=true&post_id=0', false);
8
+
9
+ // Re-define the global function 'send_to_editor'
10
+ // Define where the new value will be sent to
11
+ window.send_to_editor = function(html) {
12
+
13
+ // Get the URL of new image
14
+ var domElement = new DOMParser().parseFromString("<p>" + html + "</p>", "text/xml");
15
+ var image = $('img', domElement);
16
+ $("#custom_image_url").val(image.attr('src'));
17
+ $("#custom_image_width").val(image.attr('width'));
18
+ $("#custom_image_height").val(image.attr('height'));
19
+
20
+ tb_remove(); // Then close the popup window
21
+ }
22
+ return false;
23
+ });
24
+
25
+ });
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.3.0
6
Tested up to: 3.5.1
7
- Stable tag: 0.9.2
8
License: GPLv2 or later
9
10
Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
@@ -53,7 +53,7 @@ On the plugin settings page, there is a "Enabled classes" setting. Please enter
53
Use the "Disabled classes" setting on the settings page - add there specific classes or use the "nopin" class.
54
55
= Can I use my own "Pin it" button design? =
56
- Yes. On the settings page, there's a section named "Use custom Pinterest button". You need to check the Use custom image checkbox and provide a URL address of the image, image's width and height.
57
58
To upload you own image, you can use **Media Library** on your Wordpress installation or an image hosting service like **Photobucket**. Make sure you provide the proper address, width and height of the image. Otherwise, the button won't be displayed properly, or won't be displayed at all.
59
@@ -69,6 +69,13 @@ Please report them in the plugin's support forum on Wordpress.org.
69
70
== Changelog ==
71
72
= 0.9.2 =
73
* Released 2013-02-12
74
* It now works with jQuery versions older than 1.7
@@ -108,6 +115,12 @@ Please report them in the plugin's support forum on Wordpress.org.
108
109
== Upgrade Notice ==
110
111
= 0.9.2 =
112
Small update - plugin now works with jQuery versions older than 1.7.
113
4
Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
Requires at least: 3.3.0
6
Tested up to: 3.5.1
7
+ Stable tag: 0.9.5
8
License: GPLv2 or later
9
10
Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
53
Use the "Disabled classes" setting on the settings page - add there specific classes or use the "nopin" class.
54
55
= Can I use my own "Pin it" button design? =
56
+ Yes. On the settings page, there's a section named "Custom Pit It button". You need to check the Use custom image checkbox and provide a URL address of the image, image's width and height.
57
58
To upload you own image, you can use **Media Library** on your Wordpress installation or an image hosting service like **Photobucket**. Make sure you provide the proper address, width and height of the image. Otherwise, the button won't be displayed properly, or won't be displayed at all.
59
69
70
== Changelog ==
71
72
+ = 0.9.5 =
73
+ * Released 2013-03-04
74
+ * Fixed some issues with image sizing and responsive themes
75
+ * Code refactoring
76
+ * Added preview in the settings panel
77
+ * New feature: adding images using media library
78
+
79
= 0.9.2 =
80
* Released 2013-02-12
81
* It now works with jQuery versions older than 1.7
115
116
== Upgrade Notice ==
117
118
+ = 0.9.5 =
119
+ Few minor bug fixes and tweaks
120
+
121
+ = 0.9.3 =
122
+ Fixed bugs with image sizing and responsive themes
123
+
124
= 0.9.2 =
125
Small update - plugin now works with jQuery versions older than 1.7.
126
screenshot-3.jpg CHANGED
Binary file