|
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. |
@@ -169,112 +171,19 @@ public function init_actions() { |
169 | 171 |
|
170 | 172 | // Localize our plugin |
171 | 173 | add_action( 'init', [ $this, 'localization_setup' ] ); |
172 | | - add_action( 'init', [ $this, 'register_blocks' ] ); |
173 | | - // add_action('init', [$this, 'register_blocks']); |
174 | | - add_filter('block_categories_all', [$this, 'register_block_category']); |
175 | | - add_filter( 'render_block', [ $this, 'gate_pro_blocks' ], 10, 2 ); |
| 174 | + add_action('init', [$this, 'register_blocks']); |
176 | 175 |
|
177 | 176 | // registeer our widget |
178 | 177 | add_action( 'widgets_init', [ $this, 'register_widget' ] ); |
179 | 178 | } |
180 | 179 |
|
181 | 180 | public function register_blocks() { |
182 | | - // Enqueue admin script early to make weDocsAdminScriptVars available for blocks |
183 | | - wp_enqueue_script( 'wedocs-admin-script' ); |
184 | | - |
185 | | - // Modern WordPress block registration using block.json files |
186 | | - $block_directories = [ |
187 | | - // Free blocks |
188 | | - 'assets/build/blocks/DocsGrid', |
189 | | - 'assets/build/blocks/Breadcrumb', |
190 | | - 'assets/build/blocks/HelpfulFeedback', |
191 | | - 'assets/build/blocks/QuickSearch', |
192 | | - 'assets/build/blocks/PrintButton', |
193 | | - 'assets/build/blocks/DocNavigation', |
194 | | - 'assets/build/blocks/Sidebar', |
195 | | - 'assets/build/blocks/Search', |
196 | | - 'assets/build/blocks/HelpfulModal', |
197 | | - 'assets/build/blocks/LastUpdated', |
198 | | - // Pro blocks — always registered so they appear in the inserter; |
199 | | - // JS handles the pro gate and shows the PRO badge when pro is inactive. |
200 | | - 'assets/build/blocks/TableOfContents', |
201 | | - // 'assets/build/blocks/AdvanceContributors', |
202 | | - 'assets/build/blocks/Contributors', |
203 | | - 'assets/build/blocks/SocialShare', |
204 | | - 'assets/build/blocks/AISummary', |
205 | | - 'assets/build/blocks/DocActions', |
206 | | - 'assets/build/blocks/ReadingProgress', |
207 | | - 'assets/build/blocks/FontSizeSwitcher', |
208 | | - ]; |
209 | | - |
210 | | - |
211 | | - foreach ( $block_directories as $block_dir ) { |
212 | | - $block_path = plugin_dir_path(__FILE__) . $block_dir; |
213 | | - |
214 | | - if ( file_exists( $block_path . '/block.json' ) ) { |
215 | | - |
216 | | - // Register block using block.json (modern approach - render callback is handled by block.json) |
217 | | - register_block_type( $block_path ); |
218 | | - } |
219 | | - } |
220 | | - } |
221 | | - |
222 | | - /** |
223 | | - * Prevent pro-only blocks from rendering on the frontend when weDocs Pro is inactive. |
224 | | - * Covers blocks that use a save() function (static HTML stored in DB). |
225 | | - * |
226 | | - * @param string $block_content Rendered block HTML. |
227 | | - * @param array $block Block data. |
228 | | - * @return string |
229 | | - */ |
230 | | - public function gate_pro_blocks( $block_content, $block ) { |
231 | | - static $pro_active = null; |
232 | | - if ( $pro_active === null ) { |
233 | | - $pro_active = function_exists( 'wedocs_is_pro_active' ) && wedocs_is_pro_active(); |
234 | | - } |
235 | | - |
236 | | - if ( $pro_active ) { |
237 | | - return $block_content; |
238 | | - } |
239 | | - |
240 | | - $pro_blocks = [ |
241 | | - 'wedocs/reading-progress', |
242 | | - 'wedocs/ai-summary', |
243 | | - 'wedocs/doc-actions', |
244 | | - 'wedocs/font-size-switcher', |
245 | | - ]; |
246 | | - |
247 | | - if ( isset( $block['blockName'] ) && in_array( $block['blockName'], $pro_blocks, true ) ) { |
248 | | - return ''; |
249 | | - } |
250 | | - |
251 | | - return $block_content; |
252 | | - } |
253 | | - |
254 | | - /** |
255 | | - * Register the weDocs block category. |
256 | | - * |
257 | | - * @param array $categories Existing block categories. |
258 | | - * @return array Modified block categories. |
259 | | - */ |
260 | | - public function register_block_category($categories) { |
261 | | - // Check if weDocs category already exists |
262 | | - foreach ($categories as $category) { |
263 | | - if ($category['slug'] === 'wedocs') { |
264 | | - return $categories; |
265 | | - } |
266 | | - } |
267 | | - |
268 | | - // Add weDocs category at the beginning |
269 | | - return array_merge( |
270 | | - [ |
271 | | - [ |
272 | | - 'slug' => 'wedocs', |
273 | | - 'title' => __('weDocs', 'wedocs'), |
274 | | - 'icon' => null |
275 | | - ] |
276 | | - ], |
277 | | - $categories |
| 181 | + // Register the DocsGrid block |
| 182 | + register_block_type( |
| 183 | + plugin_dir_path(__FILE__) . 'assets/build/blocks/DocsGrid', |
| 184 | + array( |
| 185 | + 'render_callback' => 'render_wedocs_docs_grid' |
| 186 | + ) |
278 | 187 | ); |
279 | 188 | } |
280 | 189 |
|
@@ -329,10 +238,10 @@ public function init_classes() { |
329 | 238 | $this->container['ajax'] = new WeDevs\WeDocs\Ajax(); |
330 | 239 | } |
331 | 240 |
|
332 | | - $this->container['api'] = new WeDevs\WeDocs\API(); |
333 | | - $this->container['assets'] = new WeDevs\WeDocs\Assets(); |
334 | | - $this->container['migrate'] = new WeDevs\WeDocs\Admin\Migrate(); |
335 | | - $this->container['upgrader'] = new WeDevs\WeDocs\Upgrader\Upgrader(); |
| 241 | + $this->container['api'] = new WeDevs\WeDocs\API(); |
| 242 | + $this->container['assets'] = new WeDevs\WeDocs\Assets(); |
| 243 | + $this->container['migrate'] = new WeDevs\WeDocs\Admin\Migrate(); |
| 244 | + $this->container['upgrader'] = new WeDevs\WeDocs\Upgrader\Upgrader(); |
336 | 245 | $this->container['capability'] = new Capability(); |
337 | 246 | $this->container['templates'] = new WeDevs\WeDocs\Templates\TemplateManager(); |
338 | 247 | $this->container['privacy'] = new WeDevs\WeDocs\Privacy(); |
@@ -428,18 +337,3 @@ function wedocs() { |
428 | 337 |
|
429 | 338 | // kick it off |
430 | 339 | wedocs(); |
431 | | - |
432 | | - |
433 | | -/** |
434 | | - * Dequeue wedocs-pro-frontend-css on non-docs post types |
435 | | - */ |
436 | | -function dequeue_wedocs_pro_frontend_css() { |
437 | | - // Check if we're not on a docs post type |
438 | | - if ( ! is_singular( 'docs' ) && ! is_post_type_archive( 'docs' ) && ! is_tax( array( 'doc_category', 'doc_tag' ) ) ) { |
439 | | - wp_dequeue_style( 'wedocs-pro-frontend-css' ); |
440 | | - wp_deregister_style( 'wedocs-pro-frontend-css' ); |
441 | | - } |
442 | | -} |
443 | | -add_action( 'wp_enqueue_scripts', 'dequeue_wedocs_pro_frontend_css', 20 ); |
444 | | - |
445 | | - |
0 commit comments