| @@ -31,11 +31,14 @@ | ||
| 31 | 31 | use WPDeveloper\BetterDocs\Dependencies\DI\Container; |
| 32 | 32 | use WPDeveloper\BetterDocs\Dependencies\DI\ContainerBuilder; |
| 33 | 33 | use WPDeveloper\BetterDocs\Editors\Editor; |
| 34 | 34 | use WPDeveloper\BetterDocs\FrontEnd\FrontEnd; |
| 35 | +use WPDeveloper\BetterDocs\FrontEnd\PrintTemplate; | |
| 35 | 36 | use WPDeveloper\BetterDocs\FrontEnd\SearchExtender; |
| 36 | 37 | use WPDeveloper\BetterDocs\FrontEnd\TemplateTags; |
| 37 | 38 | use WPDeveloper\BetterDocs\FrontEnd\WooProductFAQ; |
| 39 | +use WPDeveloper\BetterDocs\Abilities\AbilitiesRegistrar; | |
| 40 | +use WPDeveloper\BetterDocs\Mcp\MCPManager; | |
| 38 | 41 | use WPDeveloper\BetterDocs\Modules\StyleHandler as ModulesStyleHandler; |
| 39 | 42 | use WPDeveloper\BetterDocs\Utils\Database; |
| 40 | 43 | use WPDeveloper\BetterDocs\Utils\Enqueue; |
| 41 | 44 | use WPDeveloper\BetterDocs\Utils\Helper; |
| @@ -129,9 +132,9 @@ | ||
| 129 | 132 | /** |
| 130 | 133 | * Plugin Version |
| 131 | 134 | * @var string |
| 132 | 135 | */ |
| 133 | - public $version = '4.8.2'; | |
| 136 | + public $version = '4.9.2'; | |
| 134 | 137 | |
| 135 | 138 | /** |
| 136 | 139 | * WriteWithAI Class |
| 137 | 140 | * @var string |
| @@ -148,9 +151,9 @@ | ||
| 148 | 151 | /** |
| 149 | 152 | * Plugin DB Version |
| 150 | 153 | * @var string |
| 151 | 154 | */ |
| 152 | - public $db_version = '1.0.2'; | |
| 155 | + public $db_version = '1.0.3'; | |
| 153 | 156 | |
| 154 | 157 | public function __construct() { |
| 155 | 158 | $this->define_constants(); |
| 156 | 159 | |
| @@ -162,8 +165,21 @@ | ||
| 162 | 165 | * and version updates check |
| 163 | 166 | */ |
| 164 | 167 | $this->container->get( Install::class ); |
| 165 | 168 | |
| 169 | + /** | |
| 170 | + * Abilities API registrar. | |
| 171 | + * | |
| 172 | + * Resolved here, at plugin load, and not from initialize(): both the | |
| 173 | + * bundled Abilities API and WordPress core's build their registry as a | |
| 174 | + * lazy singleton and fire `wp_abilities_api_init` from it, at or after | |
| 175 | + * `init`, the first time anything reads the registry. Our listeners | |
| 176 | + * therefore have to be attached before that first read, whenever it | |
| 177 | + * happens — and a container resolve on `init` would already be too late | |
| 178 | + * for a plugin that reads the registry earlier in the same hook. | |
| 179 | + */ | |
| 180 | + $this->container->get( AbilitiesRegistrar::class ); | |
| 181 | + | |
| 166 | 182 | add_action( 'init', array( $this, 'initialize' ), 0 ); |
| 167 | 183 | |
| 168 | 184 | /** |
| 169 | 185 | * Initialize API |
| @@ -280,8 +296,17 @@ | ||
| 280 | 296 | $this->container->get( DocsAISuite::class ); |
| 281 | 297 | |
| 282 | 298 | $this->container->get( Admin::class ); |
| 283 | 299 | $this->container->get( Roles::class ); |
| 300 | + | |
| 301 | + /** | |
| 302 | + * MCP transport: rewrite rules, the pretty endpoint, OAuth discovery | |
| 303 | + * and every REST route. Resolved here rather than at plugin load | |
| 304 | + * (where the abilities registrar has to be) because its earliest hook | |
| 305 | + * is `init`, which is what this method already runs on. | |
| 306 | + */ | |
| 307 | + $this->container->get( MCPManager::class ); | |
| 308 | + | |
| 284 | 309 | $this->container->get( ReportEmail::class ); |
| 285 | 310 | // Usage-analytics collector. Registered here (runs on every request, incl. |
| 286 | 311 | // WP-Cron) rather than in Admin so its `betterdocs_insights_data` filter |
| 287 | 312 | // callback is present whenever the tracking payload is built. |
| @@ -294,8 +319,13 @@ | ||
| 294 | 319 | |
| 295 | 320 | $this->container->get( FrontEnd::class ); |
| 296 | 321 | $this->container->get( SearchExtender::class ); |
| 297 | 322 | |
| 323 | + // Running logo header / page footer for the browser's own Print command. | |
| 324 | + // Registered unconditionally: it covers every front-end page, including | |
| 325 | + // the ones that carry no BetterDocs print button. | |
| 326 | + $this->container->get( PrintTemplate::class ); | |
| 327 | + | |
| 298 | 328 | /** |
| 299 | 329 | * Single-product FAQ rendering (WooCommerce). The class itself bails when |
| 300 | 330 | * WooCommerce is inactive or the feature is disabled. |
| 301 | 331 | */ |
| @@ -454,8 +484,63 @@ | ||
| 454 | 484 | public function show_api_docs_teaser() { |
| 455 | 485 | return ! $this->is_pro_active() && ! $this->has_api_docs(); |
| 456 | 486 | } |
| 457 | 487 | |
| 488 | + /** | |
| 489 | + * Whether the real Glossaries screen is available (i.e. Pro is licensing it). | |
| 490 | + * | |
| 491 | + * Glossaries ships in Free's code but is Pro-licensed, so unlike API Docs there | |
| 492 | + * is no separate Pro class to detect — the gate is simply Pro being active. Kept | |
| 493 | + * behind a filter so Pro/add-ons can flip it explicitly, mirroring | |
| 494 | + * `betterdocs_pro_has_api_docs`. | |
| 495 | + * | |
| 496 | + * @return bool | |
| 497 | + */ | |
| 498 | + public function has_glossaries() { | |
| 499 | + return (bool) apply_filters( 'betterdocs_pro_has_glossaries', $this->is_pro_active() ); | |
| 500 | + } | |
| 501 | + | |
| 502 | + /** | |
| 503 | + * Whether Free should show its locked Glossaries teaser. | |
| 504 | + * | |
| 505 | + * Only without Pro — an active Pro either has the feature or has simply left it | |
| 506 | + * disabled in settings; neither case wants an upsell. Mirrors | |
| 507 | + * show_api_docs_teaser(). | |
| 508 | + * | |
| 509 | + * @return bool | |
| 510 | + */ | |
| 511 | + public function show_glossary_teaser() { | |
| 512 | + return ! $this->is_pro_active() && ! $this->has_glossaries(); | |
| 513 | + } | |
| 514 | + | |
| 515 | + /** | |
| 516 | + * Whether Pro provides the real Content Intelligence screen. | |
| 517 | + * | |
| 518 | + * Pro flips this via `betterdocs_pro_has_content_intelligence`; the | |
| 519 | + * class_exists() default keeps the gate correct against a Pro build that | |
| 520 | + * predates that filter. | |
| 521 | + * | |
| 522 | + * @return bool | |
| 523 | + */ | |
| 524 | + public function has_content_intelligence() { | |
| 525 | + return (bool) apply_filters( | |
| 526 | + 'betterdocs_pro_has_content_intelligence', | |
| 527 | + class_exists( '\\WPDeveloper\\BetterDocsPro\\Core\\ContentIntelligenceService' ) | |
| 528 | + ); | |
| 529 | + } | |
| 530 | + | |
| 531 | + /** | |
| 532 | + * Whether Free should show its locked Content Intelligence teaser. | |
| 533 | + * | |
| 534 | + * Only without Pro. An older Pro has already paid, so they get nothing here — | |
| 535 | + * they need a plugin update, not an upsell. | |
| 536 | + * | |
| 537 | + * @return bool | |
| 538 | + */ | |
| 539 | + public function show_content_intelligence_teaser() { | |
| 540 | + return ! $this->is_pro_active() && ! $this->has_content_intelligence(); | |
| 541 | + } | |
| 542 | + | |
| 458 | 543 | public function pro_version() { |
| 459 | 544 | if ( ! $this->is_pro_active() ) { |
| 460 | 545 | return false; |
| 461 | 546 | } |
| @@ -507,9 +592,11 @@ | ||
| 507 | 592 | 'toplevel_page_betterdocs-admin', |
| 508 | 593 | 'admin_page_betterdocs-admin', |
| 509 | 594 | 'betterdocs_page_betterdocs-admin', |
| 510 | 595 | 'betterdocs_page_betterdocs-analytics', |
| 596 | + 'betterdocs_page_betterdocs-content-iq', | |
| 511 | 597 | 'betterdocs_page_betterdocs-settings', |
| 598 | + 'betterdocs_page_betterdocs-mcp', | |
| 512 | 599 | 'betterdocs_page_betterdocs-faq', |
| 513 | 600 | 'betterdocs_page_betterdocs-glossaries', |
| 514 | 601 | 'betterdocs_page_betterdocs-ai-chatbot', |
| 515 | 602 | 'betterdocs_page_betterdocs-api-docs', |
| @@ -533,8 +620,9 @@ | ||
| 533 | 620 | 'toplevel_page_betterdocs-dashboard', |
| 534 | 621 | 'admin_page_betterdocs-admin', |
| 535 | 622 | 'betterdocs_page_betterdocs-admin', |
| 536 | 623 | 'betterdocs_page_betterdocs-settings', |
| 624 | + 'betterdocs_page_betterdocs-mcp', | |
| 537 | 625 | 'betterdocs_page_betterdocs-analytics', |
| 538 | 626 | 'betterdocs_page_betterdocs-faq', |
| 539 | 627 | 'betterdocs_page_betterdocs-glossaries', |
| 540 | 628 | 'betterdocs_page_betterdocs-ai-chatbot', |