Skip to content

Commit 9ee3005

Browse files
xxsimoxxxxsimoxx
andauthored
Do not load admin code on frontend (#41)
In #40 an undefined variable warning was noticed. There is no need to load `PluginInstall` and `ThemeInstall` classes on frontend. The `Helper` trait was left in place as in a future it could contain helpful code for other classes. * Do not load admin code when on frontend * Fix workflows --------- Co-authored-by: xxsimoxx <simone@gieffeedizioni.it>
1 parent 1ef0a32 commit 9ee3005

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.github/workflows/cpcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
sed -i '/MY_DOMAIN/ s//classicpress-directory-integration/' phpcs.xml
2222
mv phpcs.xml phpcs.xml.dist
2323
- name: CPCS checks
24-
uses: 10up/wpcs-action@stable
24+
uses: 10up/wpcs-action@v1.7.0
2525
with:
2626
use_local_config: 'true'
2727
enable_warnings: 'true'

.github/workflows/wpcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: WPCS checks
16-
uses: 10up/wpcs-action@stable
16+
uses: 10up/wpcs-action@v1.7.0
1717
with:
1818
use_local_config: 'true'
1919
enable_warnings: 'true'

classicpress-directory-integration.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,10 @@ function error_is_wp() {
6161
require_once 'classes/class-plugin-update.php';
6262
$plugin_update = new PluginUpdate();
6363

64-
// Load Plugin Install functionality class.
65-
require_once 'classes/class-plugin-install.php';
66-
$plugin_install = new PluginInstall();
67-
6864
// Load Theme Update functionality class.
6965
require_once 'classes/class-theme-update.php';
7066
$theme_update = new ThemeUpdate();
7167

72-
// Load Theme Install functionality class.
73-
require_once 'classes/class-theme-install.php';
74-
$theme_install = new ThemeInstall();
75-
7668
// Register text domain
7769
function register_text_domain() {
7870
load_plugin_textdomain( 'classicpress-directory-integration', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
@@ -84,3 +76,15 @@ function register_text_domain() {
8476
if ( defined( 'WP_CLI' ) && WP_CLI ) {
8577
\WP_CLI::add_command( 'cpdi', '\ClassicPress\Directory\CPDICLI' );
8678
}
79+
80+
if ( ! is_admin() ) {
81+
return;
82+
}
83+
84+
// Load Plugin Install functionality class.
85+
require_once 'classes/class-plugin-install.php';
86+
$plugin_install = new PluginInstall();
87+
88+
// Load Theme Install functionality class.
89+
require_once 'classes/class-theme-install.php';
90+
$theme_install = new ThemeInstall();

0 commit comments

Comments
 (0)