-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptomatic.php
More file actions
100 lines (86 loc) · 4.24 KB
/
Copy pathscriptomatic.php
File metadata and controls
100 lines (86 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Plugin Name: Scriptomatic
* Plugin URI: https://github.com/richardkentgates/scriptomatic
* Description: Inject custom JavaScript into the head and footer of your WordPress site. Manage standalone JS files with a built-in code editor, conditional per-page loading, external script URLs, revision history, rollback, activity logging, and fine-grained admin controls.
* Version: 3.3.0
* Requires at least: 6.2
* Tested up to: 6.9
* Requires PHP: 7.2
* Author: Richard Kent Gates
* Author URI: https://richardkentgates.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: scriptomatic
* Domain Path: /languages
*
* @package Scriptomatic
* @author Richard Kent Gates
* @copyright 2026 Richard Kent Gates
* @license GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// ---- Core ----
define( 'SCRIPTOMATIC_VERSION', '3.3.0' );
define( 'SCRIPTOMATIC_PLUGIN_FILE', __FILE__ );
define( 'SCRIPTOMATIC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'SCRIPTOMATIC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// ---- Option keys: location data (script + conditions + urls combined) ----
define( 'SCRIPTOMATIC_LOCATION_HEAD', 'scriptomatic_head' );
define( 'SCRIPTOMATIC_LOCATION_FOOTER', 'scriptomatic_footer' );
// ---- Option keys: plugin settings ----
define( 'SCRIPTOMATIC_PLUGIN_SETTINGS_OPTION', 'scriptomatic_plugin_settings' );
// ---- Limits / timing ----
define( 'SCRIPTOMATIC_MAX_SCRIPT_LENGTH', 100000 ); // 100 KB hard limit per inline script
// ---- Nonces ----
define( 'SCRIPTOMATIC_HEAD_NONCE', 'scriptomatic_save_head' ); // Head script form secondary nonce
define( 'SCRIPTOMATIC_FOOTER_NONCE', 'scriptomatic_save_footer' ); // Footer script form secondary nonce
define( 'SCRIPTOMATIC_GENERAL_NONCE', 'scriptomatic_save_general' ); // General settings form secondary nonce
define( 'SCRIPTOMATIC_ROLLBACK_NONCE', 'scriptomatic_rollback' ); // AJAX rollback nonce
// ---- Option keys: managed JS files ----
define( 'SCRIPTOMATIC_JS_FILES_OPTION', 'scriptomatic_js_files' ); // DB option key for JS file metadata array
// ---- Activity log ----
define( 'SCRIPTOMATIC_LOG_TABLE', 'scriptomatic_log' ); // Base name (without DB prefix) for the script/file activity log table
define( 'SCRIPTOMATIC_PREFS_LOG_TABLE', 'scriptomatic_prefs_log' ); // Base name (without DB prefix) for the preferences change log table
define( 'SCRIPTOMATIC_MAX_LOG_ENTRIES', 200 ); // Default maximum entries shown in the UI
// ---- Nonces: JS files ----
define( 'SCRIPTOMATIC_FILES_NONCE', 'scriptomatic_save_js_file' ); // File edit form + AJAX delete nonce
// Initialise Freemius (defines scriptomatic_fs() and scriptomatic_is_premium()).
// The set_basename() call enables auto-deactivation of the free version when
// the Pro version is activated.
if ( function_exists( 'scriptomatic_fs' ) ) {
scriptomatic_fs()->set_basename( true, __FILE__ );
} else {
require_once SCRIPTOMATIC_PLUGIN_DIR . 'includes/freemius-init.php';
// Load the main class (also requires all trait files).
require_once SCRIPTOMATIC_PLUGIN_DIR . 'includes/class-scriptomatic.php';
/**
* Bootstrap the plugin by returning (and, on first call, creating) the
* singleton {@see Scriptomatic} instance.
*
* Hooked on {@see 'plugins_loaded'} so that all WordPress APIs are available
* before any plugin logic runs.
*
* @since 1.0.0
* @return Scriptomatic
*/
function scriptomatic_init() {
return Scriptomatic::get_instance();
}
add_action( 'plugins_loaded', 'scriptomatic_init' );
}