Plugin Directory

Changeset 3286295


Ignore:
Timestamp:
05/02/2025 01:38:02 PM (11 months ago)
Author:
twkmedia
Message:

Add options page with option to disable script for admins

Location:
image-protection
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • image-protection/trunk/CHANGELOG.md

    r3265158 r3286295  
    66and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
    77
     8## [1.0.2] - 2025-05-02
     9
     10### Added
     11- Added settings page under Settings menu
     12- Added option to disable image protection for admin users
    813
    914## [1.0.1] - 2025-04-01
  • image-protection/trunk/README.md

    r3265158 r3286295  
    44**Tags:** image, protection, security 
    55**Requires at least:** 5.0 
    6 **Tested up to:** 6.7
    7 **Stable tag:** 1.0.
     6**Tested up to:** 6.8
     7**Stable tag:** 1.0.2
    88**Requires PHP:** 7.4 
    99**License:** GPLv2 or later 
  • image-protection/trunk/image-protection.php

    r3265158 r3286295  
    44 * Plugin URI: https://wordpress.org/plugins/image-protection
    55 * Description: Protects images from being copied, saved, or screenshot.
    6  * Version: 1.0.1
     6 * Version: 1.0.2
    77 * Requires at least: 5.0
    88 * Requires PHP: 7.4
     
    2424 * Define plugin constants.
    2525 */
    26 define( 'IMAGE_PROTECTION_VERSION', '1.0.1' );
     26define( 'IMAGE_PROTECTION_VERSION', '1.0.2' );
    2727define( 'IMAGE_PROTECTION_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2828define( 'IMAGE_PROTECTION_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     29
     30/**
     31 * Register plugin settings.
     32 *
     33 * @return void
     34 */
     35function image_protection_register_settings() {
     36    register_setting(
     37        'image_protection_options',
     38        'image_protection_disable_for_admin',
     39        array(
     40            'type'    => 'boolean',
     41            'default' => false,
     42        )
     43    );
     44}
     45add_action( 'admin_init', 'image_protection_register_settings' );
     46
     47/**
     48 * Add settings page to the admin menu.
     49 *
     50 * @return void
     51 */
     52function image_protection_add_settings_page() {
     53    add_options_page(
     54        __( 'Image Protection Settings', 'image-protection' ),
     55        __( 'Image Protection', 'image-protection' ),
     56        'manage_options',
     57        'image-protection',
     58        'image_protection_settings_page'
     59    );
     60}
     61add_action( 'admin_menu', 'image_protection_add_settings_page' );
     62
     63/**
     64 * Render the settings page.
     65 *
     66 * @return void
     67 */
     68function image_protection_settings_page() {
     69    ?>
     70    <div class="wrap">
     71        <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
     72        <form method="post" action="options.php">
     73            <?php
     74            settings_fields( 'image_protection_options' );
     75            do_settings_sections( 'image-protection' );
     76            ?>
     77            <table class="form-table">
     78                <tr valign="top">
     79                    <th scope="row"><?php esc_html_e( 'Disable for admin users', 'image-protection' ); ?></th>
     80                    <td>
     81                        <label for="image_protection_disable_for_admin">
     82                            <input type="checkbox" id="image_protection_disable_for_admin" name="image_protection_disable_for_admin" value="1" <?php checked( get_option( 'image_protection_disable_for_admin' ), 1 ); ?> />
     83                            <?php esc_html_e( 'Disable image protection for logged-in admin users', 'image-protection' ); ?>
     84                        </label>
     85                        <p class="description"><?php esc_html_e( 'When enabled, administrators will not see the image protection effects.', 'image-protection' ); ?></p>
     86                    </td>
     87                </tr>
     88            </table>
     89            <?php submit_button(); ?>
     90        </form>
     91    </div>
     92    <?php
     93}
    2994
    3095/**
     
    3499 */
    35100function image_protection_enqueue_scripts() {
    36     wp_enqueue_script(
    37         'image-protection',
    38         IMAGE_PROTECTION_PLUGIN_URL . 'protection.js',
    39         array(),
    40         IMAGE_PROTECTION_VERSION,
    41         true
    42     );
     101    // Skip loading the script for admin users if the option is enabled
     102    if ( get_option( 'image_protection_disable_for_admin' ) && current_user_can( 'manage_options' ) ) {
     103        return;
     104    }
     105
     106    wp_enqueue_script(
     107        'image-protection',
     108        IMAGE_PROTECTION_PLUGIN_URL . 'protection.js',
     109        array(),
     110        IMAGE_PROTECTION_VERSION,
     111        true
     112    );
    43113}
    44114add_action( 'wp_enqueue_scripts', 'image_protection_enqueue_scripts' );
     
    57127}
    58128add_action( 'plugins_loaded', 'image_protection_load_textdomain' );
     129
  • image-protection/trunk/protection.js

    r3265158 r3286295  
    160160                e.key === "4"
    161161            ) {
    162                 setTimeout(() => this.unblurImages(), 1000);
     162                setTimeout(() => this.unblurImages(), 2000);
    163163            }
    164164        }
  • image-protection/trunk/readme.txt

    r3265158 r3286295  
    33Tags: image, protection, security
    44Requires at least: 5.0
    5 Tested up to: 6.7
    6 Stable tag: 1.0.1
     5Tested up to: 6.8
     6Stable tag: 1.0.2
    77Requires PHP: 7.4
    88License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.