PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 1.0.7
Adminify – White Label, Admin Menu Editor, Login Customizer v1.0.7
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
adminify / Inc / Modules / ServerInformation / ServerInfo_Robots_Details.php

ServerInfo_Robots_Details.php in Adminify – White Label, Admin Menu Editor, Login Customizer 1.0.7, at Inc/Modules/ServerInformation/ServerInfo_Robots_Details.php

120 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\ServerInformation;
4
5 use WPAdminify\Inc\Utils;
6
7 // no direct access allowed
8 if (!defined('ABSPATH')) exit;
9
10 /**
11 * WPAdminify
12 * @package Server Information: Robots.txt file
13 *
14 * @author WP Adminify <support@wpadminify.com>
15 */
16
17 class ServerInfo_Robots_Details
18 {
19
20 public function __construct()
21 {
22 $this->init();
23 }
24
25 public function init()
26 {
27 ?>
28
29 <div class="wrap">
30
31 <h1>
32 <?php echo Utils::admin_page_title(esc_html__('Robots.txt File', WP_ADMINIFY_TD)); ?>
33 </h1>
34
35 <p style="color: #ce2754; font-weight: bold">
36 <?php $name = 'robots.txt';
37 printf(wp_kses_post(__('For security reasons you can only read the %1$s file! Please connect to your server and modify the file in a file editor.', WP_ADMINIFY_TD)), $name); ?>
38 </p>
39
40 <p>
41 <strong><?php esc_html_e('To affect your custom configuration in the robots.txt file, you have to save the file in the "root" folder of your WordPress installation.', WP_ADMINIFY_TD); ?></strong>
42 </p>
43
44 <p>
45 <?php esc_html_e("Search Engines read a file at yourdomain.com/robots.txt to get information on what they should and shouldn’t check. Adding entries to robots.txt to help SEO is popular misconception. Google says you are welcome to use robots.txt to block parts of your site but these days prefers you don’t.", WP_ADMINIFY_TD); ?>
46 <br>
47 <a href="https://wordpress.org/support/article/search-engine-optimization/#robots-txt-optimization" target="_blank" rel="noopener"><?php esc_html_e('Learn more about the robots.txt file in WordPress.', WP_ADMINIFY_TD); ?></a>
48 </p>
49 </div>
50
51 <?php
52
53 // Get the wp "robots.txt" file
54 $file = $this->jltwp_adminify_robots_txt_file();
55
56 // Get the wp "robots.txt" file content
57 $file_content = $this->jltwp_adminify_robots_txt_file_content($file);
58
59 if ($file) { ?>
60 <p>
61 <?php echo esc_html__('robots.txt file was found at:', WP_ADMINIFY_TD) . ' <strong>' . esc_html($file) . '</strong>'; ?>
62 <br>
63 </p>
64 <?php } ?>
65
66 <textarea id="robots_log_area" class="adminify-info-text-area" readonly><?php echo esc_html($file_content); ?></textarea>
67
68
69
70 <?php
71 }
72
73
74 function jltwp_adminify_robots_txt_file()
75 {
76
77 // Call wp file system
78 global $wp_filesystem;
79 WP_Filesystem();
80
81 // Get the path of wp "robots.txt" file
82 $file = get_home_path() . 'robots.txt';
83
84 // Check if "robots.txt" file exist
85 if (
86 $wp_filesystem->exists($file)
87 ) {
88 return $file;
89 }
90
91 // File not exist
92 return false;
93 }
94
95
96
97 function jltwp_adminify_robots_txt_file_content($file)
98 {
99
100 // Call wp file system
101 global $wp_filesystem;
102 WP_Filesystem();
103
104 // Show this notice, if no file exist
105 $content = esc_html__('robots.txt file not found!', WP_ADMINIFY_TD);
106
107 // Check if "robots.txt" file exist
108 if ($wp_filesystem->exists($file)) {
109 $content = $wp_filesystem->get_contents($file);
110
111 // Check if the file content is empty
112 if ($wp_filesystem->get_contents($file) == '') {
113 $content = esc_html__('File content is empty.', WP_ADMINIFY_TD);
114 }
115 }
116
117 return $content;
118 }
119 }
120