소스 검색

working with blcok

Mozahidur Rahman 1 년 전
부모
커밋
f1fcdff0c6
2개의 변경된 파일25개의 추가작업 그리고 94개의 파일을 삭제
  1. 4 49
      inc/acf-json/group_64534cae361a7.json
  2. 21 45
      template-parts/blocks/portfolio-item/block-portfolio-item.php

+ 4 - 49
inc/acf-json/group_64534cae361a7.json

@@ -3,34 +3,9 @@
     "title": "Block - Faculty API",
     "fields": [
         {
-            "key": "field_64534cae08e9a",
-            "label": "Logo",
-            "name": "logo",
-            "aria-label": "",
-            "type": "image",
-            "instructions": "",
-            "required": 0,
-            "conditional_logic": 0,
-            "wrapper": {
-                "width": "",
-                "class": "",
-                "id": ""
-            },
-            "return_format": "array",
-            "preview_size": "medium",
-            "library": "all",
-            "min_width": 0,
-            "min_height": 0,
-            "min_size": 0,
-            "max_width": 0,
-            "max_height": 0,
-            "max_size": 0,
-            "mime_types": ""
-        },
-        {
-            "key": "field_64534cec08e9b",
-            "label": "Title",
-            "name": "title",
+            "key": "field_64535feb0511e",
+            "label": "Login ID",
+            "name": "login_id",
             "aria-label": "",
             "type": "text",
             "instructions": "",
@@ -46,26 +21,6 @@
             "placeholder": "",
             "prepend": "",
             "append": ""
-        },
-        {
-            "key": "field_64534cf308e9c",
-            "label": "Description",
-            "name": "description",
-            "aria-label": "",
-            "type": "wysiwyg",
-            "instructions": "",
-            "required": 0,
-            "conditional_logic": 0,
-            "wrapper": {
-                "width": "",
-                "class": "",
-                "id": ""
-            },
-            "tabs": "all",
-            "toolbar": "full",
-            "media_upload": 1,
-            "default_value": "",
-            "delay": 0
         }
     ],
     "location": [
@@ -86,5 +41,5 @@
     "active": true,
     "description": "",
     "show_in_rest": 0,
-    "modified": 1683180815
+    "modified": 1683186854
 }

+ 21 - 45
template-parts/blocks/portfolio-item/block-portfolio-item.php

@@ -1,64 +1,40 @@
 <?php
 
-$logo = get_field('logo');
-$title = get_field('title');
-$description = get_field('description');
-
-
+$login_id = get_field('login_id');
 $url = 'http://103.109.52.3/webapi/api/EmployeeInfo';
-
 $response = wp_remote_post(
     $url,
     array(
-        // 'timeout'     => 120,
-        // 'httpversion' => '1.1',
         'body' => array(
             'user_login_id' => 'api_user',
-            'login_id' => 'SS',
+            'login_id' => $login_id,
             'auth_token' => 'api_user20230419045143'
         )
 
     )
 );
 
-// $url = 'https://www.flickr.com/services/rest/';
-// $arguments = array(
-//     'api_key' => 'f49df4a290d8f224ecd56536af51FF77',
-//     'method'  => 'flickr.people.getPublicPhotos',
-//     'format'  => 'json',
-//     'user_id' => $user_id,
-//     'per_page'=> $photos_number,
-// );
-// $url_parameters = array();
-// foreach ($arguments as $key => $value){
-//     $url_parameters[] = $key.'='.$value;
-// }
-// $url = $url.implode('&', $url_parameters);
-
-
-
-// $request = wp_remote_get($url, $options);
-
-// return load_request($request);
-
-// function load_request($response)
-// {
-//     try {
-//         $json = json_decode($response['body']);
-//     } catch (Exception $ex) {
-//         $json = null;
-//     }
-//     return $json;
-// }
+$data = json_decode(wp_remote_retrieve_body($response), true);
 
+foreach ($data as $query) {
+    $EmployeeID = $query['EmployeeID'];
+}
 
 echo '<div class="portfolio-item">';
-if (!empty($logo))
+if (!empty($logo)) {
     echo wp_get_attachment_image($logo['ID'], 'thumbnail', null, array('class' => 'portfolio-logo alignleft'));
-if (!empty($title))
-    echo '<h3 class="portfolio-title">' . $title . '</h3>';
-if (!empty($description))
-    echo '<div class="portfolio-description">' . $description . '</div>';
-var_dump($response);
-// echo '<div class="test">' . $request . '</div>';
+}
+if (!empty($login_id)) {
+    echo '<h3 class="portfolio-title">Faculty Member Information</h3>';
+    echo '<div class="portfolio-description"> <ul>';
+    foreach ($data[0]  as $key => $value) {
+        echo "<li> <strong>" . $key . " </strong>: " . $value . "</li>\n";
+    }
+    echo '</ul></div>';
+} else {
+    echo 'Please insert Login ID of the faculty member</ul></div>';
+}
+
+// var_dump($data[0]);
+// print_r($data);
 echo '</div>';