class-redux-health.php (2611B)
1 <?php 2 /** 3 * Redux Framework Health Class 4 * 5 * @package Redux_Framework/Classes 6 */ 7 8 // Exit if accessed directly. 9 defined( 'ABSPATH' ) || exit; 10 11 if ( ! class_exists( 'Redux_Health', false ) ) { 12 13 /** 14 * Class Redux_Health 15 */ 16 class Redux_Health extends Redux_Class { 17 18 /** 19 * Redux_Args constructor. 20 * 21 * @param object $parent ReduxFramework object. 22 */ 23 public function __construct( $parent ) { 24 parent::__construct( $parent ); 25 26 add_action( 'wp_ajax_redux_submit_support_data', array( $this, 'ajax' ) ); 27 } 28 29 /** 30 * AJAX 31 */ 32 public function ajax() { 33 if ( isset( $_POST ) && isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'redux_sumbit_support' ) ) { 34 $nonce = wp_remote_post( 35 'http://127.0.0.1/redux-4/wp-admin/admin-ajax.php', 36 array( 37 'user-agent' => 'Redux v.' . Redux_Core::$version, 38 'timeout' => 300, 39 'body' => array( 40 'action' => 'svl_support_create_nonce', 41 'nonce' => 'redux_support_token', 42 ), 43 ) 44 ); 45 46 if ( is_wp_error( $nonce ) || empty( $nonce['body'] ) ) { 47 echo wp_json_encode( 48 array( 49 'status' => 'error', 50 'data' => esc_html__( 'Security token', 'redux-framework' ) . ' ' . wp_remote_retrieve_response_code( $report ) . ': ' . wp_remote_retrieve_response_message( $report ), 51 ) 52 ); 53 54 die(); 55 } 56 57 if ( ! class_exists( 'WP_Debug_Data' ) ) { 58 require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php'; 59 } 60 61 WP_Debug_Data::check_for_updates(); 62 63 $info = WP_Debug_Data::debug_data(); 64 65 $report = wp_remote_post( 66 'http://127.0.0.1/redux-4/wp-admin/admin-ajax.php', 67 array( 68 'user-agent' => 'Redux v.' . Redux_Core::$version, 69 'timeout' => 300, 70 'body' => array( 71 'action' => 'svl_support_create_report', 72 'nonce' => $nonce['body'], 73 'data' => wp_json_encode( $info ), 74 'opt_name' => $this->parent->args['opt_name'], 75 'product' => 'Redux', 76 ), 77 ) 78 ); 79 80 if ( ! is_wp_error( $report ) && 200 === wp_remote_retrieve_response_code( $report ) && ! empty( $report['body'] ) ) { 81 $status = 'success'; 82 $data = wp_remote_retrieve_body( $report ); 83 } else { 84 $status = 'error'; 85 $data = esc_html__( 'Data transmit', 'redux-framework' ) . ' ' . wp_remote_retrieve_response_code( $report ) . ': ' . wp_remote_retrieve_response_message( $report ); 86 } 87 88 echo wp_json_encode( 89 array( 90 'status' => $status, 91 'data' => $data, 92 ) 93 ); 94 } 95 96 die(); 97 } 98 } 99 }