Skip to content

Development #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,5 +7,6 @@ dist
logs
node_modules
vendor
vendor-prefixed
assets/admin/js/build/
assets/public/js/build/
51 changes: 47 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -2,12 +2,22 @@
"scripts": {
"lint" : "mkdir -p logs; vendor/bin/phpcs -s > ./logs/log.txt",
"format": "vendor/bin/phpcbf -p",
"dist": "sh bin/dist.sh"
"dist": "sh bin/dist.sh",
"namespace-dependencies": [
"sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'",
"php bin/strauss.phar",
"composer dump-autoload"
],
"post-install-cmd": [
"@namespace-dependencies"
],
"post-update-cmd": [
"@namespace-dependencies"
]
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "0.7.1",
"wp-coding-standards/wpcs": "2.3",
"suin/phpcs-psr4-sniff": "^3.0"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"wp-coding-standards/wpcs": "dev-develop"
},
"autoload":{
"psr-4": {
@@ -18,5 +28,38 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"strauss": {
"target_directory": "vendor-prefixed",
"namespace_prefix": "Root\\",
"classmap_prefix": "Root_",
"constant_prefix": "PREFIX_",
"packages": [
],
"update_call_sites": false,
"override_autoload": {
},
"exclude_from_copy": {
"packages": [
],
"namespaces": [
],
"file_patterns": [
]
},
"exclude_from_prefix": {
"packages": [
],
"namespaces": [
],
"file_patterns": [
]
},
"namespace_replacement_patterns" : {
},
"delete_vendor_packages": true,
"delete_vendor_files": false
}
}
}
356 changes: 208 additions & 148 deletions composer.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion includes/Bootstrap/AdminEnqueues.php
Original file line number Diff line number Diff line change
@@ -107,5 +107,4 @@ public function getScriptsAsModules( string $tag, string $handle, string $src )

return Functions::makeScriptsModules( $tag, $handle, $src );
}

}
1 change: 0 additions & 1 deletion includes/Bootstrap/FrontendEnqueues.php
Original file line number Diff line number Diff line change
@@ -115,5 +115,4 @@ public function getScriptsAsModules( string $tag, string $handle, string $src )

return Functions::makeScriptsModules( $tag, $handle, $src );
}

}
1 change: 0 additions & 1 deletion includes/Bootstrap/I18n.php
Original file line number Diff line number Diff line change
@@ -47,5 +47,4 @@ public function loadPluginTextdomain() {
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}

}
1 change: 0 additions & 1 deletion includes/Bootstrap/Loader.php
Original file line number Diff line number Diff line change
@@ -124,5 +124,4 @@ public function run() {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
}

}
2 changes: 1 addition & 1 deletion includes/Bootstrap/Main.php
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ private function defineAdminHooks() {
$this->loader->add_action( 'admin_notices', $notices_loader, 'loadNotices' );
// Notices Ajax dismiss method (uncomment if making use of notice class).
$this->loader->add_action( 'wp_ajax_prefix_dismissNotice', $notice, 'dismissNotice' );
$this->loader->add_action( 'wp_ajax_suffix_dismissNotice', $notice, 'dismissNotice' );
*/
}

1 change: 0 additions & 1 deletion includes/Bootstrap/SetupCron.php
Original file line number Diff line number Diff line change
@@ -38,5 +38,4 @@ public function setCronTasks() {
}
*/
}

}
Empty file added includes/Compatibility/.gitkeep
Empty file.
3 changes: 1 addition & 2 deletions includes/Notices/Admin.php
Original file line number Diff line number Diff line change
@@ -43,10 +43,9 @@ public function siteNotHttps() {
<div class="notice notice-error is-dismissible">
<?php
/* translators: 1: Opening <p> HTML element 2: Opening <strong> HTML element 3: Closing <strong> HTML element 4: Closing <p> HTML element */
echo sprintf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s HTTPS not detected on this website. The plugin will not work. Please enable HTTPS on this website.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
printf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s HTTPS not detected on this website. The plugin will not work. Please enable HTTPS on this website.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
?>
</div>
<?php
}

}
1 change: 0 additions & 1 deletion includes/Notices/Notice.php
Original file line number Diff line number Diff line change
@@ -156,5 +156,4 @@ public function dismissNotice() {
wp_safe_redirect( sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ?? get_admin_url() ) ) );
exit;
}

}
2 changes: 0 additions & 2 deletions includes/Notices/ReviewNotices.php
Original file line number Diff line number Diff line change
@@ -59,6 +59,4 @@ public function createReviewPluginNotice() {

$this->createNoticeMarkup( 'leave_review_notice_1', $content );
}


}
4 changes: 1 addition & 3 deletions includes/RootActivator.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* @package Root
*/

namespace Root\Notices;
namespace Root;

