get_tran('wpxpo_data_collect'); $is_frequency = get_transient( 'wpxpo_data_collect_every' ); if ($is_frequency == false && $is_collect == 'yes') { add_action( 'init', array( $this, 'send_frequency_plugin_data' ) ); set_transient( 'wpxpo_data_collect_every', 'yes', MONTH_IN_SECONDS ); // every 30 days } add_action( 'wp_ajax_ultp_deactive_plugin', array( $this, 'send_plugin_data' ) ); } public function send_frequency_plugin_data() { $this->send_plugin_data( 'allow' ); } /** * 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 , $site = '' ) { $data = $this->get_data(); $data['site_type'] = $site ? $site : get_option( '__ultp_site_type' ); $data['type'] = $type ? $type : 'deactive'; $form_data = isset($_POST) ? $this->sanitize_array($_POST) : array(); //phpcs:Ignore 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() { ?>