Adding direct access prevention to files
This commit is contained in:
parent
023c0f53e6
commit
3e03887bda
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace PluginNamespace\Admin;
|
namespace PluginNamespace\Admin;
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +49,7 @@ class Settings {
|
|||||||
public function show_main_settings_page(): string {
|
public function show_main_settings_page(): string {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$this->localize_script();
|
$this->localize_script( array() );
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
echo nmsp_plugin_app()->blade->run( 'admin.settings', $data );
|
echo nmsp_plugin_app()->blade->run( 'admin.settings', $data );
|
||||||
@ -78,9 +82,12 @@ class Settings {
|
|||||||
private function localize_script( array $additional_data = array() ): void {
|
private function localize_script( array $additional_data = array() ): void {
|
||||||
wp_enqueue_script( 'nmsp-plugin-name-admin-js' );
|
wp_enqueue_script( 'nmsp-plugin-name-admin-js' );
|
||||||
|
|
||||||
$payload = array(
|
$payload = array_merge(
|
||||||
|
$additional_data,
|
||||||
|
array(
|
||||||
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||||
'_nonce' => wp_create_nonce( NMSP_PLUGIN_NONCE ),
|
'_nonce' => wp_create_nonce( NMSP_PLUGIN_NONCE ),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
wp_localize_script( 'nmsp-plugin-name-admin-js', 'nmspPluginAdminApi', $payload );
|
wp_localize_script( 'nmsp-plugin-name-admin-js', 'nmspPluginAdminApi', $payload );
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
| ----------------------------------------------------------------
|
| ----------------------------------------------------------------
|
||||||
| Bootstrap
|
| Bootstrap
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
| ----------------------------------------------------------------
|
| ----------------------------------------------------------------
|
||||||
| Base Definitions
|
| Base Definitions
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
| ----------------------------------------------------------------
|
| ----------------------------------------------------------------
|
||||||
| HTTP Status Code Definitions
|
| HTTP Status Code Definitions
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
| ----------------------------------------------------------------
|
| ----------------------------------------------------------------
|
||||||
| URL Rewrite Definitions
|
| URL Rewrite Definitions
|
||||||
|
@ -5,6 +5,10 @@ namespace PluginNamespace;
|
|||||||
use eftec\bladeone\BladeOne;
|
use eftec\bladeone\BladeOne;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
||||||
/** @var \PluginNamespace\App */
|
/** @var \PluginNamespace\App */
|
||||||
|
@ -5,7 +5,7 @@ namespace PluginNamespace;
|
|||||||
use WP_CLI;
|
use WP_CLI;
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NmspCli {
|
class NmspCli {
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace PluginNamespace\Front;
|
namespace PluginNamespace\Front;
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
class CustomPage {
|
class CustomPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace PluginNamespace\Front;
|
namespace PluginNamespace\Front;
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
class Rewrites {
|
class Rewrites {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
* Boilerplate Plugin
|
* Boilerplate Plugin
|
||||||
*
|
*
|
||||||
* @package BoilerplatePlugin
|
* @package BoilerplatePlugin
|
||||||
* @author
|
* @author Plugin Author
|
||||||
* @copyright
|
* @copyright GPL v2
|
||||||
* @license
|
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
|
||||||
*
|
*
|
||||||
* @wordpress-plugin
|
* @wordpress-plugin
|
||||||
* Plugin Name: Boilerplate Plugin
|
* Plugin Name: Boilerplate Plugin
|
||||||
* Description: Your plugin description.
|
* Description: Your plugin description.
|
||||||
* License: GPL v2
|
* License: GPL v2
|
||||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
|
||||||
* Plugin URI: https://domain.com
|
* Plugin URI: https://domain.com
|
||||||
* Update URI: https://example.com/my-plugin/
|
* Update URI: https://example.com/my-plugin/
|
||||||
* Version: 1.0.0
|
* Version: 1.0.0
|
||||||
@ -21,12 +21,21 @@
|
|||||||
* Author: Plugin Author
|
* Author: Plugin Author
|
||||||
* Author URI: https://plugin-author.com
|
* Author URI: https://plugin-author.com
|
||||||
* Text Domain: nmsp-plugin-name-text-domain
|
* Text Domain: nmsp-plugin-name-text-domain
|
||||||
|
* Domain Path: /languages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// If this file is called directly, abort.
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently plugin version.
|
||||||
|
* Start at version 1.0.0 and use SemVer - https://semver.org
|
||||||
|
* Rename this for your plugin and update it as you release new versions.
|
||||||
|
*/
|
||||||
|
define( 'PLUGIN_NAME_VERSION', '1.0.0' );
|
||||||
|
|
||||||
define( 'NMSP_PLUGIN_BASE_DIR', __DIR__ );
|
define( 'NMSP_PLUGIN_BASE_DIR', __DIR__ );
|
||||||
|
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
// Exit if accessed directly
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
||||||
// This constant gets set when WordPress' uninstall.php file is invoked.
|
// This constant gets set when WordPress' uninstall.php file is invoked.
|
||||||
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user