DragDropBuilder
1 month ago
EmailSettings
1 year ago
Membership
1 month ago
AbstractSettingsPage.php
2 years ago
AddNewForm.php
1 year ago
AdminFooter.php
4 years ago
ExtensionsSettingsPage.php
1 year ago
FormList.php
4 months ago
Forms.php
1 year ago
FuseWP.php
3 years ago
GeneralSettings.php
9 months ago
IDUserColumn.php
5 years ago
LicenseUpgrader.php
3 years ago
MailOptin.php
3 years ago
MemberDirectories.php
1 year ago
MembersDirectoryList.php
4 years ago
ToolsSettingsPage.php
4 years ago
index.php
3 years ago
ToolsSettingsPage.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages; |
| 4 | |
| 5 | use ProfilePress\Custom_Settings_Page_Api; |
| 6 | |
| 7 | class ToolsSettingsPage |
| 8 | { |
| 9 | public function __construct() |
| 10 | { |
| 11 | add_action('admin_init', [$this, 'clear_error_log']); |
| 12 | |
| 13 | add_action('ppress_admin_settings_submenu_page_general_tools', [$this, 'admin_page']); |
| 14 | |
| 15 | add_action('ppress_register_menu_page_general_tools', function () { |
| 16 | |
| 17 | add_filter('ppress_general_settings_admin_page_title', function () { |
| 18 | return esc_html__('Tools', 'wp-user-avatar'); |
| 19 | }); |
| 20 | }); |
| 21 | } |
| 22 | |
| 23 | public function clear_error_log() |
| 24 | { |
| 25 | if ( ! isset($_GET['ppress-delete-log']) || ! current_user_can('manage_options') || ! ppress_verify_nonce()) return; |
| 26 | |
| 27 | if ( ! in_array($_GET['ppress-delete-log'], ['social-login', 'debug'])) return; |
| 28 | |
| 29 | ppress_clear_error_log($_GET['ppress-delete-log']); |
| 30 | wp_safe_redirect(esc_url_raw(add_query_arg('section', 'tools', PPRESS_SETTINGS_SETTING_PAGE))); |
| 31 | exit; |
| 32 | } |
| 33 | |
| 34 | public function admin_page() |
| 35 | { |
| 36 | $debug_log_content = ppress_get_error_log(); |
| 37 | $delete_debug_log_url = esc_url_raw(add_query_arg(['ppress-delete-log' => 'debug', '_wpnonce' => ppress_create_nonce()])); |
| 38 | |
| 39 | $settings = [ |
| 40 | 'logs' => apply_filters('ppress_error_log_settings', [ |
| 41 | 'tab_title' => esc_html__('Logs', 'wp-user-avatar'), |
| 42 | 'dashicon' => '', |
| 43 | [ |
| 44 | 'section_title' => esc_html__('Debug Error Log', 'wp-user-avatar'), |
| 45 | 'disable_submit_button' => true, |
| 46 | 'debug_log_content' => [ |
| 47 | 'type' => 'arbitrary', |
| 48 | 'data' => sprintf( |
| 49 | '<textarea class="ppress-error-log-textarea" disabled>%s</textarea>', |
| 50 | $debug_log_content |
| 51 | ), |
| 52 | 'description' => sprintf( |
| 53 | '<div style="margin-top: 10px"><a class="button pp-confirm-delete" href="%s">%s</a></div>', $delete_debug_log_url, |
| 54 | esc_html__('Delete Log', 'wp-user-avatar') |
| 55 | ) |
| 56 | ] |
| 57 | ] |
| 58 | ]) |
| 59 | ]; |
| 60 | |
| 61 | $instance = Custom_Settings_Page_Api::instance($settings, 'ppress_tools', esc_html__('Tools', 'wp-user-avatar')); |
| 62 | $instance->build_sidebar_tab_style(); |
| 63 | } |
| 64 | |
| 65 | public static function get_instance() |
| 66 | { |
| 67 | static $instance = null; |
| 68 | |
| 69 | if (is_null($instance)) { |
| 70 | $instance = new self(); |
| 71 | } |
| 72 | |
| 73 | return $instance; |
| 74 | } |
| 75 | } |