Update lelms-copyright.php

This commit is contained in:
文派备案 2025-04-06 23:13:37 +08:00
parent ee72143cbb
commit d74ddf7618

View file

@ -3,7 +3,7 @@
* Plugin Name: LeLMS Copyright
* Plugin URI: https://wenpai.org/plugins/lelms-copyright
* Description: Adds watermark with username and prevents unauthorized screenshots
* Version: 1.1.5
* Version: 1.1.6
* Author: LeLMS.com
* Author URI: https://lelms.com
* License: GPL v2 or later
@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
exit;
}
define('LELMS_COPYRIGHT_VERSION', '1.1.5');
define('LELMS_COPYRIGHT_VERSION', '1.1.6');
define('LELMS_COPYRIGHT_DIR_URL', plugin_dir_url(__FILE__));
define('LELMS_COPYRIGHT_DIR_PATH', plugin_dir_path(__FILE__));
define('LELMS_COPYRIGHT_BASENAME', plugin_basename(__FILE__));
@ -47,7 +47,14 @@ class LELMS_Copyright {
'excluded_post_types' => array(),
'excluded_roles' => array(),
);
$this->options = wp_parse_args(get_option('lelms_copyright_options', array()), $defaults);
$current_options = get_option('lelms_copyright_options', false);
if ($current_options === false) {
update_option('lelms_copyright_options', $defaults);
$this->options = $defaults;
} else {
$this->options = wp_parse_args($current_options, $defaults);
}
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
if (did_action('wp_body_open')) {
@ -91,15 +98,11 @@ class LELMS_Copyright {
}
public function section_description() {
echo '<p>';
esc_html_e('Customize the watermark appearance and protection settings to secure your content.', 'lelms-copyright');
echo '</p>';
echo '<p>' . esc_html__('Customize the watermark appearance and protection settings to secure your content.', 'lelms-copyright') . '</p>';
}
public function advanced_section_description() {
echo '<p>';
esc_html_e('Configure advanced options to exclude specific post types or user roles from watermark and protection.', 'lelms-copyright');
echo '</p>';
echo '<p>' . esc_html__('Configure advanced options to exclude specific post types or user roles from watermark and protection.', 'lelms-copyright') . '</p>';
}
public function sanitize_options($input) {
@ -128,13 +131,13 @@ class LELMS_Copyright {
$sanitized['watermark_spacing'] = absint($input['watermark_spacing']);
$sanitized['watermark_color'] = sanitize_hex_color($input['watermark_color']);
$sanitized['watermark_angle'] = intval($input['watermark_angle']);
$sanitized['enable_devtools_protection'] = isset($input['enable_devtools_protection']) ? 'yes' : 'no';
$sanitized['enable_print_protection'] = isset($input['enable_print_protection']) ? 'yes' : 'no';
$sanitized['enable_copy_protection'] = isset($input['enable_copy_protection']) ? 'yes' : 'no';
$sanitized['enable_for_guests'] = isset($input['enable_for_guests']) ? 'yes' : 'no';
$sanitized['enable_guest_protection_only'] = isset($input['enable_guest_protection_only']) ? 'yes' : 'no';
$sanitized['enable_guest_custom_watermark'] = isset($input['enable_guest_custom_watermark']) ? 'yes' : 'no';
$sanitized['enable_custom_watermark'] = isset($input['enable_custom_watermark']) ? 'yes' : 'no';
$sanitilized['enable_devtools_protection'] = isset($input['enable_devtools_protection']) && $input['enable_devtools_protection'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_print_protection'] = isset($input['enable_print_protection']) && $input['enable_print_protection'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_copy_protection'] = isset($input['enable_copy_protection']) && $input['enable_copy_protection'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_for_guests'] = isset($input['enable_for_guests']) && $input['enable_for_guests'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_guest_protection_only'] = isset($input['enable_guest_protection_only']) && $input['enable_guest_protection_only'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_guest_custom_watermark'] = isset($input['enable_guest_custom_watermark']) && $input['enable_guest_custom_watermark'] === 'yes' ? 'yes' : 'no';
$sanitized['enable_custom_watermark'] = isset($input['enable_custom_watermark']) && $input['enable_custom_watermark'] === 'yes' ? 'yes' : 'no';
$sanitized['custom_watermark_text'] = sanitize_text_field($input['custom_watermark_text']);
$sanitized['watermark_type'] = in_array($input['watermark_type'], ['username', 'nickname', 'email', 'timestamp']) ? $input['watermark_type'] : 'username';
$sanitized['excluded_post_types'] = array_map('sanitize_key', (array) $input['excluded_post_types']);
@ -375,9 +378,7 @@ class LELMS_Copyright {
}
if ($description) {
echo '<p class="description">';
echo esc_html($description);
echo '</p>';
echo '<p class="description">' . esc_html($description) . '</p>';
}
}
@ -529,7 +530,6 @@ class LELMS_Copyright {
</script>
</div>
</div>
<?php
}
@ -622,7 +622,7 @@ require_once plugin_dir_path(__FILE__) . 'lib/plugin-update-checker/plugin-updat
use YahnisElsts\PluginUpdateChecker\v5p3\PucFactory;
$lelmsUpdateChecker = PucFactory::buildUpdateChecker(
'https://updates.weixiaoduo.com/updatepulse.json',
'https://updates.weixiaoduo.com/lelms-copyright.json',
__FILE__,
'lelms-copyright'
);