Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions assets/css/paywall-styles.css
Original file line number Diff line number Diff line change
@@ -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 */
}
50 changes: 5 additions & 45 deletions includes/class-paybutton-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}

Expand Down Expand Up @@ -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)");
}
}

/**
Expand Down
8 changes: 3 additions & 5 deletions includes/class-paybutton-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'] ) ) {
Expand Down
10 changes: 4 additions & 6 deletions includes/class-paybutton-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "
Expand All @@ -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 ) );
Expand Down Expand Up @@ -201,7 +199,7 @@ public function paybutton_paywall_shortcode( $atts, $content = null ) {
$indicator = '';
if ( get_option('paybutton_scroll_to_unlocked', '0') === '1' ) {
$indicator = '<div id="unlocked" class="unlocked-indicator">
<p>Unlocked Content Below</p>
<span>Unlocked Content Below</span>
</div>';
}
return $indicator . do_shortcode( $content );
Expand Down
24 changes: 5 additions & 19 deletions templates/admin/paywall-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,16 @@
<tbody id="unlockedIndicatorColors">
<tr>
<th scope="row">
<label for="paybutton_unlocked_indicator_bg_color">Background Color</label>
<label for="paybutton_unlocked_indicator_color">Indicator Color</label>
</th>
<td>
<input type="color" name="paybutton_unlocked_indicator_bg_color" id="paybutton_unlocked_indicator_bg_color"
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_bg_color', '#007bff') ); ?>">
<input type="color" name="paybutton_unlocked_indicator_color" id="paybutton_unlocked_indicator_color"
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_color', '#000000') ); ?>">
<button type="button"
onclick="document.getElementById('paybutton_unlocked_indicator_bg_color').value = '#007bff';">
onclick="document.getElementById('paybutton_unlocked_indicator_color').value = '#000000';">
Reset
</button>
<p class="description">Controls the background color of the indicator.</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="paybutton_unlocked_indicator_text_color">Text Color</label>
</th>
<td>
<input type="color" name="paybutton_unlocked_indicator_text_color" id="paybutton_unlocked_indicator_text_color"
value="<?php echo esc_attr( get_option('paybutton_unlocked_indicator_text_color', '#ffffff') ); ?>">
<button type="button"
onclick="document.getElementById('paybutton_unlocked_indicator_text_color').value = '#ffffff';">
Reset
</button>
<p class="description">Controls the text color of the indicator.</p>
<p class="description">Controls the text and line colors of the unlocked content indicator.</p>
</td>
</tr>
</tbody>
Expand Down