Changeset 2193208
- Timestamp:
- 11/14/2019 11:11:15 PM (6 years ago)
- Location:
- lightpost/trunk
- Files:
-
- 3 edited
-
includes/Directory.php (modified) (5 diffs)
-
lightpost.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lightpost/trunk/includes/Directory.php
r2192466 r2193208 9 9 protected $directory; 10 10 protected $family; 11 protected $error = false; 12 protected $error_message; 11 13 12 14 public function __construct() … … 22 24 global $post; 23 25 24 if ($this->page_id !== $post->ID || get_option('lightpost_directory_disclaimer') != 'true') {26 if ($this->page_id !== $post->ID) { 25 27 return; 26 28 } … … 33 35 } 34 36 35 public function getContent($content )37 public function getContent($content = null) 36 38 { 39 // If page is password protected and not authenticated, return existing content. 40 if(post_password_required()) { 41 return get_the_content(); 42 } 43 // If we have not agreed to the terms for this page, error out. 44 if(get_option('lightpost_directory_disclaimer') != 'true') { 45 return 'Cannot load content: the Lightpost member directory page disclaimer is not checked.'; 46 } 47 37 48 $this->loadData(); 38 49 39 50 if ($this->error) { 40 return 'Unable to load directory information! Please try again later.';51 return $this->error_message ?: 'Unable to load directory information! Please try again later.'; 41 52 } 42 53 … … 76 87 if (!is_array($response)) { 77 88 $this->error = true; 89 $this->error_message = 'The API response was not properly formatted.'; 78 90 return; 79 91 } 80 92 if ($response['response']['code'] === 404) { 81 93 $this->error = true; 94 $this->error_message = 'The API response code was 404.'; 82 95 return; 83 96 } 84 97 85 $response = json_decode($response['body'], true); 86 87 $this->directory = $response; 98 $this->directory = json_decode($response['body'], true); 88 99 } 89 100 … … 105 116 ]); 106 117 107 if (!is_array($response)) {118 if (!is_array($response)) { 108 119 $this->error = true; 120 $this->error_message = 'The API response was not properly formatted.'; 109 121 return; 110 122 } 111 123 if ($response['response']['code'] === 404) { 112 124 $this->error = true; 125 $this->error_message = 'The API response code was 404.'; 113 126 return; 114 127 } 115 116 $response = json_decode($response['body'], true); 117 118 $this->family = $response; 128 129 $this->family = json_decode($response['body'], true); 119 130 } 120 131 } -
lightpost/trunk/lightpost.php
r2192466 r2193208 7 7 Author: Lightpost 8 8 Author URI: https://lightpost.app 9 Version: 1.1 9 Version: 1.1.2 10 10 Requires PHP: 7.0 11 11 Requires at least: 5.0 -
lightpost/trunk/readme.txt
r2192492 r2193208 36 36 == Changelog == 37 37 38 = 1.1.2 = 39 40 * Added better error handling. 41 42 = 1.1.1 = 43 44 * Fixed a check for protected pages. 45 38 46 = 1.1 = 39 47
Note: See TracChangeset
for help on using the changeset viewer.