if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -53,7 +53,5 @@ private static function prefix_add_default_settings() {
if ( empty( $installed_at ) ) {
add_option( 'prefix_installed_at_version', PREFIX_VERSION, '', false );
}

}

}
3 changes: 1 addition & 2 deletions includes/RootDeactivator.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* @package Root
*/

namespace Root\Notices;
namespace Root;

if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -32,5 +32,4 @@ class RootDeactivator {
*/
public static function deactivate() {
}

}
6 changes: 3 additions & 3 deletions includes/Traits/PluginInfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Trait which holds information about the PREFIX plugin.
* Trait which holds information about the plugin.
*
* Author: plugin_author_name
*
@@ -23,7 +23,7 @@
trait PluginInfo {

/**
* Returns the number of days since PREFIX has been installed.
* Returns the number of days since the plugin has been installed.
*
* If the prefix_first_install_date option is not found. We return 2 days.
*
@@ -50,7 +50,7 @@ private function getDaysSinceInstalled() {
}

/**
* Get the version PREFIX was installed at.
* Get the version the plugin was installed at.
*
* @return mixed
*/
2,568 changes: 2,563 additions & 5 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "Root",
"name": "my_plugin_shortname",
"version": "1.0.0",
"description": "",
"dependencies": {},
"devDependencies": {
"husky": "^7.0.0",
"parcel": "^2.0.0-rc.0",
"prettier": "^2.5.1",
"husky": "^7.0.0"
"prettier": "^2.5.1"
},
"scripts": {
"dev": "parcel watch --no-hmr",
9 changes: 2 additions & 7 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Root">
<description>PREFIX rules for PHP_CodeSnifferr</description>
<description>Plugin rules for PHP_CodeSnifferr</description>

<file>.</file>
<arg name="basepath" value="."/>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>vendor-prefixed/*</exclude-pattern>
<exclude-pattern>dist/*</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
@@ -13,11 +14,5 @@
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
</rule>
<rule ref="vendor/suin/phpcs-psr4-sniff/src/Suin"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
<!-- <rule ref="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing">
<severity>0</severity>
</rule> -->

</ruleset>
50 changes: 25 additions & 25 deletions plugin-boilerplate.php
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@
define( 'PREFIX_VERSION', '1.0.0' );
}


/**
* Check PHP version
*/
@@ -41,10 +40,10 @@
if ( version_compare( phpversion(), '7.4', '<' ) ) {
add_action(
'admin_notices',
function() {
function () {
echo "<div class='notice notice-error is-dismissible'>";
/* translators: 1: Opening <p> HTML element 2: Opening <strong> HTML element 3: Closing <strong> HTML element 4: Closing <p> HTML element */
echo sprintf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s PHP version too low to use this plugin. Please change to at least PHP 7.4. You can contact your web host for assistance in updating your PHP version.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
printf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s PHP version too low to use this plugin. Please change to at least PHP 7.4. You can contact your web host for assistance in updating your PHP version.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
echo '</div>';
}
);
@@ -59,10 +58,10 @@ function() {
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
add_action(
'admin_notices',
function() {
function () {
echo "<div class='notice notice-error is-dismissible'>";
/* translators: 1: Opening <p> HTML element 2: Opening <strong> HTML element 3: Closing <strong> HTML element 4: Closing <p> HTML element */
echo sprintf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s PHP version too low to use this plugin. Please change to at least PHP 7.4. You can contact your web host for assistance in updating your PHP version.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
printf( esc_html__( '%1$s%2$s my_plugin_name NOTICE:%3$s PHP version too low to use this plugin. Please change to at least PHP 7.4. You can contact your web host for assistance in updating your PHP version.%4$s', 'text-domain' ), '<p>', '<strong>', '</strong>', '</p>' );
echo '</div>';
}
);
@@ -71,40 +70,35 @@ function() {
}

// Composer autoload.
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor-prefixed/autoload.php';

/**
* The code that runs during plugin activation.
* This action is documented in includes/class-prefix-activator.php
*/
if ( ! function_exists( 'activate_prefix' ) ) {
if ( ! function_exists( 'activate_suffix' ) ) {
/**
* Code to run when plugin is activated.
*
* @return void
*/
function activate_prefix() {
\Root\Notices\RootActivator::activate();
function activate_suffix() {
require_once plugin_dir_path( __FILE__ ) . 'includes/RootActivator.php';
\Root\RootActivator::activate();
}
}

/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-prefix-deactivator.php
*/
if ( ! function_exists( 'deactivate_prefix' ) ) {
if ( ! function_exists( 'deactivate_suffix' ) ) {
/**
* Code to run when plugin is deactivated.
*
* @return void
*/
function deactivate_prefix() {
\Root\Notices\RootDeactivator::deactivate();
function deactivate_suffix() {
require_once plugin_dir_path( __FILE__ ) . 'includes/RootDeactivator.php';
\Root\RootDeactivator::deactivate();
}
}

register_activation_hook( __FILE__, 'activate_prefix' );
register_deactivation_hook( __FILE__, 'deactivate_prefix' );
register_activation_hook( __FILE__, 'activate_suffix' );
register_deactivation_hook( __FILE__, 'deactivate_suffix' );

define( 'PREFIX_BASE_FILE', basename( plugin_dir_path( __FILE__ ) ) );
define( 'PREFIX_PLUGIN_NAME', 'my_plugin_shortname' );
@@ -122,10 +116,16 @@ function deactivate_prefix() {

define( 'PREFIX_DEBUG', $debug );

if ( ! function_exists( 'PREFIX_INIT' ) ) {
function PREFIX_INIT() {
if ( ! function_exists( 'prefix_init' ) ) {
/**
* Bootstrap plugin.
*
* @return void
* @since 1.0.0
*/
function prefix_init() {
$plugin_instance = \Root\Bootstrap\Main::getInstance();
$plugin_instance->run();
}
}
add_action( 'plugins_loaded', 'PREFIX_INIT' );
add_action( 'init', 'prefix_init' );
20 changes: 10 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -24,28 +24,26 @@ Run `composer install`

- Replace 'my_plugin_name' with the Plugin name example `Awesome WordPress Plugin` (exact match [whole word])

- Replace 'my_plugin_shortname' with a short lowercase version of the plugin name example `awesome_wp_plugin`. USE UNDERSCORES for the sparation (exact match [whole word])
- Replace 'my_plugin_shortname' with a short lowercase version of the plugin name example `awesome_wp_plugin`. USE UNDERSCORES for the separation (exact match [whole word])

- Replace 'text-domain' with plugin text domain (exact match [whole word])

- Replace 'PREFIX' with a prefix for constants (loose match, case sensitive)
- Replace 'PREFIX' with a prefix for constants (loose match, case-sensitive)

- Replace 'prefix_' with a lowercase version of the plugin name example `myplugin_` etc. USE UNDERSCORES for the sparation example `my_plugin_` (loose match, case sensitive)
- Replace 'prefix_' with a lowercase version of the plugin name example `myplugin_` etc. USE UNDERSCORES for the sparation example `my_plugin_` (loose match, case-sensitive)

- Replace '_prefix' with lowercase version of plugin name example `_my_plugin` (loose match, case sensitive)
- Replace '_suffix' with lowercase version of plugin name example `_my_plugin` (loose match, case sensitive)

- Replace 'prefix-' with a lowercase version of the plugin name example `myplugin-` etc. USE DASHES for the sparation example `my-plugin-` (exact match [whole word], case sensitive)
- Replace 'prefix-' with a lowercase version of the plugin name example `myplugin-` etc. USE DASHES for the sparation example `my-plugin-` (exact match [whole word], case-sensitive)

- Replace 'root' in file name for activator and deactivator classes located in `/includes` with a lowercase version of the plugin name, example `myplugin`. USE DASHES for the sparation example `my-plugin-`
- Rename `RootActivator` and `RootDeactivator` class files inside `includes` folder with the plugin name example `MyAwesomePluginActivator` and `MyAwesomePluginDeactivator`

- Replace `RootActivator` and `RootDeactivator` class names with the preferred class names for the activator and deactivator files. (exact match [whole word], case sensitive)
- Replace 'Root' with plugin example `MyAwesomePlugin`. This is used as your namespace prefix. (loose match, case-sensitive)

- Replace 'prefix' in file name for your asset files located in `/assets` with a lowercase version of the plugin name, example `myplugin`. USE DASHES for the sparation example `my-plugin-`
- Replace 'prefix' in file name for your asset files located in `/assets` with a lowercase version of the plugin name, example `myplugin`. USE DASHES for the separation example `my-plugin-`

- Open `dist.sh` in the `bin` folder and replace prefix.zip with the name for your dist file that will be created when you run `composer dist` example `myplugin.zip`

- Replace 'Root' with a shortname for plugin example `Myplugin`. This is used as your namespace prefix. (exact match, whole word)

You need to run `composer dumpautoload` after making this change to refresh autoload file with correct details.

- Replace 'plugin_author_name' with your name, (exact match [whole word])
@@ -54,6 +52,8 @@ You need to run `composer dumpautoload` after making this change to refresh auto

- Replace 'plugin_author_email' with your email address (exact match [whole word])

- Rename plugin-boilerplate.php in the root folder of the plugin with your actual plugin name. Example `my-awesome-plugin.php`

- Replace `SL_DEV_DEBUGGING` with a constant of your choice. This constant should be defined as true in your local wp install's `wp-config.php` file where you work on the plugin. It is used to set the plugin's main debug constant as true and loads the unminified JS of the plugin while working in your local environment.

### Note