| @@ -1,14 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\System_Info; |
| 3 | 3 | |
| 4 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 4 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 6 | -use Elementor\Modules\System_Info\AdminMenuItems\Editor_One_System_Info_Menu; | |
| 7 | -use Elementor\Modules\System_Info\AdminMenuItems\Editor_One_System_Menu; | |
| 6 | +use Elementor\Modules\System_Info\Reporters\Base; | |
| 8 | 7 | use Elementor\Modules\System_Info\Helpers\Model_Helper; |
| 9 | -use Elementor\Modules\System_Info\Reporters\Base; | |
| 10 | -use Elementor\Modules\System_Info\Rest\Rest_Api; | |
| 11 | 8 | use Elementor\Plugin; |
| 12 | 9 | use Elementor\Settings; |
| 13 | 10 | |
| 14 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -120,56 +117,29 @@ | ||
| 120 | 117 | * @since 2.9.0 |
| 121 | 118 | * @access private |
| 122 | 119 | */ |
| 123 | 120 | private function add_actions() { |
| 124 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 125 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 126 | - } ); | |
| 121 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu_manager ) { | |
| 122 | + $this->register_menu( $admin_menu_manager ); | |
| 123 | + }, Settings::ADMIN_MENU_PRIORITY + 30 ); | |
| 127 | 124 | |
| 128 | 125 | add_action( 'wp_ajax_elementor_system_info_download_file', [ $this, 'download_file' ] ); |
| 129 | - add_action( 'rest_api_init', [ $this, 'register_rest_routes' ] ); | |
| 130 | 126 | } |
| 131 | 127 | |
| 132 | - public function register_rest_routes(): void { | |
| 133 | - ( new Rest_Api() )->register_routes(); | |
| 128 | + /** | |
| 129 | + * Register admin menu. | |
| 130 | + * | |
| 131 | + * Add new Elementor system info admin menu. | |
| 132 | + * | |
| 133 | + * Fired by `admin_menu` action. | |
| 134 | + * | |
| 135 | + * @since 2.9.0 | |
| 136 | + * @access private | |
| 137 | + */ | |
| 138 | + private function register_menu( Admin_Menu_Manager $admin_menu ) { | |
| 139 | + $admin_menu->register( 'elementor-system-info', new System_Info_Menu_Item( $this ) ); | |
| 134 | 140 | } |
| 135 | 141 | |
| 136 | - public function get_reports_data(): array { | |
| 137 | - $reports = $this->load_reports( self::get_allowed_reports() ); | |
| 138 | - | |
| 139 | - return $this->build_reports_data( $reports ); | |
| 140 | - } | |
| 141 | - | |
| 142 | - private function build_reports_data( array $reports ): array { | |
| 143 | - $data = []; | |
| 144 | - | |
| 145 | - foreach ( $reports as $report_name => $report_details ) { | |
| 146 | - $report = $report_details['report']->get_report(); | |
| 147 | - | |
| 148 | - if ( is_wp_error( $report ) ) { | |
| 149 | - continue; | |
| 150 | - } | |
| 151 | - | |
| 152 | - $report_data = [ | |
| 153 | - 'label' => $report_details['label'], | |
| 154 | - 'report' => $report, | |
| 155 | - ]; | |
| 156 | - | |
| 157 | - if ( ! empty( $report_details['sub'] ) ) { | |
| 158 | - $report_data['sub'] = $this->build_reports_data( $report_details['sub'] ); | |
| 159 | - } | |
| 160 | - | |
| 161 | - $data[ $report_name ] = $report_data; | |
| 162 | - } | |
| 163 | - | |
| 164 | - return $data; | |
| 165 | - } | |
| 166 | - | |
| 167 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 168 | - $menu_data_provider->register_menu( new Editor_One_System_Menu() ); | |
| 169 | - $menu_data_provider->register_menu( new Editor_One_System_Info_Menu() ); | |
| 170 | - } | |
| 171 | - | |
| 172 | 142 | /** |
| 173 | 143 | * Display page. |
| 174 | 144 | * |
| 175 | 145 | * Output the content for the main system info page. |
| @@ -186,9 +156,9 @@ | ||
| 186 | 156 | <div class="elementor-system-info-header"> |
| 187 | 157 | <h3 class="wp-heading-inline"><?php echo esc_html__( 'System Info', 'elementor' ); ?></h3> |
| 188 | 158 | <form action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> |
| 189 | 159 | <input type="hidden" name="action" value="elementor_system_info_download_file"> |
| 190 | - <input type="submit" data-id="elementor-system-info-download-file" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 160 | + <input type="submit" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 191 | 161 | </form> |
| 192 | 162 | </div> |
| 193 | 163 | <div><?php $this->print_report( $reports, 'html' ); ?></div> |
| 194 | 164 | <h3><?php echo esc_html__( 'Copy & Paste Info', 'elementor' ); ?></h3> |
| @@ -210,9 +180,9 @@ | ||
| 210 | 180 | </div> |
| 211 | 181 | <hr> |
| 212 | 182 | <form action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> |
| 213 | 183 | <input type="hidden" name="action" value="elementor_system_info_download_file"> |
| 214 | - <input type="submit" data-id="elementor-system-info-download-file" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 184 | + <input type="submit" class="button button-primary" value="<?php echo esc_attr__( 'Download System Info', 'elementor' ); ?>"> | |
| 215 | 185 | </form> |
| 216 | 186 | </div> |
| 217 | 187 | <?php |
| 218 | 188 | } |