Compare commits

...

2 Commits

6 changed files with 75 additions and 24 deletions

View File

@ -44,16 +44,16 @@ class AdminSettings {
* *
* @since 1.0.0 * @since 1.0.0
* *
* @return string * @return void
*/ */
public function show_main_settings_page(): string { public function show_main_settings_page(): void {
$data = array(); $data = array();
$this->localize_script(); $this->localize_script();
ob_start(); ob_start();
echo nmsp_plugin_app()->blade->run( 'admin.settings', $data ); echo nmsp_plugin_app()->blade->run( 'admin.settings', $data );
$output = ob_get_clean(); $output = ob_get_clean();
return wp_kses_post( $output ); echo wp_kses_post( $output );
} }
/** /**

View File

@ -0,0 +1,48 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Show a notice on the admin panel.
*
* @since 1.0.0
*
* @param string $message The message to show in the notice
* @param string $type The 'type' of notice, e.g. info (default), success, warning, or error
* @param bool $dismissible Whether the notice should be dismissible
*
* @return string
*/
function nmsp_admin_notice( string $message, string $type = 'info', bool $dismissible = true ) {
$classes = 'notice';
switch ($type) {
case 'success':
$classes .= ' notice-success';
break;
case 'warning':
$classes .= ' notice-warning';
break;
case 'error':
$classes .= ' notice-error';
break;
case 'info':
default:
$classes .= ' notice-info';
}
if ( $dismissible ) {
$classes .= ' is-dismissible';
}
add_action( 'admin_notices', function () use ( $classes, $message ) {
ob_start();
?>
<div class="<?php echo $classes; ?>">
<p><?php _e( $message, 'nmsp-plugin-name-text-domain' ); ?></p>
</div>
<?php
echo ob_get_clean();
});
}

View File

@ -12,7 +12,7 @@
], ],
"require": { "require": {
"php": ">=7.3.0", "php": ">=7.3.0",
"eftec/bladeone": "^3.52" "eftec/bladeone": "^4.1"
}, },
"require-dev": { "require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.3.0", "php-parallel-lint/php-parallel-lint": "^1.3.0",

20
composer.lock generated
View File

@ -4,30 +4,30 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "2684d1770bbee2bb8f671fbbb3919f1e", "content-hash": "93b4f488145c9bf1c4ecf7adad47614e",
"packages": [ "packages": [
{ {
"name": "eftec/bladeone", "name": "eftec/bladeone",
"version": "3.52", "version": "4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/EFTEC/BladeOne.git", "url": "https://github.com/EFTEC/BladeOne.git",
"reference": "a19bf66917de0b29836983db87a455a4f6e32148" "reference": "d3e1efa1c6f776aa87fe47164d77e7ea67fc196f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/EFTEC/BladeOne/zipball/a19bf66917de0b29836983db87a455a4f6e32148", "url": "https://api.github.com/repos/EFTEC/BladeOne/zipball/d3e1efa1c6f776aa87fe47164d77e7ea67fc196f",
"reference": "a19bf66917de0b29836983db87a455a4f6e32148", "reference": "d3e1efa1c6f776aa87fe47164d77e7ea67fc196f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"php": ">=5.6" "php": ">=7.1.3"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.16.1", "friendsofphp/php-cs-fixer": "^3.1",
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.5.4" "squizlabs/php_codesniffer": "^3.6.0"
}, },
"suggest": { "suggest": {
"eftec/bladeonehtml": "Extension to create forms", "eftec/bladeonehtml": "Extension to create forms",
@ -60,9 +60,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/EFTEC/BladeOne/issues", "issues": "https://github.com/EFTEC/BladeOne/issues",
"source": "https://github.com/EFTEC/BladeOne/tree/3.52" "source": "https://github.com/EFTEC/BladeOne/tree/4.1"
}, },
"time": "2021-04-17T13:49:01+00:00" "time": "2021-09-29T15:23:25+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [

View File

@ -11,12 +11,6 @@ if ( ! defined( 'ABSPATH' ) ) {
class App { class App {
/** @var string */
public $version = '1.0.0';
/** @var string */
public $db_version = '1.0.0';
/** @var \PluginNamespace\App */ /** @var \PluginNamespace\App */
public static $instance; public static $instance;
@ -32,6 +26,12 @@ class App {
*/ */
public static function plugin_activation(): void { public static function plugin_activation(): void {
self::ensure_template_cache_dir_exists(); self::ensure_template_cache_dir_exists();
$plugin_metadata = array(
'plugin_version' => PLUGIN_NAME_VERSION,
'db_version' => PLUGIN_NAME_DB_VERSION,
);
add_option( 'nmsp_plugin_metadata', $plugin_metadata );
} }
/** /**
@ -151,9 +151,10 @@ class App {
public function includes(): void { public function includes(): void {
// Files to include on the admin. // Files to include on the admin.
if ( is_admin() ) { if ( is_admin() ) {
require_once NMSP_PLUGIN_BASE_DIR . '/admin/nmsp-admin-functions.php';
require_once NMSP_PLUGIN_BASE_DIR . '/admin/nmsp-update-functions.php';
require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-adminsettings.php'; require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-adminsettings.php';
} }
//
// Files to include on every request. // Files to include on every request.
// //
@ -163,7 +164,7 @@ class App {
} }
/** /**
* Load Blade as the templating engine for the plugin. * Load BladeOne as the templating engine for the plugin.
* *
* @since 1.0.0 * @since 1.0.0
* *

View File

@ -40,6 +40,9 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! defined( 'PLUGIN_NAME_VERSION' ) ) { if ( ! defined( 'PLUGIN_NAME_VERSION' ) ) {
define( 'PLUGIN_NAME_VERSION', '1.0.0' ); define( 'PLUGIN_NAME_VERSION', '1.0.0' );
} }
if ( ! defined( 'PLUGIN_NAME_DB_VERSION' ) ) {
define( 'PLUGIN_NAME_DB_VERSION', '1.0.0' );
}
if ( ! defined('NMSP_PLUGIN_BASE_DIR') ) { if ( ! defined('NMSP_PLUGIN_BASE_DIR') ) {
define( 'NMSP_PLUGIN_BASE_DIR', __DIR__ ); define( 'NMSP_PLUGIN_BASE_DIR', __DIR__ );
@ -54,8 +57,7 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once __DIR__ . '/includes/class-nmspcli.php'; require_once __DIR__ . '/includes/class-nmspcli.php';
} }
$mode = BladeOne::MODE_DEBUG; // Can also be MODE_AUTO|MODE_DEBUG $blade = new BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade' );
$blade = new BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade', $mode );
register_activation_hook( __FILE__, array( App::class, 'plugin_activation' ) ); register_activation_hook( __FILE__, array( App::class, 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( App::class, 'plugin_deactivation' ) ); register_deactivation_hook( __FILE__, array( App::class, 'plugin_deactivation' ) );