Plugin Directory

Changeset 2193208


Ignore:
Timestamp:
11/14/2019 11:11:15 PM (6 years ago)
Author:
lightpost
Message:

Update to v1.1.2
Added better error handling
Fixed a check for protected pages

Location:
lightpost/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lightpost/trunk/includes/Directory.php

    r2192466 r2193208  
    99    protected $directory;
    1010    protected $family;
     11    protected $error = false;
     12    protected $error_message;
    1113   
    1214    public function __construct()
     
    2224        global $post;
    2325       
    24         if ($this->page_id !== $post->ID || get_option('lightpost_directory_disclaimer') != 'true') {
     26        if ($this->page_id !== $post->ID) {
    2527            return;
    2628        }
     
    3335    }
    3436   
    35     public function getContent($content)
     37    public function getContent($content = null)
    3638    {
     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       
    3748        $this->loadData();
    3849
    3950        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.';
    4152        }
    4253       
     
    7687        if (!is_array($response)) {
    7788            $this->error = true;
     89            $this->error_message = 'The API response was not properly formatted.';
    7890            return;
    7991        }
    8092        if ($response['response']['code'] === 404) {
    8193            $this->error = true;
     94            $this->error_message = 'The API response code was 404.';
    8295            return;
    8396        }
    8497       
    85         $response = json_decode($response['body'], true);
    86        
    87         $this->directory = $response;
     98        $this->directory = json_decode($response['body'], true);
    8899    }
    89100   
     
    105116        ]);
    106117
    107         if (!is_array($response)) {
     118        if (!is_array($response)) {
    108119            $this->error = true;
     120            $this->error_message = 'The API response was not properly formatted.';
    109121            return;
    110122        }
    111123        if ($response['response']['code'] === 404) {
    112124            $this->error = true;
     125            $this->error_message = 'The API response code was 404.';
    113126            return;
    114127        }
    115        
    116         $response = json_decode($response['body'], true);
    117        
    118         $this->family = $response;
     128       
     129        $this->family = json_decode($response['body'], true);
    119130    }
    120131}
  • lightpost/trunk/lightpost.php

    r2192466 r2193208  
    77Author:            Lightpost
    88Author URI:        https://lightpost.app
    9 Version:           1.1
     9Version:           1.1.2
    1010Requires PHP:      7.0
    1111Requires at least: 5.0
  • lightpost/trunk/readme.txt

    r2192492 r2193208  
    3636== Changelog ==
    3737
     38= 1.1.2 =
     39
     40* Added better error handling.
     41
     42= 1.1.1 =
     43
     44* Fixed a check for protected pages.
     45
    3846= 1.1 =
    3947
Note: See TracChangeset for help on using the changeset viewer.