PluginProbe
Getwid – Gutenberg Blocks / 3.0.2
Getwid – Gutenberg Blocks v3.0.2
3.0.2 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.2, at includes/getwid.php

235 lines 4.6 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 private function __construct() {
71
72 require_once GETWID_PLUGIN_DIR . 'includes/load.php';
73
74 add_action( 'init', array( $this, 'init' ), 0 );
75
76 add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
77 add_filter( 'plugin_action_links_' . GETWID_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
78 }
79
80 /**
81 * Init Getwid when WordPress Initialises.
82 */
83 public function init() {
84 $this->settings = new Settings();
85 $this->versionControl = new VersionControl();
86 $this->scriptsManager = new ScriptsManager();
87 $this->fontIconsManager = new FontIconsManager();
88 $this->blocksManager = new BlocksManager();
89 $this->instagramTokenManager = new InstagramTokenManager();
90 $this->settingsPage = new SettingsPage();
91 $this->restAPI = new RestAPI();
92 $this->postTemplatePart = new PostTemplatePart();
93 $this->allowedCssTags = new AllowedCssTags();
94 $this->mailer = new Mailer();
95 }
96
97 /**
98 * @return ScriptsManager
99 */
100 public function scriptsManager(){
101 return $this->scriptsManager;
102 }
103
104 /**
105 * @return FontIconsManager
106 */
107 public function fontIconsManager(){
108 return $this->fontIconsManager;
109 }
110
111 /**
112 * @return BlocksManager
113 */
114 public function blocksManager(){
115 return $this->blocksManager;
116 }
117
118 /**
119 * @return InstagramTokenManager
120 */
121 public function instagramTokenManager(){
122 return $this->instagramTokenManager;
123 }
124
125 /**
126 * @return VersionControl
127 */
128 public function versionControl(){
129 return $this->versionControl;
130 }
131
132 /**
133 * @return SettingsPage
134 */
135 public function settingsPage(){
136 return $this->settingsPage;
137 }
138
139 /**
140 * @return RestAPI
141 */
142 public function restAPI(){
143 return $this->restAPI;
144 }
145
146 /**
147 * @return PostTemplatePart
148 */
149 public function postTemplatePart(){
150 return $this->postTemplatePart;
151 }
152
153 /**
154 * @return AllowedCssTags
155 */
156 public function allowedCssTags(){
157 return $this->allowedCssTags;
158 }
159
160 /**
161 * @return Mailer
162 */
163 public function mailer(){
164 return $this->mailer;
165 }
166
167 /**
168 * @return Settings
169 */
170 public function settings(){
171 return $this->settings;
172 }
173
174 /**
175 * @return Getwid
176 */
177 public static function getInstance(){
178 if ( is_null( self::$instance ) ) {
179 self::$instance = new self();
180 }
181
182 return self::$instance;
183 }
184
185 public function is_rest_api_request() {
186
187 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
188 return false;
189 }
190
191 $rest_prefix = trailingslashit( rest_get_url_prefix() );
192 $is_rest_api_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) );
193
194 return apply_filters( 'getwid/is_rest_api_request', $is_rest_api_request );
195 }
196
197 /**
198 * Show row meta on the plugin screen.
199 *
200 * @return array
201 */
202 public function plugin_row_meta( $links, $file ) {
203
204 if ( GETWID_PLUGIN_BASENAME === $file ) {
205
206 $row_meta = array(
207 'support' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/getwid/' ) . '" aria-label="' .
208 esc_attr__( 'Support', 'getwid' ) . '">' . esc_html__( 'Support', 'getwid' ) . '</a>',
209 'review' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/getwid/reviews/' ) . '" aria-label="' .
210 esc_attr__( 'Write a Review', 'getwid' ) . '">' . esc_html__( 'Write a Review', 'getwid' ) . '</a>',
211 );
212
213 return array_merge( $links, $row_meta );
214 }
215
216 return (array) $links;
217 }
218
219 public function plugin_action_links( $actions ) {
220
221 if ( current_user_can( 'manage_options' ) ) {
222
223 $settings_url = $this->settingsPage->getTabUrl('general');
224
225 return array_merge(
226 $actions,
227 array( 'settings' => sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'getwid' ) ) )
228 );
229 }
230
231 return $actions;
232 }
233
234 }
235