| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDataAccess\Settings { |
| 4 |
|
| 5 |
use WPDataAccess\WPDA; |
| 6 |
|
| 7 |
class WPDA_Settings_Apps extends WPDA_Settings { |
| 8 |
|
| 9 |
/** |
| 10 |
* Add back-end tab content |
| 11 |
* |
| 12 |
* See class documentation for flow explanation. |
| 13 |
* |
| 14 |
* @since 5.5.71 |
| 15 |
*/ |
| 16 |
protected function add_content() { |
| 17 |
|
| 18 |
if ( isset( $_REQUEST['action'] ) ) { |
| 19 |
$action = sanitize_text_field(wp_unslash($_REQUEST['action'])); // input var okay. |
| 20 |
|
| 21 |
// Security check. |
| 22 |
$wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay. |
| 23 |
if ( ! wp_verify_nonce( $wp_nonce, 'wpda-apps-settings' ) ) { |
| 24 |
wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 25 |
} |
| 26 |
|
| 27 |
if ( 'save' === $action ) { |
| 28 |
|
| 29 |
if ( |
| 30 |
isset( $_REQUEST['scroll_offset'] ) && |
| 31 |
'' !== $_REQUEST['scroll_offset'] |
| 32 |
) { |
| 33 |
$scroll_offset = sanitize_text_field( wp_unslash( $_REQUEST['scroll_offset'] ) ); // input var okay. |
| 34 |
update_option( 'wpda_apps_scroll_offset', $scroll_offset ); |
| 35 |
} |
| 36 |
|
| 37 |
} elseif ( 'setdefaults' === $action ) { |
| 38 |
|
| 39 |
WPDA::set_option( WPDA::OPTION_APPS_SCROLL_OFFSET ); |
| 40 |
|
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
$scroll_offset = WPDA::get_option( WPDA::OPTION_APPS_SCROLL_OFFSET ); |
| 45 |
|
| 46 |
?> |
| 47 |
<form id="wpda_settings_backend" method="post" |
| 48 |
action="?page=<?php echo esc_attr( $this->page ); ?>&tab=apps"> |
| 49 |
<table class="wpda-table-settings"> |
| 50 |
<tr> |
| 51 |
<th><?php esc_html_e( 'Scroll Offset', 'wp-data-access' ); ?></th> |
| 52 |
<td> |
| 53 |
<input |
| 54 |
type="number" step="1" min="0" max="999" name="scroll_offset" maxlength="3" |
| 55 |
value="<?php echo esc_attr( $scroll_offset ); ?>"> |
| 56 |
</td> |
| 57 |
</tr> |
| 58 |
</table> |
| 59 |
<div class="wpda-table-settings-button"> |
| 60 |
<input type="hidden" name="action" value="save"/> |
| 61 |
<button type="submit" class="button button-primary"> |
| 62 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 63 |
<?php esc_html_e( 'Save Apps Settings', 'wp-data-access' ); ?> |
| 64 |
</button> |
| 65 |
<a href="javascript:void(0)" |
| 66 |
onclick="if (confirm('<?php esc_html_e( 'Reset to defaults?', 'wp-data-access' ); ?>')) { |
| 67 |
jQuery('input[name="action"]').val('setdefaults'); |
| 68 |
jQuery('#wpda_settings_backend').trigger('submit') |
| 69 |
}" |
| 70 |
class="button"> |
| 71 |
<i class="fas fa-times-circle wpda_icon_on_button"></i> |
| 72 |
<?php esc_html_e( 'Reset Apps Settings To Defaults', 'wp-data-access' ); ?> |
| 73 |
</a> |
| 74 |
</div> |
| 75 |
<?php esc_attr( wp_nonce_field( 'wpda-apps-settings', '_wpnonce', false ) ); ?> |
| 76 |
</form> |
| 77 |
<?php |
| 78 |
|
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
} |