Skip to content

Commit 9bf613b

Browse files
authored
Merge pull request #70 from PayButton/new-style-for-unlocked-content-indicator
New style for the unlocked content indicator and obsolete migration code cleanup
2 parents 21d6e32 + 3b6a4aa commit 9bf613b

5 files changed

Lines changed: 34 additions & 90 deletions

File tree

assets/css/paywall-styles.css

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
.unlocked-indicator {
2-
margin: 20px 0;
3-
display: flex;
4-
align-items: center;
5-
justify-content: center;
6-
text-align: center;
7-
background-color: var(--pb-unlocked-bg, #007bff);
8-
color: var(--pb-unlocked-text, #ffffff);
9-
padding: 8px;
10-
font-family: sans-serif;
11-
font-weight: bold;
12-
font-size: 1.2em;
13-
border-radius: 5px;
14-
box-sizing: border-box;
2+
display: flex;
3+
align-items: center;
4+
margin: 2rem 0;
5+
color: var(--pb-unlocked-indicator-color); /* Line + text color */
6+
font-family: inherit;
7+
font-weight: 800; /* Strong text */
8+
font-size: 1rem;
159
}
1610

17-
.unlocked-indicator p {
18-
margin: 0;
11+
.unlocked-indicator::before,
12+
.unlocked-indicator::after {
13+
content: "";
14+
flex: 1;
15+
height: 1px;
16+
background: currentColor; /* Uses the same color as the text */
17+
}
18+
19+
.unlocked-indicator span {
20+
padding: 0 1rem; /* Space between text and lines */
1921
}

includes/class-paybutton-activator.php

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,12 @@ public static function activate() {
2323
}
2424

2525
private static function migrate_old_option() {
26-
// --- 1. admin wallet address ---
27-
$old_admin_addr = get_option( 'pb_paywall_admin_wallet_address', '' );
28-
$new_admin_addr = get_option( 'paybutton_admin_wallet_address', '' );
29-
if ( ! empty( $old_admin_addr ) && empty( $new_admin_addr ) ) {
30-
update_option( 'paybutton_admin_wallet_address', $old_admin_addr );
31-
delete_option( 'pb_paywall_admin_wallet_address' );
32-
}
33-
34-
// --- 2. unlocked‑indicator colours ---
35-
$bg_old = get_option( 'unlocked_indicator_bg_color', '' );
36-
$bg_new = get_option( 'paybutton_unlocked_indicator_bg_color', '' );
37-
if ( ! empty( $bg_old ) && empty( $bg_new ) ) {
38-
update_option( 'paybutton_unlocked_indicator_bg_color', $bg_old );
39-
delete_option( 'unlocked_indicator_bg_color' );
40-
}
41-
42-
$txt_old = get_option( 'unlocked_indicator_text_color', '' );
43-
$txt_new = get_option( 'paybutton_unlocked_indicator_text_color', '' );
26+
// --- 1. unlocked‑indicator colours ---
27+
$txt_old = get_option( 'paybutton_unlocked_indicator_text_color', '' );
28+
$txt_new = get_option( 'paybutton_unlocked_indicator_color', '' );
4429
if ( ! empty( $txt_old ) && empty( $txt_new ) ) {
45-
update_option( 'paybutton_unlocked_indicator_text_color', $txt_old );
46-
delete_option( 'unlocked_indicator_text_color' );
30+
update_option( 'paybutton_unlocked_indicator_color', $txt_old );
31+
delete_option( 'paybutton_unlocked_indicator_text_color' );
4732
}
4833
}
4934

@@ -74,31 +59,6 @@ public static function create_tables() {
7459
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
7560
dbDelta( $sql );
7661

77-
// Rename old 'ecash_address' column to 'pb_paywall_user_wallet_address', if it still exists
78-
$old_col_check = $wpdb->get_var(
79-
"SHOW COLUMNS FROM $table_name LIKE 'ecash_address'"
80-
);
81-
$new_col_check = $wpdb->get_var(
82-
"SHOW COLUMNS FROM $table_name LIKE 'pb_paywall_user_wallet_address'"
83-
);
84-
85-
if ( $old_col_check && ! $new_col_check ) {
86-
$wpdb->query("ALTER TABLE $table_name CHANGE ecash_address pb_paywall_user_wallet_address VARCHAR(255) NOT NULL");
87-
}
88-
89-
// Rename old index 'ecash_address_idx' to 'pb_paywall_user_wallet_address_idx'
90-
$old_idx_check = $wpdb->get_var("
91-
SHOW INDEX FROM $table_name WHERE Key_name = 'ecash_address_idx'
92-
");
93-
$new_idx_check = $wpdb->get_var("
94-
SHOW INDEX FROM $table_name WHERE Key_name = 'pb_paywall_user_wallet_address_idx'
95-
");
96-
if ( $old_idx_check && ! $new_idx_check ) {
97-
// Drop the old index
98-
$wpdb->query("ALTER TABLE $table_name DROP INDEX ecash_address_idx");
99-
// Add the new one
100-
$wpdb->query("ALTER TABLE $table_name ADD INDEX pb_paywall_user_wallet_address_idx (pb_paywall_user_wallet_address)");
101-
}
10262
}
10363

10464
/**

includes/class-paybutton-admin.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ private function save_settings() {
251251
$color_secondary = sanitize_hex_color( $_POST['paybutton_color_secondary'] );
252252
$color_tertiary = sanitize_hex_color( $_POST['paybutton_color_tertiary'] );
253253
$hide_comments = isset( $_POST['paybutton_hide_comments_until_unlocked'] ) ? '1' : '0';
254-
$paybutton_unlocked_indicator_bg_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_bg_color'] );
255-
$paybutton_unlocked_indicator_text_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_text_color'] );
254+
$paybutton_unlocked_indicator_color = sanitize_hex_color( $_POST['paybutton_unlocked_indicator_color'] );
256255

257256
if ( $unit === 'XEC' && $raw_price < 5.5 ) {
258257
$raw_price = 5.5;
@@ -277,9 +276,8 @@ private function save_settings() {
277276

278277
// New unlocked content indicator option:
279278
update_option( 'paybutton_scroll_to_unlocked', isset( $_POST['paybutton_scroll_to_unlocked'] ) ? '1' : '0' );
280-
// Default to #007bff for background, #ffffff for text
281-
update_option('paybutton_unlocked_indicator_bg_color', $paybutton_unlocked_indicator_bg_color ?: '#007bff');
282-
update_option('paybutton_unlocked_indicator_text_color', $paybutton_unlocked_indicator_text_color ?: '#ffffff');
279+
// Default to #000000 for text
280+
update_option('paybutton_unlocked_indicator_color', $paybutton_unlocked_indicator_color ?: '#000000');
283281

284282
// Save the blacklist
285283
if ( isset( $_POST['paybutton_blacklist'] ) ) {

includes/class-paybutton-public.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ public function enqueue_public_assets() {
4242
// Enqueue our new paywall styles
4343
wp_enqueue_style( 'paywall-styles', PAYBUTTON_PLUGIN_URL . 'assets/css/paywall-styles.css', array(), '1.0' );
4444

45-
// Read the admin-chosen colors for the unlocked content indicator from options
46-
$indicator_bg_color = get_option('paybutton_unlocked_indicator_bg_color', '#007bff');
47-
$indicator_text_color = get_option('paybutton_unlocked_indicator_text_color', '#ffffff');
45+
// Read the admin-chosen color for the unlocked content indicator from options
46+
$pb_indicator_color = get_option('paybutton_unlocked_indicator_color', '#000000');
4847

4948
// Add inline CSS variables.
5049
$custom_css = "
@@ -55,8 +54,7 @@ public function enqueue_public_assets() {
5554
--profile-button-text-color: " . esc_attr( get_option('paybutton_profile_button_text_color', '#000') ) . ";
5655
--logout-button-bg-color: " . esc_attr( get_option('paybutton_logout_button_bg_color', '#d9534f') ) . ";
5756
--logout-button-text-color: " . esc_attr( get_option('paybutton_logout_button_text_color', '#fff') ) . ";
58-
--pb-unlocked-bg: {$indicator_bg_color};
59-
--pb-unlocked-text: {$indicator_text_color};
57+
--pb-unlocked-indicator-color: {$pb_indicator_color};
6058
}
6159
";
6260
wp_add_inline_style( 'paybutton-sticky-header', esc_attr( $custom_css ) );
@@ -201,7 +199,7 @@ public function paybutton_paywall_shortcode( $atts, $content = null ) {
201199
$indicator = '';
202200
if ( get_option('paybutton_scroll_to_unlocked', '0') === '1' ) {
203201
$indicator = '<div id="unlocked" class="unlocked-indicator">
204-
<p>Unlocked Content Below</p>
202+
<span>Unlocked Content Below</span>
205203
</div>';
206204
}
207205
return $indicator . do_shortcode( $content );

templates/admin/paywall-settings.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,16 @@
8282
<tbody id="unlockedIndicatorColors">
8383
<tr>
8484
<th scope="row">
85-
<label for="paybutton_unlocked_indicator_bg_color">Background Color</label>
85+
<label for="paybutton_unlocked_indicator_color">Indicator Color</label>
8686
</th>
8787
<td>
88-
<input type="color" name="paybutton_unlocked_indicator_bg_color" id="paybutton_unlocked_indicator_bg_color"
89-
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_bg_color', '#007bff') ); ?>">
88+
<input type="color" name="paybutton_unlocked_indicator_color" id="paybutton_unlocked_indicator_color"
89+
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_color', '#000000') ); ?>">
9090
<button type="button"
91-
onclick="document.getElementById('paybutton_unlocked_indicator_bg_color').value = '#007bff';">
91+
onclick="document.getElementById('paybutton_unlocked_indicator_color').value = '#000000';">
9292
Reset
9393
</button>
94-
<p class="description">Controls the background color of the indicator.</p>
95-
</td>
96-
</tr>
97-
<tr>
98-
<th scope="row">
99-
<label for="paybutton_unlocked_indicator_text_color">Text Color</label>
100-
</th>
101-
<td>
102-
<input type="color" name="paybutton_unlocked_indicator_text_color" id="paybutton_unlocked_indicator_text_color"
103-
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_text_color', '#ffffff') ); ?>">
104-
<button type="button"
105-
onclick="document.getElementById('paybutton_unlocked_indicator_text_color').value = '#ffffff';">
106-
Reset
107-
</button>
108-
<p class="description">Controls the text color of the indicator.</p>
94+
<p class="description">Controls the text and line colors of the unlocked content indicator.</p>
10995
</td>
11096
</tr>
11197
</tbody>

0 commit comments

Comments
 (0)