PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / trunk
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel vtrunk
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / controllers / controller / admin.php
wp-all-export / controllers / controller Last commit date
admin.php 3 weeks ago
admin.php
127 lines
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 /**
6 * Introduce special type for controllers which render pages inside admin area
7 *
8 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
9 */
10 abstract class PMXE_Controller_Admin extends PMXE_Controller {
11 /**
12 * Admin page base url (request url without all get parameters but `page`)
13 * @var string
14 */
15 public $baseUrl;
16 /**
17 * Parameters which is left when baseUrl is detected
18 * @var array
19 */
20 public $baseUrlParamNames = array('page', 'pagenum', 'order', 'order_by', 'type', 's', 'f');
21 /**
22 * Whether controller is rendered inside wordpress page
23 * @var bool
24 */
25 public $isInline = false;
26 /**
27 * Constructor
28 */
29 public function __construct() {
30
31 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only inspection of query string keys to build baseUrl
32 $remove = array_diff(array_keys($_GET), $this->baseUrlParamNames);
33 if ($remove) {
34 $this->baseUrl = esc_url_raw(remove_query_arg($remove));
35 } else {
36 $this->baseUrl = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
37 }
38 parent::__construct();
39
40 // add special filter for url fields
41 $this->input->addFilter('pmxe_url_filter');
42
43 // enqueue required sripts and styles
44 global $wp_styles;
45 if ( ! is_a($wp_styles, 'WP_Styles'))
46 $wp_styles = new WP_Styles();
47
48 wp_enqueue_style('jquery-ui', PMXE_ROOT_URL . '/static/js/jquery/css/redmond/jquery-ui.css', array('media-views'), PMXE_VERSION);
49 wp_enqueue_style('jquery-tipsy', PMXE_ROOT_URL . '/static/js/jquery/css/smoothness/jquery.tipsy.css', array('media-views'), PMXE_VERSION);
50 wp_enqueue_style('pmxe-admin-style', PMXE_ROOT_URL . '/static/css/admin.css',array('media-views'), PMXE_VERSION.PMXE_ASSETS_VERSION);
51 wp_enqueue_style('pmxe-scheduling-style', PMXE_ROOT_URL . '/static/css/scheduling.css', array(), PMXE_VERSION);
52 wp_enqueue_style('pmxe-admin-style-upgrade-notice', PMXE_ROOT_URL . '/static/css/upgrade-notice.css',array('media-views'), PMXE_VERSION.PMXE_ASSETS_VERSION);
53 wp_enqueue_style('pmxe-admin-style-ie', PMXE_ROOT_URL . '/static/css/admin-ie.css', array('media-views'), PMXE_VERSION);
54 wp_enqueue_style('jquery-select2', PMXE_ROOT_URL . '/static/js/jquery/css/select2/select2.css', array('media-views'), PMXE_VERSION);
55 wp_enqueue_style('jquery-select2', PMXE_ROOT_URL . '/static/js/jquery/css/select2/select2-bootstrap.css', array('media-views'), PMXE_VERSION);
56 wp_enqueue_style('jquery-chosen', PMXE_ROOT_URL . '/static/js/jquery/css/chosen/chosen.css', array('media-views'), PMXE_VERSION);
57 wp_enqueue_style('jquery-codemirror', PMXE_ROOT_URL . '/static/codemirror/codemirror.css', array('media-views'), PMXE_VERSION.PMXE_ASSETS_VERSION);
58 wp_enqueue_style('jquery-timepicker', PMXE_ROOT_URL . '/static/js/jquery/css/timepicker/jquery.timepicker.css', array('media-views'), PMXE_VERSION.PMXE_ASSETS_VERSION);
59 wp_enqueue_style('pmxe-angular-scss', PMXE_ROOT_URL . '/dist/styles.css', array('media-views'), PMXE_VERSION.PMXE_ASSETS_VERSION);
60 wp_enqueue_style('jquery-codemirror', PMXE_ROOT_URL . '/static/css/codemirror.css', array(), PMXE_VERSION);
61
62 // IE conditional comments removed - no longer supported in modern browsers or WordPress 6.9+
63 wp_enqueue_style('wp-pointer');
64
65 if ( version_compare(get_bloginfo('version'), '3.8-RC1') >= 0 ){
66 wp_enqueue_style('pmxe-admin-style-wp-3.8', PMXE_ROOT_URL . '/static/css/admin-wp-3.8.css', array('media-views'), PMXE_VERSION);
67 }
68
69 if ( version_compare(get_bloginfo('version'), '4.4') >= 0 ){
70 wp_enqueue_style('pmxe-admin-style-wp-4.4', PMXE_ROOT_URL . '/static/css/admin-wp-4.4.css', array('media-views'), PMXE_VERSION);
71 }
72
73 $scheme_color = get_user_option('admin_color') and is_file(PMXE_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css') or $scheme_color = 'fresh';
74 if (is_file(PMXE_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css')) {
75 wp_enqueue_style('pmxe-admin-style-color', PMXE_ROOT_URL . '/static/css/admin-colors-' . $scheme_color . '.css', array('media-views'), PMXE_VERSION);
76 }
77
78 wp_enqueue_script('jquery-ui-datepicker', PMXE_ROOT_URL . '/static/js/jquery/ui.datepicker.js', array('jquery-ui-core'), PMXE_VERSION, true);
79 wp_enqueue_script('tipsy', PMXE_ROOT_URL . '/static/js/jquery/jquery.tipsy.js', array('jquery'), PMXE_VERSION.PMXE_ASSETS_VERSION, true);
80 wp_enqueue_script('jquery-pmxe-nestable', PMXE_ROOT_URL . '/static/js/jquery/jquery.mjs.pmxe_nestedSortable.js', array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-tabs', 'jquery-ui-progressbar'), PMXE_VERSION, true);
81 wp_enqueue_script('jquery-select2', PMXE_ROOT_URL . '/static/js/jquery/select2.min.js', array('jquery'), PMXE_VERSION, true);
82 wp_enqueue_script('jquery-ddslick', PMXE_ROOT_URL . '/static/js/jquery/jquery.ddslick.min.js', array('jquery'), PMXE_VERSION, true);
83 wp_enqueue_script('jquery-chosen', PMXE_ROOT_URL . '/static/js/jquery/chosen.jquery.js', array('jquery'), PMXE_VERSION, true);
84
85 add_action("admin_enqueue_scripts", [$this, 'add_admin_scripts']);
86
87 wp_enqueue_script('jquery-timepicker', PMXE_ROOT_URL . '/static/js/jquery/jquery.timepicker.js', array('jquery'), PMXE_VERSION.PMXE_ASSETS_VERSION, true);
88
89 wp_enqueue_script('wp-pointer');
90
91 /* load plupload scripts */
92 wp_enqueue_script('pmxe-admin-script', PMXE_ROOT_URL . '/static/js/admin.js', array('jquery', 'jquery-ui-dialog', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-autocomplete' ), PMXE_VERSION, true);
93 wp_enqueue_script('pmxe-scheduling-script', PMXE_ROOT_URL . '/static/js/scheduling.js', array('pmxe-admin-script'), PMXE_VERSION, true);
94 wp_enqueue_script('pmxe-admin-validate-braces', PMXE_ROOT_URL . '/static/js/validate-braces.js', array('pmxe-admin-script' ), PMXE_VERSION.PMXE_ASSETS_VERSION, true);
95 wp_enqueue_script('pmxe-admin-update-notice', PMXE_ROOT_URL . '/static/js/upgrade-notice.js', array('pmxe-admin-script' ), PMXE_VERSION.PMXE_ASSETS_VERSION, true);
96
97 if(getenv('WPAE_DEV')) {
98 // Loaded in the header (not the footer): the admin_head inline script registers the
99 // GoogleMerchants 'NONCE' Angular constant and requires this module to already exist.
100 wp_enqueue_script('pmxe-angular-app', PMXE_ROOT_URL . '/dist/app.js', array('jquery'), PMXE_VERSION.PMXE_ASSETS_VERSION);
101 } else {
102 wp_enqueue_script('pmxe-angular-app', PMXE_ROOT_URL . '/dist/app.min.js', array('jquery'), PMXE_VERSION.PMXE_ASSETS_VERSION);
103 }
104 }
105
106 public function add_admin_scripts() {
107
108 $cm_settings['codeEditor'] = wp_enqueue_code_editor(['type' => 'php']);
109 wp_localize_script('jquery', 'wpae_cm_settings', $cm_settings);
110
111 }
112
113 /**
114 * @see Controller::render()
115 */
116 protected function render($viewPath = NULL)
117 {
118 // assume template file name depending on calling function
119 if (is_null($viewPath)) {
120 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace -- used to derive view path from calling class/function
121 $trace = debug_backtrace();
122 $viewPath = str_replace('_', '/', preg_replace('%^' . preg_quote(PMXE_Plugin::PREFIX, '%') . '%', '', strtolower($trace[1]['class']))) . '/' . $trace[1]['function'];
123 }
124 parent::render($viewPath);
125 }
126
127 }