Core.php
3 weeks ago
Debug.php
3 weeks ago
FixDates.php
3 weeks ago
FixPermalink.php
3 weeks ago
FixTitle.php
3 weeks ago
ShamsiDate.php
3 weeks ago
Debug.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPParsidate\App\Core; |
| 4 | |
| 5 | use WPParsidate\Helper\Notice; |
| 6 | use WPParsidate\Settings\Settings; |
| 7 | |
| 8 | class Debug { |
| 9 | private const sectionID = 'debug'; |
| 10 | |
| 11 | public function __construct() { |
| 12 | add_filter( 'wp_parsidate_core_settings_sections', [ $this, 'addSectionSettings' ] ); |
| 13 | add_action( 'wp_parsidate_admin_init', [ $this, 'addNotice' ] ); |
| 14 | } |
| 15 | |
| 16 | public function addNotice( $tab ): void { |
| 17 | if ( Settings::get( 'debug_mode', false ) ) { |
| 18 | Notice::add( 'dashboard', esc_html__( 'Debug mode is enabled!', 'wp-parsidate' ), 'warning' ); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | public function addSectionSettings( array $sections ): array { |
| 23 | $settings = array( |
| 24 | 'start_grid_plugin' => array( |
| 25 | 'title' => esc_html__( 'Debug', 'wp-parsidate' ), |
| 26 | 'type' => 'startGrid', |
| 27 | ), |
| 28 | 'debug_mode' => array( |
| 29 | 'id' => 'debug_mode', |
| 30 | 'title' => esc_html__( 'Debug Mode', 'wp-parsidate' ), |
| 31 | 'type' => 'toggle', |
| 32 | 'default' => false, |
| 33 | 'desc' => esc_html__( 'By enabling this option, the uncompressed version of the JS and CSS files will be loaded.', |
| 34 | 'wp-parsidate' ), |
| 35 | 'sanitize' => 'bool' |
| 36 | ), |
| 37 | 'local_text_domain' => array( |
| 38 | 'id' => 'local_text_domain', |
| 39 | 'title' => esc_html__( 'Load translate file', 'wp-parsidate' ), |
| 40 | 'type' => 'toggle', |
| 41 | 'default' => false, |
| 42 | 'desc' => esc_html__( 'Load translate file from plugin directory.', 'wp-parsidate' ), |
| 43 | 'sanitize' => 'bool' |
| 44 | ), |
| 45 | 'end_grid_plugin' => array( |
| 46 | 'type' => 'endGrid', |
| 47 | ) |
| 48 | ); |
| 49 | |
| 50 | $sections[ self::sectionID ] = array( |
| 51 | 'title' => esc_html__( 'Debug', 'wp-parsidate' ), |
| 52 | 'desc' => esc_html__( 'Debug settings', 'wp-parsidate' ), |
| 53 | 'settings' => $settings |
| 54 | ); |
| 55 | |
| 56 | return $sections; |
| 57 | } |
| 58 | } |
| 59 |