Skip to content

Commit

Permalink
Added support for configuring error text resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mangrose committed Dec 19, 2023
1 parent 77b027a commit c8d2ea4
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 98 deletions.
27 changes: 26 additions & 1 deletion admin/tulo-payway-paywall-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
if(isset($_POST['action']) && $_POST['action'] == 'update')
{
update_option('tulo_paywall_enabled', isset($_POST["tulo_paywall_enabled"]) ? "on" : "" );
update_option('tulo_paywall_error_header', $_POST["tulo_paywall_error_header"]);
update_option('tulo_paywall_error_message', $_POST["tulo_paywall_error_message"]);
//update_option('tulo_paywall_error_function', $_POST["tulo_paywall_error_function"]);
update_option('tulo_paywall_template_login_url', $_POST["tulo_paywall_template_login_url"]);
update_option('tulo_paywall_template_shop_url', $_POST["tulo_paywall_template_shop_url"]);
update_option('tulo_paywall_client_id', $_POST["tulo_paywall_client_id"]);
Expand Down Expand Up @@ -141,12 +144,18 @@ function tulo_server_render_custom_variables()
</td>
</tr>
<tr>
<td>
<td colspan="2">
<textarea name="tulo_variables_val">{{model.Variables}}</textarea>
<a class="tulo_add_variable" ng-click="addVariable()"><?php _e('Add variable', 'tulo'); ?></a>

</td>
</tr>
<tr>
<td colspan="2">
<p><?php echo __('Tulo Paywall custom variable.', 'tulo');?></p>
</td>
</tr>


</table>

Expand Down Expand Up @@ -206,6 +215,21 @@ function tulo_server_render_custom_variables()

</table>

<hr/>
<h2><?php esc_html_e( 'Paywall error handling settings', 'tulo'); ?></h1>
<table class="form-table">

<?php
tulo_server_render_text_option_setting(__("Tulo Paywall Error header", "tulo"), "tulo_paywall_error_header", __("Error header text shown when the paywall cannot be loaded", "tulo"));
tulo_server_render_text_option_setting(__("Tulo Paywall Error description", "tulo"), "tulo_paywall_error_message", __("Error description text shown when the paywall cannot be loaded", "tulo"));
//tulo_server_render_text_option_setting(__("Tulo Paywall Error function", "tulo"), "tulo_paywall_error_function", __("External function called when the paywall cannot be loaded", "tulo"));
?>
<tr>
<td colspan="2">
<p><?php echo __('Tulo Paywall error handling.', 'tulo');?></p>
</td>
</tr>
</table>
<hr/>
<h2><?php esc_html_e( 'Paywall other settings', 'tulo'); ?></h1>
<table class="form-table">
Expand All @@ -223,6 +247,7 @@ function tulo_server_render_custom_variables()
<?php
tulo_server_render_custom_variables();
?>

</table>


Expand Down
19 changes: 19 additions & 0 deletions includes/class-tulo-paywall.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ public function get_shop_url() {
return get_option("tulo_paywall_template_shop_url");
}

public function get_error_header() {
$header = __('Error loading paywall', 'tulo');
$custom_header = get_option("tulo_paywall_error_header");
if ($custom_header != "") {
$header = $custom_header;
}
return $header;
}

public function get_error_message() {
$message = __('The paywall could not be loaded due to an unexpected error. Please try again later.', 'tulo');
$custom_message = get_option("tulo_paywall_error_message");
if ($custom_message != "") {
$message = $custom_message;
}
return $message;
}


public function get_paywall_css() {
$version = Tulo_Paywall_Common::PAYWALL_VERSION;
if ($version == '1.0') {
Expand Down
Binary file modified lang/tulo-en_US.mo
Binary file not shown.
Loading

0 comments on commit c8d2ea4

Please sign in to comment.