Plugin Directory

Changeset 2386338

Timestamp:
09/22/2020 12:31:54 PM (4 years ago)
Author:
alexanderkoledov
Message:

upd to 1.2

Location:
mouse-cursor-customizer/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mouse-cursor-customizer/trunk/admin-cursor.css

    r2173884 r2386338  
    2121    -ms-touch-action: none;
    2222    touch-action: none;
     23
    2324}
    2425
     
    244245    box-shadow: 0px 0px 5px #666666;
    245246}
     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  
    4646    $options['cursor_file2']['url_new'] = isset( $options['cursor_file2']['url_new'] ) ? esc_url( $options['cursor_file2']['url_new'] ) : '';
    4747    $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'];
    4948    $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
    5065
    5166    $custom_css = "
     
    5570    body span,
    5671    body div {
    57         cursor: url({$options['cursor_file1']['url_new']}), auto!important;
     72        cursor: url(), auto!important;
    5873    }
    5974   
     
    6277    body.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 span,
    6378    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 */
    6984
    7085    body a {
     
    7287    }
    7388   
    74 
    7589    body a.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 {
    7690        cursor: url($url_on_link), pointer!important;
    7791    }
    78 
    79 
    80     /* Cursor customization for buttons, inputs */
     92   
     93   
     94    /*
    8195
    8296    body button {
     
    8498    }
    8599   
    86 
    87100    body button.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 {
    88101        cursor: url($url_on_button), pointer!important;
    89102    }
    90103
    91 
    92104    body input {
    93105        cursor: url($url_on_button), pointer!important;
    94106    }
    95107
    96    
    97108    body input.cursor-customizer103.cursor-customizer104.cursor-customizer105.cursor-customizer106 {
    98109        cursor: url($url_on_button), pointer!important;
    99110    }
    100     ";
     111   
     112    */";
    101113
    102114    wp_add_inline_style( 'cursor_css', $custom_css );
    103115}
    104 // end of cursor_custom_add_script_and_style() 
     116// end of cursor_custom_add_script_and_style()
    105117
    106118
    107119function cursor_custom_add_admin_scripts( $slug ) {
    108    
     120
    109121    wp_register_style( 'slider_ui_css', plugins_url( 'admin-cursor.css', __FILE__ ));
    110122    wp_register_script( 'plugin_admin_js', plugins_url( 'plugin-admin.js', __FILE__ ), array('jquery-ui-slider') );
    111123
    112124    $options = get_option( 'cursor_details' );
    113    
     125
    114126    if ( $slug != 'appearance_page_cursor-settings' ) {
    115127        return;
    116     }   
     128    }
    117129
    118130    wp_enqueue_script( 'plugin_admin_js' );
     
    129141    }
    130142
    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',
    134146    );
    135147
     
    147159function cursor_custom_sanitize_callback_set( $options ) {
    148160    $options__old = get_option( 'cursor_details' );
    149    
     161
    150162    if ( isset( $_FILES ) ) {
    151163
     
    158170                $value['type'] = sanitize_mime_type( $value['type'] );
    159171
    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' ) {
    161173                    $overrides = array( 'test_form' => false );
    162174                    $fileimg = wp_handle_upload( $value, $overrides );
     
    170182                    $options[ $file ]['url_new'] = isset( $options__old[ $file ]['url_new'] ) ? $options__old[ $file ]['url_new'] : 'none';
    171183                }
    172            } else {
    173 
    174                  if ( ! empty( $_POST['cursor_details'][ $file ]['size'] ) && isset( $options__old[ $file ]['url'] ) ) {
    175                         $options[ $file ] = cursor_custom_resize( $_POST['cursor_details'][ $file ]['size'], $options__old[ $file ], $file );
    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           }
    179191        }
    180192    }
    181193
    182194
    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';
    185201    $options['onbutton'] = isset( $_POST['cursor_details']['onbutton'] ) ? sanitize_text_field( $_POST['cursor_details']['onbutton'] ) : 'off';
    186202
     
    199215    }
    200216
    201    
     217
    202218    $clean_options = array();
    203     foreach ( $options as $key_ => $val_ ) {
     219foreach ( $options as $key_ => $val_ ) {
    204220
    205221        if ( is_array( $val_ ) ) {
    206222            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 );
    208224            }
    209225        } else {
     
    227243        if ( $img_size['width'] > 60 ) {
    228244            $path = __DIR__ . "/cursor/$dir/*";
    229             $trash_file = glob( $path ); 
     245            $trash_file = glob( $path );
    230246
    231247            foreach ( $trash_file as $file ) {
     
    233249                if ( is_file( $file ) ) {
    234250                    unlink( $file );
    235                     }
     251                }
    236252
    237253            }
     
    242258            $result['url'] = $img_old;
    243259            $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;
    246262            return $result;
    247263        } else {
     
    252268            return $result;
    253269        }
    254    
    255      } else {
    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    }
    258274
    259275}
     
    261277
    262278function cursor_custom_resize( $new_size, $options_old, $dir ) {
    263    
     279
    264280    $new_size = (int) sanitize_text_field( $new_size );
    265281
     
    270286    $result = array();
    271287    $path = __DIR__ . "/cursor/$dir/*";
    272     $trash_file = glob( $path ); 
     288    $trash_file = glob( $path );
    273289
    274290    foreach ( $trash_file as $file ) {
    275291
    276292        if ( is_file( $file ) ) {
    277             unlink( $file ); 
    278             }
    279            
    280     }
    281    
     293            unlink( $file );
     294        }
     295
     296    }
     297
    282298    $cursor_original = wp_get_image_editor( $options_old['url'] );
    283299    $cursor_old_size = $cursor_original->get_size( $options_old['url'] );
     
    287303    $result['url'] = $options_old['url'];
    288304    $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;
    291307    return $result;
    292308}
     
    296312    $options = get_option( 'cursor_details' );
    297313    ?>
    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
    319349    <?php
    320350}
     
    325355    isset( $options['onlink'] ) ? $options['onlink'] : $options['onlink'] = 'on';
    326356    ?>
    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            <>
    348378        </div>
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
    349395    <?php
    350396}
     
    356402    isset( $options['onbutton'] ) ? $options['onbutton'] : $options['onbutton'] = 'on';
    357403    ?>
    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  } ?>
    379424        </div>
     425
    380426    <?php
    381427}
     
    384430// Create page
    385431function cursor_custom_create_page() {
    386     add_theme_page( 'Cursor Settings', 'Cursor Settings', 'manage_options', 'cursor-settings', 'cursor_custom_cursor_settings_render_page' );
     432add_theme_page( 'Cursor Settings', 'Cursor Settings', 'manage_options', 'cursor-settings', 'cursor_custom_cursor_settings_render_page' );
    387433}
    388434
     
    391437    $options = get_option( 'cursor_details' );
    392438    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  
    6262
    6363  // show/hide input files #2 and #3
    64   $( '.subinput' ).fadeOut();
    65   $( '.subinput-togler' ).on( 'click', function(){
     64  $( '.subinput-togler' ).on( 'click', function(event){
    6665    event.preventDefault();
    67     $(this).next().fadeToggle();
     66    $( '.subinput' ).toggleClass('img-loaded');
     67    //$(this).next().fadeToggle();
    6868  });
    6969
  • mouse-cursor-customizer/trunk/readme.txt

    r2306597 r2386338  
    55Requires at least: 4.8
    66Tested up to: 5.4.2
    7 Stable tag: 1.1
     7Stable tag: 1.
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    6666== Changelog ==
    6767
     68
     69
     70
    6871= 1.1 =
    6972 Resolving an error caused by the inability to process certain images
     
    7275* Release this plugin.
    7376
    74 == Upgrade Notice ==
     77== Upgrade Notice ==
     78
     79= 1.2 =
     80Added the ability to use a link to an image. Disable the ability to change the cursor on buttons
    7581
    7682= 1.1 =
Note: See TracChangeset for help on using the changeset viewer.