@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function distributionAssetsPath() |
| 138 | 138 | { |
| 139 | - return $this->pluginPath() . 'assets/dist/'; |
|
| 139 | + return $this->pluginPath().'assets/dist/'; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function distributionAssetsUrl() |
| 147 | 147 | { |
| 148 | - return $this->pluginUrl() . 'assets/dist/'; |
|
| 148 | + return $this->pluginUrl().'assets/dist/'; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -16,153 +16,153 @@ |
||
| 16 | 16 | abstract class DomainBase implements DomainInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Equivalent to `__FILE__` for main plugin file. |
|
| 21 | - * |
|
| 22 | - * @var FilePath |
|
| 23 | - */ |
|
| 24 | - private $plugin_file; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * String indicating version for plugin |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - private $version; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var string $plugin_basename |
|
| 35 | - */ |
|
| 36 | - private $plugin_basename; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string $plugin_path |
|
| 40 | - */ |
|
| 41 | - private $plugin_path; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string $plugin_url |
|
| 45 | - */ |
|
| 46 | - private $plugin_url; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string $asset_namespace |
|
| 50 | - */ |
|
| 51 | - private $asset_namespace; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Initializes internal properties. |
|
| 57 | - * |
|
| 58 | - * @param FilePath $plugin_file |
|
| 59 | - * @param Version $version |
|
| 60 | - */ |
|
| 61 | - public function __construct(FilePath $plugin_file, Version $version) |
|
| 62 | - { |
|
| 63 | - $this->plugin_file = $plugin_file; |
|
| 64 | - $this->version = $version; |
|
| 65 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
| 66 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
| 67 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
| 68 | - $this->setAssetNamespace(); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function pluginFile() |
|
| 76 | - { |
|
| 77 | - return (string) $this->plugin_file; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @return string |
|
| 84 | - */ |
|
| 85 | - public function pluginBasename() |
|
| 86 | - { |
|
| 87 | - return $this->plugin_basename; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function pluginPath() |
|
| 96 | - { |
|
| 97 | - return $this->plugin_path; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return string |
|
| 104 | - */ |
|
| 105 | - public function pluginUrl() |
|
| 106 | - { |
|
| 107 | - return $this->plugin_url; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @return string |
|
| 114 | - */ |
|
| 115 | - public function version() |
|
| 116 | - { |
|
| 117 | - return (string) $this->version; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return Version |
|
| 124 | - */ |
|
| 125 | - public function versionValueObject() |
|
| 126 | - { |
|
| 127 | - return $this->version; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function distributionAssetsPath() |
|
| 135 | - { |
|
| 136 | - return $this->pluginPath() . 'assets/dist/'; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public function distributionAssetsUrl() |
|
| 144 | - { |
|
| 145 | - return $this->pluginUrl() . 'assets/dist/'; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @return string |
|
| 151 | - */ |
|
| 152 | - public function assetNamespace() |
|
| 153 | - { |
|
| 154 | - return $this->asset_namespace; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @return void |
|
| 160 | - */ |
|
| 161 | - private function setAssetNamespace() |
|
| 162 | - { |
|
| 163 | - $this->asset_namespace = sanitize_key( |
|
| 164 | - // convert directory separators to dashes and remove file extension |
|
| 165 | - str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
| 166 | - ); |
|
| 167 | - } |
|
| 19 | + /** |
|
| 20 | + * Equivalent to `__FILE__` for main plugin file. |
|
| 21 | + * |
|
| 22 | + * @var FilePath |
|
| 23 | + */ |
|
| 24 | + private $plugin_file; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * String indicating version for plugin |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + private $version; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var string $plugin_basename |
|
| 35 | + */ |
|
| 36 | + private $plugin_basename; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string $plugin_path |
|
| 40 | + */ |
|
| 41 | + private $plugin_path; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string $plugin_url |
|
| 45 | + */ |
|
| 46 | + private $plugin_url; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string $asset_namespace |
|
| 50 | + */ |
|
| 51 | + private $asset_namespace; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Initializes internal properties. |
|
| 57 | + * |
|
| 58 | + * @param FilePath $plugin_file |
|
| 59 | + * @param Version $version |
|
| 60 | + */ |
|
| 61 | + public function __construct(FilePath $plugin_file, Version $version) |
|
| 62 | + { |
|
| 63 | + $this->plugin_file = $plugin_file; |
|
| 64 | + $this->version = $version; |
|
| 65 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
| 66 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
| 67 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
| 68 | + $this->setAssetNamespace(); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function pluginFile() |
|
| 76 | + { |
|
| 77 | + return (string) $this->plugin_file; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @return string |
|
| 84 | + */ |
|
| 85 | + public function pluginBasename() |
|
| 86 | + { |
|
| 87 | + return $this->plugin_basename; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 95 | + public function pluginPath() |
|
| 96 | + { |
|
| 97 | + return $this->plugin_path; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return string |
|
| 104 | + */ |
|
| 105 | + public function pluginUrl() |
|
| 106 | + { |
|
| 107 | + return $this->plugin_url; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @return string |
|
| 114 | + */ |
|
| 115 | + public function version() |
|
| 116 | + { |
|
| 117 | + return (string) $this->version; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return Version |
|
| 124 | + */ |
|
| 125 | + public function versionValueObject() |
|
| 126 | + { |
|
| 127 | + return $this->version; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function distributionAssetsPath() |
|
| 135 | + { |
|
| 136 | + return $this->pluginPath() . 'assets/dist/'; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public function distributionAssetsUrl() |
|
| 144 | + { |
|
| 145 | + return $this->pluginUrl() . 'assets/dist/'; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @return string |
|
| 151 | + */ |
|
| 152 | + public function assetNamespace() |
|
| 153 | + { |
|
| 154 | + return $this->asset_namespace; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @return void |
|
| 160 | + */ |
|
| 161 | + private function setAssetNamespace() |
|
| 162 | + { |
|
| 163 | + $this->asset_namespace = sanitize_key( |
|
| 164 | + // convert directory separators to dashes and remove file extension |
|
| 165 | + str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
| 166 | + ); |
|
| 167 | + } |
|
| 168 | 168 | } |
@@ -16,26 +16,26 @@ |
||
| 16 | 16 | class ManifestFile extends Asset |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Asset constructor. |
|
| 21 | - * |
|
| 22 | - * @param DomainInterface $domain |
|
| 23 | - * @throws InvalidDataTypeException |
|
| 24 | - */ |
|
| 25 | - public function __construct(DomainInterface $domain) |
|
| 26 | - { |
|
| 27 | - parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - public function urlBase() |
|
| 32 | - { |
|
| 33 | - return $this->domain->distributionAssetsUrl(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - public function filepath() |
|
| 38 | - { |
|
| 39 | - return $this->domain->distributionAssetsPath(); |
|
| 40 | - } |
|
| 19 | + /** |
|
| 20 | + * Asset constructor. |
|
| 21 | + * |
|
| 22 | + * @param DomainInterface $domain |
|
| 23 | + * @throws InvalidDataTypeException |
|
| 24 | + */ |
|
| 25 | + public function __construct(DomainInterface $domain) |
|
| 26 | + { |
|
| 27 | + parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + public function urlBase() |
|
| 32 | + { |
|
| 33 | + return $this->domain->distributionAssetsUrl(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + public function filepath() |
|
| 38 | + { |
|
| 39 | + return $this->domain->distributionAssetsPath(); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function setType($type) |
| 84 | 84 | { |
| 85 | - if (! in_array($type, $this->validAssetTypes(), true)) { |
|
| 85 | + if ( ! in_array($type, $this->validAssetTypes(), true)) { |
|
| 86 | 86 | throw new InvalidDataTypeException( |
| 87 | 87 | 'Asset::$type', |
| 88 | 88 | $type, |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | private function setHandle($handle) |
| 101 | 101 | { |
| 102 | - if (! is_string($handle)) { |
|
| 102 | + if ( ! is_string($handle)) { |
|
| 103 | 103 | throw new InvalidDataTypeException( |
| 104 | 104 | '$handle', |
| 105 | 105 | $handle, |
@@ -16,168 +16,168 @@ |
||
| 16 | 16 | abstract class Asset |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * indicates the file extension for a build distribution CSS file |
|
| 21 | - */ |
|
| 22 | - const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * indicates the file extension for a build distribution JS file |
|
| 26 | - */ |
|
| 27 | - const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Indicates the file extension for a build distribution dependencies json file. |
|
| 31 | - */ |
|
| 32 | - const FILE_EXTENSION_DISTRIBUTION_DEPS = '.dist.deps.php'; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * indicates a Cascading Style Sheet asset |
|
| 36 | - */ |
|
| 37 | - const TYPE_CSS = 'css'; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * indicates a Javascript asset |
|
| 41 | - */ |
|
| 42 | - const TYPE_JS = 'js'; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * indicates a JSON asset |
|
| 46 | - */ |
|
| 47 | - CONST TYPE_JSON = 'json'; |
|
| 48 | - /** |
|
| 49 | - * indicates a PHP asset |
|
| 50 | - */ |
|
| 51 | - CONST TYPE_PHP = 'php'; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * indicates a Javascript manifest file |
|
| 55 | - */ |
|
| 56 | - const TYPE_MANIFEST = 'manifest'; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var DomainInterface $domain |
|
| 60 | - */ |
|
| 61 | - protected $domain; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @var string $type |
|
| 65 | - */ |
|
| 66 | - private $type; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @var string $handle |
|
| 70 | - */ |
|
| 71 | - private $handle; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @var bool $registered |
|
| 75 | - */ |
|
| 76 | - private $registered = false; |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Asset constructor. |
|
| 81 | - * |
|
| 82 | - * @param $type |
|
| 83 | - * @param string $handle |
|
| 84 | - * @param DomainInterface $domain |
|
| 85 | - * @throws InvalidDataTypeException |
|
| 86 | - */ |
|
| 87 | - public function __construct($type, $handle, DomainInterface $domain) |
|
| 88 | - { |
|
| 89 | - $this->domain = $domain; |
|
| 90 | - $this->setType($type); |
|
| 91 | - $this->setHandle($handle); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @return array |
|
| 97 | - */ |
|
| 98 | - public function validAssetTypes() |
|
| 99 | - { |
|
| 100 | - return array( |
|
| 101 | - Asset::TYPE_CSS, |
|
| 102 | - Asset::TYPE_JS, |
|
| 103 | - Asset::TYPE_MANIFEST, |
|
| 104 | - ); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @param string $type |
|
| 110 | - * @throws InvalidDataTypeException |
|
| 111 | - */ |
|
| 112 | - private function setType($type) |
|
| 113 | - { |
|
| 114 | - if (! in_array($type, $this->validAssetTypes(), true)) { |
|
| 115 | - throw new InvalidDataTypeException( |
|
| 116 | - 'Asset::$type', |
|
| 117 | - $type, |
|
| 118 | - 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
| 119 | - ); |
|
| 120 | - } |
|
| 121 | - $this->type = $type; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @param string $handle |
|
| 127 | - * @throws InvalidDataTypeException |
|
| 128 | - */ |
|
| 129 | - private function setHandle($handle) |
|
| 130 | - { |
|
| 131 | - if (! is_string($handle)) { |
|
| 132 | - throw new InvalidDataTypeException( |
|
| 133 | - '$handle', |
|
| 134 | - $handle, |
|
| 135 | - 'string' |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - $this->handle = $handle; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function assetNamespace() |
|
| 146 | - { |
|
| 147 | - return $this->domain->assetNamespace(); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 154 | - public function type() |
|
| 155 | - { |
|
| 156 | - return $this->type; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function handle() |
|
| 164 | - { |
|
| 165 | - return $this->handle; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @return bool |
|
| 170 | - */ |
|
| 171 | - public function isRegistered() |
|
| 172 | - { |
|
| 173 | - return $this->registered; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param bool $registered |
|
| 178 | - */ |
|
| 179 | - public function setRegistered($registered = true) |
|
| 180 | - { |
|
| 181 | - $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
| 182 | - } |
|
| 19 | + /** |
|
| 20 | + * indicates the file extension for a build distribution CSS file |
|
| 21 | + */ |
|
| 22 | + const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * indicates the file extension for a build distribution JS file |
|
| 26 | + */ |
|
| 27 | + const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Indicates the file extension for a build distribution dependencies json file. |
|
| 31 | + */ |
|
| 32 | + const FILE_EXTENSION_DISTRIBUTION_DEPS = '.dist.deps.php'; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * indicates a Cascading Style Sheet asset |
|
| 36 | + */ |
|
| 37 | + const TYPE_CSS = 'css'; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * indicates a Javascript asset |
|
| 41 | + */ |
|
| 42 | + const TYPE_JS = 'js'; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * indicates a JSON asset |
|
| 46 | + */ |
|
| 47 | + CONST TYPE_JSON = 'json'; |
|
| 48 | + /** |
|
| 49 | + * indicates a PHP asset |
|
| 50 | + */ |
|
| 51 | + CONST TYPE_PHP = 'php'; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * indicates a Javascript manifest file |
|
| 55 | + */ |
|
| 56 | + const TYPE_MANIFEST = 'manifest'; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var DomainInterface $domain |
|
| 60 | + */ |
|
| 61 | + protected $domain; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @var string $type |
|
| 65 | + */ |
|
| 66 | + private $type; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @var string $handle |
|
| 70 | + */ |
|
| 71 | + private $handle; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @var bool $registered |
|
| 75 | + */ |
|
| 76 | + private $registered = false; |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Asset constructor. |
|
| 81 | + * |
|
| 82 | + * @param $type |
|
| 83 | + * @param string $handle |
|
| 84 | + * @param DomainInterface $domain |
|
| 85 | + * @throws InvalidDataTypeException |
|
| 86 | + */ |
|
| 87 | + public function __construct($type, $handle, DomainInterface $domain) |
|
| 88 | + { |
|
| 89 | + $this->domain = $domain; |
|
| 90 | + $this->setType($type); |
|
| 91 | + $this->setHandle($handle); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @return array |
|
| 97 | + */ |
|
| 98 | + public function validAssetTypes() |
|
| 99 | + { |
|
| 100 | + return array( |
|
| 101 | + Asset::TYPE_CSS, |
|
| 102 | + Asset::TYPE_JS, |
|
| 103 | + Asset::TYPE_MANIFEST, |
|
| 104 | + ); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @param string $type |
|
| 110 | + * @throws InvalidDataTypeException |
|
| 111 | + */ |
|
| 112 | + private function setType($type) |
|
| 113 | + { |
|
| 114 | + if (! in_array($type, $this->validAssetTypes(), true)) { |
|
| 115 | + throw new InvalidDataTypeException( |
|
| 116 | + 'Asset::$type', |
|
| 117 | + $type, |
|
| 118 | + 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
| 119 | + ); |
|
| 120 | + } |
|
| 121 | + $this->type = $type; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @param string $handle |
|
| 127 | + * @throws InvalidDataTypeException |
|
| 128 | + */ |
|
| 129 | + private function setHandle($handle) |
|
| 130 | + { |
|
| 131 | + if (! is_string($handle)) { |
|
| 132 | + throw new InvalidDataTypeException( |
|
| 133 | + '$handle', |
|
| 134 | + $handle, |
|
| 135 | + 'string' |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + $this->handle = $handle; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function assetNamespace() |
|
| 146 | + { |
|
| 147 | + return $this->domain->assetNamespace(); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | + public function type() |
|
| 155 | + { |
|
| 156 | + return $this->type; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @return string |
|
| 162 | + */ |
|
| 163 | + public function handle() |
|
| 164 | + { |
|
| 165 | + return $this->handle; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @return bool |
|
| 170 | + */ |
|
| 171 | + public function isRegistered() |
|
| 172 | + { |
|
| 173 | + return $this->registered; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param bool $registered |
|
| 178 | + */ |
|
| 179 | + public function setRegistered($registered = true) |
|
| 180 | + { |
|
| 181 | + $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
| 182 | + } |
|
| 183 | 183 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | private function setMedia($media) |
| 56 | 56 | { |
| 57 | - if (! is_string($media)) { |
|
| 57 | + if ( ! is_string($media)) { |
|
| 58 | 58 | throw new InvalidDataTypeException( |
| 59 | 59 | '$media', |
| 60 | 60 | $media, |
@@ -17,68 +17,68 @@ |
||
| 17 | 17 | class StylesheetAsset extends BrowserAsset |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string $media |
|
| 22 | - */ |
|
| 23 | - private $media; |
|
| 20 | + /** |
|
| 21 | + * @var string $media |
|
| 22 | + */ |
|
| 23 | + private $media; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * CssFile constructor. |
|
| 28 | - * |
|
| 29 | - * @param $handle |
|
| 30 | - * @param string $source |
|
| 31 | - * @param array $dependencies |
|
| 32 | - * @param DomainInterface $domain |
|
| 33 | - * @param string $media |
|
| 34 | - * @param string $version |
|
| 35 | - * @throws InvalidDataTypeException |
|
| 36 | - * @throws DomainException |
|
| 37 | - */ |
|
| 38 | - public function __construct( |
|
| 39 | - $handle, |
|
| 40 | - $source, |
|
| 41 | - array $dependencies, |
|
| 42 | - DomainInterface $domain, |
|
| 43 | - $media = 'all', |
|
| 44 | - $version = '' |
|
| 45 | - ) { |
|
| 46 | - parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain, $version); |
|
| 47 | - $this->setMedia($media); |
|
| 48 | - } |
|
| 26 | + /** |
|
| 27 | + * CssFile constructor. |
|
| 28 | + * |
|
| 29 | + * @param $handle |
|
| 30 | + * @param string $source |
|
| 31 | + * @param array $dependencies |
|
| 32 | + * @param DomainInterface $domain |
|
| 33 | + * @param string $media |
|
| 34 | + * @param string $version |
|
| 35 | + * @throws InvalidDataTypeException |
|
| 36 | + * @throws DomainException |
|
| 37 | + */ |
|
| 38 | + public function __construct( |
|
| 39 | + $handle, |
|
| 40 | + $source, |
|
| 41 | + array $dependencies, |
|
| 42 | + DomainInterface $domain, |
|
| 43 | + $media = 'all', |
|
| 44 | + $version = '' |
|
| 45 | + ) { |
|
| 46 | + parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain, $version); |
|
| 47 | + $this->setMedia($media); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string |
|
| 53 | - */ |
|
| 54 | - public function media() |
|
| 55 | - { |
|
| 56 | - return $this->media; |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 54 | + public function media() |
|
| 55 | + { |
|
| 56 | + return $this->media; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param string $media |
|
| 62 | - * @throws InvalidDataTypeException |
|
| 63 | - */ |
|
| 64 | - private function setMedia($media) |
|
| 65 | - { |
|
| 66 | - if (! is_string($media)) { |
|
| 67 | - throw new InvalidDataTypeException( |
|
| 68 | - '$media', |
|
| 69 | - $media, |
|
| 70 | - 'string' |
|
| 71 | - ); |
|
| 72 | - } |
|
| 73 | - $this->media = $media; |
|
| 74 | - } |
|
| 60 | + /** |
|
| 61 | + * @param string $media |
|
| 62 | + * @throws InvalidDataTypeException |
|
| 63 | + */ |
|
| 64 | + private function setMedia($media) |
|
| 65 | + { |
|
| 66 | + if (! is_string($media)) { |
|
| 67 | + throw new InvalidDataTypeException( |
|
| 68 | + '$media', |
|
| 69 | + $media, |
|
| 70 | + 'string' |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | + $this->media = $media; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @since 4.9.62.p |
|
| 79 | - */ |
|
| 80 | - public function enqueueAsset() |
|
| 81 | - { |
|
| 82 | - wp_enqueue_style($this->handle()); |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @since 4.9.62.p |
|
| 79 | + */ |
|
| 80 | + public function enqueueAsset() |
|
| 81 | + { |
|
| 82 | + wp_enqueue_style($this->handle()); |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -13,28 +13,28 @@ |
||
| 13 | 13 | { |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param string $name |
|
| 18 | - * @param array $widget_options |
|
| 19 | - * @param array $control_options |
|
| 20 | - */ |
|
| 21 | - public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
| 22 | - { |
|
| 23 | - $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
| 24 | - $control_options['id_base'] = $id_base; |
|
| 25 | - $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
| 26 | - $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
| 27 | - // Register widget with WordPress |
|
| 28 | - parent::__construct($id_base, $name, $widget_options, $control_options); |
|
| 29 | - } |
|
| 16 | + /** |
|
| 17 | + * @param string $name |
|
| 18 | + * @param array $widget_options |
|
| 19 | + * @param array $control_options |
|
| 20 | + */ |
|
| 21 | + public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
| 22 | + { |
|
| 23 | + $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
| 24 | + $control_options['id_base'] = $id_base; |
|
| 25 | + $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
| 26 | + $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
| 27 | + // Register widget with WordPress |
|
| 28 | + parent::__construct($id_base, $name, $widget_options, $control_options); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $widget_class |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - public static function getIdBase($widget_class) |
|
| 37 | - { |
|
| 38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string $widget_class |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + public static function getIdBase($widget_class) |
|
| 37 | + { |
|
| 38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -35,6 +35,6 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public static function getIdBase($widget_class) |
| 37 | 37 | { |
| 38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
| 38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget'; |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -14,24 +14,24 @@ |
||
| 14 | 14 | class TicketSelectorIframeEmbedButton extends IframeEmbedButton |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * TicketSelectorIframeEmbedButton constructor. |
|
| 19 | - */ |
|
| 20 | - public function __construct() |
|
| 21 | - { |
|
| 22 | - parent::__construct( |
|
| 23 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
| 24 | - 'ticket_selector' |
|
| 25 | - ); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * TicketSelectorIframeEmbedButton constructor. |
|
| 19 | + */ |
|
| 20 | + public function __construct() |
|
| 21 | + { |
|
| 22 | + parent::__construct( |
|
| 23 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
| 24 | + 'ticket_selector' |
|
| 25 | + ); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Adds an iframe embed code button to the Event editor. |
|
| 31 | - */ |
|
| 32 | - public function addEventEditorIframeEmbedButton() |
|
| 33 | - { |
|
| 34 | - // add button for iframe code to event editor. |
|
| 35 | - $this->addEventEditorIframeEmbedButtonFilter(); |
|
| 36 | - } |
|
| 29 | + /** |
|
| 30 | + * Adds an iframe embed code button to the Event editor. |
|
| 31 | + */ |
|
| 32 | + public function addEventEditorIframeEmbedButton() |
|
| 33 | + { |
|
| 34 | + // add button for iframe code to event editor. |
|
| 35 | + $this->addEventEditorIframeEmbedButtonFilter(); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this |
| 61 | 61 | ) |
| 62 | 62 | ); |
| 63 | - if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
| 63 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
| 64 | 64 | $this->addStylesheets(array('site_theme' => '')); |
| 65 | 65 | } |
| 66 | 66 | $this->addScripts( |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | array(), |
| 80 | 80 | $this |
| 81 | 81 | ); |
| 82 | - if (! empty($js_attributes)) { |
|
| 82 | + if ( ! empty($js_attributes)) { |
|
| 83 | 83 | $this->addScriptAttributes($js_attributes); |
| 84 | 84 | } |
| 85 | 85 | $this->addLocalizedVars( |
@@ -19,77 +19,77 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class TicketSelectorIframe extends Iframe |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * TicketSelectorIframe constructor. |
|
| 24 | - * |
|
| 25 | - * @param EEM_Event $event_model |
|
| 26 | - * @param CurrentPage $current_page |
|
| 27 | - * @param RequestInterface $request |
|
| 28 | - * @throws EE_Error |
|
| 29 | - */ |
|
| 30 | - public function __construct(EEM_Event $event_model, CurrentPage $current_page, RequestInterface $request) |
|
| 31 | - { |
|
| 32 | - $current_page->setEspressoPage(true); |
|
| 33 | - $ticket_selector = LoaderFactory::getLoader()->getNew(DisplayTicketSelector::class); |
|
| 34 | - $ticket_selector->setIframe(); |
|
| 35 | - $event = $event_model->get_one_by_ID($request->getRequestParam('event', 0, 'int')); |
|
| 36 | - parent::__construct( |
|
| 37 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
| 38 | - $ticket_selector->display($event) |
|
| 39 | - ); |
|
| 40 | - $this->addStylesheets( |
|
| 41 | - apply_filters( |
|
| 42 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 43 | - array( |
|
| 44 | - 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
| 45 | - . 'ticket_selector_embed.css?ver=' |
|
| 46 | - . EVENT_ESPRESSO_VERSION, |
|
| 47 | - 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
| 48 | - . 'ticket_selector.css?ver=' |
|
| 49 | - . EVENT_ESPRESSO_VERSION, |
|
| 50 | - ), |
|
| 51 | - $this |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 54 | - if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
| 55 | - $this->addStylesheets(array('site_theme' => '')); |
|
| 56 | - } |
|
| 57 | - $this->addScripts( |
|
| 58 | - apply_filters( |
|
| 59 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 60 | - array( |
|
| 61 | - 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
| 62 | - . 'ticket_selector_iframe_embed.js?ver=' |
|
| 63 | - . EVENT_ESPRESSO_VERSION, |
|
| 64 | - ), |
|
| 65 | - $this |
|
| 66 | - ) |
|
| 67 | - ); |
|
| 68 | - $js_attributes = apply_filters( |
|
| 69 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
| 70 | - array(), |
|
| 71 | - $this |
|
| 72 | - ); |
|
| 73 | - if (! empty($js_attributes)) { |
|
| 74 | - $this->addScriptAttributes($js_attributes); |
|
| 75 | - } |
|
| 76 | - $this->addLocalizedVars( |
|
| 77 | - apply_filters( |
|
| 78 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars', |
|
| 79 | - array( |
|
| 80 | - 'ticket_selector_iframe' => true, |
|
| 81 | - 'EEDTicketSelectorMsg' => wp_strip_all_tags( |
|
| 82 | - __( |
|
| 83 | - 'Please choose at least one ticket before continuing.', |
|
| 84 | - 'event_espresso' |
|
| 85 | - ) |
|
| 86 | - ), |
|
| 87 | - ) |
|
| 88 | - ) |
|
| 89 | - ); |
|
| 90 | - do_action( |
|
| 91 | - 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
| 92 | - $this |
|
| 93 | - ); |
|
| 94 | - } |
|
| 22 | + /** |
|
| 23 | + * TicketSelectorIframe constructor. |
|
| 24 | + * |
|
| 25 | + * @param EEM_Event $event_model |
|
| 26 | + * @param CurrentPage $current_page |
|
| 27 | + * @param RequestInterface $request |
|
| 28 | + * @throws EE_Error |
|
| 29 | + */ |
|
| 30 | + public function __construct(EEM_Event $event_model, CurrentPage $current_page, RequestInterface $request) |
|
| 31 | + { |
|
| 32 | + $current_page->setEspressoPage(true); |
|
| 33 | + $ticket_selector = LoaderFactory::getLoader()->getNew(DisplayTicketSelector::class); |
|
| 34 | + $ticket_selector->setIframe(); |
|
| 35 | + $event = $event_model->get_one_by_ID($request->getRequestParam('event', 0, 'int')); |
|
| 36 | + parent::__construct( |
|
| 37 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
| 38 | + $ticket_selector->display($event) |
|
| 39 | + ); |
|
| 40 | + $this->addStylesheets( |
|
| 41 | + apply_filters( |
|
| 42 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 43 | + array( |
|
| 44 | + 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
| 45 | + . 'ticket_selector_embed.css?ver=' |
|
| 46 | + . EVENT_ESPRESSO_VERSION, |
|
| 47 | + 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
| 48 | + . 'ticket_selector.css?ver=' |
|
| 49 | + . EVENT_ESPRESSO_VERSION, |
|
| 50 | + ), |
|
| 51 | + $this |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | + if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
| 55 | + $this->addStylesheets(array('site_theme' => '')); |
|
| 56 | + } |
|
| 57 | + $this->addScripts( |
|
| 58 | + apply_filters( |
|
| 59 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 60 | + array( |
|
| 61 | + 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
| 62 | + . 'ticket_selector_iframe_embed.js?ver=' |
|
| 63 | + . EVENT_ESPRESSO_VERSION, |
|
| 64 | + ), |
|
| 65 | + $this |
|
| 66 | + ) |
|
| 67 | + ); |
|
| 68 | + $js_attributes = apply_filters( |
|
| 69 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
| 70 | + array(), |
|
| 71 | + $this |
|
| 72 | + ); |
|
| 73 | + if (! empty($js_attributes)) { |
|
| 74 | + $this->addScriptAttributes($js_attributes); |
|
| 75 | + } |
|
| 76 | + $this->addLocalizedVars( |
|
| 77 | + apply_filters( |
|
| 78 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars', |
|
| 79 | + array( |
|
| 80 | + 'ticket_selector_iframe' => true, |
|
| 81 | + 'EEDTicketSelectorMsg' => wp_strip_all_tags( |
|
| 82 | + __( |
|
| 83 | + 'Please choose at least one ticket before continuing.', |
|
| 84 | + 'event_espresso' |
|
| 85 | + ) |
|
| 86 | + ), |
|
| 87 | + ) |
|
| 88 | + ) |
|
| 89 | + ); |
|
| 90 | + do_action( |
|
| 91 | + 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
| 92 | + $this |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -19,35 +19,35 @@ |
||
| 19 | 19 | class RecaptchaFactory implements FactoryInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @param array $arguments |
|
| 24 | - * @return InvisibleRecaptcha |
|
| 25 | - * @throws InvalidDataTypeException |
|
| 26 | - * @throws InvalidInterfaceException |
|
| 27 | - * @throws InvalidArgumentException |
|
| 28 | - */ |
|
| 29 | - public static function create($arguments = array()) |
|
| 30 | - { |
|
| 31 | - return LoaderFactory::getLoader()->getShared( |
|
| 32 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha', |
|
| 33 | - $arguments |
|
| 34 | - ); |
|
| 35 | - } |
|
| 22 | + /** |
|
| 23 | + * @param array $arguments |
|
| 24 | + * @return InvisibleRecaptcha |
|
| 25 | + * @throws InvalidDataTypeException |
|
| 26 | + * @throws InvalidInterfaceException |
|
| 27 | + * @throws InvalidArgumentException |
|
| 28 | + */ |
|
| 29 | + public static function create($arguments = array()) |
|
| 30 | + { |
|
| 31 | + return LoaderFactory::getLoader()->getShared( |
|
| 32 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha', |
|
| 33 | + $arguments |
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param array $arguments |
|
| 41 | - * @return RecaptchaAdminSettings |
|
| 42 | - * @throws InvalidDataTypeException |
|
| 43 | - * @throws InvalidInterfaceException |
|
| 44 | - * @throws InvalidArgumentException |
|
| 45 | - */ |
|
| 46 | - public static function getAdminModule($arguments = array()) |
|
| 47 | - { |
|
| 48 | - return LoaderFactory::getLoader()->getShared( |
|
| 49 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings', |
|
| 50 | - $arguments |
|
| 51 | - ); |
|
| 52 | - } |
|
| 39 | + /** |
|
| 40 | + * @param array $arguments |
|
| 41 | + * @return RecaptchaAdminSettings |
|
| 42 | + * @throws InvalidDataTypeException |
|
| 43 | + * @throws InvalidInterfaceException |
|
| 44 | + * @throws InvalidArgumentException |
|
| 45 | + */ |
|
| 46 | + public static function getAdminModule($arguments = array()) |
|
| 47 | + { |
|
| 48 | + return LoaderFactory::getLoader()->getShared( |
|
| 49 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings', |
|
| 50 | + $arguments |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -33,87 +33,87 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class SocketPost implements RequestMethod |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * reCAPTCHA service host. |
|
| 38 | - * |
|
| 39 | - * @const string |
|
| 40 | - */ |
|
| 41 | - const RECAPTCHA_HOST = 'www.google.com'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @const string reCAPTCHA service path |
|
| 45 | - */ |
|
| 46 | - const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @const string Bad request error |
|
| 50 | - */ |
|
| 51 | - const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @const string Bad response error |
|
| 55 | - */ |
|
| 56 | - const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Socket to the reCAPTCHA service |
|
| 60 | - * |
|
| 61 | - * @var Socket |
|
| 62 | - */ |
|
| 63 | - private $socket; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Constructor |
|
| 67 | - * |
|
| 68 | - * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
| 69 | - */ |
|
| 70 | - public function __construct(Socket $socket = null) |
|
| 71 | - { |
|
| 72 | - if (! is_null($socket)) { |
|
| 73 | - $this->socket = $socket; |
|
| 74 | - } else { |
|
| 75 | - $this->socket = new Socket(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Submit the POST request with the specified parameters. |
|
| 81 | - * |
|
| 82 | - * @param RequestParameters $params Request parameters |
|
| 83 | - * @return string Body of the reCAPTCHA response |
|
| 84 | - */ |
|
| 85 | - public function submit(RequestParameters $params) |
|
| 86 | - { |
|
| 87 | - $errno = 0; |
|
| 88 | - $errstr = ''; |
|
| 89 | - |
|
| 90 | - if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
| 91 | - $content = $params->toQueryString(); |
|
| 92 | - |
|
| 93 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
| 94 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
| 95 | - $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
| 96 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
| 97 | - $request .= "Connection: close\r\n\r\n"; |
|
| 98 | - $request .= $content . "\r\n\r\n"; |
|
| 99 | - |
|
| 100 | - $this->socket->fwrite($request); |
|
| 101 | - $response = ''; |
|
| 102 | - |
|
| 103 | - while (! $this->socket->feof()) { |
|
| 104 | - $response .= $this->socket->fgets(4096); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $this->socket->fclose(); |
|
| 108 | - |
|
| 109 | - if (0 === strpos($response, 'HTTP/1.1 200 OK')) { |
|
| 110 | - $parts = preg_split("#\n\s*\n#Uis", $response); |
|
| 111 | - return $parts[1]; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return self::BAD_RESPONSE; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - return self::BAD_REQUEST; |
|
| 118 | - } |
|
| 36 | + /** |
|
| 37 | + * reCAPTCHA service host. |
|
| 38 | + * |
|
| 39 | + * @const string |
|
| 40 | + */ |
|
| 41 | + const RECAPTCHA_HOST = 'www.google.com'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @const string reCAPTCHA service path |
|
| 45 | + */ |
|
| 46 | + const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @const string Bad request error |
|
| 50 | + */ |
|
| 51 | + const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @const string Bad response error |
|
| 55 | + */ |
|
| 56 | + const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Socket to the reCAPTCHA service |
|
| 60 | + * |
|
| 61 | + * @var Socket |
|
| 62 | + */ |
|
| 63 | + private $socket; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Constructor |
|
| 67 | + * |
|
| 68 | + * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
| 69 | + */ |
|
| 70 | + public function __construct(Socket $socket = null) |
|
| 71 | + { |
|
| 72 | + if (! is_null($socket)) { |
|
| 73 | + $this->socket = $socket; |
|
| 74 | + } else { |
|
| 75 | + $this->socket = new Socket(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Submit the POST request with the specified parameters. |
|
| 81 | + * |
|
| 82 | + * @param RequestParameters $params Request parameters |
|
| 83 | + * @return string Body of the reCAPTCHA response |
|
| 84 | + */ |
|
| 85 | + public function submit(RequestParameters $params) |
|
| 86 | + { |
|
| 87 | + $errno = 0; |
|
| 88 | + $errstr = ''; |
|
| 89 | + |
|
| 90 | + if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
| 91 | + $content = $params->toQueryString(); |
|
| 92 | + |
|
| 93 | + $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
| 94 | + $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
| 95 | + $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
| 96 | + $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
| 97 | + $request .= "Connection: close\r\n\r\n"; |
|
| 98 | + $request .= $content . "\r\n\r\n"; |
|
| 99 | + |
|
| 100 | + $this->socket->fwrite($request); |
|
| 101 | + $response = ''; |
|
| 102 | + |
|
| 103 | + while (! $this->socket->feof()) { |
|
| 104 | + $response .= $this->socket->fgets(4096); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $this->socket->fclose(); |
|
| 108 | + |
|
| 109 | + if (0 === strpos($response, 'HTTP/1.1 200 OK')) { |
|
| 110 | + $parts = preg_split("#\n\s*\n#Uis", $response); |
|
| 111 | + return $parts[1]; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return self::BAD_RESPONSE; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + return self::BAD_REQUEST; |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function __construct(Socket $socket = null) |
| 71 | 71 | { |
| 72 | - if (! is_null($socket)) { |
|
| 72 | + if ( ! is_null($socket)) { |
|
| 73 | 73 | $this->socket = $socket; |
| 74 | 74 | } else { |
| 75 | 75 | $this->socket = new Socket(); |
@@ -87,20 +87,20 @@ discard block |
||
| 87 | 87 | $errno = 0; |
| 88 | 88 | $errstr = ''; |
| 89 | 89 | |
| 90 | - if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
| 90 | + if ($this->socket->fsockopen('ssl://'.self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
| 91 | 91 | $content = $params->toQueryString(); |
| 92 | 92 | |
| 93 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
| 94 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
| 93 | + $request = "POST ".self::SITE_VERIFY_PATH." HTTP/1.1\r\n"; |
|
| 94 | + $request .= "Host: ".self::RECAPTCHA_HOST."\r\n"; |
|
| 95 | 95 | $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| 96 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
| 96 | + $request .= "Content-length: ".strlen($content)."\r\n"; |
|
| 97 | 97 | $request .= "Connection: close\r\n\r\n"; |
| 98 | - $request .= $content . "\r\n\r\n"; |
|
| 98 | + $request .= $content."\r\n\r\n"; |
|
| 99 | 99 | |
| 100 | 100 | $this->socket->fwrite($request); |
| 101 | 101 | $response = ''; |
| 102 | 102 | |
| 103 | - while (! $this->socket->feof()) { |
|
| 103 | + while ( ! $this->socket->feof()) { |
|
| 104 | 104 | $response .= $this->socket->fgets(4096); |
| 105 | 105 | } |
| 106 | 106 | |