| @@ -3,13 +3,8 @@ | ||
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | 5 | use Elementor\Modules\System_Info\Reporters\Base; |
| 6 | 6 | use Elementor\Modules\System_Info\Helpers\Model_Helper; |
| 7 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 8 | -use Elementor\Modules\System_Info\AdminMenuItems\Editor_One_System_Info_Menu; | |
| 9 | -use Elementor\Modules\System_Info\AdminMenuItems\Editor_One_System_Menu; | |
| 10 | -use Elementor\Plugin; | |
| 11 | -use Elementor\Settings; | |
| 12 | 7 | |
| 13 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 9 | exit; // Exit if accessed directly. |
| 15 | 10 | } |
| @@ -22,9 +17,8 @@ | ||
| 22 | 17 | * |
| 23 | 18 | * @since 2.9.0 |
| 24 | 19 | */ |
| 25 | 20 | class Module extends BaseModule { |
| 26 | - | |
| 27 | 21 | /** |
| 28 | 22 | * Get module name. |
| 29 | 23 | * |
| 30 | 24 | * Retrieve the system info module name. |
| @@ -69,12 +63,8 @@ | ||
| 69 | 63 | 'network_plugins' => [], |
| 70 | 64 | 'mu_plugins' => [], |
| 71 | 65 | ]; |
| 72 | 66 | |
| 73 | - public function get_capability() { | |
| 74 | - return $this->capability; | |
| 75 | - } | |
| 76 | - | |
| 77 | 67 | /** |
| 78 | 68 | * Main system info page constructor. |
| 79 | 69 | * |
| 80 | 70 | * Initializing Elementor system info page. |
| @@ -119,18 +109,33 @@ | ||
| 119 | 109 | * @since 2.9.0 |
| 120 | 110 | * @access private |
| 121 | 111 | */ |
| 122 | 112 | private function add_actions() { |
| 123 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 124 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 125 | - } ); | |
| 126 | - | |
| 113 | + add_action( 'admin_menu', [ $this, 'register_menu' ], 500 ); | |
| 127 | 114 | add_action( 'wp_ajax_elementor_system_info_download_file', [ $this, 'download_file' ] ); |
| 128 | 115 | } |
| 129 | 116 | |
| 130 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 131 | - $menu_data_provider->register_menu( new Editor_One_System_Menu() ); | |
| 132 | - $menu_data_provider->register_menu( new Editor_One_System_Info_Menu() ); | |
| 117 | + /** | |
| 118 | + * Register admin menu. | |
| 119 | + * | |
| 120 | + * Add new Elementor system info admin menu. | |
| 121 | + * | |
| 122 | + * Fired by `admin_menu` action. | |
| 123 | + * | |
| 124 | + * @since 2.9.0 | |
| 125 | + * @access public | |
| 126 | + */ | |
| 127 | + public function register_menu() { | |
| 128 | + $system_info_text = esc_html__( 'System Info', 'elementor' ); | |
| 129 | + | |
| 130 | + add_submenu_page( | |
| 131 | + 'elementor', | |
| 132 | + $system_info_text, | |
| 133 | + $system_info_text, | |
| 134 | + $this->capability, | |
| 135 | + 'elementor-system-info', | |
| 136 | + [ $this, 'display_page' ] | |
| 137 | + ); | |
| 133 | 138 | } |
| 134 | 139 | |
| 135 | 140 | /** |
| 136 | 141 | * Display page. |
| @@ -142,18 +147,15 @@ | ||
| 142 | 147 | */ |
| 143 | 148 | public function display_page() { |
| 144 | 149 | $reports_info = self::get_allowed_reports(); |
| 145 | 150 | |
| 146 | - $reports = $this->load_reports( $reports_info ); | |
| 151 | + $reports = $this->load_reports( $reports_info, 'html' ); | |
| 152 | + | |
| 153 | + $raw_reports = $this->load_reports( $reports_info, 'raw' ); | |
| 154 | + | |
| 147 | 155 | ?> |
| 148 | 156 | <div id="elementor-system-info"> |
| 149 | - <div class="elementor-system-info-header"> | |
| 150 | - <h3 class="wp-heading-inline"><?php echo esc_html__( 'System Info', 'elementor' ); ?></h3> | |
| 151 | - <form action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> | |
| 152 | - <input type="hidden" name="action" value="elementor_system_info_download_file"> | |
| 153 | - <input type="submit" data-id="elementor-system-info-download-file" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 154 | - </form> | |
| 155 | - </div> | |
| 157 | + <h3 class="wp-heading-inline"><?php echo esc_html__( 'System Info', 'elementor' ); ?></h3> | |
| 156 | 158 | <div><?php $this->print_report( $reports, 'html' ); ?></div> |
| 157 | 159 | <h3><?php echo esc_html__( 'Copy & Paste Info', 'elementor' ); ?></h3> |
| 158 | 160 | <div id="elementor-system-info-raw"> |
| 159 | 161 | <label id="elementor-system-info-raw-code-label" for="elementor-system-info-raw-code"><?php echo esc_html__( 'You can copy the below info as simple text with Ctrl+C / Ctrl+V:', 'elementor' ); ?></label> |
| @@ -158,9 +160,11 @@ | ||
| 158 | 160 | <div id="elementor-system-info-raw"> |
| 159 | 161 | <label id="elementor-system-info-raw-code-label" for="elementor-system-info-raw-code"><?php echo esc_html__( 'You can copy the below info as simple text with Ctrl+C / Ctrl+V:', 'elementor' ); ?></label> |
| 160 | 162 | <textarea id="elementor-system-info-raw-code" readonly> |
| 161 | 163 | <?php |
| 162 | - $this->print_report( $reports, 'raw' ); | |
| 164 | + unset( $raw_reports['wordpress']['report']['admin_email'] ); | |
| 165 | + | |
| 166 | + $this->print_report( $raw_reports, 'raw' ); | |
| 163 | 167 | ?> |
| 164 | 168 | </textarea> |
| 165 | 169 | <script> |
| 166 | 170 | var textarea = document.getElementById( 'elementor-system-info-raw-code' ); |
| @@ -173,9 +177,9 @@ | ||
| 173 | 177 | </div> |
| 174 | 178 | <hr> |
| 175 | 179 | <form action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> |
| 176 | 180 | <input type="hidden" name="action" value="elementor_system_info_download_file"> |
| 177 | - <input type="submit" data-id="elementor-system-info-download-file" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 181 | + <input type="submit" class="button button-primary" value="<?php echo esc_html__( 'Download System Info', 'elementor' ); ?>"> | |
| 178 | 182 | </form> |
| 179 | 183 | </div> |
| 180 | 184 | <?php |
| 181 | 185 | } |
| @@ -191,13 +195,13 @@ | ||
| 191 | 195 | * @access public |
| 192 | 196 | */ |
| 193 | 197 | public function download_file() { |
| 194 | 198 | if ( ! current_user_can( $this->capability ) ) { |
| 195 | - wp_die( esc_html__( 'You do not have permission to download this file.', 'elementor' ) ); | |
| 199 | + wp_die( esc_html__( 'You don\'t have permissions to download this file', 'elementor' ) ); | |
| 196 | 200 | } |
| 197 | 201 | |
| 198 | 202 | $reports_info = self::get_allowed_reports(); |
| 199 | - $reports = $this->load_reports( $reports_info ); | |
| 203 | + $reports = $this->load_reports( $reports_info, 'raw' ); | |
| 200 | 204 | |
| 201 | 205 | $domain = parse_url( site_url(), PHP_URL_HOST ); |
| 202 | 206 | |
| 203 | 207 | header( 'Content-Type: text/plain' ); |
| @@ -232,17 +236,19 @@ | ||
| 232 | 236 | * @since 2.9.0 |
| 233 | 237 | * @access public |
| 234 | 238 | * |
| 235 | 239 | * @param array $reports An array of system info reports. |
| 240 | + * @param string $format - possible values: 'raw' or empty string, meaning 'html' | |
| 236 | 241 | * |
| 237 | 242 | * @return array An array of system info reports. |
| 238 | 243 | */ |
| 239 | - public function load_reports( $reports ) { | |
| 244 | + public function load_reports( $reports, $format = '' ) { | |
| 240 | 245 | $result = []; |
| 241 | 246 | |
| 242 | 247 | foreach ( $reports as $report_name => $report_info ) { |
| 243 | 248 | $reporter_params = [ |
| 244 | 249 | 'name' => $report_name, |
| 250 | + 'format' => $format, | |
| 245 | 251 | ]; |
| 246 | 252 | |
| 247 | 253 | $reporter_params = array_merge( $reporter_params, $report_info ); |
| 248 | 254 | |
| @@ -252,9 +258,9 @@ | ||
| 252 | 258 | continue; |
| 253 | 259 | } |
| 254 | 260 | |
| 255 | 261 | $result[ $report_name ] = [ |
| 256 | - 'report' => $reporter, | |
| 262 | + 'report' => $reporter->get_report( $format ), | |
| 257 | 263 | 'label' => $reporter->get_title(), |
| 258 | 264 | ]; |
| 259 | 265 | |
| 260 | 266 | if ( ! empty( $report_info['sub'] ) ) { |
| @@ -273,10 +279,11 @@ | ||
| 273 | 279 | * @param array $properties Report properties. |
| 274 | 280 | * |
| 275 | 281 | * @return \WP_Error|false|Base Base instance if the report was created, |
| 276 | 282 | * False or WP_Error otherwise. |
| 277 | - * @since 2.9.0 | |
| 283 | + *@since 2.9.0 | |
| 278 | 284 | * @access public |
| 285 | + * | |
| 279 | 286 | */ |
| 280 | 287 | public function create_reporter( array $properties ) { |
| 281 | 288 | $properties = Model_Helper::prepare_properties( $this->get_settings( 'reporter_properties' ), $properties ); |
| 282 | 289 | |
| @@ -309,8 +316,15 @@ | ||
| 309 | 316 | */ |
| 310 | 317 | public function print_report( $reports, $template = 'raw' ) { |
| 311 | 318 | static $tabs_count = 0; |
| 312 | 319 | |
| 320 | + static $required_plugins_properties = [ | |
| 321 | + 'Name', | |
| 322 | + 'Version', | |
| 323 | + 'URL', | |
| 324 | + 'Author', | |
| 325 | + ]; | |
| 326 | + | |
| 313 | 327 | $template_path = __DIR__ . '/templates/' . $template . '.php'; |
| 314 | 328 | |
| 315 | 329 | require $template_path; |
| 316 | 330 | } |
| @@ -326,10 +340,8 @@ | ||
| 326 | 340 | * |
| 327 | 341 | * @return array Available reports in Elementor system info page. |
| 328 | 342 | */ |
| 329 | 343 | public static function get_allowed_reports() { |
| 330 | - do_action( 'elementor/system_info/get_allowed_reports' ); | |
| 331 | - | |
| 332 | 344 | return self::$reports; |
| 333 | 345 | } |
| 334 | 346 | |
| 335 | 347 | /** |