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_Htaccess_Details.php

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

131 lines 3.9 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\Classes\ServerInfo;
6 use PXLBSAdminify\Inc\Utils;
7
8 // no direct access allowed
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * PXLBSAdminify
15 *
16 * @package Server Information
17 *
18 * @author WP Adminify <support@wpadminify.com>
19 */
20
21 class ServerInfo_Htaccess_Details {
22
23
24 public function __construct() {
25 $this->init();
26 }
27
28 public function init() {
29 $server_info = new ServerInfo();
30
31 $help = '<span class="dashicons dashicons-editor-help"></span>';
32 $enabled = '<span class="adminify-compability enable"><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Enabled', 'adminify' ) . '</span>';
33 $disabled = '<span class="adminify-compability disable"><span class="dashicons dashicons-no"></span> ' . esc_html__( 'Disabled', 'adminify' ) . '</span>';
34 $yes = '<span class="adminify-compability enable"><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Yes', 'adminify' ) . '</span>';
35 $no = '<span class="adminify-compability disable"><span class="dashicons dashicons-no"></span> ' . esc_html__( 'No', 'adminify' ) . '</span>';
36 $entered = '<span class="adminify-compability enable"><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Defined', 'adminify' ) . '</span>';
37 $not_entered = '<span class="adminify-compability disable"><span class="dashicons dashicons-no"></span> ' . esc_html__( 'Not defined', 'adminify' ) . '</span>';
38 $sec_key = '<span class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Please enter this security key in the wp-confiq.php file', 'adminify' ) . '!</span>';
39 ?>
40 <div class="wrap">
41 <h1>
42 <?php echo wp_kses_post( Utils::admin_page_title( esc_html__( '.htaccess file', 'adminify' ) ) ); ?>
43 </h1>
44 </div>
45
46 <p style="color: #ce2754; font-weight: bold">
47 <?php
48 $name = '.htaccess';
49 /* translators: %s: File name */
50 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 ) );
51 ?>
52 </p>
53
54 <p>
55 <?php esc_html_e( 'The .htaccess is a distributed configuration file, and is how Apache server handles configuration changes on a per-directory basis.', 'adminify' ); ?>
56 <br>
57 <a href="https://wordpress.org/support/article/htaccess/" target="_blank" rel="noopener"><?php esc_html_e( 'Learn more about the .htaccess file in WordPress.', 'adminify' ); ?></a>
58 </p>
59
60 <?php
61
62 // Get the wp ".htaccess" file
63 $file = $this->htaccess_file();
64
65 // Get the wp ".htaccess" file content
66 $file_content = $this->htaccess_file_content( $file );
67
68 if ( $file ) {
69 ?>
70 <p>
71 <?php echo esc_html__( '.htaccess file was found at:', 'adminify' ) . ' <strong>' . esc_html( $file ) . '</strong>'; ?>
72 <br>
73 </p>
74 <?php } ?>
75
76 <textarea id="htaccess_log_area" class="adminify-info-text-area" readonly><?php echo esc_html( $file_content ); ?></textarea>
77
78 <?php
79 }
80
81
82 /**
83 * htaccess file
84 */
85 public function htaccess_file() {
86
87 // Call wp file system
88 global $wp_filesystem;
89 WP_Filesystem();
90
91 // Get the path of wp ".htaccess" file
92 $file = get_home_path() . '.htaccess';
93
94 // Check if ".htaccess" file exist
95 if (
96 $wp_filesystem->exists( $file )
97 ) {
98 return $file;
99 }
100
101 // File not exist
102 return false;
103 }
104
105 /**
106 * .htaccess file contents
107 */
108
109 public function htaccess_file_content( $file ) {
110
111 // Call wp file system
112 global $wp_filesystem;
113 WP_Filesystem();
114
115 // Show this notice, if no file exist
116 $content = esc_html__( '.htaccess file not found!', 'adminify' );
117
118 // Check if ".htaccess" file exist
119 if ( $wp_filesystem->exists( $file ) ) {
120 $content = $wp_filesystem->get_contents( $file );
121
122 // Check if the file content is empty
123 if ( $wp_filesystem->get_contents( $file ) == '' ) {
124 $content = esc_html__( 'File content is empty.', 'adminify' );
125 }
126 }
127
128 return $content;
129 }
130 }
131