Changeset 2386338
- Timestamp:
- 09/22/2020 12:31:54 PM (4 years ago)
- Location:
- mouse-cursor-customizer/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
mouse-cursor-customizer/trunk/admin-cursor.css
r2173884 r2386338 21 21 -ms-touch-action: none; 22 22 touch-action: none; 23 23 24 } 24 25 … … 244 245 box-shadow: 0px 0px 5px #666666; 245 246 } 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 -
mouse-cursor-customizer/trunk/cursor-customizer.php
r2306602 r2386338 46 46 $options['cursor_file2']['url_new'] = isset( $options['cursor_file2']['url_new'] ) ? esc_url( $options['cursor_file2']['url_new'] ) : ''; 47 47 $options['cursor_file3']['url_new'] = isset( $options['cursor_file3']['url_new'] ) ? esc_url( $options['cursor_file3']['url_new'] ) : ''; 48 $url_on_link = ( isset( $options['onlink'] ) && $options['onlink'] == 'on' ) ? $options['cursor_file1']['url_new'] : $options['cursor_file2']['url_new'];49 48 $url_on_button = ( isset( $options['onbutton'] ) && $options['onbutton'] == 'on' ) ? $options['cursor_file1']['url_new'] : $options['cursor_file3']['url_new']; 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 50 65 51 66 $custom_css = " … … 55 70 body span, 56 71 body div { 57 cursor: url( {$options['cursor_file1']['url_new']}), auto!important;72 cursor: url(), auto!important; 58 73 } 59 74 … … 62 77 body.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 span, 63 78 body.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 div { 64 cursor: url( {$options['cursor_file1']['url_new']}), auto!important;65 } 66 67 68 /* Cursor customization for links */79 cursor: url(), auto!important; 80 } 81 82 83 /* Cursor customization for links */ 69 84 70 85 body a { … … 72 87 } 73 88 74 75 89 body a.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 { 76 90 cursor: url($url_on_link), pointer!important; 77 91 } 78 79 80 /* Cursor customization for buttons, inputs */92 93 94 /* 81 95 82 96 body button { … … 84 98 } 85 99 86 87 100 body button.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 { 88 101 cursor: url($url_on_button), pointer!important; 89 102 } 90 103 91 92 104 body input { 93 105 cursor: url($url_on_button), pointer!important; 94 106 } 95 107 96 97 108 body input.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 { 98 109 cursor: url($url_on_button), pointer!important; 99 110 } 100 "; 111 112 */"; 101 113 102 114 wp_add_inline_style( 'cursor_css', $custom_css ); 103 115 } 104 // end of cursor_custom_add_script_and_style() 116 // end of cursor_custom_add_script_and_style() 105 117 106 118 107 119 function cursor_custom_add_admin_scripts( $slug ) { 108 120 109 121 wp_register_style( 'slider_ui_css', plugins_url( 'admin-cursor.css', __FILE__ )); 110 122 wp_register_script( 'plugin_admin_js', plugins_url( 'plugin-admin.js', __FILE__ ), array('jquery-ui-slider') ); 111 123 112 124 $options = get_option( 'cursor_details' ); 113 125 114 126 if ( $slug != 'appearance_page_cursor-settings' ) { 115 127 return; 116 } 128 } 117 129 118 130 wp_enqueue_script( 'plugin_admin_js' ); … … 129 141 } 130 142 131 $args = array( 132 'sanitize_callback' => 'cursor_custom_sanitize_callback_set',133 'group' => 'cursor_details',143 $args = array( 144 'sanitize_callback' => 'cursor_custom_sanitize_callback_set', 145 'group' => 'cursor_details', 134 146 ); 135 147 … … 147 159 function cursor_custom_sanitize_callback_set( $options ) { 148 160 $options__old = get_option( 'cursor_details' ); 149 161 150 162 if ( isset( $_FILES ) ) { 151 163 … … 158 170 $value['type'] = sanitize_mime_type( $value['type'] ); 159 171 160 if ( $value['type'] == 'image/gif' || $value['type'] == 'image/png' || $value['type'] == 'image/jpeg' || $value['type'] == 'image/GIF' || $value['type'] == 'image/PNG' || $value['type'] == 'image/JPEG' ) { 172 if ( $value['type'] == 'image/gif' || $value['type'] == 'image/png' || $value['type'] == 'image/jpeg' || $value['type'] == 'image/GIF' || $value['type'] == 'image/PNG' || $value['type'] == 'image/JPEG' ) { 161 173 $overrides = array( 'test_form' => false ); 162 174 $fileimg = wp_handle_upload( $value, $overrides ); … … 170 182 $options[ $file ]['url_new'] = isset( $options__old[ $file ]['url_new'] ) ? $options__old[ $file ]['url_new'] : 'none'; 171 183 } 172 } else {173 174 175 176 177 178 }184 } else { 185 186 if ( ! empty( $_POST['cursor_details'][ $file ]['size'] ) && isset( $options__old[ $file ]['url'] ) ) { 187 $options[ $file ] = cursor_custom_resize( $_POST['cursor_details'][ $file ]['size'], $options__old[ $file ], $file ); 188 } 189 190 } 179 191 } 180 192 } 181 193 182 194 183 184 $options['onlink'] = isset( $_POST['cursor_details']['onlink'] ) ? sanitize_text_field( $_POST['cursor_details']['onlink'] ) : 'off'; 195 $options['use_url_body'] = isset( $_POST['cursor_details']['use_url_body'] ) ? sanitize_text_field( $_POST['cursor_details']['use_url_body'] ) : 'off'; 196 $options['url_body'] = isset( $_POST['cursor_details']['url_body'] ) ? esc_url( $_POST['cursor_details']['url_body'] ) : ''; 197 $options['use_url_link'] = isset( $_POST['cursor_details']['use_url_link'] ) ? sanitize_text_field( $_POST['cursor_details']['use_url_link'] ) : 'off'; 198 $options['url_link'] = isset( $_POST['cursor_details']['url_link'] ) ? esc_url( $_POST['cursor_details']['url_link'] ) : ''; 199 200 $options['onlink'] = isset( $_POST['cursor_details']['onlink'] ) ? sanitize_text_field( $_POST['cursor_details']['onlink'] ) : 'off'; 185 201 $options['onbutton'] = isset( $_POST['cursor_details']['onbutton'] ) ? sanitize_text_field( $_POST['cursor_details']['onbutton'] ) : 'off'; 186 202 … … 199 215 } 200 216 201 217 202 218 $clean_options = array(); 203 219 foreach ( $options as $key_ => $val_ ) { 204 220 205 221 if ( is_array( $val_ ) ) { 206 222 foreach ( $val_ as $k => $v ) { 207 $clean_options[ $key_ ][ $k ] = wp_filter_nohtml_kses( $v );223 $clean_options[ $key_ ][ $k ] = wp_filter_nohtml_kses( $v ); 208 224 } 209 225 } else { … … 227 243 if ( $img_size['width'] > 60 ) { 228 244 $path = __DIR__ . "/cursor/$dir/*"; 229 $trash_file = glob( $path ); 245 $trash_file = glob( $path ); 230 246 231 247 foreach ( $trash_file as $file ) { … … 233 249 if ( is_file( $file ) ) { 234 250 unlink( $file ); 235 251 } 236 252 237 253 } … … 242 258 $result['url'] = $img_old; 243 259 $result['url_new'] = plugins_url( "/cursor/$dir/{$saved['file']}", __FILE__ ); 244 $result['size'] = $img_size['width']; 245 $result['size_new'] = 60; 260 $result['size'] = $img_size['width']; 261 $result['size_new'] = 60; 246 262 return $result; 247 263 } else { … … 252 268 return $result; 253 269 } 254 255 256 add_settings_error( 'my_option', 'settings_updated', 'Sorry, but this image could not be processed.', 'error' ); 257 } 270 271 } else { 272 add_settings_error( 'my_option', 'settings_updated', 'Sorry, but this image could not be processed.', 'error' ); 273 } 258 274 259 275 } … … 261 277 262 278 function cursor_custom_resize( $new_size, $options_old, $dir ) { 263 279 264 280 $new_size = (int) sanitize_text_field( $new_size ); 265 281 … … 270 286 $result = array(); 271 287 $path = __DIR__ . "/cursor/$dir/*"; 272 $trash_file = glob( $path ); 288 $trash_file = glob( $path ); 273 289 274 290 foreach ( $trash_file as $file ) { 275 291 276 292 if ( is_file( $file ) ) { 277 unlink( $file ); 278 279 280 } 281 293 unlink( $file ); 294 } 295 296 } 297 282 298 $cursor_original = wp_get_image_editor( $options_old['url'] ); 283 299 $cursor_old_size = $cursor_original->get_size( $options_old['url'] ); … … 287 303 $result['url'] = $options_old['url']; 288 304 $result['url_new'] = plugins_url( "/cursor/$dir/{$saved['file']}", __FILE__ ); 289 $result['size'] = $cursor_old_size['width']; 290 $result['size_new'] = $new_size; 305 $result['size'] = $cursor_old_size['width']; 306 $result['size_new'] = $new_size; 291 307 return $result; 292 308 } … … 296 312 $options = get_option( 'cursor_details' ); 297 313 ?> 298 <div style="max-width:200px;"> 299 <p> 300 <input type="file" name="cursor_file1" id="cursor_image1" /> 301 </p> 302 <?php if ( isset( $options['cursor_file1']['url_new'] ) ) { ?> 303 <p style="margin: 20px auto; min-height:65px; display:flex; align-items:center; justify-content:center;"> 304 <img id="img-adm-cursor1" src="<?php echo esc_url( $options['cursor_file1']['url'] ); ?>" style="width: <?php echo esc_attr( (int) $options['cursor_file1']['size_new'] ); ?>px;" alt="" /> 305 </p> 306 <div style="margin:20px 0px; max-width:200px; text-align:center;"> 307 <input type="hidden" name="cursor_details[cursor_file1][size]" id="cursor-size1" value="" /> 308 <div id="size1"></div> 309 <p> 310 <span id="amount1"></span><span> pixels </span> 311 </p> 312 <p> 313 <input type="checkbox" name="cursor_details[delete1]" id="cursor-body-onlink-delete1" class="regular-text" value="on" /> 314 <label for="cursor-body-onlink"> Delete this image </label> 315 </p> 316 </div> 317 <?php } ?> 318 </div> 314 <div class="cursor_details_onbody"> 315 <h4>Body</h4> 316 <p> 317 <input type="file" name="cursor_file1" id="cursor_image1" /> 318 </p> 319 <?php if ( isset( $options['cursor_file1']['url_new'] ) ) { ?> 320 <p style="margin: 20px auto; min-height:65px; display:flex; align-items:center; justify-content:center;"> 321 <img id="img-adm-cursor1" src="<?php echo esc_url( $options['cursor_file1']['url'] ); ?>" style="width: <?php echo esc_attr( (int) $options['cursor_file1']['size_new'] ); ?>px;" alt="" /> 322 </p> 323 <div style="margin:20px 0px; max-width:100%; text-align:center;"> 324 <input type="hidden" name="cursor_details[cursor_file1][size]" id="cursor-size1" value="" /> 325 <div id="size1"></div> 326 <p> 327 <span id="amount1"></span><span> pixels </span> 328 </p> 329 <p> 330 <input type="checkbox" name="cursor_details[delete1]" id="cursor-body-onlink-delete1" class="regular-text" value="on" /> 331 <label for="cursor-body-onlink-delete1"> Delete this image </label> 332 </p> 333 </div> 334 <?php } ?> 335 <div class="cursor_url_block" > 336 <?php 337 $url_body = ''; 338 if( isset( $options['url_body'] ) ){ 339 $url_body = $options['url_body']; 340 } 341 ?> 342 <input type="checkbox" name="cursor_details[use_url_body]" id="use_url_body" class="regular-text" <?php checked( $options['use_url_body'], 'on' ) ?> /> 343 <label for="use_url_body">Use image url?</label><br /> 344 <input type="text" name="cursor_details[url_body]" class="regular-text" value="<?php echo esc_url( $url_body ) ?>" /> 345 <span class="recommend_for_url">Less than 60x60 px is recommended</span> 346 </div> 347 </div> 348 319 349 <?php 320 350 } … … 325 355 isset( $options['onlink'] ) ? $options['onlink'] : $options['onlink'] = 'on'; 326 356 ?> 327 <div>328 <input type="checkbox" name="cursor_details[onlink]" id="cursor-body-onlink" class="regular-text" <?php checked( $options['onlink'], 'on' ) ?> />329 <label for="cursor-body-onlink">Do not change the cursor when hovering over a <strong>link</strong>.</label><br/>330 <a class="subinput-togler" href="">upload another image for links</a>331 <div class="subinput" style="margin:20px 0px; max-width:200px; text-align:center;">332 <input type="file" name="cursor_file2" id="cursor_image2" />333 <?php if ( isset( $options['cursor_file2']['url_new'] ) ) { ?>334 <p style="margin: 20px auto; min-height:65px; display:flex; align-items:center;justify-content:center;">335 <img id="img-adm-cursor2" src="<?php echo esc_url( $options['cursor_file2']['url'] ); ?>" style="width: <?php echo esc_attr( (int) $options['cursor_file2']['size_new'] ); ?>px;" alt="" />336 < /p>337 <input type="hidden" name="cursor_details[cursor_file2][size]" id="cursor-size2" value="" />338 <div id="size2"></div>339 <p>340 <span id="amount2"></span><span> pixels </span>341 < /p>342 <p>343 <input type="checkbox" name="cursor_details[delete2]" id="cursor-body-onlink-delete2" class="regular-text" value="on" />344 <label for="cursor-body-onlink"> Delete this image </label>345 < /p>346 < ?php }?>347 < /div>357 > 358 > 359 /> 360 > 361 > 362 > 363 > 364 > 365 > 366 <> 367 > 368 > 369 > 370 > 371 <> 372 p> 373 > 374 > 375 <> 376 <> 377 <> 348 378 </div> 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 349 395 <?php 350 396 } … … 356 402 isset( $options['onbutton'] ) ? $options['onbutton'] : $options['onbutton'] = 'on'; 357 403 ?> 358 <div> 359 <input type="checkbox" name="cursor_details[onbutton]" id="cursor-body-onbutton" class="regular-text" <?php checked( $options['onbutton'], 'on' ) ?> /> 360 <label for="cursor-body-onbutton">Do not change the cursor when hovering over a <strong>button</strong>.</label> <br /> 361 <a class="subinput-togler" href="">upload another image for buttons</a> 362 <div class="subinput" style="margin:20px 0px;max-width:200px; text-align:center;"> 363 <input type="file" name="cursor_file3" id="cursor_image3" /> 364 <?php if ( isset( $options['cursor_file3']['url_new'] ) ) { ?> 365 <p style="margin: 20px auto; min-height:65px; display:flex; align-items:center;justify-content:center;"> 366 <img id="img-adm-cursor3" src="<?php echo esc_url( $options['cursor_file3']['url'] ); ?>" style="width: <?php echo esc_attr( (int) $options['cursor_file3']['size_new'] ); ?>px;" alt="" /> 367 </p> 368 <input type="hidden" name="cursor_details[cursor_file3][size]" id="cursor-size3" value="" /> 369 <div id="size3"></div> 370 <p> 371 <span id="amount3"></span><span> pixels </span> 372 </p> 373 <p> 374 <input type="checkbox" name="cursor_details[delete3]" id="cursor-body-onlink-delete3" class="regular-text" value="on" /> 375 <label for="cursor-body-onlink"> Delete this image </label> 376 </p> 377 <?php } ?> 378 </div> 404 <div class="cursor_details_onbutton" > 405 <input type="checkbox" name="cursor_details[onbutton]" id="cursor-body-onbutton" class="regular-text" <?php checked( $options['onbutton'], 'on' ) ?> /> 406 <label for="cursor-body-onbutton">Do not change the cursor when hovering over a <strong>button</strong>.</label> <br /> 407 <a class="subinput-togler" href="">upload another image for buttons</a> 408 <div class="subinput <?php if( isset($options['cursor_file3']['url']) ) print 'img-loaded'; ?>" style="margin:20px 0px;max-width:200px; text-align:center;"> 409 <input type="file" name="cursor_file3" id="cursor_image3" /> 410 <?php if ( isset( $options['cursor_file3']['url_new'] ) ) { ?> 411 <p style="margin: 20px auto; min-height:65px; display:flex; align-items:center;justify-content:center;"> 412 <img id="img-adm-cursor3" src="<?php echo esc_url( $options['cursor_file3']['url'] ); ?>" style="width: <?php echo esc_attr( (int) $options['cursor_file3']['size_new'] ); ?>px;" alt="" /> 413 </p> 414 <input type="hidden" name="cursor_details[cursor_file3][size]" id="cursor-size3" value="" /> 415 <div id="size3"></div> 416 <p> 417 <span id="amount3"></span><span> pixels </span> 418 </p> 419 <p> 420 <input type="checkbox" name="cursor_details[delete3]" id="cursor-body-onlink-delete3" class="regular-text" value="on" /> 421 <label for="cursor-body-onlink"> Delete this image </label> 422 </p> 423 <?php } ?> 379 424 </div> 425 380 426 <?php 381 427 } … … 384 430 // Create page 385 431 function cursor_custom_create_page() { 386 432 add_theme_page( 'Cursor Settings', 'Cursor Settings', 'manage_options', 'cursor-settings', 'cursor_custom_cursor_settings_render_page' ); 387 433 } 388 434 … … 391 437 $options = get_option( 'cursor_details' ); 392 438 settings_errors(); 393 ?> 394 <div class="wrap"> 395 <h2>Cursor Settings</h2> 396 <form action="options.php" method="post" enctype="multipart/form-data"> 397 <?php settings_fields( 'cursor_details' ); ?> 398 <?php do_settings_sections( 'cursor-settings' ); ?> 399 <?php submit_button(); ?> 400 </form> 401 </div> 402 <?php 403 } 439 ?> 440 <div class="wrap"> 441 <h2>Cursor Settings</h2> 442 <form action="options.php" method="post" enctype="multipart/form-data"> 443 <?php settings_fields( 'cursor_details' ); ?> 444 <?php do_settings_sections( 'cursor-settings' ); ?> 445 <?php submit_button(); ?> 446 </form> 447 <div id="cursor-customizer-author-msg"><strong>This is free software.</strong><a href="https://www.paypal.com/paypalme/alexanderkoledov">Donate for plugin support.</a></div> 448 </div> 449 <?php 450 } -
mouse-cursor-customizer/trunk/plugin-admin.js
r2173884 r2386338 62 62 63 63 // show/hide input files #2 and #3 64 $( '.subinput' ).fadeOut(); 65 $( '.subinput-togler' ).on( 'click', function(){ 64 $( '.subinput-togler' ).on( 'click', function(event){ 66 65 event.preventDefault(); 67 $(this).next().fadeToggle(); 66 $( '.subinput' ).toggleClass('img-loaded'); 67 //$(this).next().fadeToggle(); 68 68 }); 69 69 -
mouse-cursor-customizer/trunk/readme.txt
r2306597 r2386338 5 5 Requires at least: 4.8 6 6 Tested up to: 5.4.2 7 Stable tag: 1. 17 Stable tag: 1. 8 8 Requires PHP: 5.6 9 9 License: GPLv2 or later … … 66 66 == Changelog == 67 67 68 69 70 68 71 = 1.1 = 69 72 Resolving an error caused by the inability to process certain images … … 72 75 * Release this plugin. 73 76 74 == Upgrade Notice == 77 == Upgrade Notice == 78 79 = 1.2 = 80 Added the ability to use a link to an image. Disable the ability to change the cursor on buttons 75 81 76 82 = 1.1 =
Note: See TracChangeset
for help on using the changeset viewer.