PluginProbe
Selection Lite / 1.12
Selection Lite v1.12
trunk 1.0 1.1 1.10 1.11 1.12 1.14 1.15 1.16 1.17 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
selection-lite / src / Merkulove / Unity / PluginHelper.php

PluginHelper.php in Selection Lite 1.12, at src/Merkulove/Unity/PluginHelper.php

229 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Selection Lite
4 * Carefully selected Elementor addons bundle, for building the most awesome websites
5 *
6 * @encoding UTF-8
7 * @version 1.12
8 * @copyright (C) 2018-2024 Merkulove ( https://merkulov.design/ ). All rights reserved.
9 * @license GPLv3
10 * @contributors merkulove, vladcherviakov, phoenixmkua, podolianochka, viktorialev01
11 * @support help@merkulov.design
12 **/
13
14 namespace Merkulove\SelectionLite\Unity;
15
16 /** Exit if accessed directly. */
17 if ( ! defined( 'ABSPATH' ) ) {
18 header( 'Status: 403 Forbidden' );
19 header( 'HTTP/1.1 403 Forbidden' );
20 exit;
21 }
22
23 /**
24 * SINGLETON: Class used to implement base plugin features.
25 *
26 * @since 1.0
27 *
28 **/
29 final class PluginHelper {
30
31 /**
32 * The one true PluginHelper.
33 *
34 * @since 1.0
35 * @access private
36 * @var PluginHelper
37 **/
38 private static $instance;
39
40 /**
41 * Sets up a new PluginHelper instance.
42 *
43 * @since 1.0
44 * @access private
45 *
46 * @return void
47 **/
48 private function __construct() {
49
50 /** Add plugin links. */
51 add_filter( 'plugin_action_links_' . Plugin::get_basename(), [$this, 'add_links'] );
52
53 /** Load JS and CSS for Backend Area. */
54 $this->enqueue_backend();
55
56 /** Remove unnecessary WordPress branding and messages. */
57
58 /** Remove all "third-party" notices from plugin settings page. */
59 add_action( 'in_admin_header', [ $this, 'remove_all_notices' ], 1000 );
60
61 /** Remove "Thank you for creating with WordPress" and WP version only from plugin settings page. */
62 add_action( 'admin_enqueue_scripts', [ $this, 'remove_wp_copyrights' ] );
63
64 }
65
66 /**
67 * Load JS and CSS for Backend Area.
68 *
69 * @since 1.0
70 * @access public
71 *
72 * @return void
73 **/
74 public function enqueue_backend() {
75
76 /** Add admin styles. */
77 add_action( 'admin_enqueue_scripts', [ $this, 'admin_styles' ] );
78
79 /** Add admin javascript. */
80 add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
81
82 }
83
84 /**
85 * Add CSS for admin area.
86 *
87 * @since 1.0
88 * @access public
89 *
90 * @return void
91 **/
92 public function admin_styles() {
93
94 $screen = get_current_screen();
95 if ( null === $screen ) { return; }
96
97 /** Add styles only on WP Plugins page. */
98 if ( 'plugins' !== $screen->base ) { return; }
99
100 wp_enqueue_style( 'mdp-plugins', Plugin::get_url() . 'src/Merkulove/Unity/assets/css/plugins' . Plugin::get_suffix() . '.css', [], Plugin::get_version() );
101
102 }
103
104 /**
105 * Add JS for admin area.
106 *
107 * @since 1.0
108 * @access public
109 *
110 * @return void
111 **/
112 public function admin_scripts() {
113
114 $screen = get_current_screen();
115 if ( null === $screen ) { return; }
116
117 /** Add scripts only on WP Plugins page. */
118 if ( 'plugins' !== $screen->base ) { return; }
119
120 wp_enqueue_script( 'mdp-plugins', Plugin::get_url() . 'src/Merkulove/Unity/assets/js/plugins' . Plugin::get_suffix() . '.js', ['jquery'], Plugin::get_version(), true );
121
122 }
123
124 /**
125 * Add "merkulov.design" and "Envato Profile" links on plugin page.
126 *
127 * @param array $links Current links: Deactivate | Edit
128 *
129 * @since 1.0
130 * @access public
131 *
132 * @return array
133 **/
134 public function add_links( $links ) {
135
136 array_unshift( $links, '<a title="' . esc_html__( 'Settings', 'selection-lite' ) . '" href="' . admin_url( 'admin.php?page=mdp_selection_lite_settings' ) . '">' . esc_html__( 'Settings', 'selection-lite' ) . '</a>' );
137 $links[] = '<a title="' . esc_html__( 'Documentation', 'selection-lite' ) . '" href="https://docs.merkulov.design/tag/selection" target="_blank">' . esc_html__( 'Documentation', 'selection-lite' ) . '</a>';
138 $links[] = '<a href="https://1.envato.market/cc-merkulove" target="_blank" class="cc-merkulove"><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2aWV3Qm94PSIwIDAgMTE3Ljk5IDY3LjUxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8ZGVmcz4KPHN0eWxlPi5jbHMtMSwuY2xzLTJ7ZmlsbDojMDA5ZWQ1O30uY2xzLTIsLmNscy0ze2ZpbGwtcnVsZTpldmVub2RkO30uY2xzLTN7ZmlsbDojMDA5ZWUyO308L3N0eWxlPgo8L2RlZnM+CjxjaXJjbGUgY2xhc3M9ImNscy0xIiBjeD0iMTUiIGN5PSI1Mi41MSIgcj0iMTUiLz4KPHBhdGggY2xhc3M9ImNscy0yIiBkPSJNMzAsMmgwQTE1LDE1LDAsMCwxLDUwLjQ4LDcuNUw3Miw0NC43NGExNSwxNSwwLDEsMS0yNiwxNUwyNC41LDIyLjVBMTUsMTUsMCwwLDEsMzAsMloiLz4KPHBhdGggY2xhc3M9ImNscy0zIiBkPSJNNzQsMmgwQTE1LDE1LDAsMCwxLDk0LjQ4LDcuNUwxMTYsNDQuNzRhMTUsMTUsMCwxLDEtMjYsMTVMNjguNSwyMi41QTE1LDE1LDAsMCwxLDc0LDJaIi8+Cjwvc3ZnPgo=" alt="' . esc_html__( 'Plugins', 'selection-lite' ) . '">' . esc_html__( 'Plugins', 'selection-lite' ) . '</a>';
139
140 return $links;
141
142 }
143
144 /**
145 * Remove "Thank you for creating with WordPress" and WP version only from plugin settings page.
146 *
147 * @since 1.0
148 * @access public
149 *
150 * @return void
151 **/
152 public function remove_wp_copyrights() {
153
154 /** Remove "Thank you for creating with WordPress" and WP version from plugin settings page. */
155 $screen = get_current_screen();
156 if ( null === $screen ) { return; }
157
158 /** If not Plugin Settings Page. */
159 if ( ! in_array( $screen->base, Plugin::get_menu_bases(), true ) ) { return; }
160
161 /** Plugin Settings Page. */
162 add_filter( 'admin_footer_text', '__return_empty_string', 11 );
163 add_filter( 'update_footer', '__return_empty_string', 11 );
164
165 }
166
167 /**
168 * Remove all other notices.
169 *
170 * @since 1.0
171 * @access public
172 *
173 * @return void
174 **/
175 public function remove_all_notices() {
176
177 /** Work only on plugin settings page. */
178 $screen = get_current_screen();
179 if ( null === $screen ) { return; }
180
181 /** If not Plugin Settings Page. */
182 if ( ! in_array( $screen->base, Plugin::get_menu_bases(), true ) ) { return; }
183
184 /** Plugin Settings Page. */
185 remove_all_actions( 'admin_notices' );
186 remove_all_actions( 'all_admin_notices' );
187
188 }
189
190 /**
191 * Loads the plugin translated strings.
192 *
193 * @static
194 * @since 1.0
195 * @access public
196 *
197 * @return void
198 **/
199 public static function load_textdomain() {
200
201 load_plugin_textdomain( 'selection-lite', false, Plugin::get_path() . '/languages/' );
202
203 }
204
205 /**
206 * Main PluginHelper Instance.
207 * Insures that only one instance of PluginHelper exists in memory at any one time.
208 *
209 * @static
210 * @since 1.0
211 * @access public
212 *
213 * @return PluginHelper
214 **/
215 public static function get_instance() {
216
217 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
218
219 self::$instance = new self;
220
221 }
222
223 return self::$instance;
224
225 }
226
227 }
228
229