PluginProbe
Getwid – Gutenberg Blocks / 3.0.0
Getwid – Gutenberg Blocks v3.0.0
3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
getwid / includes / getwid.php

getwid.php in Getwid – Gutenberg Blocks 3.0.0, at includes/getwid.php

249 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Getwid;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 final class Getwid {
10 /**
11 * @var Getwid
12 */
13 private static $instance = null;
14
15 /**
16 * @var Settings
17 */
18 private $settings;
19
20 /**
21 * @var ScriptsManager
22 */
23 private $scriptsManager;
24
25 /**
26 * @var FontIconsManager
27 */
28 private $fontIconsManager;
29
30 /**
31 * @var BlocksManager
32 */
33 private $blocksManager;
34
35 /**
36 * @var InstagramTokenManager
37 */
38 private $instagramTokenManager;
39
40 /**
41 * @var VersionControl
42 */
43 private $versionControl;
44
45 /**
46 * @var SettingsPage
47 */
48 private $settingsPage;
49
50 /**
51 * @var RestAPI
52 */
53 private $restAPI;
54
55 /**
56 * @var PostTemplatePart
57 */
58 private $postTemplatePart;
59
60 /**
61 * @var AllowedCssTags
62 */
63 private $allowedCssTags;
64
65 /**
66 * @var Mailer
67 */
68 private $mailer;
69
70 /**
71 * @var AssetsOptimization
72 */
73 private $assetsOptimization;
74
75 private function __construct() {
76
77 require_once GETWID_PLUGIN_DIR . 'includes/load.php';
78
79 $this->assetsOptimization = AssetsOptimization::getInstance();
80
81 add_action( 'init', array( $this, 'init' ), 0 );
82
83 add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
84 add_filter( 'plugin_action_links_' . GETWID_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
85 }
86
87 /**
88 * Init Getwid when WordPress Initialises.
89 */
90 public function init() {
91 $this->settings = new Settings();
92 $this->versionControl = new VersionControl();
93 $this->scriptsManager = new ScriptsManager();
94 $this->fontIconsManager = new FontIconsManager();
95 $this->blocksManager = new BlocksManager();
96 $this->instagramTokenManager = new InstagramTokenManager();
97 $this->settingsPage = new SettingsPage();
98 $this->restAPI = new RestAPI();
99 $this->postTemplatePart = new PostTemplatePart();
100 $this->allowedCssTags = new AllowedCssTags();
101 $this->mailer = new Mailer();
102 }
103
104 /**
105 * @return ScriptsManager
106 */
107 public function scriptsManager(){
108 return $this->scriptsManager;
109 }
110
111 /**
112 * @return FontIconsManager
113 */
114 public function fontIconsManager(){
115 return $this->fontIconsManager;
116 }
117
118 /**
119 * @return BlocksManager
120 */
121 public function blocksManager(){
122 return $this->blocksManager;
123 }
124
125 /**
126 * @return InstagramTokenManager
127 */
128 public function instagramTokenManager(){
129 return $this->instagramTokenManager;
130 }
131
132 /**
133 * @return VersionControl
134 */
135 public function versionControl(){
136 return $this->versionControl;
137 }
138
139 /**
140 * @return SettingsPage
141 */
142 public function settingsPage(){
143 return $this->settingsPage;
144 }
145
146 /**
147 * @return RestAPI
148 */
149 public function restAPI(){
150 return $this->restAPI;
151 }
152
153 /**
154 * @return PostTemplatePart
155 */
156 public function postTemplatePart(){
157 return $this->postTemplatePart;
158 }
159
160 /**
161 * @return AllowedCssTags
162 */
163 public function allowedCssTags(){
164 return $this->allowedCssTags;
165 }
166
167 /**
168 * @return Mailer
169 */
170 public function mailer(){
171 return $this->mailer;
172 }
173
174 /**
175 * @return Settings
176 */
177 public function settings(){
178 return $this->settings;
179 }
180
181 /**
182 * @return AssetsOptimization
183 */
184 public function assetsOptimization(){
185 return $this->assetsOptimization;
186 }
187
188 /**
189 * @return Getwid
190 */
191 public static function getInstance(){
192 if ( is_null( self::$instance ) ) {
193 self::$instance = new self();
194 }
195
196 return self::$instance;
197 }
198
199 public function is_rest_api_request() {
200
201 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
202 return false;
203 }
204
205 $rest_prefix = trailingslashit( rest_get_url_prefix() );
206 $is_rest_api_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) );
207
208 return apply_filters( 'getwid/is_rest_api_request', $is_rest_api_request );
209 }
210
211 /**
212 * Show row meta on the plugin screen.
213 *
214 * @return array
215 */
216 public function plugin_row_meta( $links, $file ) {
217
218 if ( GETWID_PLUGIN_BASENAME === $file ) {
219
220 $row_meta = array(
221 'support' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/getwid/' ) . '" aria-label="' .
222 esc_attr__( 'Support', 'getwid' ) . '">' . esc_html__( 'Support', 'getwid' ) . '</a>',
223 'review' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/getwid/reviews/' ) . '" aria-label="' .
224 esc_attr__( 'Write a Review', 'getwid' ) . '">' . esc_html__( 'Write a Review', 'getwid' ) . '</a>',
225 );
226
227 return array_merge( $links, $row_meta );
228 }
229
230 return (array) $links;
231 }
232
233 public function plugin_action_links( $actions ) {
234
235 if ( current_user_can( 'manage_options' ) ) {
236
237 $settings_url = $this->settingsPage->getTabUrl('general');
238
239 return array_merge(
240 $actions,
241 array( 'settings' => sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'getwid' ) ) )
242 );
243 }
244
245 return $actions;
246 }
247
248 }
249