| 1 |
<?php |
| 2 |
/** |
| 3 |
* Scaffold |
| 4 |
* |
| 5 |
* @namespace UsabilityDynamics |
| 6 |
* |
| 7 |
*/ |
| 8 |
namespace UsabilityDynamics\UD_API { |
| 9 |
|
| 10 |
if( !class_exists( 'UsabilityDynamics\UD_API\Scaffold' ) ) { |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
* @class Scaffold |
| 15 |
* @author: peshkov@UD |
| 16 |
*/ |
| 17 |
abstract class Scaffold { |
| 18 |
|
| 19 |
public $type; |
| 20 |
public $blog; |
| 21 |
public $name; |
| 22 |
public $slug; |
| 23 |
public $referrer_slug; |
| 24 |
public $domain; |
| 25 |
|
| 26 |
/** |
| 27 |
* Email is required for activation. |
| 28 |
* |
| 29 |
* @var boolean |
| 30 |
*/ |
| 31 |
public $activation_email; |
| 32 |
|
| 33 |
/** |
| 34 |
* Storage for dynamic properties |
| 35 |
* Used by magic __set, __get |
| 36 |
* |
| 37 |
* @protected |
| 38 |
* @type array |
| 39 |
*/ |
| 40 |
protected $_properties = array(); |
| 41 |
|
| 42 |
/** |
| 43 |
* Constructor |
| 44 |
* |
| 45 |
* @author peshkov@UD |
| 46 |
*/ |
| 47 |
public function __construct( $args = array() ) { |
| 48 |
//** Setup our plugin's data */ |
| 49 |
$this->type = isset( $args[ 'type' ] ) ? trim( $args[ 'type' ] ) : false; |
| 50 |
$this->activation_email = isset( $args[ 'activation_email' ] ) && $args[ 'activation_email' ] ? true : false; |
| 51 |
$this->name = isset( $args[ 'name' ] ) ? trim( $args[ 'name' ] ) : false; |
| 52 |
$this->slug = isset( $args[ 'slug' ] ) ? trim( $args[ 'slug' ] ) : sanitize_key( $this->name ); |
| 53 |
$this->referrer_slug = isset( $args[ 'referrer_slug' ] ) ? $args[ 'referrer_slug' ] : false; |
| 54 |
$this->domain = isset( $args[ 'domain' ] ) ? trim( $args[ 'domain' ] ) : false; |
| 55 |
|
| 56 |
/** |
| 57 |
* Some web hosts have security policies that block the : (colon) and // (slashes) in http://, |
| 58 |
* so only the host portion of the URL can be sent. For example the host portion might be |
| 59 |
* www.example.com or example.com. http://www.example.com includes the scheme http, |
| 60 |
* and the host www.example.com. |
| 61 |
* Sending only the host also eliminates issues when a client site changes from http to https, |
| 62 |
* but their activation still uses the original scheme. |
| 63 |
* To send only the host, use a line like the one below: |
| 64 |
*/ |
| 65 |
$this->blog = str_ireplace( array( 'http://', 'https://' ), '', home_url() ); |
| 66 |
|
| 67 |
$this->args = $args; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* |
| 72 |
*/ |
| 73 |
public function __get( $key ) { |
| 74 |
return isset( $this->_properties[ $key ] ) ? $this->_properties[ $key ] : NULL; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* |
| 79 |
*/ |
| 80 |
public function __set( $key, $value ) { |
| 81 |
$this->_properties[ $key ] = $value; |
| 82 |
} |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
} |
| 87 |
|
| 88 |
} |