PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / integrations / class-smartcrawl.php

class-smartcrawl.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at src/integrations/class-smartcrawl.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles interactions with SmartCrawl SEO.
4 *
5 * @package WP_Defender\Integrations
6 */
7
8 namespace WP_Defender\Integrations;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 die;
12 }
13
14 /**
15 * SmartCrawl integration module.
16 *
17 * @since 5.8.0
18 */
19 class Smartcrawl {
20
21 /**
22 * Check if SmartCrawl plugin is active.
23 *
24 * @return bool True if SmartCrawl is active, false otherwise.
25 */
26 public function is_activated(): bool {
27 if ( ! function_exists( 'is_plugin_active' ) ) {
28 require_once ABSPATH . 'wp-admin/includes/plugin.php';
29 }
30
31 return class_exists( '\SmartCrawl\Modules\Advanced\Robots\Controller' ) ||
32 function_exists( 'smartcrawl_get_robots_url' ) ||
33 is_plugin_active( 'smartcrawl-seo/wpmu-dev-seo.php' );
34 }
35
36 /**
37 * Check if we should use SmartCrawl's filter instead of direct injection.
38 *
39 * SmartCrawl will serve robots.txt only when ALL conditions are met:
40 * 1. Plugin is loaded (class exists)
41 * 2. Robots.txt module is enabled in settings
42 * 3. No physical robots.txt file exists
43 * 4. Site is in root directory (not a subdirectory install)
44 *
45 * @return bool True if SmartCrawl will actually serve robots.txt, false otherwise.
46 */
47 public function should_serve_robots(): bool {
48 // Quick check: SmartCrawl controller class must exist.
49 if ( ! class_exists( '\SmartCrawl\Modules\Advanced\Robots\Controller' ) ) {
50 return false;
51 }
52
53 // Let SmartCrawl's own logic determine if it will serve robots.txt.
54 // This checks: module enabled, no physical file, root directory, etc.
55 $sc_controller = \SmartCrawl\Modules\Advanced\Robots\Controller::get();
56
57 return $sc_controller->should_run();
58 }
59
60 /**
61 * Get SmartCrawl's robots.txt content.
62 *
63 * @return string The robots.txt content from SmartCrawl, or empty string if unavailable.
64 */
65 public function get_robots_content(): string {
66 if ( ! class_exists( '\SmartCrawl\Modules\Advanced\Robots\Controller' ) ) {
67 return '';
68 }
69
70 $sc_controller = \SmartCrawl\Modules\Advanced\Robots\Controller::get();
71
72 return $sc_controller->get_content();
73 }
74 }
75