Add setting to override Patreon gate message

This commit is contained in:
Tetrakern 2024-05-01 00:53:51 +02:00
parent a7c002cdb0
commit f9db209800
3 changed files with 23 additions and 11 deletions

View File

@ -526,7 +526,7 @@ function fictioneer_unlock_with_patreon( $form ) {
// Any tiers or amounts set up?
if ( $patreon_post_data['gated'] ) {
$options = [];
$patreon_message = '';
$patreon_message = get_option( 'fictioneer_patreon_unlock_message' );
foreach ( $patreon_post_data['gate_tiers'] as $tier_id ) {
if ( isset( $patreon_tiers[ $tier_id ] ) ) {
@ -549,16 +549,18 @@ function fictioneer_unlock_with_patreon( $form ) {
return $form;
}
if ( count( $options ) < 2 && $patreon_post_data['gate_cents'] > 0 ) {
$patreon_message = sprintf(
_x( '… %s.', 'Unlock with Patreon monetary threshold only wrapper.', 'fictioneer' ),
fictioneer_get_human_readable_list( $options )
);
} else {
$patreon_message = sprintf(
_x( '… as %s.', 'Unlock with Patreon tier options wrapper.', 'fictioneer' ),
fictioneer_get_human_readable_list( $options )
);
if ( empty( $patreon_message ) ) {
if ( count( $options ) < 2 && $patreon_post_data['gate_cents'] > 0 ) {
$patreon_message = sprintf(
_x( '… %s.', 'Unlock with Patreon monetary threshold only wrapper.', 'fictioneer' ),
fictioneer_get_human_readable_list( $options )
);
} else {
$patreon_message = sprintf(
_x( '… as %s.', 'Unlock with Patreon tier options wrapper.', 'fictioneer' ),
fictioneer_get_human_readable_list( $options )
);
}
}
$tooltip = __( 'You can unlock this content by supporting me on Patreon. If you are already a member and not see anything, log out and log in again to refresh your membership information.', 'fictioneer' );

View File

@ -954,6 +954,12 @@ define( 'FICTIONEER_OPTIONS', array(
'sanitize_callback' => 'fictioneer_sanitize_patreon_url',
'label' => __( 'Patreon campaign link', 'fictioneer' )
),
'fictioneer_patreon_unlock_message' => array(
'name' => 'fictioneer_patreon_unlock_message',
'group' => 'fictioneer-settings-connections-group',
'sanitize_callback' => 'wp_kses_post',
'label' => __( 'Patreon gate message override (leave empty for default)', 'fictioneer' )
),
'fictioneer_patreon_global_lock_tiers' => array(
'name' => 'fictioneer_patreon_global_lock_tiers',
'group' => 'fictioneer-settings-connections-group',

View File

@ -114,6 +114,10 @@ $patreon_tiers = is_array( $patreon_tiers ) ? $patreon_tiers : [];
<?php fictioneer_settings_text_input( 'fictioneer_patreon_campaign_link' ); ?>
</div>
<div class="fictioneer-card__row">
<?php fictioneer_settings_text_input( 'fictioneer_patreon_unlock_message' ); ?>
</div>
<hr>
<div class="fictioneer-card__row">