From 3b6a4aa0f66a1924b862b5c1377ed80f445735ac Mon Sep 17 00:00:00 2001 From: xecdev Date: Fri, 30 May 2025 08:10:29 +0430 Subject: [PATCH] New style for the unlocked content indicator and obsolete migration code cleanup --- assets/css/paywall-styles.css | 32 +++++++++-------- includes/class-paybutton-activator.php | 50 +++----------------------- includes/class-paybutton-admin.php | 8 ++--- includes/class-paybutton-public.php | 10 +++--- templates/admin/paywall-settings.php | 24 +++---------- 5 files changed, 34 insertions(+), 90 deletions(-) diff --git a/assets/css/paywall-styles.css b/assets/css/paywall-styles.css index 2d2b292..2d3ebcc 100644 --- a/assets/css/paywall-styles.css +++ b/assets/css/paywall-styles.css @@ -1,19 +1,21 @@ .unlocked-indicator { - margin: 20px 0; - display: flex; - align-items: center; - justify-content: center; - text-align: center; - background-color: var(--pb-unlocked-bg, #007bff); - color: var(--pb-unlocked-text, #ffffff); - padding: 8px; - font-family: sans-serif; - font-weight: bold; - font-size: 1.2em; - border-radius: 5px; - box-sizing: border-box; + display: flex; + align-items: center; + margin: 2rem 0; + color: var(--pb-unlocked-indicator-color); /* Line + text color */ + font-family: inherit; + font-weight: 800; /* Strong text */ + font-size: 1rem; } -.unlocked-indicator p { - margin: 0; +.unlocked-indicator::before, +.unlocked-indicator::after { + content: ""; + flex: 1; + height: 1px; + background: currentColor; /* Uses the same color as the text */ +} + +.unlocked-indicator span { + padding: 0 1rem; /* Space between text and lines */ } \ No newline at end of file diff --git a/includes/class-paybutton-activator.php b/includes/class-paybutton-activator.php index 3d29114..86cbac9 100644 --- a/includes/class-paybutton-activator.php +++ b/includes/class-paybutton-activator.php @@ -23,27 +23,12 @@ public static function activate() { } private static function migrate_old_option() { - // --- 1. admin wallet address --- - $old_admin_addr = get_option( 'pb_paywall_admin_wallet_address', '' ); - $new_admin_addr = get_option( 'paybutton_admin_wallet_address', '' ); - if ( ! empty( $old_admin_addr ) && empty( $new_admin_addr ) ) { - update_option( 'paybutton_admin_wallet_address', $old_admin_addr ); - delete_option( 'pb_paywall_admin_wallet_address' ); - } - - // --- 2. unlocked‑indicator colours --- - $bg_old = get_option( 'unlocked_indicator_bg_color', '' ); - $bg_new = get_option( 'paybutton_unlocked_indicator_bg_color', '' ); - if ( ! empty( $bg_old ) && empty( $bg_new ) ) { - update_option( 'paybutton_unlocked_indicator_bg_color', $bg_old ); - delete_option( 'unlocked_indicator_bg_color' ); - } - - $txt_old = get_option( 'unlocked_indicator_text_color', '' ); - $txt_new = get_option( 'paybutton_unlocked_indicator_text_color', '' ); + // --- 1. unlocked‑indicator colours --- + $txt_old = get_option( 'paybutton_unlocked_indicator_text_color', '' ); + $txt_new = get_option( 'paybutton_unlocked_indicator_color', '' ); if ( ! empty( $txt_old ) && empty( $txt_new ) ) { - update_option( 'paybutton_unlocked_indicator_text_color', $txt_old ); - delete_option( 'unlocked_indicator_text_color' ); + update_option( 'paybutton_unlocked_indicator_color', $txt_old ); + delete_option( 'paybutton_unlocked_indicator_text_color' ); } } @@ -74,31 +59,6 @@ public static function create_tables() { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); - // Rename old 'ecash_address' column to 'pb_paywall_user_wallet_address', if it still exists - $old_col_check = $wpdb->get_var( - "SHOW COLUMNS FROM $table_name LIKE 'ecash_address'" - ); - $new_col_check = $wpdb->get_var( - "SHOW COLUMNS FROM $table_name LIKE 'pb_paywall_user_wallet_address'" - ); - - if ( $old_col_check && ! $new_col_check ) { - $wpdb->query("ALTER TABLE $table_name CHANGE ecash_address pb_paywall_user_wallet_address VARCHAR(255) NOT NULL"); - } - - // Rename old index 'ecash_address_idx' to 'pb_paywall_user_wallet_address_idx' - $old_idx_check = $wpdb->get_var(" - SHOW INDEX FROM $table_name WHERE Key_name = 'ecash_address_idx' - "); - $new_idx_check = $wpdb->get_var(" - SHOW INDEX FROM $table_name WHERE Key_name = 'pb_paywall_user_wallet_address_idx' - "); - if ( $old_idx_check && ! $new_idx_check ) { - // Drop the old index - $wpdb->query("ALTER TABLE $table_name DROP INDEX ecash_address_idx"); - // Add the new one - $wpdb->query("ALTER TABLE $table_name ADD INDEX pb_paywall_user_wallet_address_idx (pb_paywall_user_wallet_address)"); - } } /** diff --git a/includes/class-paybutton-admin.php b/includes/class-paybutton-admin.php index aceceab..9310ccd 100644 --- a/includes/class-paybutton-admin.php +++ b/includes/class-paybutton-admin.php @@ -251,8 +251,7 @@ private function save_settings() { $color_secondary = sanitize_hex_color( $_POST['paybutton_color_secondary'] ); $color_tertiary = sanitize_hex_color( $_POST['paybutton_color_tertiary'] ); $hide_comments = isset( $_POST['paybutton_hide_comments_until_unlocked'] ) ? '1' : '0'; - $paybutton_unlocked_indicator_bg_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_bg_color'] ); - $paybutton_unlocked_indicator_text_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_text_color'] ); + $paybutton_unlocked_indicator_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_color'] ); if ( $unit === 'XEC' && $raw_price < 5.5 ) { $raw_price = 5.5; @@ -277,9 +276,8 @@ private function save_settings() { // New unlocked content indicator option: update_option( 'paybutton_scroll_to_unlocked', isset( $_POST['paybutton_scroll_to_unlocked'] ) ? '1' : '0' ); - // Default to #007bff for background, #ffffff for text - update_option('paybutton_unlocked_indicator_bg_color', $paybutton_unlocked_indicator_bg_color ?: '#007bff'); - update_option('paybutton_unlocked_indicator_text_color', $paybutton_unlocked_indicator_text_color ?: '#ffffff'); + // Default to #000000 for text + update_option('paybutton_unlocked_indicator_color', $paybutton_unlocked_indicator_color ?: '#000000'); // Save the blacklist if ( isset( $_POST['paybutton_blacklist'] ) ) { diff --git a/includes/class-paybutton-public.php b/includes/class-paybutton-public.php index e0ce6ff..4fef79f 100644 --- a/includes/class-paybutton-public.php +++ b/includes/class-paybutton-public.php @@ -42,9 +42,8 @@ public function enqueue_public_assets() { // Enqueue our new paywall styles wp_enqueue_style( 'paywall-styles', PAYBUTTON_PLUGIN_URL . 'assets/css/paywall-styles.css', array(), '1.0' ); - // Read the admin-chosen colors for the unlocked content indicator from options - $indicator_bg_color = get_option('paybutton_unlocked_indicator_bg_color', '#007bff'); - $indicator_text_color = get_option('paybutton_unlocked_indicator_text_color', '#ffffff'); + // Read the admin-chosen color for the unlocked content indicator from options + $pb_indicator_color = get_option('paybutton_unlocked_indicator_color', '#000000'); // Add inline CSS variables. $custom_css = " @@ -55,8 +54,7 @@ public function enqueue_public_assets() { --profile-button-text-color: " . esc_attr( get_option('paybutton_profile_button_text_color', '#000') ) . "; --logout-button-bg-color: " . esc_attr( get_option('paybutton_logout_button_bg_color', '#d9534f') ) . "; --logout-button-text-color: " . esc_attr( get_option('paybutton_logout_button_text_color', '#fff') ) . "; - --pb-unlocked-bg: {$indicator_bg_color}; - --pb-unlocked-text: {$indicator_text_color}; + --pb-unlocked-indicator-color: {$pb_indicator_color}; } "; wp_add_inline_style( 'paybutton-sticky-header', esc_attr( $custom_css ) ); @@ -201,7 +199,7 @@ public function paybutton_paywall_shortcode( $atts, $content = null ) { $indicator = ''; if ( get_option('paybutton_scroll_to_unlocked', '0') === '1' ) { $indicator = '
-

Unlocked Content Below

+ Unlocked Content Below
'; } return $indicator . do_shortcode( $content ); diff --git a/templates/admin/paywall-settings.php b/templates/admin/paywall-settings.php index 7ae4576..82dc051 100644 --- a/templates/admin/paywall-settings.php +++ b/templates/admin/paywall-settings.php @@ -82,30 +82,16 @@ - + - + -

Controls the background color of the indicator.

- - - - - - - - - -

Controls the text color of the indicator.

+

Controls the text and line colors of the unlocked content indicator.