From 4b02ba16c13499f832f232b8c8873a6f4887361d Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 20:53:29 +0300 Subject: [PATCH 01/13] Added some whitespae --- query-apis.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/query-apis.php b/query-apis.php index 6d59b48..7aaed87 100644 --- a/query-apis.php +++ b/query-apis.php @@ -33,6 +33,9 @@ function techiepress_get_send_data() { + + + $response->get_error_message();return From d9f302def791b995b8e94700232cbd8a17a57200 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 20:57:17 +0300 Subject: [PATCH 02/13] Add some more whitespace --- .github/{workflow => workflows}/wpcs.yml | 0 query-apis.php | 2 ++ 2 files changed, 2 insertions(+) rename .github/{workflow => workflows}/wpcs.yml (100%) diff --git a/.github/workflow/wpcs.yml b/.github/workflows/wpcs.yml similarity index 100% rename from .github/workflow/wpcs.yml rename to .github/workflows/wpcs.yml diff --git a/query-apis.php b/query-apis.php index 7aaed87..9826bb7 100644 --- a/query-apis.php +++ b/query-apis.php @@ -35,6 +35,8 @@ function techiepress_get_send_data() { + + $response->get_error_message();return From 4eb459f20d09502416003a200d71ab2d0886e422 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:00:26 +0300 Subject: [PATCH 03/13] Fixed line 77 --- query-apis.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/query-apis.php b/query-apis.php index 9826bb7..379fb9e 100644 --- a/query-apis.php +++ b/query-apis.php @@ -36,7 +36,7 @@ function techiepress_get_send_data() { - + $response->get_error_message();return @@ -70,9 +70,4 @@ function ); } -add_action( - 'admin_menu', 'techiepress_register_my_custom_menu_page' - - - -); +add_action('admin_menu', 'techiepress_register_my_custom_menu_page'); From 0574f044365c2ce2929d8388b6f3bda77d5de316 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:01:58 +0300 Subject: [PATCH 04/13] Fix line 73 --- query-apis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query-apis.php b/query-apis.php index 379fb9e..a7e99f9 100644 --- a/query-apis.php +++ b/query-apis.php @@ -70,4 +70,4 @@ function ); } -add_action('admin_menu', 'techiepress_register_my_custom_menu_page'); +add_action( 'admin_menu', 'techiepress_register_my_custom_menu_page' ); From a17fa9caaa3146109603bf8bda6159ac62f4a576 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:13:16 +0300 Subject: [PATCH 05/13] Remove whitespace --- query-apis.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/query-apis.php b/query-apis.php index a7e99f9..9e9086f 100644 --- a/query-apis.php +++ b/query-apis.php @@ -30,9 +30,7 @@ function techiepress_get_send_data() { if (is_wp_error($response)){ $error_message = - - From eda925bf252b267cdb3ef7b114631c57ce0e9dac Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:16:45 +0300 Subject: [PATCH 06/13] Remove whitespace againa --- query-apis.php | 1 - 1 file changed, 1 deletion(-) diff --git a/query-apis.php b/query-apis.php index 9e9086f..2593725 100644 --- a/query-apis.php +++ b/query-apis.php @@ -34,7 +34,6 @@ function techiepress_get_send_data() { - $response->get_error_message();return From f0daf4bd489c171b8ee1c364f6db1effbf49ac87 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:20:37 +0300 Subject: [PATCH 07/13] Add cleaner code --- query-apis.php | 61 +++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/query-apis.php b/query-apis.php index 2593725..c138b22 100644 --- a/query-apis.php +++ b/query-apis.php @@ -11,58 +11,39 @@ */ // If this file is access directly, abort!!! -defined( 'ABSPATH' - -) or die( 'Unauthorized Access' - -); +defined( 'ABSPATH' ) or die( 'Unauthorized Access' ); function techiepress_get_send_data() { - $url = 'https://jsonplaceholder.typicode.com/users';$arguments = - array('method' => 'GET'); - $response = wp_remote_get( - - - $url, $arguments - - ); - - if (is_wp_error($response)){ - $error_message = - + $url = 'https://jsonplaceholder.typicode.com/users'; + + $arguments = array( + 'method' => 'GET' + ); + $response = wp_remote_get( $url, $arguments ); - - - $response->get_error_message();return - - - "Something went wrong: $error_message"; } else { - echo '
'; var_dump( 
-			
-			wp_remote_retrieve_body( 
-			
-			
-			$response ) ); echo '
'; - }} + if ( is_wp_error( $response ) ) { + $error_message = $response->get_error_message(); + return "Something went wrong: $error_message"; + } else { + echo '
';
+		var_dump( wp_remote_retrieve_body( $response ) );
+		echo '
'; + } +} /** * Register a custom menu page to view the information queried. */ -function - -techiepress_register_my_custom_menu_page() { +function techiepress_register_my_custom_menu_page() { add_menu_page( - __( - - - 'Query API Test Settings', 'query-apis' ), + __( 'Query API Test Settings', 'query-apis' ), 'Query API Test', 'manage_options', - - - 'api-test.php','techiepress_get_send_data','dashicons-testimonial', + 'api-test.php', + 'techiepress_get_send_data', + 'dashicons-testimonial', 16 ); } From 1da95f2a668ef81c8ba1dad868ea5dfed1fa376b Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:23:49 +0300 Subject: [PATCH 08/13] More fixes --- query-apis.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/query-apis.php b/query-apis.php index c138b22..4e374e7 100644 --- a/query-apis.php +++ b/query-apis.php @@ -8,18 +8,25 @@ * version: 0.1.0 * License: GPL2 or later. * text-domain: query-apis + * + * @package query_apis */ // If this file is access directly, abort!!! defined( 'ABSPATH' ) or die( 'Unauthorized Access' ); +/** + * Gets data from API and var_dumps it. + * + * @return void + */ function techiepress_get_send_data() { - $url = 'https://jsonplaceholder.typicode.com/users'; - - $arguments = array( - 'method' => 'GET' - ); + $url = 'https://jsonplaceholder.typicode.com/users'; + + $arguments = array( + 'method' => 'GET', + ); $response = wp_remote_get( $url, $arguments ); From 9f5d4026593dc77f7836137038ecda0bd2ccf801 Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:28:52 +0300 Subject: [PATCH 09/13] Remove space --- query-apis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query-apis.php b/query-apis.php index 4e374e7..4787e3b 100644 --- a/query-apis.php +++ b/query-apis.php @@ -38,7 +38,7 @@ function techiepress_get_send_data() { var_dump( wp_remote_retrieve_body( $response ) ); echo ''; } -} +} /** * Register a custom menu page to view the information queried. From df5ac6aa9abb148406588c9221edfa93a292729c Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:38:16 +0300 Subject: [PATCH 10/13] Code fix --- query-apis.php | 69 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/query-apis.php b/query-apis.php index 4787e3b..6d59b48 100644 --- a/query-apis.php +++ b/query-apis.php @@ -8,51 +8,66 @@ * version: 0.1.0 * License: GPL2 or later. * text-domain: query-apis - * - * @package query_apis */ // If this file is access directly, abort!!! -defined( 'ABSPATH' ) or die( 'Unauthorized Access' ); +defined( 'ABSPATH' + +) or die( 'Unauthorized Access' + +); -/** - * Gets data from API and var_dumps it. - * - * @return void - */ function techiepress_get_send_data() { - $url = 'https://jsonplaceholder.typicode.com/users'; + $url = 'https://jsonplaceholder.typicode.com/users';$arguments = + array('method' => 'GET'); + $response = wp_remote_get( + + + $url, $arguments - $arguments = array( - 'method' => 'GET', ); - $response = wp_remote_get( $url, $arguments ); + if (is_wp_error($response)){ + $error_message = + - if ( is_wp_error( $response ) ) { - $error_message = $response->get_error_message(); - return "Something went wrong: $error_message"; - } else { - echo '
';
-		var_dump( wp_remote_retrieve_body( $response ) );
-		echo '
'; - } -} + + $response->get_error_message();return + + + "Something went wrong: $error_message"; } else { + echo '
'; var_dump( 
+			
+			wp_remote_retrieve_body( 
+			
+			
+			$response ) ); echo '
'; + }} /** * Register a custom menu page to view the information queried. */ -function techiepress_register_my_custom_menu_page() { +function + +techiepress_register_my_custom_menu_page() { add_menu_page( - __( 'Query API Test Settings', 'query-apis' ), + __( + + + 'Query API Test Settings', 'query-apis' ), 'Query API Test', 'manage_options', - 'api-test.php', - 'techiepress_get_send_data', - 'dashicons-testimonial', + + + 'api-test.php','techiepress_get_send_data','dashicons-testimonial', 16 ); } -add_action( 'admin_menu', 'techiepress_register_my_custom_menu_page' ); +add_action( + 'admin_menu', 'techiepress_register_my_custom_menu_page' + + + +); From f784598cfa54ea2de73e8c37f88151fc0d51246b Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:40:02 +0300 Subject: [PATCH 11/13] Fix issues --- query-apis.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/query-apis.php b/query-apis.php index 6d59b48..eba032f 100644 --- a/query-apis.php +++ b/query-apis.php @@ -42,6 +42,8 @@ function techiepress_get_send_data() { wp_remote_retrieve_body( + + $response ) ); echo ''; }} From ff79e50a41cee247fe7ab1816b2230c2a6994eaf Mon Sep 17 00:00:00 2001 From: Laurence Bahiirwa Date: Tue, 26 Apr 2022 21:41:29 +0300 Subject: [PATCH 12/13] Space --- query-apis.php | 1 + 1 file changed, 1 insertion(+) diff --git a/query-apis.php b/query-apis.php index eba032f..22581b6 100644 --- a/query-apis.php +++ b/query-apis.php @@ -36,6 +36,7 @@ function techiepress_get_send_data() { $response->get_error_message();return + "Something went wrong: $error_message"; } else { echo '
'; var_dump( 
 			

From 963e059565a27599b19f21c34ea474c99a0c00d9 Mon Sep 17 00:00:00 2001
From: Laurence Bahiirwa 
Date: Tue, 26 Apr 2022 21:46:16 +0300
Subject: [PATCH 13/13] Cleaner code

---
 query-apis.php | 72 +++++++++++++++++++-------------------------------
 1 file changed, 27 insertions(+), 45 deletions(-)

diff --git a/query-apis.php b/query-apis.php
index 22581b6..4787e3b 100644
--- a/query-apis.php
+++ b/query-apis.php
@@ -8,69 +8,51 @@
  * version: 0.1.0
  * License: GPL2 or later.
  * text-domain: query-apis
+ * 
+ * @package query_apis
  */
 
 // If this file is access directly, abort!!!
-defined( 'ABSPATH'
-
-) or die( 'Unauthorized Access'
-
-);
+defined( 'ABSPATH' ) or die( 'Unauthorized Access' );
 
+/**
+ * Gets data from API and var_dumps it.
+ *
+ * @return void
+ */
 function techiepress_get_send_data() {
 
-    $url = 'https://jsonplaceholder.typicode.com/users';$arguments = 
-	array('method' => 'GET');
-	$response = wp_remote_get( 
-		
-		
-		$url, $arguments 
+	$url = 'https://jsonplaceholder.typicode.com/users';
 	
+	$arguments = array(
+		'method' => 'GET',
 	);
 
-	if (is_wp_error($response)){
-		$error_message = 
-		
-
-		
-		$response->get_error_message();return
-		
-		
-		
-		"Something went wrong: $error_message"; } else {
-		echo '
'; var_dump( 
-			
-			wp_remote_retrieve_body( 
-			
-			
+	$response = wp_remote_get( $url, $arguments );
 
-				
-			$response ) ); echo '
'; - }} + if ( is_wp_error( $response ) ) { + $error_message = $response->get_error_message(); + return "Something went wrong: $error_message"; + } else { + echo '
';
+		var_dump( wp_remote_retrieve_body( $response ) );
+		echo '
'; + } +} /** * Register a custom menu page to view the information queried. */ -function - -techiepress_register_my_custom_menu_page() { +function techiepress_register_my_custom_menu_page() { add_menu_page( - __( - - - 'Query API Test Settings', 'query-apis' ), + __( 'Query API Test Settings', 'query-apis' ), 'Query API Test', 'manage_options', - - - 'api-test.php','techiepress_get_send_data','dashicons-testimonial', + 'api-test.php', + 'techiepress_get_send_data', + 'dashicons-testimonial', 16 ); } -add_action( - 'admin_menu', 'techiepress_register_my_custom_menu_page' - - - -); +add_action( 'admin_menu', 'techiepress_register_my_custom_menu_page' );