Skip to content

Commit e9f7310

Browse files
committed
add namespace to all files outside of src
Signed-off-by: Giuseppe Foti <foti.giuseppe@gmail.com>
1 parent 62d74fc commit e9f7310

30 files changed

+130
-88
lines changed

admin/class-no-unsafe-inline-admin.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin;
13+
1214
use NUNIL\Nunil_Lib_Db as DB;
1315
use NUNIL\Nunil_Lib_Utils as Utils;
1416
use NUNIL\Nunil_Lib_Log as Log;
@@ -116,7 +118,7 @@ public function enqueue_styles(): void {
116118
* @return void
117119
*/
118120
public function enqueue_scripts(): void {
119-
$plugin = new No_Unsafe_Inline();
121+
$plugin = new \NUNIL\includes\No_Unsafe_Inline();
120122
$plugin->enqueue_common_scripts();
121123
$suffix = wp_scripts_get_suffix();
122124

@@ -216,9 +218,9 @@ public function update_muplugin( $new_ver, $old_ver ): void {
216218
if ( $old_ver === $new_ver ) {
217219
return;
218220
}
219-
if ( NUNIL\Nunil_Manage_Muplugin::is_nunil_muplugin_installed() ) {
220-
NUNIL\Nunil_Manage_Muplugin::toggle_nunil_muplugin_installation();
221-
NUNIL\Nunil_Manage_Muplugin::toggle_nunil_muplugin_installation();
221+
if ( \NUNIL\Nunil_Manage_Muplugin::is_nunil_muplugin_installed() ) {
222+
\NUNIL\Nunil_Manage_Muplugin::toggle_nunil_muplugin_installation();
223+
\NUNIL\Nunil_Manage_Muplugin::toggle_nunil_muplugin_installation();
222224
}
223225
}
224226

@@ -411,7 +413,7 @@ public function nunil_set_screen(): void {
411413
);
412414
add_screen_option( 'per_page', $args );
413415
require_once plugin_dir_path( __FILE__ ) . 'partials/class-no-unsafe-inline-external-list.php';
414-
$this->show_table = new No_Unsafe_Inline_External_List();
416+
$this->show_table = new \NUNIL\admin\partials\No_Unsafe_Inline_External_List();
415417
break;
416418
case 'inline':
417419
$help_tabs->set_help_tabs( 'inline' );
@@ -422,7 +424,7 @@ public function nunil_set_screen(): void {
422424
);
423425
add_screen_option( 'per_page', $args );
424426
require_once plugin_dir_path( __FILE__ ) . 'partials/class-no-unsafe-inline-inline-list.php';
425-
$this->show_table = new No_Unsafe_Inline_Inline_List();
427+
$this->show_table = new \NUNIL\admin\partials\No_Unsafe_Inline_Inline_List();
426428
break;
427429
case 'events':
428430
$help_tabs->set_help_tabs( 'events' );
@@ -433,7 +435,7 @@ public function nunil_set_screen(): void {
433435
);
434436
add_screen_option( 'per_page', $args );
435437
require_once plugin_dir_path( __FILE__ ) . 'partials/class-no-unsafe-inline-events-list.php';
436-
$this->show_table = new No_Unsafe_Inline_Events_List();
438+
$this->show_table = new \NUNIL\admin\partials\No_Unsafe_Inline_Events_List();
437439
break;
438440
default:
439441
$help_tabs->set_help_tabs( 'nunil-tools' );
@@ -2225,7 +2227,7 @@ public function trigger_clustering(): void {
22252227
exit( esc_html__( 'Nope! Security check failed!', 'no-unsafe-inline' ) );
22262228
}
22272229

2228-
$obj = new NUNIL\Nunil_Clustering();
2230+
$obj = new \NUNIL\Nunil_Clustering();
22292231

22302232
$result = $obj->cluster_by_dbscan();
22312233

@@ -2528,7 +2530,7 @@ public function test_classifier(): void {
25282530
) ) {
25292531
exit( esc_html__( 'Nope! Security check failed!', 'no-unsafe-inline' ) );
25302532
}
2531-
$test = new NUNIL\Nunil_Classification();
2533+
$test = new \NUNIL\Nunil_Classification();
25322534

25332535
$result_string = $test->test_cases();
25342536
$result = array(

admin/partials/class-no-unsafe-inline-admin-logs-table.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* @subpackage No_unsafe-inline/admin
1111
*/
1212

13+
namespace NUNIL\admin\partials;
14+
1315
if ( ! class_exists( 'WP_List_Table' ) ) {
1416
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
1517
}
@@ -22,7 +24,7 @@
2224
* @package No_unsafe-inline
2325
* @subpackage No_unsafe-inline/admin
2426
*/
25-
class No_Unsafe_Inline_Admin_Logs_Table extends WP_List_Table {
27+
class No_Unsafe_Inline_Admin_Logs_Table extends \WP_List_Table {
2628
private const MAX_LENGTH = 1500;
2729

2830
/** Class constructor */
@@ -100,9 +102,9 @@ public function prepare_items() {
100102
$order = ( isset( $_REQUEST['order'] ) && in_array( $_REQUEST['order'], array( 'asc', 'desc' ) ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) : 'desc';
101103

102104
try {
103-
$logs = NUNIL\Nunil_Lib_Db::get_logs( $paged * $per_page, $per_page, $orderby, $order, ARRAY_A );
105+
$logs = \NUNIL\Nunil_Lib_Db::get_logs( $paged * $per_page, $per_page, $orderby, $order, ARRAY_A );
104106
$this->items = (array) $logs;
105-
} catch ( NUNIL\Nunil_Exception $ex ) {
107+
} catch ( \NUNIL\Nunil_Exception $ex ) {
106108
$ex->logexception();
107109
}
108110

admin/partials/class-no-unsafe-inline-base-rule-list.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin\partials;
13+
1214
defined( 'ABSPATH' ) || die( 'you do not have acces to this page!' );
1315

1416
if ( ! class_exists( 'WP_List_Table' ) ) {
@@ -23,7 +25,7 @@
2325
* @package No_unsafe-inline
2426
* @subpackage No_unsafe-inline/admin
2527
*/
26-
class No_Unsafe_Inline_Base_Rule_List extends WP_List_Table {
28+
class No_Unsafe_Inline_Base_Rule_List extends \WP_List_Table {
2729

2830
/** Class constructor */
2931
public function __construct() {
@@ -44,7 +46,7 @@ public function __construct() {
4446
* @return array<array{ID: int, directive: string, source: string}>>
4547
*/
4648
public static function get_sources() {
47-
$basesrc = new NUNIL\Nunil_Base_Src_Rules();
49+
$basesrc = new \NUNIL\Nunil_Base_Src_Rules();
4850

4951
$result = $basesrc->get_db_entries();
5052
return $result;
@@ -125,7 +127,7 @@ public function prepare_items() {
125127
$this->_column_headers = array( $columns, $hidden, $sortable );
126128
try {
127129
$this->items = self::get_sources();
128-
} catch ( NUNIL\Nunil_Exception $ex ) {
130+
} catch ( \NUNIL\Nunil_Exception $ex ) {
129131
$ex->logexception();
130132
}
131133
}

admin/partials/class-no-unsafe-inline-events-list.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin\partials;
13+
1214
use Highlight\Highlighter;
1315
use NUNIL\Nunil_Lib_Db as DB;
1416
use NUNIL\Nunil_Lib_Log as Log;
@@ -30,7 +32,7 @@
3032
* @package No_unsafe-inline
3133
* @subpackage No_unsafe-inline/admin
3234
*/
33-
class No_Unsafe_Inline_Events_List extends WP_List_Table {
35+
class No_Unsafe_Inline_Events_List extends \WP_List_Table {
3436

3537
/** Class constructor */
3638
public function __construct() {

admin/partials/class-no-unsafe-inline-external-list.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin\partials;
13+
1214
use NUNIL\Nunil_Lib_Db as DB;
1315
use NUNIL\Nunil_Lib_Log as Log;
1416
use NUNIL\Nunil_Lib_Utils as Utils;
@@ -32,7 +34,7 @@
3234
* @package No_unsafe-inline
3335
* @subpackage No_unsafe-inline/admin
3436
*/
35-
class No_Unsafe_Inline_External_List extends WP_List_Table {
37+
class No_Unsafe_Inline_External_List extends \WP_List_Table {
3638

3739
/** Class constructor */
3840
public function __construct() {

admin/partials/class-no-unsafe-inline-inline-list.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin\partials;
13+
1214
use Highlight\Highlighter;
1315
use NUNIL\Nunil_Lib_Db as DB;
1416
use NUNIL\Nunil_Lib_Log as Log;
@@ -30,7 +32,7 @@
3032
* @package No_unsafe-inline
3133
* @subpackage No_unsafe-inline/admin
3234
*/
33-
class No_Unsafe_Inline_Inline_List extends WP_List_Table {
35+
class No_Unsafe_Inline_Inline_List extends \WP_List_Table {
3436

3537
/** Class constructor */
3638
public function __construct() {

admin/partials/no-unsafe-inline-admin-options.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
* @package No_unsafe-inline
99
* @subpackage No_unsafe-inline/admin
1010
*
11-
* @var \No_Unsafe_Inline_Admin $this
11+
* @var \NUNIL\admin\No_Unsafe_Inline_Admin $this
1212
*/
1313

14+
namespace NUNIL\admin\partials;
15+
1416
?>
1517
<form method="post" action="options.php" class="no-unsafe-inline-settings-form">
1618
<?php

admin/partials/no-unsafe-inline-base-rule.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
* @package No_unsafe-inline
99
* @subpackage No_unsafe-inline/admin
1010
*
11-
* @var \No_Unsafe_Inline_Admin $this
11+
* @var \NUNIL\admin\No_Unsafe_Inline_Admin $this
1212
*/
1313

14+
namespace NUNIL\admin\partials;
15+
1416
?>
1517
<form method="post" action="options.php" class="no-unsafe-inline-base-rule-form">
1618
<?php

admin/partials/no-unsafe-inline-logs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* @var string|false $enabled_logs
1212
*/
1313

14+
namespace NUNIL\admin\partials;
15+
1416
?>
1517
<div class="wrap" id="nunil-logs-list">
1618
<?php

admin/partials/no-unsafe-inline-tools.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/admin
1010
*/
1111

12+
namespace NUNIL\admin\partials;
13+
1214
?>
1315
<form method="post" action="options.php" class="no-unsafe-inline-tools-form">
1416
<?php
@@ -146,23 +148,23 @@
146148
'id' => true,
147149
),
148150
);
149-
echo wp_kses( No_Unsafe_Inline_Admin::output_summary_tables(), $nunil_allowed_html );
151+
echo wp_kses( \NUNIL\admin\No_Unsafe_Inline_Admin::output_summary_tables(), $nunil_allowed_html );
150152
?>
151153
</div>
152154
</div>
153155
<div id="nunil-db-sum-tabs-2">
154156
<div id="nunil_summary_external_table_container" class="nunil_summary_external_table_container">
155-
<?php echo wp_kses( No_Unsafe_Inline_Admin::output_summary_external_table(), $nunil_allowed_html ); ?>
157+
<?php echo wp_kses( \NUNIL\admin\No_Unsafe_Inline_Admin::output_summary_external_table(), $nunil_allowed_html ); ?>
156158
</div>
157159
</div>
158160
<div id="nunil-db-sum-tabs-3">
159161
<div id="nunil_summary_inline_table_container" class="nunil_summary_inline_table_container">
160-
<?php echo wp_kses( No_Unsafe_Inline_Admin::output_summary_inline_table(), $nunil_allowed_html ); ?>
162+
<?php echo wp_kses( \NUNIL\admin\No_Unsafe_Inline_Admin::output_summary_inline_table(), $nunil_allowed_html ); ?>
161163
</div>
162164
</div>
163165
<div id="nunil-db-sum-tabs-4">
164166
<div id="nunil_summary_eventhandlers_table_container" class="nunil_summary_eventhandlers_table_container">
165-
<?php echo wp_kses( No_Unsafe_Inline_Admin::output_summary_eventhandlers_table(), $nunil_allowed_html ); ?>
167+
<?php echo wp_kses( \NUNIL\admin\No_Unsafe_Inline_Admin::output_summary_eventhandlers_table(), $nunil_allowed_html ); ?>
166168
</div>
167169
</div>
168170
<div id="nunil-db-sum-tabs-5" class="nunil-db-sum-tabs-5">

admin/partials/no-unsafe-inline-whitelist-tables.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@
88
* @package No_unsafe-inline
99
* @subpackage No_unsafe-inline/admin
1010
*
11-
* @var \No_Unsafe_Inline_Admin $this
11+
* @var \NUNIL\admin\No_Unsafe_Inline_Admin $this
1212
*/
1313

14+
namespace NUNIL\admin\partials;
15+
16+
if ( ! defined( 'ABSPATH' ) ) {
17+
exit;
18+
}
19+
20+
use NUNIL\Nunil_Lib_Utils as Utils;
21+
1422
if ( isset( $_GET['tab'] ) ) {
1523
$nunil_tab = strtolower( sanitize_text_field( wp_unslash( $_GET['tab'] ) ) );
1624
$nunil_list_tabs = array(

includes/class-no-unsafe-inline-activator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/includes
1010
*/
1111

12+
namespace NUNIL\includes;
13+
1214
use NUNIL\Nunil_Manage_Muplugin;
1315
use NUNIL\Nunil_Lib_Log as Log;
1416
use NUNIL\Nunil_Lib_Db as DB;
@@ -151,7 +153,7 @@ public static function single_activate( $network_wide = false ): void {
151153
} catch ( Nunil_Exception $ex ) {
152154
$ex->logexception();
153155
require_once __DIR__ . '/class-no-unsafe-inline-deactivator.php';
154-
\No_Unsafe_Inline_Deactivator::deactivate( $network_wide );
156+
\NUNIL\includes\No_Unsafe_Inline_Deactivator::deactivate( $network_wide );
155157
}
156158
}
157159
Log::info( 'Activated plugin.' );
@@ -267,7 +269,7 @@ private static function set_default_options(): void {
267269
* Running setup whenever a new blog is created
268270
*
269271
* @since 1.0.0
270-
* @param WP_Site $params New site object.
272+
* @param \WP_Site $params New site object.
271273
* @return void
272274
*/
273275
public static function add_blog( $params ) {

includes/class-no-unsafe-inline-deactivator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/includes
1010
*/
1111

12+
namespace NUNIL\includes;
13+
1214
use NUNIL\Nunil_Manage_Muplugin;
1315
use NUNIL\Nunil_Lib_Log as Log;
1416
use NUNIL\Nunil_Lib_Db as DB;
@@ -111,7 +113,7 @@ public static function deactivate( $network_wide ) {
111113
* Run when a blog is removed from network
112114
*
113115
* @since 1.0.0
114-
* @param WP_Site $params Site object.
116+
* @param \WP_Site $params Site object.
115117
* @return void
116118
*/
117119
public static function remove_blog( $params ) {

includes/class-no-unsafe-inline-i18n.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* @subpackage No_unsafe-inline/includes
1313
*/
1414

15+
namespace NUNIL\includes;
16+
1517
/**
1618
* Define the internationalization functionality.
1719
*

includes/class-no-unsafe-inline-loader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @subpackage No_unsafe-inline/includes
1010
*/
1111

12+
namespace NUNIL\includes;
13+
1214
/**
1315
* Register all actions and filters for the plugin.
1416
*

includes/class-no-unsafe-inline.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* @subpackage No_unsafe-inline/includes
1313
*/
1414

15+
namespace NUNIL\includes;
16+
1517
use NUNIL\Nunil_Lib_Utils as Utils;
1618
/**
1719
* The core plugin class.
@@ -201,7 +203,7 @@ private function set_locale() {
201203
* @return void
202204
*/
203205
private function define_admin_hooks() {
204-
$plugin_admin = new No_Unsafe_Inline_Admin( $this->get_plugin_name(), $this->get_version(), $this->get_managed_directives() );
206+
$plugin_admin = new \NUNIL\admin\No_Unsafe_Inline_Admin( $this->get_plugin_name(), $this->get_version(), $this->get_managed_directives() );
205207

206208
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
207209
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 0 );
@@ -244,7 +246,7 @@ private function define_admin_hooks() {
244246
* @return void
245247
*/
246248
private function define_public_hooks() {
247-
$plugin_public = new No_Unsafe_Inline_Public( $this->get_plugin_name(), $this->get_version() );
249+
$plugin_public = new \NUNIL\public\No_Unsafe_Inline_Public( $this->get_plugin_name(), $this->get_version() );
248250

249251
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts', 0 );
250252

0 commit comments

Comments
 (0)