PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.10
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.10
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 4.2.10, at Inc/Modules/ServerInformation/ServerInfo_Robots_Details.php

123 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Modules\ServerInformation;
4
5 use PXLBSAdminify\Inc\Utils;
6
7 // no direct access allowed
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * PXLBSAdminify
14 *
15 * @package Server Information: Robots.txt file
16 *
17 * @author WP Adminify <support@wpadminify.com>
18 */
19
20 class ServerInfo_Robots_Details {
21
22
23 public function __construct() {
24 $this->init();
25 }
26
27 public function init() {
28 ?>
29
30 <div class="wrap">
31
32 <h1>
33 <?php echo wp_kses_post( Utils::admin_page_title( esc_html__( 'Robots.txt File', 'adminify' ) ) ); ?>
34 </h1>
35
36 <p style="color: #ce2754; font-weight: bold">
37 <?php
38 $name = 'robots.txt';
39 /* translators: %s: File name */
40 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.', 'adminify' ) ), esc_html( $name ) );
41 ?>
42 </p>
43
44 <p>
45 <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.', 'adminify' ); ?></strong>
46 </p>
47
48 <p>
49 <?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.', 'adminify' ); ?>
50 <br>
51 <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.', 'adminify' ); ?></a>
52 </p>
53 </div>
54
55 <?php
56
57 // Get the wp "robots.txt" file
58 $file = $this->robots_txt_file();
59
60 // Get the wp "robots.txt" file content
61 $file_content = $this->robots_txt_file_content( $file );
62
63 if ( $file ) {
64 ?>
65 <p>
66 <?php echo esc_html__( 'robots.txt file was found at:', 'adminify' ) . ' <strong>' . esc_html( $file ) . '</strong>'; ?>
67 <br>
68 </p>
69 <?php } ?>
70
71 <textarea id="robots_log_area" class="adminify-info-text-area" readonly><?php echo esc_html( $file_content ); ?></textarea>
72
73
74
75 <?php
76 }
77
78
79 function robots_txt_file() {
80
81 // Call wp file system
82 global $wp_filesystem;
83 WP_Filesystem();
84
85 // Get the path of wp "robots.txt" file
86 $file = get_home_path() . 'robots.txt';
87
88 // Check if "robots.txt" file exist
89 if (
90 $wp_filesystem->exists( $file )
91 ) {
92 return $file;
93 }
94
95 // File not exist
96 return false;
97 }
98
99
100
101 function robots_txt_file_content( $file ) {
102
103 // Call wp file system
104 global $wp_filesystem;
105 WP_Filesystem();
106
107 // Show this notice, if no file exist
108 $content = esc_html__( 'robots.txt file not found!', 'adminify' );
109
110 // Check if "robots.txt" file exist
111 if ( $wp_filesystem->exists( $file ) ) {
112 $content = $wp_filesystem->get_contents( $file );
113
114 // Check if the file content is empty
115 if ( $wp_filesystem->get_contents( $file ) == '' ) {
116 $content = esc_html__( 'File content is empty.', 'adminify' );
117 }
118 }
119
120 return $content;
121 }
122 }
123