├── vendor ├── khartnett │ └── address-normalization │ │ ├── .gitignore │ │ ├── composer.json │ │ ├── README.md │ │ └── src │ │ └── Normalization.php ├── autoload.php └── composer │ ├── autoload_classmap.php │ ├── autoload_namespaces.php │ ├── autoload_psr4.php │ ├── autoload_static.php │ ├── LICENSE │ ├── installed.json │ ├── autoload_real.php │ └── ClassLoader.php ├── composer.phar ├── images └── loading.gif ├── composer.json ├── README.md ├── uninstall.php ├── composer.lock ├── js └── demission-scripts.js └── demission.php /vendor/khartnett/address-normalization/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | .DS_Store 3 | /nbproject/ -------------------------------------------------------------------------------- /composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piaocreative/wp-demission-plugin/HEAD/composer.phar -------------------------------------------------------------------------------- /images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piaocreative/wp-demission-plugin/HEAD/images/loading.gif -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "khartnett/address-normalization": "^1.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Demission 2 | 3 | # The shortcode for main page 4 | [demission_main] 5 | 6 | # The shortcode for property detail page 7 | [demission_property] -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/khartnett/address-normalization/src'), 10 | ); 11 | -------------------------------------------------------------------------------- /vendor/khartnett/address-normalization/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "khartnett/address-normalization", 3 | "description": "Converts mailing addresses into a normalized format", 4 | "keywords": ["mailing", "address", "normalization"], 5 | "version": "1.0.0", 6 | "license": "MIT", 7 | "authors": [ 8 | {"name": "Kieran Hartnett", "email": "khartnet@gmail.com"} 9 | ], 10 | "autoload": { 11 | "psr-4": { 12 | "Khartnett\\": "src/" 13 | } 14 | }, 15 | "require": { 16 | "php": ">=5.3.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 | prefix . $tn; 17 | $wpdb->query( $sql ); 18 | } 19 | } 20 | 21 | demis_drop_db_tables( array( 'demis_entries' ) ); 22 | -------------------------------------------------------------------------------- /vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | 11 | array ( 12 | 'Khartnett\\' => 10, 13 | ), 14 | ); 15 | 16 | public static $prefixDirsPsr4 = array ( 17 | 'Khartnett\\' => 18 | array ( 19 | 0 => __DIR__ . '/..' . '/khartnett/address-normalization/src', 20 | ), 21 | ); 22 | 23 | public static function getInitializer(ClassLoader $loader) 24 | { 25 | return \Closure::bind(function () use ($loader) { 26 | $loader->prefixLengthsPsr4 = ComposerStaticInitb00fffd2a9cedc0a58a9f7a83bf95a1c::$prefixLengthsPsr4; 27 | $loader->prefixDirsPsr4 = ComposerStaticInitb00fffd2a9cedc0a58a9f7a83bf95a1c::$prefixDirsPsr4; 28 | 29 | }, null, ClassLoader::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /vendor/khartnett/address-normalization/README.md: -------------------------------------------------------------------------------- 1 | **Purpose** 2 | 3 | A way to normalize US mailing addresses without the need for an external service. This is a port of the perl module Geo::StreetAddress::US originally written by Schuyler D. Erle. 4 | 5 | **Installation** 6 | 7 | `$composer require khartnett/address-normalization` 8 | 9 | **Usage** 10 | 11 | ``` 12 | parse('204 southeast Smith Street Harrisburg, or 97446'); 16 | /* result: 17 | [ 18 | "number" => "204", 19 | "street" => "Smith", 20 | "street_type" => "St", 21 | "unit" => "", 22 | "unit_prefix" => "", 23 | "suffix" => "", 24 | "prefix" => "SE", 25 | "city" => "Harrisburg", 26 | "state" => "OR", 27 | "postal_code" => "97446", 28 | "postal_code_ext" => null, 29 | "street_type2" => null, 30 | "prefix2" => null, 31 | "suffix2" => null, 32 | "street2" => null, 33 | ] */ 34 | $string_result = $n->parse('204 southeast Smith Street Harrisburg, or 97446', true); 35 | /* string_result: 36 | "204 SE Smith St, Harrisburg, OR 97446" 37 | */ 38 | ``` -------------------------------------------------------------------------------- /vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "khartnett/address-normalization", 4 | "version": "1.0.0", 5 | "version_normalized": "1.0.0.0", 6 | "source": { 7 | "type": "git", 8 | "url": "https://github.com/khartnett/address-normalization.git", 9 | "reference": "363572bb810c0e931e3e5f89cadc6ae81d8e1f89" 10 | }, 11 | "dist": { 12 | "type": "zip", 13 | "url": "https://api.github.com/repos/khartnett/address-normalization/zipball/363572bb810c0e931e3e5f89cadc6ae81d8e1f89", 14 | "reference": "363572bb810c0e931e3e5f89cadc6ae81d8e1f89", 15 | "shasum": "" 16 | }, 17 | "require": { 18 | "php": ">=5.3.0" 19 | }, 20 | "time": "2017-12-14T21:59:29+00:00", 21 | "type": "library", 22 | "installation-source": "dist", 23 | "autoload": { 24 | "psr-4": { 25 | "Khartnett\\": "src/" 26 | } 27 | }, 28 | "notification-url": "https://packagist.org/downloads/", 29 | "license": [ 30 | "MIT" 31 | ], 32 | "authors": [ 33 | { 34 | "name": "Kieran Hartnett", 35 | "email": "khartnet@gmail.com" 36 | } 37 | ], 38 | "description": "Converts mailing addresses into a normalized format", 39 | "keywords": [ 40 | "address", 41 | "mailing", 42 | "normalization" 43 | ] 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 30 | if ($useStaticLoader) { 31 | require_once __DIR__ . '/autoload_static.php'; 32 | 33 | call_user_func(\Composer\Autoload\ComposerStaticInitb00fffd2a9cedc0a58a9f7a83bf95a1c::getInitializer($loader)); 34 | } else { 35 | $map = require __DIR__ . '/autoload_namespaces.php'; 36 | foreach ($map as $namespace => $path) { 37 | $loader->set($namespace, $path); 38 | } 39 | 40 | $map = require __DIR__ . '/autoload_psr4.php'; 41 | foreach ($map as $namespace => $path) { 42 | $loader->setPsr4($namespace, $path); 43 | } 44 | 45 | $classMap = require __DIR__ . '/autoload_classmap.php'; 46 | if ($classMap) { 47 | $loader->addClassMap($classMap); 48 | } 49 | } 50 | 51 | $loader->register(true); 52 | 53 | return $loader; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "73bc732a26fb239a0fd6a6508147cdb0", 8 | "packages": [ 9 | { 10 | "name": "khartnett/address-normalization", 11 | "version": "1.0.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/khartnett/address-normalization.git", 15 | "reference": "363572bb810c0e931e3e5f89cadc6ae81d8e1f89" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/khartnett/address-normalization/zipball/363572bb810c0e931e3e5f89cadc6ae81d8e1f89", 20 | "reference": "363572bb810c0e931e3e5f89cadc6ae81d8e1f89", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=5.3.0" 25 | }, 26 | "type": "library", 27 | "autoload": { 28 | "psr-4": { 29 | "Khartnett\\": "src/" 30 | } 31 | }, 32 | "notification-url": "https://packagist.org/downloads/", 33 | "license": [ 34 | "MIT" 35 | ], 36 | "authors": [ 37 | { 38 | "name": "Kieran Hartnett", 39 | "email": "khartnet@gmail.com" 40 | } 41 | ], 42 | "description": "Converts mailing addresses into a normalized format", 43 | "keywords": [ 44 | "address", 45 | "mailing", 46 | "normalization" 47 | ], 48 | "time": "2017-12-14T21:59:29+00:00" 49 | } 50 | ], 51 | "packages-dev": [], 52 | "aliases": [], 53 | "minimum-stability": "stable", 54 | "stability-flags": [], 55 | "prefer-stable": false, 56 | "prefer-lowest": false, 57 | "platform": [], 58 | "platform-dev": [], 59 | "plugin-api-version": "1.1.0" 60 | } 61 | -------------------------------------------------------------------------------- /vendor/composer/ClassLoader.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Composer\Autoload; 14 | 15 | /** 16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. 17 | * 18 | * $loader = new \Composer\Autoload\ClassLoader(); 19 | * 20 | * // register classes with namespaces 21 | * $loader->add('Symfony\Component', __DIR__.'/component'); 22 | * $loader->add('Symfony', __DIR__.'/framework'); 23 | * 24 | * // activate the autoloader 25 | * $loader->register(); 26 | * 27 | * // to enable searching the include path (eg. for PEAR packages) 28 | * $loader->setUseIncludePath(true); 29 | * 30 | * In this example, if you try to use a class in the Symfony\Component 31 | * namespace or one of its children (Symfony\Component\Console for instance), 32 | * the autoloader will first look for the class under the component/ 33 | * directory, and it will then fallback to the framework/ directory if not 34 | * found before giving up. 35 | * 36 | * This class is loosely based on the Symfony UniversalClassLoader. 37 | * 38 | * @author Fabien Potencier 39 | * @author Jordi Boggiano 40 | * @see http://www.php-fig.org/psr/psr-0/ 41 | * @see http://www.php-fig.org/psr/psr-4/ 42 | */ 43 | class ClassLoader 44 | { 45 | // PSR-4 46 | private $prefixLengthsPsr4 = array(); 47 | private $prefixDirsPsr4 = array(); 48 | private $fallbackDirsPsr4 = array(); 49 | 50 | // PSR-0 51 | private $prefixesPsr0 = array(); 52 | private $fallbackDirsPsr0 = array(); 53 | 54 | private $useIncludePath = false; 55 | private $classMap = array(); 56 | private $classMapAuthoritative = false; 57 | private $missingClasses = array(); 58 | private $apcuPrefix; 59 | 60 | public function getPrefixes() 61 | { 62 | if (!empty($this->prefixesPsr0)) { 63 | return call_user_func_array('array_merge', $this->prefixesPsr0); 64 | } 65 | 66 | return array(); 67 | } 68 | 69 | public function getPrefixesPsr4() 70 | { 71 | return $this->prefixDirsPsr4; 72 | } 73 | 74 | public function getFallbackDirs() 75 | { 76 | return $this->fallbackDirsPsr0; 77 | } 78 | 79 | public function getFallbackDirsPsr4() 80 | { 81 | return $this->fallbackDirsPsr4; 82 | } 83 | 84 | public function getClassMap() 85 | { 86 | return $this->classMap; 87 | } 88 | 89 | /** 90 | * @param array $classMap Class to filename map 91 | */ 92 | public function addClassMap(array $classMap) 93 | { 94 | if ($this->classMap) { 95 | $this->classMap = array_merge($this->classMap, $classMap); 96 | } else { 97 | $this->classMap = $classMap; 98 | } 99 | } 100 | 101 | /** 102 | * Registers a set of PSR-0 directories for a given prefix, either 103 | * appending or prepending to the ones previously set for this prefix. 104 | * 105 | * @param string $prefix The prefix 106 | * @param array|string $paths The PSR-0 root directories 107 | * @param bool $prepend Whether to prepend the directories 108 | */ 109 | public function add($prefix, $paths, $prepend = false) 110 | { 111 | if (!$prefix) { 112 | if ($prepend) { 113 | $this->fallbackDirsPsr0 = array_merge( 114 | (array) $paths, 115 | $this->fallbackDirsPsr0 116 | ); 117 | } else { 118 | $this->fallbackDirsPsr0 = array_merge( 119 | $this->fallbackDirsPsr0, 120 | (array) $paths 121 | ); 122 | } 123 | 124 | return; 125 | } 126 | 127 | $first = $prefix[0]; 128 | if (!isset($this->prefixesPsr0[$first][$prefix])) { 129 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; 130 | 131 | return; 132 | } 133 | if ($prepend) { 134 | $this->prefixesPsr0[$first][$prefix] = array_merge( 135 | (array) $paths, 136 | $this->prefixesPsr0[$first][$prefix] 137 | ); 138 | } else { 139 | $this->prefixesPsr0[$first][$prefix] = array_merge( 140 | $this->prefixesPsr0[$first][$prefix], 141 | (array) $paths 142 | ); 143 | } 144 | } 145 | 146 | /** 147 | * Registers a set of PSR-4 directories for a given namespace, either 148 | * appending or prepending to the ones previously set for this namespace. 149 | * 150 | * @param string $prefix The prefix/namespace, with trailing '\\' 151 | * @param array|string $paths The PSR-4 base directories 152 | * @param bool $prepend Whether to prepend the directories 153 | * 154 | * @throws \InvalidArgumentException 155 | */ 156 | public function addPsr4($prefix, $paths, $prepend = false) 157 | { 158 | if (!$prefix) { 159 | // Register directories for the root namespace. 160 | if ($prepend) { 161 | $this->fallbackDirsPsr4 = array_merge( 162 | (array) $paths, 163 | $this->fallbackDirsPsr4 164 | ); 165 | } else { 166 | $this->fallbackDirsPsr4 = array_merge( 167 | $this->fallbackDirsPsr4, 168 | (array) $paths 169 | ); 170 | } 171 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) { 172 | // Register directories for a new namespace. 173 | $length = strlen($prefix); 174 | if ('\\' !== $prefix[$length - 1]) { 175 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 176 | } 177 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 178 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 179 | } elseif ($prepend) { 180 | // Prepend directories for an already registered namespace. 181 | $this->prefixDirsPsr4[$prefix] = array_merge( 182 | (array) $paths, 183 | $this->prefixDirsPsr4[$prefix] 184 | ); 185 | } else { 186 | // Append directories for an already registered namespace. 187 | $this->prefixDirsPsr4[$prefix] = array_merge( 188 | $this->prefixDirsPsr4[$prefix], 189 | (array) $paths 190 | ); 191 | } 192 | } 193 | 194 | /** 195 | * Registers a set of PSR-0 directories for a given prefix, 196 | * replacing any others previously set for this prefix. 197 | * 198 | * @param string $prefix The prefix 199 | * @param array|string $paths The PSR-0 base directories 200 | */ 201 | public function set($prefix, $paths) 202 | { 203 | if (!$prefix) { 204 | $this->fallbackDirsPsr0 = (array) $paths; 205 | } else { 206 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; 207 | } 208 | } 209 | 210 | /** 211 | * Registers a set of PSR-4 directories for a given namespace, 212 | * replacing any others previously set for this namespace. 213 | * 214 | * @param string $prefix The prefix/namespace, with trailing '\\' 215 | * @param array|string $paths The PSR-4 base directories 216 | * 217 | * @throws \InvalidArgumentException 218 | */ 219 | public function setPsr4($prefix, $paths) 220 | { 221 | if (!$prefix) { 222 | $this->fallbackDirsPsr4 = (array) $paths; 223 | } else { 224 | $length = strlen($prefix); 225 | if ('\\' !== $prefix[$length - 1]) { 226 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 227 | } 228 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 229 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 230 | } 231 | } 232 | 233 | /** 234 | * Turns on searching the include path for class files. 235 | * 236 | * @param bool $useIncludePath 237 | */ 238 | public function setUseIncludePath($useIncludePath) 239 | { 240 | $this->useIncludePath = $useIncludePath; 241 | } 242 | 243 | /** 244 | * Can be used to check if the autoloader uses the include path to check 245 | * for classes. 246 | * 247 | * @return bool 248 | */ 249 | public function getUseIncludePath() 250 | { 251 | return $this->useIncludePath; 252 | } 253 | 254 | /** 255 | * Turns off searching the prefix and fallback directories for classes 256 | * that have not been registered with the class map. 257 | * 258 | * @param bool $classMapAuthoritative 259 | */ 260 | public function setClassMapAuthoritative($classMapAuthoritative) 261 | { 262 | $this->classMapAuthoritative = $classMapAuthoritative; 263 | } 264 | 265 | /** 266 | * Should class lookup fail if not found in the current class map? 267 | * 268 | * @return bool 269 | */ 270 | public function isClassMapAuthoritative() 271 | { 272 | return $this->classMapAuthoritative; 273 | } 274 | 275 | /** 276 | * APCu prefix to use to cache found/not-found classes, if the extension is enabled. 277 | * 278 | * @param string|null $apcuPrefix 279 | */ 280 | public function setApcuPrefix($apcuPrefix) 281 | { 282 | $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; 283 | } 284 | 285 | /** 286 | * The APCu prefix in use, or null if APCu caching is not enabled. 287 | * 288 | * @return string|null 289 | */ 290 | public function getApcuPrefix() 291 | { 292 | return $this->apcuPrefix; 293 | } 294 | 295 | /** 296 | * Registers this instance as an autoloader. 297 | * 298 | * @param bool $prepend Whether to prepend the autoloader or not 299 | */ 300 | public function register($prepend = false) 301 | { 302 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); 303 | } 304 | 305 | /** 306 | * Unregisters this instance as an autoloader. 307 | */ 308 | public function unregister() 309 | { 310 | spl_autoload_unregister(array($this, 'loadClass')); 311 | } 312 | 313 | /** 314 | * Loads the given class or interface. 315 | * 316 | * @param string $class The name of the class 317 | * @return bool|null True if loaded, null otherwise 318 | */ 319 | public function loadClass($class) 320 | { 321 | if ($file = $this->findFile($class)) { 322 | includeFile($file); 323 | 324 | return true; 325 | } 326 | } 327 | 328 | /** 329 | * Finds the path to the file where the class is defined. 330 | * 331 | * @param string $class The name of the class 332 | * 333 | * @return string|false The path if found, false otherwise 334 | */ 335 | public function findFile($class) 336 | { 337 | // class map lookup 338 | if (isset($this->classMap[$class])) { 339 | return $this->classMap[$class]; 340 | } 341 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 342 | return false; 343 | } 344 | if (null !== $this->apcuPrefix) { 345 | $file = apcu_fetch($this->apcuPrefix.$class, $hit); 346 | if ($hit) { 347 | return $file; 348 | } 349 | } 350 | 351 | $file = $this->findFileWithExtension($class, '.php'); 352 | 353 | // Search for Hack files if we are running on HHVM 354 | if (false === $file && defined('HHVM_VERSION')) { 355 | $file = $this->findFileWithExtension($class, '.hh'); 356 | } 357 | 358 | if (null !== $this->apcuPrefix) { 359 | apcu_add($this->apcuPrefix.$class, $file); 360 | } 361 | 362 | if (false === $file) { 363 | // Remember that this class does not exist. 364 | $this->missingClasses[$class] = true; 365 | } 366 | 367 | return $file; 368 | } 369 | 370 | private function findFileWithExtension($class, $ext) 371 | { 372 | // PSR-4 lookup 373 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; 374 | 375 | $first = $class[0]; 376 | if (isset($this->prefixLengthsPsr4[$first])) { 377 | $subPath = $class; 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { 379 | $subPath = substr($subPath, 0, $lastPos); 380 | $search = $subPath . '\\'; 381 | if (isset($this->prefixDirsPsr4[$search])) { 382 | $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { 384 | if (file_exists($file = $dir . $pathEnd)) { 385 | return $file; 386 | } 387 | } 388 | } 389 | } 390 | } 391 | 392 | // PSR-4 fallback dirs 393 | foreach ($this->fallbackDirsPsr4 as $dir) { 394 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 395 | return $file; 396 | } 397 | } 398 | 399 | // PSR-0 lookup 400 | if (false !== $pos = strrpos($class, '\\')) { 401 | // namespaced class name 402 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); 404 | } else { 405 | // PEAR-like class name 406 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; 407 | } 408 | 409 | if (isset($this->prefixesPsr0[$first])) { 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { 411 | if (0 === strpos($class, $prefix)) { 412 | foreach ($dirs as $dir) { 413 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 414 | return $file; 415 | } 416 | } 417 | } 418 | } 419 | } 420 | 421 | // PSR-0 fallback dirs 422 | foreach ($this->fallbackDirsPsr0 as $dir) { 423 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 424 | return $file; 425 | } 426 | } 427 | 428 | // PSR-0 include paths. 429 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { 430 | return $file; 431 | } 432 | 433 | return false; 434 | } 435 | } 436 | 437 | /** 438 | * Scope isolated include. 439 | * 440 | * Prevents access to $this/self from included files. 441 | */ 442 | function includeFile($file) 443 | { 444 | include $file; 445 | } 446 | -------------------------------------------------------------------------------- /js/demission-scripts.js: -------------------------------------------------------------------------------- 1 | /* Global variables */ 2 | jQuery.extend( Demission, { 3 | owedAmount: 0, 4 | accessToken: 'pk.eyJ1Ijoia2lyYW5jc2U3IiwiYSI6ImNrZDUyb3I4OTFuMDEycW10ZWk1cWZrZ2YifQ.v7ZhnuHSg018lg3MXKfkZA', 5 | map: null, 6 | marker: null, 7 | mapboxClient: null, 8 | flying: false, 9 | zip: 0, 10 | streetNumber: '', 11 | }); 12 | 13 | /** 14 | * Handle search results 15 | * 16 | * @param {array} results 17 | */ 18 | Demission.handleSearchResults = function(results) { 19 | // clear results area 20 | jQuery('#demis_entry_table tbody').html(''); 21 | 22 | var numRes = results.length; 23 | 24 | if (numRes) { 25 | for (var i = 0; i < results.length; i++) { 26 | Demission.displaySearchResults(results[i]); 27 | } 28 | 29 | Demission.scrollTo('demis_search_results_area'); 30 | } 31 | } 32 | 33 | /** 34 | * Handle search no results 35 | * 36 | */ 37 | Demission.displayNoResults = function() { 38 | // clear results area 39 | jQuery('#demis_entry_table tbody').html('No record Found'); 40 | Demission.scrollTo('demis_search_results_area'); 41 | } 42 | 43 | /** 44 | * Apeend the entity to the table 45 | * 46 | * @param {object} result 47 | */ 48 | Demission.displaySearchResults = function(result) { 49 | // console.log(result); 50 | 51 | var searchResCont = jQuery('#demis_entry_table tbody'); 52 | var resultHTML = ''; 53 | 54 | resultHTML += ''; 55 | resultHTML += '' + result.state_abbr + ''; 56 | resultHTML += '' + result.tax_year + ''; 57 | resultHTML += '' + result.due_year + ''; 58 | resultHTML += '' + result.pin + ''; 59 | resultHTML += '' + result.situs + ''; 60 | resultHTML += '' + result.legal_party_1 + ''; 61 | resultHTML += '' + result.zip + ''; 62 | resultHTML += '' + result.street_numb + ''; 63 | resultHTML += ''; 64 | 65 | searchResCont.append(resultHTML); 66 | } 67 | 68 | /** 69 | * Calculate the owed amount 70 | */ 71 | Demission.calcOwedAmount = function() { 72 | var home_insurance_option = jQuery('[name=home_insurance_option]:checked').val(); 73 | var home_insurance = Demission.getValueFromCurrency(jQuery('#home_insurance').val()); 74 | var tax = jQuery('#property_tax').val(); 75 | var pay_option = jQuery('[name=pay_option]:checked').val(); 76 | var due_year = jQuery('#property_due_year').val(); 77 | 78 | if (home_insurance_option == 'no') 79 | home_insurance = 0; 80 | 81 | Demission.owedAmount = 0; 82 | 83 | var ajaxData = { 84 | "action": "demission_calc_owe_amount", 85 | "security": Demission.security, 86 | "pay_option": pay_option, 87 | "home_insurance": home_insurance, 88 | "tax": tax, 89 | "due_year": due_year 90 | }; 91 | 92 | jQuery.ajax({ 93 | type: 'POST', 94 | url: Demission.ajaxurl, 95 | data: ajaxData, 96 | complete: function(response) { 97 | var result = jQuery.parseJSON(response.responseText); 98 | Demission.doing_ajax = false; 99 | 100 | if (result.success) { 101 | Demission.owedAmount = parseFloat(result.data).toFixed(2); 102 | jQuery('#amount_owed').html(Demission.getCurrencyFormat(Demission.owedAmount)); 103 | } else { 104 | Demission.showAlert(result.data, 'error'); 105 | } 106 | } 107 | }); 108 | } 109 | 110 | /** 111 | * Get the currency format value 112 | * 113 | * @param {text} value - number 114 | */ 115 | Demission.getCurrencyFormat = function(value) { 116 | if (value == '') 117 | return '0.00'; 118 | 119 | value = value.replace(/,/g, ''); 120 | var formatVal = parseFloat(value).toLocaleString('en-US', { 121 | style: 'decimal', 122 | maximumFractionDigits: 2, 123 | minimumFractionDigits: 2 124 | }); 125 | 126 | return formatVal; 127 | } 128 | 129 | /** 130 | * Get the number from the currency format text value 131 | * 132 | * @param {text} value - currency format text 133 | */ 134 | Demission.getValueFromCurrency = function(value) { 135 | value = value.replace(/[^0-9.-]+/g, ""); 136 | 137 | return parseFloat(value); 138 | } 139 | 140 | /** 141 | * Show alert 142 | * 143 | * @param {text} alret 144 | */ 145 | Demission.showAlert = function(alert, type='error') { 146 | jQuery('.alert').html(alert); 147 | 148 | if (type == 'error') 149 | jQuery('.alert').removeClass('alert-success').addClass('alert-danger'); 150 | else if (type == 'success') 151 | jQuery('.alert').removeClass('alert-danger').addClass('alert-success'); 152 | 153 | jQuery('.alert').show(); 154 | } 155 | 156 | /** 157 | * Hide alert 158 | * 159 | */ 160 | Demission.hideAlert = function() { 161 | jQuery('.alert').html(''); 162 | jQuery('.alert').hide(); 163 | } 164 | 165 | /** 166 | * Scroll page 167 | * 168 | * @param {string} hash 169 | */ 170 | Demission.scrollTo = function(hash) { 171 | if (hash !== "") { 172 | hash = '#' + hash; 173 | 174 | jQuery('html, body').animate({ 175 | scrollTop: jQuery(hash).offset().top 176 | }, 800, function() { 177 | 178 | }); 179 | } 180 | } 181 | 182 | /** 183 | * Geocoding with address 184 | * 185 | * @param {string} query - address 186 | */ 187 | Demission.forwardGeocode = function(query = '') { 188 | if (query == '') 189 | return; 190 | 191 | Demission.mapboxClient.geocoding 192 | .forwardGeocode({ 193 | query: query, 194 | autocomplete: false, 195 | limit: 1 196 | }) 197 | .send() 198 | .then(function(response) { 199 | if ( 200 | response && 201 | response.body && 202 | response.body.features && 203 | response.body.features.length 204 | ) { 205 | var feature = response.body.features[0]; 206 | 207 | Demission.map.fire('flystart', {feature: feature}); 208 | } 209 | }); 210 | } 211 | 212 | /** 213 | * Get the zip code and address number 214 | * 215 | * @param {array} address_components 216 | */ 217 | Demission.getZipStreetnum = function(address_components) { 218 | Demission.zip = 0; 219 | Demission.streetNumber = ''; 220 | 221 | if (address_components.length) { 222 | for (var i=0; i -1) 226 | Demission.zip = addr.long_name; 227 | 228 | if (addr.types.indexOf('street_number') > -1) 229 | Demission.streetNumber = addr.long_name; 230 | } 231 | } 232 | } 233 | 234 | /** 235 | * Get the result by zip code 236 | * 237 | * @param {number} zip - zip code 238 | * @param {number} streetNumber - street number 239 | */ 240 | Demission.getResultByZipStreetnum = function(zip, streetNumber) { 241 | if (!Demission.doing_ajax) { 242 | var ajaxData = { 243 | "action": "demission_zip_streetnum_search", 244 | "security": Demission.security, 245 | "zip": zip, 246 | "streetNumber": streetNumber 247 | }; 248 | 249 | Demission.doing_ajax = true; 250 | jQuery('#demis_search_content').addClass('loading'); 251 | 252 | jQuery.ajax({ 253 | type: 'POST', 254 | url: Demission.ajaxurl, 255 | data: ajaxData, 256 | complete: function(response) { 257 | var result = jQuery.parseJSON(response.responseText); 258 | 259 | Demission.doing_ajax = false; 260 | jQuery('#demis_search_content').removeClass('loading'); 261 | 262 | if (result.success) { 263 | if (result.data.length) 264 | Demission.handleSearchResults(result.data); 265 | else 266 | Demission.displayNoResults(); 267 | } else { 268 | Demission.showAlert(result.data); 269 | } 270 | } 271 | }) 272 | } 273 | } 274 | 275 | /** 276 | * Get the result by pin code 277 | * 278 | * @param {number} pin - pin code 279 | */ 280 | Demission.getResultByPin = function(pin) { 281 | if (!Demission.doing_ajax) { 282 | var ajaxData = { 283 | "action": "demission_pin_search", 284 | "security": Demission.security, 285 | "pin": pin 286 | }; 287 | 288 | Demission.doing_ajax = true; 289 | jQuery('#demis_search_content').addClass('loading'); 290 | 291 | jQuery.ajax({ 292 | type: 'POST', 293 | url: Demission.ajaxurl, 294 | data: ajaxData, 295 | complete: function(response) { 296 | var result = jQuery.parseJSON(response.responseText); 297 | 298 | Demission.doing_ajax = false; 299 | jQuery('#demis_search_content').removeClass('loading'); 300 | 301 | if (result.success) { 302 | if (result.data.length) 303 | Demission.handleSearchResults(result.data); 304 | else 305 | Demission.displayNoResults(); 306 | } else { 307 | Demission.showAlert(result.data); 308 | } 309 | } 310 | }) 311 | } 312 | } 313 | 314 | if (typeof is_home === "undefined") var is_home = jQuery('body').hasClass('home'); 315 | if (typeof is_property_detail === "undefined") var is_property_detail = jQuery('#property_details').length != 0; 316 | 317 | 318 | jQuery(document).ready(function($) { 319 | 320 | // Initialize map 321 | if ($('#map').length) { 322 | mapboxgl.accessToken = Demission.accessToken; 323 | 324 | Demission.mapboxClient = mapboxSdk({ accessToken: Demission.accessToken }); 325 | 326 | // Map initialize 327 | Demission.map = new mapboxgl.Map({ 328 | container: 'map', 329 | style: 'mapbox://styles/mapbox/streets-v11', 330 | center: [-77.050636, 38.889248], 331 | zoom: 13 332 | }); 333 | 334 | // Add navigation control 335 | Demission.map.addControl(new mapboxgl.NavigationControl()); 336 | 337 | // Add geolocate control to the map. 338 | Demission.map.addControl( 339 | new mapboxgl.GeolocateControl({ 340 | positionOptions: { 341 | enableHighAccuracy: true 342 | }, 343 | trackUserLocation: true 344 | }) 345 | ); 346 | 347 | Demission.map.on('moveend', function(e) { 348 | if (Demission.flying) 349 | Demission.map.fire('flyend'); 350 | }); 351 | 352 | Demission.map.on('flystart', function(event) { 353 | Demission.flying = true; 354 | 355 | var feature = event.feature; 356 | 357 | Demission.map.flyTo({ 358 | zoom: 15, 359 | center:[feature.center[0], feature.center[1]], 360 | curve: 2, // change the speed at which it zooms out 361 | easing: function(t) { 362 | return t; 363 | }, 364 | essential: true // this animation is considered essential with respect to prefers-reduced-motion 365 | }); 366 | 367 | if (Demission.marker != null) 368 | Demission.marker.remove(); 369 | 370 | Demission.marker = new mapboxgl.Marker({color: 'orange'}).setLngLat(feature.center).addTo(Demission.map); 371 | 372 | // disable the map dragging 373 | Demission.map.dragPan.disable(); 374 | }); 375 | 376 | Demission.map.on('flyend', function() { 377 | Demission.flying = false; 378 | 379 | // enable the map dragging 380 | Demission.map.dragPan.enable(); 381 | 382 | if (Demission.zip != 0 || Demission.streetNumber != '') 383 | Demission.getResultByZipStreetnum(Demission.zip, Demission.streetNumber); 384 | else 385 | Demission.displayNoResults(); 386 | }); 387 | } 388 | 389 | // Home page 390 | if (is_home) { 391 | 392 | var search_location = document.getElementById('search_location'); 393 | 394 | var autocomplete = new google.maps.places.Autocomplete(search_location, { 395 | componentRestrictions: {country: "us"} 396 | }); 397 | 398 | autocomplete.addListener('place_changed', function () { 399 | var place = autocomplete.getPlace(); 400 | 401 | if (!place.geometry) { 402 | // User entered the name of a Place that was not suggested and 403 | // pressed the Enter key, or the Place Details request failed. 404 | // Do anything you like with what was entered in the ac field. 405 | search_location.value = ""; 406 | return; 407 | } 408 | 409 | console.log('You selected: ' + place.formatted_address); 410 | console.log(place.address_components); 411 | 412 | Demission.hideAlert(); 413 | 414 | Demission.getZipStreetnum(place.address_components); 415 | Demission.forwardGeocode(place.formatted_address); 416 | }); 417 | 418 | /* Property table entity click event */ 419 | $('#demis_entry_table').on('click', 'tbody tr', function() { 420 | var property_id = $(this).attr('data-id'); 421 | 422 | if (property_id == undefined) 423 | return; 424 | 425 | var url = Demission.property_url + '?id=' + property_id; 426 | 427 | window.location.href = url; 428 | }); 429 | 430 | /* Search by Pin input blue event */ 431 | $('#search_pin').on('blur', function() { 432 | Demission.hideAlert(); 433 | Demission.getResultByPin($(this).val()); 434 | }); 435 | 436 | } 437 | 438 | // Property detail page 439 | if (is_property_detail) { 440 | // Calc owed amount 441 | Demission.calcOwedAmount(); 442 | 443 | // Get the address 444 | var query = $('#property_situs').val(); 445 | 446 | // Add marker of the address to the map 447 | if (query != 'No Property Address' && query != '') { 448 | Demission.forwardGeocode(query); 449 | } 450 | 451 | // Home Insurance Options click event 452 | $('[name=home_insurance_option]').on('click', function() { 453 | var opt = $(this).val(); 454 | 455 | if (opt == 'yes') { 456 | $('.home-insurance-wrapper').show(); 457 | } else { 458 | $('.home-insurance-wrapper').hide(); 459 | } 460 | 461 | Demission.hideAlert(); 462 | }); 463 | 464 | // Pay Options click event 465 | $('[name=pay_option]').on('click', function() { 466 | var opt = $(this).val(); 467 | 468 | if (opt == '0') { 469 | $('#amount_per_month').html('every month'); 470 | } else if (opt == '1') { 471 | $('#amount_per_month').html('every 3 months'); 472 | } else if (opt == '2') { 473 | $('#amount_per_month').html('every 6 months'); 474 | } 475 | 476 | Demission.calcOwedAmount(); 477 | Demission.hideAlert(); 478 | }); 479 | 480 | // Home Insurance Input Blur event 481 | $('#home_insurance').on('blur', function() { 482 | var formatVal = Demission.getCurrencyFormat($(this).val()); 483 | 484 | $(this).val(formatVal); 485 | 486 | Demission.calcOwedAmount(); 487 | Demission.hideAlert(); 488 | }); 489 | 490 | // Signup Button click event 491 | $('#btn_signup').on('click', function() { 492 | var property_id = $('#property_id').val(); 493 | var property_tax = $('#property_tax').val(); 494 | var home_insurance = $('#home_insurance').val(); 495 | var pay_option = $('[name=pay_option]:checked').val(); 496 | 497 | var ajaxData = { 498 | "action": "demission_pay_tax", 499 | "security": Demission.security, 500 | "property_id": property_id, 501 | "property_tax": property_tax, 502 | "home_insurance": Demission.getValueFromCurrency(home_insurance), 503 | "pay_option": pay_option, 504 | "owed_amount": Demission.owedAmount 505 | }; 506 | 507 | Demission.doing_ajax = true; 508 | 509 | $.ajax({ 510 | type: 'POST', 511 | url: Demission.ajaxurl, 512 | data: ajaxData, 513 | complete: function(response) { 514 | var result = $.parseJSON(response.responseText); 515 | Demission.doing_ajax = false; 516 | 517 | if (result.success) { 518 | Demission.showAlert(result.data, 'success'); 519 | window.location.href = Demission.checkout_url; 520 | } else { 521 | Demission.showAlert(result.data, 'error'); 522 | } 523 | } 524 | }); 525 | }); 526 | 527 | } 528 | 529 | }); -------------------------------------------------------------------------------- /vendor/khartnett/address-normalization/src/Normalization.php: -------------------------------------------------------------------------------- 1 | "N", 8 | "northeast" => "NE", 9 | "east" => "E", 10 | "southeast" => "SE", 11 | "south" => "S", 12 | "southwest" => "SW", 13 | "west" => "W", 14 | "northwest" => "NW" 15 | ); 16 | 17 | private $streetTypes = array( 18 | "allee" => "aly", 19 | "alley" => "aly", 20 | "ally" => "aly", 21 | "anex" => "anx", 22 | "annex" => "anx", 23 | "annx" => "anx", 24 | "arcade" => "arc", 25 | "av" => "ave", 26 | "aven" => "ave", 27 | "avenu" => "ave", 28 | "avenue" => "ave", 29 | "avn" => "ave", 30 | "avnue" => "ave", 31 | "bayoo" => "byu", 32 | "bayou" => "byu", 33 | "beach" => "bch", 34 | "bend" => "bnd", 35 | "bluf" => "blf", 36 | "bluff" => "blf", 37 | "bluffs" => "blfs", 38 | "bot" => "btm", 39 | "bottm" => "btm", 40 | "bottom" => "btm", 41 | "boul" => "blvd", 42 | "boulevard" => "blvd", 43 | "boulv" => "blvd", 44 | "branch" => "br", 45 | "brdge" => "brg", 46 | "bridge" => "brg", 47 | "brnch" => "br", 48 | "brook" => "brk", 49 | "brooks" => "brks", 50 | "burg" => "bg", 51 | "burgs" => "bgs", 52 | "bypa" => "byp", 53 | "bypas" => "byp", 54 | "bypass" => "byp", 55 | "byps" => "byp", 56 | "camp" => "cp", 57 | "canyn" => "cyn", 58 | "canyon" => "cyn", 59 | "cape" => "cpe", 60 | "causeway" => "cswy", 61 | "causway" => "cswy", 62 | "cen" => "ctr", 63 | "cent" => "ctr", 64 | "center" => "ctr", 65 | "centers" => "ctrs", 66 | "centr" => "ctr", 67 | "centre" => "ctr", 68 | "circ" => "cir", 69 | "circl" => "cir", 70 | "circle" => "cir", 71 | "circles" => "cirs", 72 | "ck" => "crk", 73 | "cliff" => "clf", 74 | "cliffs" => "clfs", 75 | "club" => "clb", 76 | "cmp" => "cp", 77 | "cnter" => "ctr", 78 | "cntr" => "ctr", 79 | "cnyn" => "cyn", 80 | "common" => "cmn", 81 | "corner" => "cor", 82 | "corners" => "cors", 83 | "course" => "crse", 84 | "court" => "ct", 85 | "courts" => "cts", 86 | "cove" => "cv", 87 | "coves" => "cvs", 88 | "cr" => "crk", 89 | "crcl" => "cir", 90 | "crcle" => "cir", 91 | "crecent" => "cres", 92 | "creek" => "crk", 93 | "crescent" => "cres", 94 | "cresent" => "cres", 95 | "crest" => "crst", 96 | "crossing" => "xing", 97 | "crossroad" => "xrd", 98 | "crscnt" => "cres", 99 | "crsent" => "cres", 100 | "crsnt" => "cres", 101 | "crssing" => "xing", 102 | "crssng" => "xing", 103 | "crt" => "ct", 104 | "curve" => "curv", 105 | "dale" => "dl", 106 | "dam" => "dm", 107 | "div" => "dv", 108 | "divide" => "dv", 109 | "driv" => "dr", 110 | "drive" => "dr", 111 | "drives" => "drs", 112 | "drv" => "dr", 113 | "dvd" => "dv", 114 | "estate" => "est", 115 | "estates" => "ests", 116 | "exp" => "expy", 117 | "expr" => "expy", 118 | "express" => "expy", 119 | "expressway" => "expy", 120 | "expw" => "expy", 121 | "extension" => "ext", 122 | "extensions" => "exts", 123 | "extn" => "ext", 124 | "extnsn" => "ext", 125 | "falls" => "fls", 126 | "ferry" => "fry", 127 | "field" => "fld", 128 | "fields" => "flds", 129 | "flat" => "flt", 130 | "flats" => "flts", 131 | "ford" => "frd", 132 | "fords" => "frds", 133 | "forest" => "frst", 134 | "forests" => "frst", 135 | "forg" => "frg", 136 | "forge" => "frg", 137 | "forges" => "frgs", 138 | "fork" => "frk", 139 | "forks" => "frks", 140 | "fort" => "ft", 141 | "freeway" => "fwy", 142 | "freewy" => "fwy", 143 | "frry" => "fry", 144 | "frt" => "ft", 145 | "frway" => "fwy", 146 | "frwy" => "fwy", 147 | "garden" => "gdn", 148 | "gardens" => "gdns", 149 | "gardn" => "gdn", 150 | "gateway" => "gtwy", 151 | "gatewy" => "gtwy", 152 | "gatway" => "gtwy", 153 | "glen" => "gln", 154 | "glens" => "glns", 155 | "grden" => "gdn", 156 | "grdn" => "gdn", 157 | "grdns" => "gdns", 158 | "green" => "grn", 159 | "greens" => "grns", 160 | "grov" => "grv", 161 | "grove" => "grv", 162 | "groves" => "grvs", 163 | "gtway" => "gtwy", 164 | "harb" => "hbr", 165 | "harbor" => "hbr", 166 | "harbors" => "hbrs", 167 | "harbr" => "hbr", 168 | "haven" => "hvn", 169 | "havn" => "hvn", 170 | "height" => "hts", 171 | "heights" => "hts", 172 | "hgts" => "hts", 173 | "highway" => "hwy", 174 | "highwy" => "hwy", 175 | "hill" => "hl", 176 | "hills" => "hls", 177 | "hiway" => "hwy", 178 | "hiwy" => "hwy", 179 | "hllw" => "holw", 180 | "hollow" => "holw", 181 | "hollows" => "holw", 182 | "holws" => "holw", 183 | "hrbor" => "hbr", 184 | "ht" => "hts", 185 | "hway" => "hwy", 186 | "inlet" => "inlt", 187 | "island" => "is", 188 | "islands" => "iss", 189 | "isles" => "isle", 190 | "islnd" => "is", 191 | "islnds" => "iss", 192 | "jction" => "jct", 193 | "jctn" => "jct", 194 | "jctns" => "jcts", 195 | "junction" => "jct", 196 | "junctions" => "jcts", 197 | "junctn" => "jct", 198 | "juncton" => "jct", 199 | "key" => "ky", 200 | "keys" => "kys", 201 | "knol" => "knl", 202 | "knoll" => "knl", 203 | "knolls" => "knls", 204 | "la" => "ln", 205 | "lake" => "lk", 206 | "lakes" => "lks", 207 | "landing" => "lndg", 208 | "lane" => "ln", 209 | "lanes" => "ln", 210 | "ldge" => "ldg", 211 | "light" => "lgt", 212 | "lights" => "lgts", 213 | "lndng" => "lndg", 214 | "loaf" => "lf", 215 | "lock" => "lck", 216 | "locks" => "lcks", 217 | "lodg" => "ldg", 218 | "lodge" => "ldg", 219 | "loops" => "loop", 220 | "manor" => "mnr", 221 | "manors" => "mnrs", 222 | "meadow" => "mdw", 223 | "meadows" => "mdws", 224 | "medows" => "mdws", 225 | "mill" => "ml", 226 | "mills" => "mls", 227 | "mission" => "msn", 228 | "missn" => "msn", 229 | "mnt" => "mt", 230 | "mntain" => "mtn", 231 | "mntn" => "mtn", 232 | "mntns" => "mtns", 233 | "motorway" => "mtwy", 234 | "mount" => "mt", 235 | "mountain" => "mtn", 236 | "mountains" => "mtns", 237 | "mountin" => "mtn", 238 | "mssn" => "msn", 239 | "mtin" => "mtn", 240 | "neck" => "nck", 241 | "orchard" => "orch", 242 | "orchrd" => "orch", 243 | "overpass" => "opas", 244 | "ovl" => "oval", 245 | "parks" => "park", 246 | "parkway" => "pkwy", 247 | "parkways" => "pkwy", 248 | "parkwy" => "pkwy", 249 | "passage" => "psge", 250 | "paths" => "path", 251 | "pikes" => "pike", 252 | "pine" => "pne", 253 | "pines" => "pnes", 254 | "pk" => "park", 255 | "pkway" => "pkwy", 256 | "pkwys" => "pkwy", 257 | "pky" => "pkwy", 258 | "place" => "pl", 259 | "plain" => "pln", 260 | "plaines" => "plns", 261 | "plains" => "plns", 262 | "plaza" => "plz", 263 | "plza" => "plz", 264 | "point" => "pt", 265 | "points" => "pts", 266 | "port" => "prt", 267 | "ports" => "prts", 268 | "prairie" => "pr", 269 | "prarie" => "pr", 270 | "prk" => "park", 271 | "prr" => "pr", 272 | "rad" => "radl", 273 | "radial" => "radl", 274 | "radiel" => "radl", 275 | "ranch" => "rnch", 276 | "ranches" => "rnch", 277 | "rapid" => "rpd", 278 | "rapids" => "rpds", 279 | "rdge" => "rdg", 280 | "rest" => "rst", 281 | "ridge" => "rdg", 282 | "ridges" => "rdgs", 283 | "river" => "riv", 284 | "rivr" => "riv", 285 | "rnchs" => "rnch", 286 | "road" => "rd", 287 | "roads" => "rds", 288 | "route" => "rte", 289 | "rvr" => "riv", 290 | "shoal" => "shl", 291 | "shoals" => "shls", 292 | "shoar" => "shr", 293 | "shoars" => "shrs", 294 | "shore" => "shr", 295 | "shores" => "shrs", 296 | "skyway" => "skwy", 297 | "spng" => "spg", 298 | "spngs" => "spgs", 299 | "spring" => "spg", 300 | "springs" => "spgs", 301 | "sprng" => "spg", 302 | "sprngs" => "spgs", 303 | "spurs" => "spur", 304 | "sqr" => "sq", 305 | "sqre" => "sq", 306 | "sqrs" => "sqs", 307 | "squ" => "sq", 308 | "square" => "sq", 309 | "squares" => "sqs", 310 | "station" => "sta", 311 | "statn" => "sta", 312 | "stn" => "sta", 313 | "str" => "st", 314 | "strav" => "stra", 315 | "strave" => "stra", 316 | "straven" => "stra", 317 | "stravenue" => "stra", 318 | "stravn" => "stra", 319 | "stream" => "strm", 320 | "street" => "st", 321 | "streets" => "sts", 322 | "streme" => "strm", 323 | "strt" => "st", 324 | "strvn" => "stra", 325 | "strvnue" => "stra", 326 | "sumit" => "smt", 327 | "sumitt" => "smt", 328 | "summit" => "smt", 329 | "terr" => "ter", 330 | "terrace" => "ter", 331 | "throughway" => "trwy", 332 | "tpk" => "tpke", 333 | "tr" => "trl", 334 | "trace" => "trce", 335 | "traces" => "trce", 336 | "track" => "trak", 337 | "tracks" => "trak", 338 | "trafficway" => "trfy", 339 | "trail" => "trl", 340 | "trails" => "trl", 341 | "trk" => "trak", 342 | "trks" => "trak", 343 | "trls" => "trl", 344 | "trnpk" => "tpke", 345 | "trpk" => "tpke", 346 | "tunel" => "tunl", 347 | "tunls" => "tunl", 348 | "tunnel" => "tunl", 349 | "tunnels" => "tunl", 350 | "tunnl" => "tunl", 351 | "turnpike" => "tpke", 352 | "turnpk" => "tpke", 353 | "underpass" => "upas", 354 | "union" => "un", 355 | "unions" => "uns", 356 | "valley" => "vly", 357 | "valleys" => "vlys", 358 | "vally" => "vly", 359 | "vdct" => "via", 360 | "viadct" => "via", 361 | "viaduct" => "via", 362 | "view" => "vw", 363 | "views" => "vws", 364 | "vill" => "vlg", 365 | "villag" => "vlg", 366 | "village" => "vlg", 367 | "villages" => "vlgs", 368 | "ville" => "vl", 369 | "villg" => "vlg", 370 | "villiage" => "vlg", 371 | "vist" => "vis", 372 | "vista" => "vis", 373 | "vlly" => "vly", 374 | "vst" => "vis", 375 | "vsta" => "vis", 376 | "walks" => "walk", 377 | "well" => "wl", 378 | "wells" => "wls", 379 | "wy" => "way" 380 | ); 381 | 382 | private $streetTypesList = array(); 383 | 384 | private $stateCodes = array( 385 | "alabama" => "AL", 386 | "alaska" => "AK", 387 | "american samoa" => "AS", 388 | "arizona" => "AZ", 389 | "arkansas" => "AR", 390 | "california" => "CA", 391 | "colorado" => "CO", 392 | "connecticut" => "CT", 393 | "delaware" => "DE", 394 | "district of columbia" => "DC", 395 | "federated states of micronesia" => "FM", 396 | "florida" => "FL", 397 | "georgia" => "GA", 398 | "guam" => "GU", 399 | "hawaii" => "HI", 400 | "idaho" => "ID", 401 | "illinois" => "IL", 402 | "indiana" => "IN", 403 | "iowa" => "IA", 404 | "kansas" => "KS", 405 | "kentucky" => "KY", 406 | "louisiana" => "LA", 407 | "maine" => "ME", 408 | "marshall islands" => "MH", 409 | "maryland" => "MD", 410 | "massachusetts" => "MA", 411 | "michigan" => "MI", 412 | "minnesota" => "MN", 413 | "mississippi" => "MS", 414 | "missouri" => "MO", 415 | "montana" => "MT", 416 | "nebraska" => "NE", 417 | "nevada" => "NV", 418 | "new hampshire" => "NH", 419 | "new jersey" => "NJ", 420 | "new mexico" => "NM", 421 | "new york" => "NY", 422 | "north carolina" => "NC", 423 | "north dakota" => "ND", 424 | "northern mariana islands" => "MP", 425 | "ohio" => "OH", 426 | "oklahoma" => "OK", 427 | "oregon" => "OR", 428 | "palau" => "PW", 429 | "pennsylvania" => "PA", 430 | "puerto rico" => "PR", 431 | "rhode island" => "RI", 432 | "south carolina" => "SC", 433 | "south dakota" => "SD", 434 | "tennessee" => "TN", 435 | "texas" => "TX", 436 | "utah" => "UT", 437 | "vermont" => "VT", 438 | "virgin islands" => "VI", 439 | "virginia" => "VA", 440 | "washington" => "WA", 441 | "west virginia" => "WV", 442 | "wisconsin" => "WI", 443 | "wyoming" => "WY" 444 | ); 445 | 446 | public $street_type_regexp; 447 | public $number_regexp; 448 | public $fraction_regexp; 449 | public $state_regexp; 450 | public $city_and_state_regexp; 451 | public $direct_regexp; 452 | public $zip_regexp; 453 | public $corner_regexp; 454 | public $unit_regexp; 455 | public $street_regexp; 456 | public $place_regexp; 457 | public $address_regexp; 458 | public $informal_address_regexp; 459 | public $regex; 460 | 461 | public function __construct() 462 | { 463 | $this->setupStreetTypeList(); 464 | $this->setupRegularExpressions(); 465 | } 466 | 467 | private function setupStreetTypeList() 468 | { 469 | foreach ($this->streetTypes as $streetType => $streetTypeAbbr) { 470 | $this->streetTypesList[$streetType] = true; 471 | $this->streetTypesList[$streetTypeAbbr] = true; 472 | } 473 | } 474 | 475 | private function setupRegularExpressions() 476 | { 477 | $this->street_type_regexp = implode("|", array_keys($this->streetTypesList)); 478 | $this->number_regexp = '\d+-?\d*'; 479 | $this->fraction_regexp = '\d+\/\d+'; 480 | $statesAndCodes = array(); 481 | foreach($this->stateCodes as $state => $code) { 482 | $statesAndCodes[] = $state; 483 | $statesAndCodes[] = $code; 484 | } 485 | $this->state_regexp = preg_replace('/ /', "\\s", implode("|", $statesAndCodes)); 486 | $this->city_and_state_regexp = 487 | '(?:' 488 | . '([^\d,]+?)\W+' 489 | . '(' . $this->state_regexp . ')' 490 | . ')'; 491 | $directionalValues = array_values($this->directional); 492 | $expandedDirectionalValues = array(); 493 | foreach($directionalValues as $directionalValue) { 494 | $expandedDirectionalValues[] = preg_replace('/(\w)/', "$1\\\\.", $directionalValue); 495 | $expandedDirectionalValues[] = $directionalValue; 496 | } 497 | $this->direct_regexp = implode("|", array_keys($this->directional)) 498 | . "|" 499 | . implode("|", $expandedDirectionalValues); 500 | 501 | $this->zip_regexp = '(\d{5})(?:-?(\d{4})?)'; 502 | $this->corner_regexp = '(?:\band\b|\bat\b|&|\@)'; 503 | $this->unit_regexp = '(?:(su?i?te|p\W*[om]\W*b(?:ox)?|dept|apt|apartment|ro*m|fl|unit|box)\W+|\#\W*)([\w-]+)'; 504 | $this->street_regexp = 505 | '(?:' 506 | . '(?:(' . $this->direct_regexp . ')\W+' 507 | . '(' . $this->street_type_regexp . ')\b)' 508 | . '|' 509 | . '(?:(' . $this->direct_regexp . ')\W+)?' 510 | . '(?:' 511 | . '([^,]+)' 512 | . '(?:[^\w,]+(' . $this->street_type_regexp . ')\b)' 513 | . '(?:[^\w,]+(' . $this->direct_regexp . ')\b)?' 514 | . '|' 515 | . '([^,]*\d)' 516 | . '(' . $this->direct_regexp . ')\b' 517 | . '|' 518 | . '([^,]+?)' 519 | . '(?:[^\w,]+(' . $this->street_type_regexp . ')\b)?' 520 | . '(?:[^\w,]+(' . $this->direct_regexp . ')\b)?' 521 | . ')' 522 | . ')'; 523 | 524 | $this->place_regexp = 525 | '(?:' . $this->city_and_state_regexp . '\W*)?' 526 | . '(?:' . $this->zip_regexp . ')?'; 527 | 528 | $this->address_regexp = 529 | '\A\W*' 530 | . '(' . $this->number_regexp . ')\W*' 531 | . '(?:' . $this->fraction_regexp . '\W*)?' 532 | . $this->street_regexp . '\W+' 533 | . '(?:' . $this->unit_regexp . '\W+)?' 534 | . $this->place_regexp . 535 | '\W*\Z'; 536 | 537 | $this->informal_address_regexp = 538 | '\A\s*' 539 | . '(' . $this->number_regexp . ')\W*' 540 | . '(?:' . $this->fraction_regexp . '\W*)?' 541 | . $this->street_regexp . '(?:\W+|\Z)' 542 | . '(?:' . $this->unit_regexp . '(?:\W+|\Z))?' 543 | . '(?:' . $this->place_regexp . ')?'; 544 | } 545 | 546 | public function parse($address, $toString = false) { 547 | if ($toString) { 548 | return $this->parseToString($address); 549 | } 550 | return $this->parseToArray($address); 551 | } 552 | 553 | protected function parseToString($address) { 554 | $parsedAddress = $this->parseToArray($address); 555 | if($parsedAddress) { 556 | return $this->toString($parsedAddress); 557 | } 558 | return $address; 559 | } 560 | 561 | protected function parseToArray($address) { 562 | $match = array(); 563 | preg_match('/' . $this->address_regexp . '/i', $address, $match); 564 | 565 | if (!$match) { 566 | return FALSE; 567 | } 568 | $street = @$match[5]; 569 | if(!$street) { 570 | $street = @$match[10]; 571 | if(!$street) { 572 | $street = @$match[2]; 573 | } 574 | } 575 | 576 | $streetType = @$match[6]; 577 | if(!$streetType) { 578 | $streetType = @$match[3]; 579 | } 580 | 581 | $suffix = @$match[7]; 582 | if(!$suffix) { 583 | $suffix = @$match[12]; 584 | } 585 | 586 | $parsedAddress= array( 587 | 'number' => @$match[1], 588 | 'street' => $street, 589 | 'street_type' => $streetType, 590 | 'unit' => @$match[14], 591 | 'unit_prefix' => @$match[13], 592 | 'suffix' => $suffix, 593 | 'prefix' => @$match[4], 594 | 'city' => @$match[15], 595 | 'state' => @$match[16], 596 | 'postal_code' => @$match[17], 597 | 'postal_code_ext' => @$match[18] 598 | ); 599 | 600 | return $this->normalizeAddress($parsedAddress); 601 | } 602 | 603 | private function toString($add) 604 | { 605 | $line1 = $this->lineOne($add); 606 | $line2 = $this->lineTwo($add); 607 | if ($line1 && $line2) { 608 | return $line1 . ", " . $line2; 609 | } 610 | return $line1 . $line2; 611 | } 612 | 613 | private function lineOne($add) 614 | { 615 | $s = (string)$add['number']; 616 | $s .= $add['prefix'] ? " " . $add['prefix'] : ""; 617 | $s .= $add['street'] ? " " . $add['street'] : ""; 618 | $s .= $add['street_type'] ? " " . $add['street_type'] : ""; 619 | $s .= $add['suffix'] ? " " . $add['suffix'] : ""; 620 | if ($add['unit_prefix'] && $add['unit']) { 621 | $s .= " " . $add['unit_prefix']; 622 | $s .= " " . $add['unit']; 623 | } else if (!$add['unit_prefix'] && $add['unit'] ) { 624 | $s .= " #" . $add['unit']; 625 | } 626 | return $s; 627 | } 628 | 629 | private function lineTwo($add) 630 | { 631 | $s = (string)$add['city']; 632 | $s .= $add['state'] ? ", " . $add['state'] : ""; 633 | $s .= $add['postal_code'] ? " " . $add['postal_code'] : ""; 634 | $s .= $add['postal_code_ext'] ? "-" . $add['postal_code_ext'] : ""; 635 | return $s; 636 | } 637 | 638 | private function normalizeAddress($addr) 639 | { 640 | $addr['state'] = (isset($addr['state'])) ? $this->normalizeState($addr['state']) : null; 641 | $addr['street_type'] = (isset($addr['street_type'])) ? $this->normalizeStreetType($addr['street_type']) : null; 642 | $addr['prefix'] = (isset($addr['prefix'])) ? $this->normalizeDirectional($addr['prefix']) : null; 643 | $addr['suffix'] = (isset($addr['suffix'])) ? $this->normalizeDirectional($addr['suffix']) : null; 644 | $addr['street'] = (isset($addr['street'])) ? ucwords($addr['street']) : null; 645 | $addr['street_type2'] = (isset($addr['street_type2'])) ? $this->normalizeStreetType($addr['street_type2']) : null; 646 | $addr['prefix2'] = (isset($addr['prefix2'])) ? $this->normalizeDirectional($addr['prefix2']) : null; 647 | $addr['suffix2'] = (isset($addr['suffix2'])) ? $this->normalizeDirectional($addr['suffix2']) : null; 648 | $addr['street2'] = (isset($addr['street2'])) ? ucwords($addr['street2']) : null; 649 | $addr['city'] = (isset($addr['city'])) ? ucwords($addr['city']) : null; 650 | $addr['unit_prefix'] = (isset($addr['unit_prefix'])) ? ucfirst(strtolower($addr['unit_prefix'])) : null; 651 | return $addr; 652 | } 653 | 654 | private function normalizeState($state) 655 | { 656 | if(strlen($state) < 3) { 657 | return strtoupper($state); 658 | } 659 | $state = strtolower($state); 660 | if(isset($this->stateCodes[$state])) { 661 | return $this->stateCodes[$state]; 662 | } 663 | return null; 664 | } 665 | 666 | private function normalizeStreetType($sType) 667 | { 668 | $sType = strtolower($sType); 669 | if(isset($this->streetTypes[$sType])) { 670 | return ucfirst($this->streetTypes[$sType]); 671 | } 672 | if(isset($this->streetTypesList[$sType])) { 673 | return ucfirst($sType); 674 | } 675 | return null; 676 | } 677 | 678 | private function normalizeDirectional($dir) 679 | { 680 | if(strlen($dir) < 3) { 681 | return strtoupper($dir); 682 | } 683 | $dir = strtolower($dir); 684 | if(isset($this->directional[$dir])) { 685 | return $this->directional[$dir]; 686 | } 687 | return null; 688 | } 689 | } -------------------------------------------------------------------------------- /demission.php: -------------------------------------------------------------------------------- 1 | array(4, 11) 30 | ); 31 | 32 | protected $monthly_tax_payment_id = 181; 33 | protected $quarterly_tax_payment_id = 182; 34 | protected $biyearly_tax_payment_id = 183; 35 | 36 | /** 37 | * create or return an instance of this class 38 | */ 39 | public static function get_instance() { 40 | if ( null == self::$instance ) 41 | self::$instance = new self; 42 | 43 | return self::$instance; 44 | } 45 | 46 | /** 47 | * construct 48 | */ 49 | private function __construct() { 50 | $this->plugin_path = plugin_dir_path( __FILE__ ); 51 | $this->plugin_url = plugin_dir_url( __FILE__ ); 52 | 53 | add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts_styles' ) ); 54 | 55 | register_activation_hook( __FILE__, array( $this, 'activation' ) ); 56 | 57 | // shortcode 58 | add_shortcode( 'demission_main', array( $this, 'demission_main_shortcode' ) ); 59 | add_shortcode( 'demission_property', array( $this, 'demission_property_shortcode' ) ); 60 | 61 | // ajax - search by pin 62 | add_action( 'wp_ajax_nopriv_demission_pin_search', array( $this, 'handle_demission_pin_search' ) ); 63 | add_action( 'wp_ajax_demission_pin_search', array( $this, 'handle_demission_pin_search' ) ); 64 | 65 | // ajax - search by zip & streetnum 66 | add_action( 'wp_ajax_nopriv_demission_zip_streetnum_search', array( $this, 'handle_demission_zip_streetnum_search' ) ); 67 | add_action( 'wp_ajax_demission_zip_streetnum_search', array( $this, 'handle_demission_zip_streetnum_search' ) ); 68 | 69 | // ajax - calculate owed amount 70 | add_action( 'wp_ajax_nopriv_demission_calc_owe_amount', array( $this, 'handle_demission_calc_owe_amount' ) ); 71 | add_action( 'wp_ajax_demission_calc_owe_amount', array( $this, 'handle_demission_calc_owe_amount' ) ); 72 | 73 | // ajax - pay tax 74 | add_action( 'wp_ajax_nopriv_demission_pay_tax', array( $this, 'handle_demission_pay_tax' ) ); 75 | add_action( 'wp_ajax_demission_pay_tax', array( $this, 'handle_demission_pay_tax' ) ); 76 | 77 | // hook 78 | add_action( 'admin_menu', array( $this, 'csv_import_menu' ) ); 79 | add_action( 'admin_head', array( $this, 'admin_head' ) ); 80 | 81 | add_action( 'wp_head', array( $this, 'wp_head' ) ); 82 | 83 | add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'add_property_data_to_order' ), 10, 1 ); 84 | 85 | add_filter( 'woocommerce_account_menu_items', array( $this, 'custom_account_menu_items' ), 999 ); 86 | 87 | add_action( 'woocommerce_before_calculate_totals', array( $this, 'change_cart_product_price' ) ); 88 | 89 | add_action( 'woocommerce_checkout_subscription_created', array( $this, 'update_created_subscription' ) ); 90 | 91 | add_action( 'woocommerce_thankyou', array( $this, 'redirect_custom_thankyou' ) ); 92 | 93 | add_action( 'wp_login', array( $this, 'redirect_after_login' ) ); 94 | } 95 | 96 | /** 97 | * Get plugin url 98 | */ 99 | public function get_plugin_url() { 100 | return $this->plugin_url; 101 | } 102 | 103 | /** 104 | * Get plugin path 105 | */ 106 | public function get_plugin_path() { 107 | return $this->plugin_path; 108 | } 109 | 110 | /** 111 | * Plugin Activation hook 112 | * Create the {prefix}_demis_entries table 113 | */ 114 | public function activation() { 115 | global $wpdb; 116 | 117 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 118 | 119 | $charset_collate = $wpdb->get_charset_collate(); 120 | 121 | $table_name = $wpdb->prefix . 'demis_entries'; 122 | $sql_create_table = "CREATE TABLE $table_name ( 123 | id bigint(15) unsigned NOT NULL AUTO_INCREMENT, 124 | state_abbr varchar(2), 125 | tax_year int(4) unsigned, 126 | due_year int(4) unsigned, 127 | pin bigint(12) unsigned, 128 | situs varchar(150), 129 | legal_party_1 varchar(150), 130 | summary_amount decimal(10,2), 131 | zip int(5) unsigned, 132 | street_numb varchar(50), 133 | PRIMARY KEY (id) 134 | ) $charset_collate;"; 135 | 136 | dbDelta($sql_create_table); 137 | } 138 | 139 | /* 140 | public function deactivation() { 141 | 142 | }*/ 143 | 144 | /** 145 | * Register scripts and styles for the admin 146 | */ 147 | public function admin_register_scripts_styles() { 148 | 149 | } 150 | 151 | /** 152 | * Register scripts and styles for the frontend 153 | * 154 | */ 155 | public function register_scripts_styles() { 156 | wp_register_script( 'demission', $this->plugin_url . 'js/demission-scripts.js', array( 'jquery' ), '', true ); 157 | 158 | $dl = array( 159 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), 160 | 'security' => wp_create_nonce( 'demis_nonce' ), 161 | 'doing_ajax' => false, 162 | 'property_url' => get_permalink( get_page_by_path( 'property' ) ), 163 | 'account_url' => get_permalink( wc_get_page_id( 'myaccount' ) ), 164 | 'checkout_url' => wc_get_checkout_url(), 165 | ); 166 | 167 | wp_localize_script( 168 | 'demission', 169 | 'Demission', 170 | $dl 171 | ); 172 | 173 | wp_enqueue_script( 'demission' ); 174 | 175 | // Mapbox 176 | wp_enqueue_script( 'mapbox-gl', 'https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js', array(), false, true ); 177 | wp_enqueue_style( 'mapbox-gl', 'https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.css' ); 178 | wp_enqueue_script( 'es6-promise', 'https://unpkg.com/es6-promise@4.2.4/dist/es6-promise.auto.min.js', array(), false, true ); 179 | wp_enqueue_script( 'mapbox-sdk', 'https://unpkg.com/@mapbox/mapbox-sdk/umd/mapbox-sdk.min.js', array(), false, true ); 180 | 181 | // Google Map 182 | wp_enqueue_script( 'google-map', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCzx6VMeLysmf0jUp_sguVvZxnL9ORzG5U&libraries=places', array(), false, true ); 183 | } 184 | 185 | /** 186 | * The function for shortcode [demission_main] 187 | */ 188 | public function demission_main_shortcode() { 189 | ob_start(); 190 | ?> 191 | 192 |
193 | 194 |
195 |
196 |
197 |
198 |
199 | 200 | 201 |
202 |
203 | 204 |
205 |
206 |
207 | 208 | 209 |
210 |
211 |
212 |

Search Result

213 |
214 | 215 |
216 |
217 |
218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 |
StateTax YearDue YearPinSitusLegal Party 1ZipStreet Number
234 |
235 |
236 |
237 |
238 | 239 | 257 | 258 |
259 |
260 |
261 | 262 | get_results( 'SELECT * FROM ' . $wpdb->prefix . 'demis_entries WHERE id=' . $property_id . ' LIMIT 1', ARRAY_A ); 266 | $property_data = $records[0]; 267 | ?> 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 |
State:
281 |
Tax Year:
282 |
Due Year:
283 |
Pin:
284 |
Situs:
285 |
Legal Party:
286 |
Zip:
287 |
Street Number:
288 | 289 |

Do you want to add your home insurance?

290 |
291 |
292 | 293 | 296 |
297 |
298 | 299 | 302 |
303 |
304 | 305 |
306 |

Home Insurance

307 |
308 |
309 | $ 310 |
311 | 312 |
313 |
314 | 315 |

Tax: $

316 | 317 |

Payment Options

318 |
319 |
320 | 321 | 324 |
325 |
326 | 327 | 330 |
331 |
332 | 333 | 336 |
337 |
338 | 339 |

You owe: $0.00 / every month

340 | 341 | 342 | 343 | 344 | 345 |
346 |
347 | 348 |
349 |
350 |
351 | 352 |
353 | 354 | 370 | 371 | 382 | 383 | get_results( 'SELECT * FROM ' . $wpdb->prefix . 'demis_entries WHERE pin = ' . $pin . ';', ARRAY_A ); 406 | 407 | echo json_encode( 408 | array( 409 | 'success' => true, 410 | 'data' => $records 411 | ) 412 | ); 413 | 414 | exit; 415 | } 416 | 417 | echo json_encode( 418 | array( 419 | 'success' => false, 420 | 'data' => __( 'The pin code is not available.' ) 421 | ) 422 | ); 423 | 424 | exit; 425 | } 426 | 427 | /** 428 | * Create the Zip Search Form 429 | * 430 | */ 431 | public function demission_zip_search_form() { 432 | ob_start(); 433 | ?> 434 | 435 | 449 | 450 | get_results( 'SELECT * FROM ' . $wpdb->prefix . 'demis_entries ' . $cond . ';', ARRAY_A ); 484 | 485 | echo json_encode( 486 | array( 487 | 'success' => true, 488 | 'data' => $records 489 | ) 490 | ); 491 | exit; 492 | } 493 | 494 | echo json_encode( 495 | array( 496 | 'success' => false, 497 | 'data' => __( 'The zip code & street number is not available.' ) 498 | ) 499 | ); 500 | exit; 501 | } 502 | 503 | /** 504 | * demission_calc_owe_amount ajax handler 505 | * 506 | * Calcuate the owed amount and return it 507 | * 508 | */ 509 | public function handle_demission_calc_owe_amount() { 510 | // Check security 511 | if ( ! check_ajax_referer( 'demis_nonce', 'security' ) ) { 512 | wp_send_json_error( 'Invalid security token sent.' ); 513 | wp_die(); 514 | } 515 | 516 | $pay_option = $_POST['pay_option']; // pay option 517 | $home_insurance = $_POST['home_insurance']; // home insurance 518 | $tax = $_POST['tax']; // tax 519 | $due_year = $_POST['due_year']; // due year 520 | 521 | $start_date = time(); 522 | $end_date = mktime( 23, 59, 39, 12, 31, $due_year ); 523 | 524 | $diff_months = $this->get_month_diff( $start_date, $end_date ); 525 | 526 | $result = 0; 527 | $total_amount = floatval( $home_insurance ) + $diff_months * floatval( $tax ); 528 | 529 | if ( $pay_option == '0' ) { // Monthly payment 530 | $result = floatval( $total_amount / 12 ); 531 | } else if ( $pay_option == '1' ) { // Quarterl payment 532 | $result = floatval( $total_amount / 4 ); 533 | } else if ( $pay_option == '2' ) { // Biyearly payment 534 | $result = floatval( $total_amount / 2 ); 535 | } 536 | 537 | echo json_encode( 538 | array( 539 | 'success' => true, 540 | 'data' => $result 541 | ) 542 | ); 543 | 544 | exit; 545 | } 546 | 547 | /** 548 | * Calculates how many months is past between two timestamps. 549 | * 550 | * @param int $start : Start timestamp. 551 | * @param int $end : End timestamp. 552 | * 553 | */ 554 | protected function get_month_diff( $start, $end ) { 555 | $start = new DateTime( "@$start" ); 556 | $end = new DateTime( "@$end" ); 557 | 558 | $diff = $end->diff( $start ); 559 | 560 | return $diff->format( '%y' ) * 12 + $diff->format( '%m' ) + 1; 561 | } 562 | 563 | /** 564 | * demission_pay_tax ajax handler 565 | * 566 | */ 567 | public function handle_demission_pay_tax() { 568 | // Check security 569 | if ( ! check_ajax_referer( 'demis_nonce', 'security' ) ) { 570 | wp_send_json_error( 'Invalid security token sent.' ); 571 | wp_die(); 572 | } 573 | 574 | // First make sure all required functions and classes exist 575 | if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){ 576 | wp_send_json_error( 'Not support the subscription' ); 577 | wp_die(); 578 | } 579 | 580 | global $wpdb; 581 | global $woocommerce; 582 | 583 | $id = $_POST['property_id']; // property id 584 | $tax = $_POST['property_tax']; // tax amount 585 | $home_insurance = $_POST['home_insurance']; // home insurance amount 586 | $pay_option = $_POST['pay_option']; // pay option {0, 1, 2} 587 | $owed_amount = $_POST['owed_amount']; // owed amount 588 | 589 | // $user_id = get_current_user_id(); // logged in user id 590 | 591 | $cond = 'WHERE 1'; 592 | if ( $id && !empty( $id ) ) 593 | $cond .= ' AND id="' . $id . '"'; 594 | 595 | $records = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'demis_entries ' . $cond . ';', ARRAY_A ); 596 | $property_data = $records[0]; // choosed property data 597 | 598 | // Get the product with payment option 599 | if ( $pay_option == '0' ) { // Monthly payment 600 | $product_id = $this->monthly_tax_payment_id; 601 | } else if ( $pay_option == '1' ) { // Quarterl payment 602 | $product_id = $this->quarterly_tax_payment_id; 603 | } else if ( $pay_option == '2' ) { // Biyearly payment 604 | $product_id = $this->biyearly_tax_payment_id; 605 | } 606 | 607 | // Add subscription product to the cart 608 | WC()->cart->empty_cart(); 609 | WC()->cart->add_to_cart( $product_id, 1 ); 610 | 611 | // Save the subscription amount & product id to the session 612 | WC()->session->set( 'subscription_amount', $owed_amount ); 613 | WC()->session->set( 'subscription_product_id', $product_id ); 614 | WC()->session->set( 'property_data', $property_data ); 615 | WC()->session->set( 'ordered', TRUE ); 616 | 617 | // Check if the user is logged in 618 | if ( ! is_user_logged_in() ) { 619 | 620 | wp_send_json_error( 'Oops... don\'t worry. Your order was saved. Please login and continue.' ); 621 | wp_die(); 622 | } 623 | 624 | echo json_encode( 625 | array( 626 | 'success' => true, 627 | 'data' => __( 'Successfully added order and subscription. Please check your subscriptions in your account.' ) 628 | ) 629 | ); 630 | 631 | exit; 632 | } 633 | 634 | /** 635 | * change the product price in the cart 636 | * 637 | */ 638 | public function change_cart_product_price( $cart_object ) { 639 | global $woocommerce; 640 | 641 | // Get the subscriptoin amount from the session 642 | $subscription_amount = WC()->session->get( 'subscription_amount' ); 643 | 644 | // Change prices 645 | foreach ( $cart_object->get_cart() as $hash => $value ) { 646 | $value['data']->set_price( floatval( $subscription_amount ) ); 647 | } 648 | } 649 | 650 | /** 651 | * Update the created subscription 652 | * 653 | */ 654 | public function update_created_subscription( $subscription, $order, $recurring_cart ) { 655 | // Get the subscriptoin amount from the session 656 | $product_id = WC()->session->get( 'subscription_product_id' ); 657 | $property_data = WC()->session->get( 'property_data' ); 658 | 659 | // Update the order meta with property data 660 | update_post_meta( $order->get_id(), '_property_id', sanitize_text_field( $property_data['id'] ) ); 661 | update_post_meta( $order->get_id(), '_state_abbr', sanitize_text_field( $property_data['state_abbr'] ) ); 662 | update_post_meta( $order->get_id(), '_tax_year', sanitize_text_field( $property_data['tax_year'] ) ); 663 | update_post_meta( $order->get_id(), '_due_year', sanitize_text_field( $property_data['due_year'] ) ); 664 | update_post_meta( $order->get_id(), '_pin', sanitize_text_field( $property_data['pin'] ) ); 665 | update_post_meta( $order->get_id(), '_situs', sanitize_text_field( $property_data['situs'] ) ); 666 | update_post_meta( $order->get_id(), '_legal_party_1', sanitize_text_field( $property_data['legal_party_1'] ) ); 667 | update_post_meta( $order->get_id(), '_zip', sanitize_text_field( $property_data['zip'] ) ); 668 | update_post_meta( $order->get_id(), '_street_numb', sanitize_text_field( $property_data['street_numb'] ) ); 669 | update_post_meta( $order->get_id(), '_summary_amount', sanitize_text_field( $property_data['summary_amount'] ) ); 670 | update_post_meta( $order->get_id(), '_home_insurance', sanitize_text_field( $home_insurance ) ); 671 | } 672 | 673 | /** 674 | * Redirect subscriptions page after order 675 | * 676 | */ 677 | public function redirect_custom_thankyou( $order_id ) { 678 | $custom_link = get_permalink( wc_get_page_id( 'myaccount' ) ) . '/subscriptions'; 679 | wp_safe_redirect( $custom_link ); 680 | exit; 681 | } 682 | 683 | /** 684 | * Create the Address Search Form 685 | */ 686 | public function demission_address_search_form() { 687 | ob_start(); 688 | ?> 689 | 690 |
691 | 692 | 693 |
694 | 695 | true, 743 | 'data' => __( 'Successfully searched' ) 744 | ) 745 | ); 746 | 747 | exit; 748 | } 749 | 750 | /** 751 | * Add CSV Import menu on the admin side 752 | */ 753 | public function csv_import_menu() { 754 | add_menu_page( 'CSV Import', 'CSV Import', 'manage_options', 'demis_csv_import', array( $this, 'csv_import_admin_page' ) ); 755 | } 756 | 757 | /** 758 | * Create the csv import page on the admin side 759 | */ 760 | public function csv_import_admin_page() { 761 | global $wpdb; 762 | 763 | // Table name 764 | $tablename = $wpdb->prefix . 'demis_entries'; 765 | 766 | // Import CSV 767 | if ( isset( $_POST['demisimport'] ) ) { 768 | 769 | // File extension 770 | $extension = pathinfo( $_FILES['import_file']['name'], PATHINFO_EXTENSION ); 771 | 772 | // If file extension is 'csv' 773 | if ( !empty( $_FILES['import_file']['name'] ) && $extension == 'csv' ) { 774 | 775 | $totalInserted = 0; 776 | 777 | // Open file in read mode 778 | $csvFile = fopen( $_FILES['import_file']['tmp_name'], 'r' ); 779 | 780 | fgetcsv( $csvFile ); // Skipping header row 781 | 782 | echo '
'; 783 | 784 | // Read file 785 | $line_count = 1; 786 | 787 | while ( ( $csvData = fgetcsv( $csvFile ) ) !== FALSE ) { 788 | 789 | $csvData = array_map( 'utf8_encode', $csvData ); 790 | 791 | // Row column length 792 | $dataLen = count( $csvData ); 793 | 794 | // Assign value to variables 795 | $state_abbr = trim( $csvData[0] ); // State Abbr 796 | $tax_year = intval( $csvData[1] ); // Tax Year 797 | $due_year = intval( $csvData[2] ); // Due Year 798 | $pin = trim( $csvData[3] ); // PIN 799 | $situs = trim( $csvData[4] ); // Situs 800 | $legal_party_1 = trim( $csvData[5] ); // Legal Party 1 801 | $summary_amount = trim( $csvData[6] ); // Summary Amount 802 | 803 | $exp_situs = explode( ' ', $situs ); 804 | $cnt_situs = count( $exp_situs ); 805 | 806 | if ( $cnt_situs > 1 ) { 807 | $street_numb = $exp_situs[0]; 808 | $zip = $exp_situs[$cnt_situs-1]; 809 | $zip = preg_replace( '/\D/', '', $zip ); 810 | $zip = substr( $zip, 0, 5 ); 811 | if ( !$zip ) { 812 | $zip = ''; 813 | } 814 | } else { 815 | $street_numb = ''; 816 | $zip = ''; 817 | $situs = 'No Property Address'; 818 | } 819 | ?> 820 | 821 |
822 |
823 |
state_abbr:
824 |
tax_year:
825 |
due_year:
826 |
pin:
827 |
situs:
828 |
legal_party_1:
829 |
summary_amount:
830 |
street_numb:
831 |
zip:
832 | 833 | insert( $tablename, array( 836 | 'state_abbr' => $state_abbr, 837 | 'tax_year' => $tax_year, 838 | 'due_year' => $due_year, 839 | 'pin' => $pin, 840 | 'situs' => $situs, 841 | 'legal_party_1' => $legal_party_1, 842 | 'summary_amount' => $summary_amount, 843 | 'street_numb' => $street_numb, 844 | 'zip' => $zip 845 | )); 846 | 847 | if ( $insert ) { 848 | $totalInserted ++; 849 | echo '
Inserted
'; 850 | } else { 851 | echo '
Not Inserted
'; 852 | } 853 | $line_count++; 854 | 855 | echo '
'; 856 | } 857 | echo '

Total record Inserted : ' . $totalInserted . '

'; 858 | } else { 859 | echo '

Invalid File

'; 860 | } 861 | 862 | } else { 863 | ?> 864 | 865 |

CSV Import

866 | 867 |
' enctype='multipart/form-data'> 868 | 869 | 870 |
871 | 872 | 882 | 883 | 887 | 888 | 897 | 898 | 908 | 909 | ' . __( 'Property Id' ) . ': ' . get_post_meta( $order->get_id(), '_property_id', true ) . '

'; 920 | echo '

' . __( 'State' ) . ': ' . get_post_meta( $order->get_id(), '_state_abbr', true ) . '

'; 921 | echo '

' . __( 'Tax Year' ) . ': ' . get_post_meta( $order->get_id(), '_tax_year', true ) . '

'; 922 | echo '

' . __( 'Due Year' ) . ': ' . get_post_meta( $order->get_id(), '_due_year', true ) . '

'; 923 | echo '

' . __( 'Pin' ) . ': ' . get_post_meta( $order->get_id(), '_pin', true ) . '

'; 924 | echo '

' . __( 'Address' ) . ': ' . get_post_meta( $order->get_id(), '_situs', true ) . '

'; 925 | echo '

' . __( 'Legal Party 1' ) . ': ' . get_post_meta( $order->get_id(), '_legal_party_1', true ) . '

'; 926 | echo '

' . __( 'Zip' ) . ': ' . get_post_meta( $order->get_id(), '_zip', true ) . '

'; 927 | echo '

' . __( 'Street Number' ) . ': ' . get_post_meta( $order->get_id(), '_street_numb', true ) . '

'; 928 | echo '

' . __( 'Tax Amount' ) . ': ' . get_post_meta( $order->get_id(), '_summary_amount', true ) . '

'; 929 | echo '

' . __( 'Home Insurance' ) . ': ' . get_post_meta( $order->get_id(), '_home_insurance', true ) . '

'; 930 | } 931 | 932 | /** 933 | * Customize the account menu 934 | * 935 | * @param $items - account menu items array 936 | * 937 | */ 938 | public function custom_account_menu_items( $items ) { 939 | unset( $items['downloads'] ); 940 | unset( $items['orders'] ); 941 | return $items; 942 | } 943 | 944 | /** 945 | * Redirect to home page or checkout page after login 946 | * 947 | */ 948 | public function redirect_after_login() { 949 | global $woocommerce; 950 | 951 | $ordered = WC()->session->get( 'subscription_amount' ); 952 | 953 | if ( $ordered ) { 954 | wp_safe_redirect( wc_get_checkout_url() ); 955 | } else { 956 | wp_safe_redirect( home_url() ); 957 | } 958 | 959 | exit(); 960 | } 961 | 962 | 963 | } 964 | 965 | Demission_Plugin::get_instance(); --------------------------------------------------------------------------------