This repository has been archived by the owner on Dec 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathessential-script.php
117 lines (114 loc) · 3.73 KB
/
essential-script.php
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* Essential Script
*
* @package Essential_Script
* @author Giulio <giupersu@yahoo.it>
* @version 0.8.1
*
* @wordpress-plugin
* Plugin Name: Essential Script
* Plugin URI: https://github.com/tetravalence/essential-script
* Description: Essential Script plugin offers you the ability to plug and manage your client-side script, which is an essential part of your website, through a versatile text editor made with <a href="http://codemirror.net/">CodeMirror</a>.
* Version: 0.8.1
* Requires: 4.9
* Tested up to: 4.9.2
* Requires PHP: 5.4
* Author: Giulio
* Author URI: https://www.freelancer.com/u/Tetravalente.html
* License: GPL
* Text Domain: essential-script
* Domain Path: /i18n/languages
*/
/*
* Copyright (C) 2017 docwho
*
* 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 3 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 <http://www.gnu.org/licenses/>.
*/
// Make sure we don't expose any info if called directly.
if ( !function_exists( 'add_action' ) ) {
echo "Hi there! I'm just a plugin, not much I can do when called directly.";
exit;
}
// Define all named constants here.
define ( 'ESSENTIAL_SCRIPT1_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define ( 'ESSENTIAL_SCRIPT1_PLUGIN_FILE', __FILE__ );
define ( 'ESSENTIAL_SCRIPT1_PLUGIN_PACKAGE', 'EssentialScript' );
// Include or require any necessary files here.
require_once ( ESSENTIAL_SCRIPT1_PLUGIN_DIR . 'classes/EssentialScript/Tools/Autoloader.php' );
// Activation stage
new \EssentialScript\Tools\Autoloader;
new \EssentialScript\Core\Setup;
/*
* Generic actions and filters go here using anonymous function from PHP 5.3
*
* Admin action:
*/
if ( is_admin() ) {
/*
* Settings API
*
* Creating the Essential Script submenu.
*/
add_action( 'admin_menu', function() {
// Essential Script page.
$page_essentialscript = new \EssentialScript\Admin\PageEssentialscript(
'essentialscript'
);
// Essential Script Submenu.
( new \EssentialScript\Admin\Menu() )->
init( $page_essentialscript )->
title( 'Essential Script', 'Essential Script' )->
capability( 'manage_options' )->
slug( $page_essentialscript )->
tools();
new \EssentialScript\Admin\Queuing(
\EssentialScript\Admin\Menu::get_suffix(),
array ( 'dist-codemirror-script',
'dist-codemirror-style',
'dist-codemirror-mode-js',
'dist-codemirror-mode-xml',
'codemirror-style-override' )
);
} );
}
/*
* Widget API
*
* Registering a Wordpress Widget.
*/
add_action( 'widgets_init', function() {
register_widget( 'EssentialScript\Admin\Widget' );
} );
/*
* If !admin then it's frontend.
*
* Frontend actions:
*/
$essentialscript_filter = null;
add_action( 'init', function() use ( &$essentialscript_filter ) {
$presenter = new \EssentialScript\Frontend\Presenter;
$essentialscript_filter = $presenter->router();
} );
/* The wp action hook runs immediately after the global WP class
* object is set up. Notice that init hook does not the job here
* because we need the conditional tags on the weblog frontend
* Essentialscript\Frontend.
*/
add_action( 'wp', function() use ( &$essentialscript_filter ) {
if ( !is_null( $essentialscript_filter ) ) {
$context = new \EssentialScript\Frontend\Main();
$context->trigger( $essentialscript_filter );
}
} );