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