send_plugin_data( 'allow' ); } public function ultp_tracking_callback() { if (!isset($_GET['postx_tracking'])) { return; } if( sanitize_key($_GET['postx_tracking']) == 'yes' ) { set_transient( 'wpxpo_data_collect', 'yes', 5 * YEAR_IN_SECONDS ); // 5 years notice $this->send_plugin_data('allow'); } else { set_transient( 'wpxpo_data_collect', 'no', 3 * MONTH_IN_SECONDS ); // 90 days notice } } /** * Data Collect Notice * * @since v.1.0.0 * @param NULL * @return STRING | Message Shown in Admin Area */ public function data_collect_notice() { if (!isset($_GET['postx_tracking'])) { echo '
'; echo '
'; printf( __( 'Want to help make %1$s even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.', 'ultimate-post' ), $this->PLUGIN_NAME ); echo '' . esc_html__( "Allow", "ultimate-post" ) . ' '; echo '' . esc_html__( "No Thanks", "ultimate-post" ) . ''; echo '
'; echo '
'; } } /** * Check is Local or Not * * @since v.1.0.0 * @param NULL * @return BOOLEAN | Is local or not */ public function is_local() { $seed = isset($_SERVER['REMOTE_ADDR']) ? sanitize_key($_SERVER['REMOTE_ADDR']) : ''; return in_array( $seed, array( '127.0.0.1', '::1' ) ); } /** * Sanitize Array * * @since v.2.5.8 * @param ARRAY * @return ARRAY | Product return data */ public function sanitize_array( &$array ) { foreach ($array as &$value) { if ( !is_array($value) ) { $value = sanitize_text_field( $value ); } else { $this->sanitize_array($value); } } return $array; } /** * Get Plugin Data Response * * @since v.1.0.0 * @param STRING * @return ARRAY | Product return data */ public function send_plugin_data( $type ) { $data = $this->get_data(); $data['type'] = $type ? $type : 'deactive'; $form_data = isset($_POST) ? $this->sanitize_array($_POST) : array(); if (current_user_can( 'administrator' ) ) { if (isset( $form_data['action'] )) { unset( $form_data['action'] ); } $response = wp_remote_post( $this->API_ENDPOINT, array( 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'headers' => array( 'user-agent' => 'wpxpo/' . md5( esc_url( home_url() ) ) . ';', 'Accept' => 'application/json', ), 'blocking' => true, 'httpversion' => '1.0', 'body' => array_merge($data, $form_data), ) ); return $response; } } /** * Deactive Form Settings Data * * @since v.1.0.0 * @param NULL * @return ARRAY | Settings Parameters */ public function get_settings() { $attr = array( array( 'id' => 'no-need', 'input' => false, 'text' => __( "I no longer need the plugin.", "ultimate-post" ) ), array( 'id' => 'better-plugin', 'input' => true, 'text' => __( "I found a better plugin.", "ultimate-post" ), 'placeholder' => __( "Please share which plugin.", "ultimate-post" ), ), array( 'id' => 'stop-working', 'input' => true, 'text' => __( "The plugin suddenly stopped working.", "ultimate-post" ), 'placeholder' => __( "Please share more details.", "ultimate-post" ), ), array( 'id' => 'not-working', 'input' => false, 'text' => __( "I could not get the plugin to work.", "ultimate-post" ) ), array( 'id' => 'temporary-deactivation', 'input' => false, 'text' => __( "It's a temporary deactivation.", "ultimate-post" ) ), array( 'id' => 'other', 'input' => true, 'text' => __( "Other.", "ultimate-post" ), 'placeholder' => __( "Please share the reason.", "ultimate-post" ), ), ); return $attr; } /** * Deactive HTML View * * @since v.1.0.0 * @param NULL * @return STRING | HTML Data */ public function get_source_data_callback() { global $pagenow; if ($pagenow == 'plugins.php' ) { $this->deactive_html(); } $this->deactive_css(); $this->deactive_js(); } public function deactive_html() { ?>

    get_settings() as $key => $setting) { ?>
$plugin ) { $arr = array(); $arr['name'] = isset( $plugin['Name'] ) ? $plugin['Name'] : ''; $arr['url'] = isset( $plugin['PluginURI'] ) ? $plugin['PluginURI'] : ''; $arr['author'] = isset( $plugin['Author'] ) ? $plugin['Author'] : ''; $arr['version'] = isset( $plugin['Version'] ) ? $plugin['Version'] : ''; if (in_array( $key, $active_plugins )) { $active[$key] = $arr; } else { $inactive[$key] = $arr; } } return array( 'active' => $active, 'inactive' => $inactive ); } /** * Get All the Theme Installed * * @since v.1.0.0 * @param NULL * @return ARRAY | Return Theme Information */ public function get_themes() { $theme_data = array(); $all_themes = wp_get_themes(); if (is_array($all_themes)) { foreach ($all_themes as $key => $theme) { $attr = array(); $attr['name'] = $theme->Name; $attr['url'] = $theme->ThemeURI; $attr['author'] = $theme->Author; $attr['version'] = $theme->Version; $theme_data[$key] = $attr; } } return $theme_data; } /** * Get Current User IP * * @since v.1.0.0 * @param NULL * @return STRING | Return IP */ public function get_user_ip() { $response = wp_remote_get( 'https://icanhazip.com/' ); if (is_wp_error( $response ) ) { return ''; } else { $user_ip = trim( wp_remote_retrieve_body( $response ) ); return filter_var( $user_ip, FILTER_VALIDATE_IP ) ? $user_ip : ''; } } /** * Get All the Data Collected * * @since v.1.0.0 * @param NULL * @return ARRAY | All Send Data */ public function get_data() { global $wpdb; $user = wp_get_current_user(); $user_count = count_users(); $plugins_data = $this->get_plugins(); $data = array( 'name' => get_bloginfo( 'name' ), 'home' => esc_url( home_url() ), 'admin_email' => $user->user_email, 'first_name' => isset($user->user_firstname) ? $user->user_firstname : '', 'last_name' => isset($user->user_lastname) ? $user->user_lastname : '', 'display_name' => $user->display_name, 'wordpress' => get_bloginfo( 'version' ), 'memory_limit' => WP_MEMORY_LIMIT, 'debug_mode' => ( defined('WP_DEBUG') && WP_DEBUG ) ? 'Yes' : 'No', 'locale' => get_locale(), 'multisite' => is_multisite() ? 'Yes' : 'No', 'themes' => $this->get_themes(), 'active_theme' => get_stylesheet(), 'users' => isset($user_count['total_users']) ? $user_count['total_users'] : 0, 'active_plugins' => $plugins_data['active'], 'inactive_plugins' => $plugins_data['inactive'], 'server' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_key($_SERVER['SERVER_SOFTWARE']) : '', 'timezone' => date_default_timezone_get(), 'php_curl' => function_exists( 'curl_init' ) ? 'Yes' : 'No', 'php_version' => function_exists('phpversion') ? phpversion() : '', 'upload_size' => size_format( wp_max_upload_size() ), 'mysql_version' => $wpdb->db_version(), 'php_fsockopen' => function_exists( 'fsockopen' ) ? 'Yes' : 'No', 'ip' => $this->get_user_ip(), 'plugin_name' => $this->PLUGIN_NAME, 'plugin_version' => $this->PLUGIN_VERSION, 'plugin_slug' => $this->PLUGIN_SLUG ); return $data; } }