Plugin Directory

Changeset 952302


Ignore:
Timestamp:
07/21/2014 05:29:28 PM (12 years ago)
Author:
briancolinger
Message:

Detect if the plugin has been installed on localhost and show an error.

Location:
vaultpress/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vaultpress/trunk/readme.txt

    r950961 r952302  
    5454= 1.6.3 =
    5555* Bugfix: Make sure existing empty key and secret options are always strings.  This fixes an error when run with HHVM.
     56* Bugfix: Detect if the plugin has been installed on localhost and show an error.
    5657
    5758= 1.6.2 =
  • vaultpress/trunk/vaultpress.php

    r950959 r952302  
    337337
    338338    function ui() {
     339        if ( $this->is_localhost() ) {
     340            $this->update_option( 'connection', time() );
     341            $this->update_option( 'connection_error_code', 'error_localhost' );
     342            $this->update_option( 'connection_error_message', 'Hostnames such as localhost or 127.0.0.1 can not be reached by vaultpress.com and will not work with the service. Sites must be publicly accessible in order to work with VaultPress.' );
     343            $this->error_notice();
     344            return;
     345        }
     346
    339347        if ( !empty( $_GET['error'] ) ) {
    340348            $this->error_notice();
     
    16611669    }
    16621670
     1671    function is_localhost() {
     1672        $site_url = $this->site_url();
     1673        if ( empty( $site_url ) )
     1674            return false;
     1675        $parts = parse_url( $site_url() );
     1676        if ( !empty( $parts['host'] ) && in_array( $parts['host'], array( 'localhost', '127.0.0.1' ) ) )
     1677            return true;
     1678        return false;
     1679    }
     1680
    16631681    function contact_service( $action, $args = array() ) {
    16641682        if ( 'test' != $action && 'register' != $action && !$this->check_connection() )
Note: See TracChangeset for help on using the changeset viewer.