|
3 | 3 | Plugin Name: weDocs |
4 | 4 | Plugin URI: https://wedocs.co/ |
5 | 5 | Description: A documentation plugin for WordPress |
6 | | -Version: 2.2.1 |
| 6 | +Version: 2.1.11 |
7 | 7 | Author: weDevs |
8 | 8 | Author URI: https://wedocs.co/?utm_source=wporg&utm_medium=banner&utm_campaign=author-uri |
9 | 9 | License: GPL2 |
|
47 | 47 |
|
48 | 48 | require_once __DIR__ . '/vendor/autoload.php'; |
49 | 49 | require_once plugin_dir_path(__FILE__) . 'assets/build/blocks/helpers/block-styles.php'; |
| 50 | +require_once plugin_dir_path(__FILE__) . 'assets/build/blocks/DocsGrid/render.php'; |
50 | 51 |
|
51 | 52 | /** |
52 | 53 | * WeDocs class. |
53 | 54 | * |
54 | 55 | * @class WeDocs The class that holds the entire WeDocs plugin |
55 | 56 | */ |
56 | 57 | final class WeDocs { |
| 58 | + |
57 | 59 | /** |
58 | 60 | * Plugin version. |
59 | 61 | * |
60 | 62 | * @var string |
61 | 63 | */ |
62 | | - const VERSION = '2.2.1'; |
| 64 | + const VERSION = '2.1.11'; |
63 | 65 |
|
64 | 66 | /** |
65 | 67 | * The plugin url. |
@@ -167,112 +169,19 @@ public function init_actions() { |
167 | 169 |
|
168 | 170 | // Localize our plugin |
169 | 171 | add_action( 'init', [ $this, 'localization_setup' ] ); |
170 | | - add_action( 'init', [ $this, 'register_blocks' ] ); |
171 | | - // add_action('init', [$this, 'register_blocks']); |
172 | | - add_filter('block_categories_all', [$this, 'register_block_category']); |
173 | | - add_filter( 'render_block', [ $this, 'gate_pro_blocks' ], 10, 2 ); |
| 172 | + add_action('init', [$this, 'register_blocks']); |
174 | 173 |
|
175 | 174 | // registeer our widget |
176 | 175 | add_action( 'widgets_init', [ $this, 'register_widget' ] ); |
177 | 176 | } |
178 | 177 |
|
179 | 178 | public function register_blocks() { |
180 | | - // Enqueue admin script early to make weDocsAdminScriptVars available for blocks |
181 | | - wp_enqueue_script( 'wedocs-admin-script' ); |
182 | | - |
183 | | - // Modern WordPress block registration using block.json files |
184 | | - $block_directories = [ |
185 | | - // Free blocks |
186 | | - 'assets/build/blocks/DocsGrid', |
187 | | - 'assets/build/blocks/Breadcrumb', |
188 | | - 'assets/build/blocks/HelpfulFeedback', |
189 | | - 'assets/build/blocks/QuickSearch', |
190 | | - 'assets/build/blocks/PrintButton', |
191 | | - 'assets/build/blocks/DocNavigation', |
192 | | - 'assets/build/blocks/Sidebar', |
193 | | - 'assets/build/blocks/Search', |
194 | | - 'assets/build/blocks/HelpfulModal', |
195 | | - 'assets/build/blocks/LastUpdated', |
196 | | - // Pro blocks — always registered so they appear in the inserter; |
197 | | - // JS handles the pro gate and shows the PRO badge when pro is inactive. |
198 | | - 'assets/build/blocks/TableOfContents', |
199 | | - // 'assets/build/blocks/AdvanceContributors', |
200 | | - 'assets/build/blocks/Contributors', |
201 | | - 'assets/build/blocks/SocialShare', |
202 | | - 'assets/build/blocks/AISummary', |
203 | | - 'assets/build/blocks/DocActions', |
204 | | - 'assets/build/blocks/ReadingProgress', |
205 | | - 'assets/build/blocks/FontSizeSwitcher', |
206 | | - ]; |
207 | | - |
208 | | - |
209 | | - foreach ( $block_directories as $block_dir ) { |
210 | | - $block_path = plugin_dir_path(__FILE__) . $block_dir; |
211 | | - |
212 | | - if ( file_exists( $block_path . '/block.json' ) ) { |
213 | | - |
214 | | - // Register block using block.json (modern approach - render callback is handled by block.json) |
215 | | - register_block_type( $block_path ); |
216 | | - } |
217 | | - } |
218 | | - } |
219 | | - |
220 | | - /** |
221 | | - * Prevent pro-only blocks from rendering on the frontend when weDocs Pro is inactive. |
222 | | - * Covers blocks that use a save() function (static HTML stored in DB). |
223 | | - * |
224 | | - * @param string $block_content Rendered block HTML. |
225 | | - * @param array $block Block data. |
226 | | - * @return string |
227 | | - */ |
228 | | - public function gate_pro_blocks( $block_content, $block ) { |
229 | | - static $pro_active = null; |
230 | | - if ( $pro_active === null ) { |
231 | | - $pro_active = function_exists( 'wedocs_is_pro_active' ) && wedocs_is_pro_active(); |
232 | | - } |
233 | | - |
234 | | - if ( $pro_active ) { |
235 | | - return $block_content; |
236 | | - } |
237 | | - |
238 | | - $pro_blocks = [ |
239 | | - 'wedocs/reading-progress', |
240 | | - 'wedocs/ai-summary', |
241 | | - 'wedocs/doc-actions', |
242 | | - 'wedocs/font-size-switcher', |
243 | | - ]; |
244 | | - |
245 | | - if ( isset( $block['blockName'] ) && in_array( $block['blockName'], $pro_blocks, true ) ) { |
246 | | - return ''; |
247 | | - } |
248 | | - |
249 | | - return $block_content; |
250 | | - } |
251 | | - |
252 | | - /** |
253 | | - * Register the weDocs block category. |
254 | | - * |
255 | | - * @param array $categories Existing block categories. |
256 | | - * @return array Modified block categories. |
257 | | - */ |
258 | | - public function register_block_category($categories) { |
259 | | - // Check if weDocs category already exists |
260 | | - foreach ($categories as $category) { |
261 | | - if ($category['slug'] === 'wedocs') { |
262 | | - return $categories; |
263 | | - } |
264 | | - } |
265 | | - |
266 | | - // Add weDocs category at the beginning |
267 | | - return array_merge( |
268 | | - [ |
269 | | - [ |
270 | | - 'slug' => 'wedocs', |
271 | | - 'title' => __('weDocs', 'wedocs'), |
272 | | - 'icon' => null |
273 | | - ] |
274 | | - ], |
275 | | - $categories |
| 179 | + // Register the DocsGrid block |
| 180 | + register_block_type( |
| 181 | + plugin_dir_path(__FILE__) . 'assets/build/blocks/DocsGrid', |
| 182 | + array( |
| 183 | + 'render_callback' => 'render_wedocs_docs_grid' |
| 184 | + ) |
276 | 185 | ); |
277 | 186 | } |
278 | 187 |
|
@@ -311,17 +220,11 @@ public function init_classes() { |
311 | 220 | $this->container['ajax'] = new WeDevs\WeDocs\Ajax(); |
312 | 221 | } |
313 | 222 |
|
314 | | - $this->container['api'] = new WeDevs\WeDocs\API(); |
315 | | - $this->container['assets'] = new WeDevs\WeDocs\Assets(); |
316 | | - $this->container['migrate'] = new WeDevs\WeDocs\Admin\Migrate(); |
317 | | - $this->container['upgrader'] = new WeDevs\WeDocs\Upgrader\Upgrader(); |
| 223 | + $this->container['api'] = new WeDevs\WeDocs\API(); |
| 224 | + $this->container['assets'] = new WeDevs\WeDocs\Assets(); |
| 225 | + $this->container['migrate'] = new WeDevs\WeDocs\Admin\Migrate(); |
| 226 | + $this->container['upgrader'] = new WeDevs\WeDocs\Upgrader\Upgrader(); |
318 | 227 | $this->container['capability'] = new Capability(); |
319 | | - $this->container['templates'] = new WeDevs\WeDocs\Templates\TemplateManager(); |
320 | | - |
321 | | - // Initialize Elementor integration if Elementor is active |
322 | | - if ( did_action( 'elementor/loaded' ) ) { |
323 | | - $this->container['elementor'] = new WeDevs\WeDocs\Elementor(); |
324 | | - } |
325 | 228 | } |
326 | 229 |
|
327 | 230 | /** |
@@ -409,18 +312,3 @@ function wedocs() { |
409 | 312 |
|
410 | 313 | // kick it off |
411 | 314 | wedocs(); |
412 | | - |
413 | | - |
414 | | -/** |
415 | | - * Dequeue wedocs-pro-frontend-css on non-docs post types |
416 | | - */ |
417 | | -function dequeue_wedocs_pro_frontend_css() { |
418 | | - // Check if we're not on a docs post type |
419 | | - if ( ! is_singular( 'docs' ) && ! is_post_type_archive( 'docs' ) && ! is_tax( array( 'doc_category', 'doc_tag' ) ) ) { |
420 | | - wp_dequeue_style( 'wedocs-pro-frontend-css' ); |
421 | | - wp_deregister_style( 'wedocs-pro-frontend-css' ); |
422 | | - } |
423 | | -} |
424 | | -add_action( 'wp_enqueue_scripts', 'dequeue_wedocs_pro_frontend_css', 20 ); |
425 | | - |
426 | | - |
0 commit comments