Skip to content

Commit 6abe74c

Browse files
remove: obfuscated code
1 parent 67976d5 commit 6abe74c

2 files changed

Lines changed: 16 additions & 131 deletions

File tree

tailwind.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ module.exports = {
2323
require( 'daisyui' ),
2424
require( '@tailwindcss/forms' )
2525
],
26-
};
27-
26+
};

wedocs.php

Lines changed: 15 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: weDocs
44
Plugin URI: https://wedocs.co/
55
Description: A documentation plugin for WordPress
6-
Version: 2.2.1
6+
Version: 2.1.11
77
Author: weDevs
88
Author URI: https://wedocs.co/?utm_source=wporg&utm_medium=banner&utm_campaign=author-uri
99
License: GPL2
@@ -46,21 +46,21 @@
4646
}
4747

4848
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';
5150

5251
/**
5352
* WeDocs class.
5453
*
5554
* @class WeDocs The class that holds the entire WeDocs plugin
5655
*/
5756
final class WeDocs {
57+
5858
/**
5959
* Plugin version.
6060
*
6161
* @var string
6262
*/
63-
const VERSION = '2.2.1';
63+
const VERSION = '2.1.11';
6464

6565
/**
6666
* The plugin url.
@@ -168,112 +168,19 @@ public function init_actions() {
168168

169169
// Localize our plugin
170170
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']);
175172

176173
// registeer our widget
177174
add_action( 'widgets_init', [ $this, 'register_widget' ] );
178175
}
179176

180177
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+
)
277184
);
278185
}
279186

@@ -312,17 +219,11 @@ public function init_classes() {
312219
$this->container['ajax'] = new WeDevs\WeDocs\Ajax();
313220
}
314221

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();
319226
$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-
}
326227
}
327228

328229
/**
@@ -410,18 +311,3 @@ function wedocs() {
410311

411312
// kick it off
412313
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

Comments
 (0)