diff --git a/composer.json b/composer.json index 0e89d44..93f78a9 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "license": "GPL2", "autoload": { "psr-4": { - "WeDevs\\DokanMigrator\\": "includes/" + "WeDevs\\DokanMigrator\\": "includes/", + "WeDevs\\DokanMigrator\\Dependencies\\": "dependencies/" } }, "authors": [ @@ -17,20 +18,29 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "appsero/client": "dev-develop" + "appsero/client": "^2.0.4" }, "require-dev": { "wp-coding-standards/wpcs": "*", "dealerdirect/phpcodesniffer-composer-installer": "*", "tareq1988/wp-php-cs-fixer": "*", + "coenjacobs/mozart": "^0.7.1", "phpcompatibility/phpcompatibility-wp": "*" }, "scripts": { "phpcs": [ - "phpcs -p -s" + "phpcs -p -s" ], "phpcbf": [ - "phpcbf -p" + "phpcbf -p" + ], + "post-install-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || \"vendor/bin/mozart\" compose", + "composer dump-autoload" + ], + "post-update-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || \"vendor/bin/mozart\" compose", + "composer dump-autoload" ] }, "config": { @@ -40,5 +50,28 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } + }, + "extra": { + "mozart": { + "dep_namespace": "WeDevs\\DokanMigrator\\Dependencies\\", + "dep_directory": "/dependencies/", + "classmap_directory": "/dependencies/classes/", + "classmap_prefix": "Dokan_Migrator_", + "packages": [ + "appsero/updater", + "appsero/client" + ], + "excluded_packages": [ + "psr/container" + ], + "override_autoload": { + "google/apiclient": { + "classmap": [ + "src/" + ] + } + }, + "delete_vendor_directories": true + } } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index c0f5194..2d7b272 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9f32182008d6112d75d37194fb6c9c81", + "content-hash": "1e5fcd10f0881a86c53978b1b5f4b83e", "packages": [ { "name": "appsero/client", - "version": "dev-develop", + "version": "v2.0.4", "source": { "type": "git", "url": "https://github.com/Appsero/client.git", - "reference": "3b68f17ac29d56d14a78cc4817c4b80f692e4e3a" + "reference": "12ff65b9770286d21edf314e7acfcd26fdde3315" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Appsero/client/zipball/3b68f17ac29d56d14a78cc4817c4b80f692e4e3a", - "reference": "3b68f17ac29d56d14a78cc4817c4b80f692e4e3a", + "url": "https://api.github.com/repos/Appsero/client/zipball/12ff65b9770286d21edf314e7acfcd26fdde3315", + "reference": "12ff65b9770286d21edf314e7acfcd26fdde3315", "shasum": "" }, "require": { @@ -31,7 +31,6 @@ "tareq1988/wp-php-cs-fixer": "dev-master", "wp-coding-standards/wpcs": "dev-develop" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -57,12 +56,70 @@ ], "support": { "issues": "https://github.com/Appsero/client/issues", - "source": "https://github.com/Appsero/client/tree/develop" + "source": "https://github.com/Appsero/client/tree/v2.0.4" }, - "time": "2023-10-11T09:13:55+00:00" + "time": "2024-11-25T05:58:23+00:00" } ], "packages-dev": [ + { + "name": "coenjacobs/mozart", + "version": "0.7.1", + "source": { + "type": "git", + "url": "https://github.com/coenjacobs/mozart.git", + "reference": "dbcdeb992d20d9c8914eef090f9a0d684bb1102c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/coenjacobs/mozart/zipball/dbcdeb992d20d9c8914eef090f9a0d684bb1102c", + "reference": "dbcdeb992d20d9c8914eef090f9a0d684bb1102c", + "shasum": "" + }, + "require": { + "league/flysystem": "^1.0", + "php": "^7.3|^8.0", + "symfony/console": "^4|^5", + "symfony/finder": "^4|^5" + }, + "require-dev": { + "mheap/phpunit-github-actions-printer": "^1.4", + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.4" + }, + "bin": [ + "bin/mozart" + ], + "type": "library", + "autoload": { + "psr-4": { + "CoenJacobs\\Mozart\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Coen Jacobs", + "email": "coenjacobs@gmail.com" + } + ], + "description": "Composes all dependencies as a package inside a WordPress plugin", + "support": { + "issues": "https://github.com/coenjacobs/mozart/issues", + "source": "https://github.com/coenjacobs/mozart/tree/0.7.1" + }, + "funding": [ + { + "url": "https://github.com/coenjacobs", + "type": "github" + } + ], + "time": "2021-02-02T21:37:03+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v1.0.0", @@ -141,6 +198,156 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "league/flysystem", + "version": "1.1.10", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1", + "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "league/mime-type-detection": "^1.3", + "php": "^7.2.5 || ^8.0" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "phpspec/prophecy": "^1.11.1", + "phpunit/phpunit": "^8.5.8" + }, + "suggest": { + "ext-ftp": "Allows you to use FTP server storage", + "ext-openssl": "Allows you to use FTPS server storage", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", + "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/1.1.10" + }, + "funding": [ + { + "url": "https://offset.earth/frankdejonge", + "type": "other" + } + ], + "time": "2022-10-04T09:16:37+00:00" + }, + { + "name": "league/mime-type-detection", + "version": "1.16.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/mime-type-detection.git", + "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/2d6702ff215bf922936ccc1ad31007edc76451b9", + "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.2", + "phpstan/phpstan": "^0.12.68", + "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\MimeTypeDetection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Mime-type detection for Flysystem", + "support": { + "issues": "https://github.com/thephpleague/mime-type-detection/issues", + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.16.0" + }, + "funding": [ + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2024-09-21T08:32:55+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -205,28 +412,28 @@ }, { "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.2", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/293975b465e0e709b571cbf0c957c6c0a7b9a2ac", + "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac", "shasum": "" }, "require": { "phpcompatibility/php-compatibility": "^9.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "paragonie/random_compat": "dev-master", "paragonie/sodium_compat": "dev-master" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -256,22 +463,37 @@ ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" }, - "time": "2022-10-25T01:46:02+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:30:46+00:00" }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.4", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", - "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", "shasum": "" }, "require": { @@ -279,10 +501,10 @@ "phpcompatibility/phpcompatibility-paragonie": "^1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -311,9 +533,24 @@ ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2022-10-24T09:00:36+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-24T21:37:59+00:00" }, { "name": "phpcsstandards/phpcsextra", @@ -395,22 +632,22 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.9", + "version": "1.0.12", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.8.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -479,20 +716,68 @@ "type": "open_collective" } ], - "time": "2023-12-08T14:50:00+00:00" + "time": "2024-05-20T13:34:27+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.0", + "version": "3.11.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", "shasum": "" }, "require": { @@ -502,11 +787,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -559,27 +844,65 @@ "type": "open_collective" } ], - "time": "2023-12-08T12:32:31+00:00" + "time": "2024-11-16T12:02:36+00:00" }, { - "name": "tareq1988/wp-php-cs-fixer", - "version": "1.0.0", + "name": "symfony/console", + "version": "v5.4.47", "source": { "type": "git", - "url": "https://github.com/tareq1988/wp-php-cs-fixer.git", - "reference": "eeef65598ae7bac55a09073e666ec0eabf303a12" + "url": "https://github.com/symfony/console.git", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tareq1988/wp-php-cs-fixer/zipball/eeef65598ae7bac55a09073e666ec0eabf303a12", - "reference": "eeef65598ae7bac55a09073e666ec0eabf303a12", + "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", "shasum": "" }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, "type": "library", "autoload": { "psr-4": { - "WeDevs\\Fixer\\": "src" - } + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -587,89 +910,921 @@ ], "authors": [ { - "name": "Tareq Hasan", - "email": "tareq@wedevs.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "WordPress rules for php-cs-fixer", + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], "support": { - "issues": "https://github.com/tareq1988/wp-php-cs-fixer/issues", - "source": "https://github.com/tareq1988/wp-php-cs-fixer/tree/1.0.0" + "source": "https://github.com/symfony/console/tree/v5.4.47" }, - "time": "2022-08-26T09:36:52+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-11-06T11:30:55+00:00" }, { - "name": "wp-coding-standards/wpcs", - "version": "3.0.1", + "name": "symfony/deprecation-contracts", + "version": "v2.5.4", "source": { "type": "git", - "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", "shasum": "" }, "require": { - "ext-filter": "*", - "ext-libxml": "*", - "ext-tokenizer": "*", - "ext-xmlreader": "*", - "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.1.0", - "phpcsstandards/phpcsutils": "^1.0.8", - "squizlabs/php_codesniffer": "^3.7.2" + "php": ">=7.1" }, - "require-dev": { - "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } }, - "suggest": { - "ext-iconv": "For improved results", - "ext-mbstring": "For improved results" + "autoload": { + "files": [ + "function.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Contributors", - "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", - "keywords": [ - "phpcs", - "standards", - "static analysis", - "wordpress" - ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", "support": { - "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", - "source": "https://github.com/WordPress/WordPress-Coding-Standards", - "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" }, "funding": [ { - "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "url": "https://symfony.com/sponsor", "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "time": "2023-09-14T07:06:09+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "appsero/client": 20 - }, + "time": "2024-09-25T14:11:13+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.4.45", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "63741784cd7b9967975eec610b256eed3ede022b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b", + "reference": "63741784cd7b9967975eec610b256eed3ede022b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-28T13:32:08+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "3833d7255cc303546435cb650316bff708a1c75c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.5.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300", + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:11:13+00:00" + }, + { + "name": "symfony/string", + "version": "v5.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-11-10T20:33:58+00:00" + }, + { + "name": "tareq1988/wp-php-cs-fixer", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/tareq1988/wp-php-cs-fixer.git", + "reference": "eeef65598ae7bac55a09073e666ec0eabf303a12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tareq1988/wp-php-cs-fixer/zipball/eeef65598ae7bac55a09073e666ec0eabf303a12", + "reference": "eeef65598ae7bac55a09073e666ec0eabf303a12", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "WeDevs\\Fixer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tareq Hasan", + "email": "tareq@wedevs.com" + } + ], + "description": "WordPress rules for php-cs-fixer", + "support": { + "issues": "https://github.com/tareq1988/wp-php-cs-fixer/issues", + "source": "https://github.com/tareq1988/wp-php-cs-fixer/tree/1.0.0" + }, + "time": "2022-08-26T09:36:52+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=5.4", + "phpcsstandards/phpcsextra": "^1.2.1", + "phpcsstandards/phpcsutils": "^1.0.10", + "squizlabs/php_codesniffer": "^3.9.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcompatibility/php-compatibility": "^9.0", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2024-03-25T16:39:00+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -679,5 +1834,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/dependencies/Appsero/Client.php b/dependencies/Appsero/Client.php new file mode 100644 index 0000000..8756dae --- /dev/null +++ b/dependencies/Appsero/Client.php @@ -0,0 +1,278 @@ +hash = $hash; + $this->name = $name; + $this->file = $file; + + $this->set_basename_and_slug(); + } + + /** + * Initialize insights class + * + * @return WeDevs\DokanMigrator\Dependencies\Appsero\Insights + */ + public function insights() { + if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) { + require_once __DIR__ . '/Insights.php'; + } + + // if already instantiated, return the cached one + if ( $this->insights ) { + return $this->insights; + } + + $this->insights = new Insights( $this ); + + return $this->insights; + } + + /** + * Initialize plugin/theme updater + * + * @return void + */ + public function updater() { + // do not show update notice on ajax request and rest api request + if ( wp_doing_ajax() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { + return; + } + + // show deprecated notice + _deprecated_function( __CLASS__ . '::updater', '2.0', '\WeDevs\DokanMigrator\Dependencies\Appsero\Updater::init($client);, for more details please visit: https://appsero.com/docs/appsero-developers-guide/appsero-client/appsero-sdk-updater-changes/' ); + + // initialize the new updater + if ( method_exists( '\WeDevs\DokanMigrator\Dependencies\Appsero\Updater', 'init' ) ) { + \WeDevs\DokanMigrator\Dependencies\Appsero\Updater::init( $this ); + } + } + + /** + * Initialize license checker + * + * @return WeDevs\DokanMigrator\Dependencies\Appsero\License + */ + public function license() { + if ( ! class_exists( __NAMESPACE__ . '\License' ) ) { + require_once __DIR__ . '/License.php'; + } + + // if already instantiated, return the cached one + if ( $this->license ) { + return $this->license; + } + + $this->license = new License( $this ); + + return $this->license; + } + + /** + * API Endpoint + * + * @return string + */ + public function endpoint() { + $endpoint = apply_filters( 'appsero_endpoint', 'https://api.appsero.com' ); + + return trailingslashit( $endpoint ); + } + + /** + * Set project basename, slug and version + * + * @return void + */ + protected function set_basename_and_slug() { + if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) { + $this->basename = plugin_basename( $this->file ); + + list( $this->slug, $mainfile ) = explode( '/', $this->basename ); + + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + + $plugin_data = get_plugin_data( $this->file, false, false ); + + $this->project_version = $plugin_data['Version']; + $this->type = 'plugin'; + } else { + $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file ); + + list( $this->slug, $mainfile ) = explode( '/', $this->basename ); + + $theme = wp_get_theme( $this->slug ); + + $this->project_version = $theme->version; + $this->type = 'theme'; + } + + $this->textdomain = $this->slug; + } + + /** + * Send request to remote endpoint + * + * @param array $params + * @param string $route + * + * @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed + */ + public function send_request( $params, $route, $blocking = false ) { + $url = $this->endpoint() . $route; + + $headers = [ + 'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';', + 'Accept' => 'application/json', + ]; + + $response = wp_remote_post( + $url, + [ + 'method' => 'POST', + 'timeout' => 30, + 'redirection' => 5, + 'httpversion' => '1.0', + 'blocking' => $blocking, + 'headers' => $headers, + 'body' => array_merge( $params, [ 'client' => $this->version ] ), + 'cookies' => [], + ] + ); + + return $response; + } + + /** + * Check if the current server is localhost + * + * @return bool + */ + public function is_local_server() { + $is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ], true ); + + return apply_filters( 'appsero_is_local', $is_local ); + } + + /** + * Translate function _e() + */ + // phpcs:ignore + public function _etrans( $text ) { + call_user_func( '_e', $text, $this->textdomain ); + } + + /** + * Translate function __() + */ + // phpcs:ignore + public function __trans( $text ) { + return call_user_func( '__', $text, $this->textdomain ); + } + + /** + * Set project textdomain + */ + public function set_textdomain( $textdomain ) { + $this->textdomain = $textdomain; + } +} diff --git a/dependencies/Appsero/Insights.php b/dependencies/Appsero/Insights.php new file mode 100644 index 0000000..c862425 --- /dev/null +++ b/dependencies/Appsero/Insights.php @@ -0,0 +1,1291 @@ +client = $client; + } + } + + /** + * Don't show the notice + * + * @return self + */ + public function hide_notice() { + $this->show_notice = false; + + return $this; + } + + /** + * Add plugin data if needed + * + * @return self + */ + public function add_plugin_data() { + $this->plugin_data = true; + + return $this; + } + + /** + * Add extra data if needed + * + * @param array $data Extra data. + * + * @return self + */ + public function add_extra( $data = array() ) { + $this->extra_data = $data; + + return $this; + } + + /** + * Set custom notice text + * + * @param string $text Custom notice text. + * + * @return self + */ + public function notice( $text = '' ) { + $this->notice = $text; + + return $this; + } + + /** + * Initialize insights + * + * @return void + */ + public function init() { + if ( 'plugin' === $this->client->type ) { + $this->init_plugin(); + } elseif ( 'theme' === $this->client->type ) { + $this->init_theme(); + } + } + + /** + * Initialize theme hooks + * + * @return void + */ + public function init_theme() { + $this->init_common(); + + add_action( 'switch_theme', array( $this, 'deactivation_cleanup' ) ); + add_action( 'switch_theme', array( $this, 'theme_deactivated' ), 12, 3 ); + } + + /** + * Initialize plugin hooks + * + * @return void + */ + public function init_plugin() { + add_filter( 'plugin_action_links_' . $this->client->basename, array( $this, 'plugin_action_links' ) ); + add_action( 'admin_footer', array( $this, 'deactivate_scripts' ) ); + + $this->init_common(); + + register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) ); + register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) ); + } + + /** + * Initialize common hooks + * + * @return void + */ + protected function init_common() { + if ( $this->show_notice ) { + add_action( 'admin_notices', array( $this, 'admin_notice' ) ); + } + + add_action( 'admin_init', array( $this, 'handle_optin_optout' ) ); + + add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $this, 'uninstall_reason_submission' ) ); + + add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) ); + add_action( $this->client->slug . '_tracker_send_event', array( $this, 'send_tracking_data' ) ); + } + + /** + * Send tracking data to AppSero server + * + * @param bool $override Whether to override the tracking allowed check. + * + * @return void + */ + public function send_tracking_data( $override = false ) { + if ( ! $this->tracking_allowed() && ! $override ) { + return; + } + + // Send a maximum of once per week. + $last_send = $this->get_last_send(); + + if ( $last_send && $last_send > strtotime( '-1 week' ) ) { + return; + } + + $tracking_data = $this->get_tracking_data(); + + $response = $this->client->send_request( $tracking_data, 'track' ); + + update_option( $this->client->slug . '_tracking_last_send', time() ); + } + + /** + * Get the tracking data points + * + * @return array + */ + protected function get_tracking_data() { + $all_plugins = $this->get_all_plugins(); + + $users = get_users( + array( + 'role' => 'administrator', + 'orderby' => 'ID', + 'order' => 'ASC', + 'number' => 1, + 'paged' => 1, + ) + ); + + $admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false; + $first_name = ''; + $last_name = ''; + + if ( $admin_user ) { + $first_name = $admin_user->first_name ? $admin_user->first_name : $admin_user->display_name; + $last_name = $admin_user->last_name; + } + + $data = array( + 'url' => esc_url( home_url() ), + 'site' => $this->get_site_name(), + 'admin_email' => get_option( 'admin_email' ), + 'first_name' => $first_name, + 'last_name' => $last_name, + 'hash' => $this->client->hash, + 'server' => $this->get_server_info(), + 'wp' => $this->get_wp_info(), + 'users' => $this->get_user_counts(), + 'active_plugins' => count( $all_plugins['active_plugins'] ), + 'inactive_plugins' => count( $all_plugins['inactive_plugins'] ), + 'ip_address' => $this->get_user_ip_address(), + 'project_version' => $this->client->project_version, + 'tracking_skipped' => false, + 'is_local' => $this->is_local_server(), + ); + + // Add Plugins. + if ( $this->plugin_data ) { + $plugins_data = array(); + + foreach ( $all_plugins['active_plugins'] as $slug => $plugin ) { + $slug = strstr( $slug, '/', true ); + + if ( ! $slug ) { + continue; + } + + $plugins_data[ $slug ] = array( + 'name' => isset( $plugin['name'] ) ? $plugin['name'] : '', + 'version' => isset( $plugin['version'] ) ? $plugin['version'] : '', + ); + } + + if ( array_key_exists( $this->client->slug, $plugins_data ) ) { + unset( $plugins_data[ $this->client->slug ] ); + } + + $data['plugins'] = $plugins_data; + } + + // Add Metadata. + $extra = $this->get_extra_data(); + + if ( $extra ) { + $data['extra'] = $extra; + } + + // Check if tracking was previously skipped. + $skipped = get_option( $this->client->slug . '_tracking_skipped' ); + + if ( 'yes' === $skipped ) { + delete_option( $this->client->slug . '_tracking_skipped' ); + + $data['tracking_skipped'] = true; + } + + return apply_filters( $this->client->slug . '_tracker_data', $data ); + } + + /** + * If a child class wants to send extra data + * + * @return mixed + */ + protected function get_extra_data() { + if ( is_callable( $this->extra_data ) ) { + return call_user_func( $this->extra_data ); + } + + if ( is_array( $this->extra_data ) ) { + return $this->extra_data; + } + + return array(); + } + + /** + * Explain the user which data we collect + * + * @return array + */ + protected function data_we_collect() { + $data = array( + 'Server environment details (php, mysql, server, WordPress versions)', + 'Number of users in your site', + 'Site language', + 'Number of active and inactive plugins', + 'Site name and URL', + 'Your name and email address', + ); + + if ( $this->plugin_data ) { + array_splice( $data, 4, 0, array( "active plugins' name" ) ); + } + + return $data; + } + + /** + * Check if the user has opted into tracking + * + * @return bool + */ + public function tracking_allowed() { + $allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' ); + + return 'yes' === $allow_tracking; + } + + /** + * Get the last time a tracking was sent + * + * @return false|string + */ + private function get_last_send() { + return get_option( $this->client->slug . '_tracking_last_send', false ); + } + + /** + * Check if the notice has been dismissed or enabled + * + * @return bool + */ + public function notice_dismissed() { + $hide_notice = get_option( $this->client->slug . '_tracking_notice', null ); + + if ( 'hide' === $hide_notice ) { + return true; + } + + return false; + } + + /** + * Check if the current server is localhost + * + * @return bool + */ + private function is_local_server() { + $host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : 'localhost'; + $ip = isset( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) : '127.0.0.1'; + $is_local = false; + + if ( + in_array( $ip, array( '127.0.0.1', '::1' ), true ) || + ! strpos( $host, '.' ) || + in_array( strrchr( $host, '.' ), array( '.test', '.testing', '.local', '.localhost', '.localdomain' ), true ) + ) { + $is_local = true; + } + + return apply_filters( 'appsero_is_local', $is_local ); + } + + /** + * Schedule the event weekly + * + * @return void + */ + private function schedule_event() { + $hook_name = wp_unslash( $this->client->slug . '_tracker_send_event' ); + + if ( ! wp_next_scheduled( $hook_name ) ) { + wp_schedule_event( time(), 'weekly', $hook_name ); + } + } + + /** + * Clear any scheduled hook + * + * @return void + */ + private function clear_schedule_event() { + wp_clear_scheduled_hook( $this->client->slug . '_tracker_send_event' ); + } + + /** + * Display the admin notice to users that have not opted-in or out + * + * @return void + */ + public function admin_notice() { + if ( $this->notice_dismissed() ) { + return; + } + + if ( $this->tracking_allowed() ) { + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + + $optin_url = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optin', 'true' ), '_wpnonce' ); + $optout_url = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optout', 'true' ), '_wpnonce' ); + + if ( empty( $this->notice ) ) { + $notice = sprintf( + $this->client->__trans( 'Want to help make %1$s even more awesome? Allow %1$s to collect diagnostic data and usage information.' ), + $this->client->name + ); + } else { + $notice = $this->notice; + } + + $policy_url = 'https://appsero.com/privacy-policy/'; + + $notice .= ' (' . $this->client->__trans( 'what we collect' ) . ')'; + $notice .= ''; + + echo '

'; + echo wp_kses_post( $notice ); + echo '

'; + echo ' ' . esc_html( $this->client->__trans( 'Allow' ) ) . ''; + echo ' ' . esc_html( $this->client->__trans( 'No thanks' ) ) . ''; + echo '

'; + + echo ""; + } + + /** + * Handle the optin/optout + * + * @return void + */ + public function handle_optin_optout() { + if ( ! $this->is_valid_request() || ! $this->has_manage_options_capability() ) { + return; + } + + if ( $this->is_optin_request() ) { + $this->optin(); + $this->handle_redirection( $this->client->slug . '_tracker_optin' ); + } + + if ( $this->is_optout_request() ) { + $this->optout(); + $this->handle_redirection( $this->client->slug . '_tracker_optout' ); + } + } + + /** + * Validate the request nonce. + * + * @return bool + */ + private function is_valid_request() { + return isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), '_wpnonce' ); + } + + /** + * Check if the current user has manage options capability. + * + * @return bool + */ + private function has_manage_options_capability() { + return current_user_can( 'manage_options' ); + } + + /** + * Check if the current request is for opt-in. + * + * @return bool + */ + private function is_optin_request() { + return isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && 'true' === $_GET[ $this->client->slug . '_tracker_optin' ]; + } + + /** + * Check if the current request is for opt-out. + * + * @return bool + */ + private function is_optout_request() { + return isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && 'true' === $_GET[ $this->client->slug . '_tracker_optout' ]; + } + + /** + * Handle redirection after opt-in/opt-out actions. + * + * @param string $param The query parameter to remove. + */ + private function handle_redirection( $param ) { + if ( $this->is_inaccessible_page() ) { + wp_safe_redirect( admin_url() ); + } else { + wp_safe_redirect( remove_query_arg( $param ) ); + } + exit; + } + + /** + * Check if the current page is updater.php or similar inaccessible pages. + * + * @return bool + */ + private function is_inaccessible_page() { + $inaccessible_pages = array( + '/wp-admin/update.php', // Add similar inaccessible PHP files here + ); + + // Sanitize and unslash the REQUEST_URI before using it + $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; + + // Ensure REQUEST_URI is properly sanitized before use + $request_uri = esc_url_raw( $request_uri ); + + foreach ( $inaccessible_pages as $page ) { + if ( false !== strpos( $request_uri, $page ) ) { + return true; + } + } + + return false; + } + + /** + * Tracking optin + * + * @return void + */ + public function optin() { + update_option( $this->client->slug . '_allow_tracking', 'yes' ); + update_option( $this->client->slug . '_tracking_notice', 'hide' ); + + $this->clear_schedule_event(); + $this->schedule_event(); + $this->send_tracking_data(); + + do_action( $this->client->slug . '_tracker_optin', $this->get_tracking_data() ); + } + + /** + * Optout from tracking + * + * @return void + */ + public function optout() { + update_option( $this->client->slug . '_allow_tracking', 'no' ); + update_option( $this->client->slug . '_tracking_notice', 'hide' ); + + $this->send_tracking_skipped_request(); + + $this->clear_schedule_event(); + + do_action( $this->client->slug . '_tracker_optout' ); + } + + /** + * Get the number of post counts + * + * @param string $post_type The post type to count. + * @return int + */ + public function get_post_count( $post_type ) { + global $wpdb; + + return (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = %s", + $post_type, + 'publish' + ) + ); + } + + /** + * Get server related info. + * + * @return array + */ + private static function get_server_info() { + global $wpdb; + + $server_data = array(); + + if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) { + $server_data['software'] = sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ); + } + + if ( function_exists( 'phpversion' ) ) { + $server_data['php_version'] = phpversion(); + } + + $server_data['mysql_version'] = $wpdb->db_version(); + + $server_data['php_max_upload_size'] = size_format( wp_max_upload_size() ); + $server_data['php_default_timezone'] = date_default_timezone_get(); + $server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No'; + $server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No'; + $server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No'; + + return $server_data; + } + + /** + * Get WordPress related data. + * + * @return array + */ + private function get_wp_info() { + $wp_data = array( + 'memory_limit' => WP_MEMORY_LIMIT, + 'debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No', + 'locale' => get_locale(), + 'version' => get_bloginfo( 'version' ), + 'multisite' => is_multisite() ? 'Yes' : 'No', + 'theme_slug' => get_stylesheet(), + ); + + $theme = wp_get_theme( $wp_data['theme_slug'] ); + + $wp_data['theme_name'] = $theme->get( 'Name' ); + $wp_data['theme_version'] = $theme->get( 'Version' ); + $wp_data['theme_uri'] = $theme->get( 'ThemeURI' ); + $wp_data['theme_author'] = $theme->get( 'Author' ); + + return $wp_data; + } + + /** + * Get the list of active and inactive plugins + * + * @return array + */ + private function get_all_plugins() { + if ( ! function_exists( 'get_plugins' ) ) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + + $plugins = get_plugins(); + $active_plugins_keys = get_option( 'active_plugins', array() ); + $active_plugins = array(); + + foreach ( $plugins as $k => $v ) { + $formatted = array( + 'name' => wp_strip_all_tags( $v['Name'] ), + 'version' => wp_strip_all_tags( $v['Version'] ), + 'author' => wp_strip_all_tags( $v['Author'] ), + ); + + if ( isset( $v['Network'] ) ) { + $formatted['network'] = wp_strip_all_tags( $v['Network'] ); + } + + if ( isset( $v['PluginURI'] ) ) { + $formatted['plugin_uri'] = wp_strip_all_tags( $v['PluginURI'] ); + } + + if ( in_array( $k, $active_plugins_keys, true ) ) { + unset( $plugins[ $k ] ); + $active_plugins[ $k ] = $formatted; + } else { + $plugins[ $k ] = $formatted; + } + } + + return array( + 'active_plugins' => $active_plugins, + 'inactive_plugins' => $plugins, + ); + } + + /** + * Get user totals based on user role. + * + * @return array + */ + public function get_user_counts() { + $user_count = array(); + $user_count_data = count_users(); + $user_count['total'] = $user_count_data['total_users']; + + foreach ( $user_count_data['avail_roles'] as $role => $count ) { + if ( ! $count ) { + continue; + } + $user_count[ $role ] = $count; + } + + return $user_count; + } + + /** + * Add weekly cron schedule + * + * @param array $schedules Existing cron schedules. + * @return array + */ + public function add_weekly_schedule( $schedules ) { + $schedules['weekly'] = array( + 'interval' => DAY_IN_SECONDS * 7, + 'display' => __( 'Once Weekly', 'appsero' ), + ); + + return $schedules; + } + + /** + * Plugin activation hook + * + * @return void + */ + public function activate_plugin() { + $allowed = get_option( $this->client->slug . '_allow_tracking', 'no' ); + + if ( 'yes' !== $allowed ) { + return; + } + + $hook_name = $this->client->slug . '_tracker_send_event'; + + if ( ! wp_next_scheduled( $hook_name ) ) { + wp_schedule_event( time(), 'weekly', $hook_name ); + } + + delete_option( $this->client->slug . '_tracking_last_send' ); + + $this->send_tracking_data( true ); + } + + /** + * Clear our options upon deactivation + * + * @return void + */ + public function deactivation_cleanup() { + $this->clear_schedule_event(); + + if ( 'theme' === $this->client->type ) { + delete_option( $this->client->slug . '_tracking_last_send' ); + delete_option( $this->client->slug . '_allow_tracking' ); + } + + delete_option( $this->client->slug . '_tracking_notice' ); + } + + /** + * Hook into action links and modify the deactivate link + * + * @param array $links + * + * @return array + */ + public function plugin_action_links( $links ) { + if ( array_key_exists( 'deactivate', $links ) ) { + $links['deactivate'] = str_replace( ' 'could-not-understand', + 'text' => $this->client->__trans( "Couldn't understand" ), + 'placeholder' => $this->client->__trans( 'Would you like us to assist you?' ), + 'icon' => '', + ], + [ + 'id' => 'found-better-plugin', + 'text' => $this->client->__trans( 'Found a better plugin' ), + 'placeholder' => $this->client->__trans( 'Which plugin?' ), + 'icon' => '', + ], + [ + 'id' => 'not-have-that-feature', + 'text' => $this->client->__trans( 'Missing a specific feature' ), + 'placeholder' => $this->client->__trans( 'Could you tell us more about that feature?' ), + 'icon' => '', + ], + [ + 'id' => 'is-not-working', + 'text' => $this->client->__trans( 'Not working' ), + 'placeholder' => $this->client->__trans( 'Could you tell us a bit more whats not working?' ), + 'icon' => '', + ], + [ + 'id' => 'looking-for-other', + 'text' => $this->client->__trans( 'Not what I was looking' ), + 'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ), + 'icon' => '', + ], + [ + 'id' => 'did-not-work-as-expected', + 'text' => $this->client->__trans( "Didn't work as expected" ), + 'placeholder' => $this->client->__trans( 'What did you expect?' ), + 'icon' => '', + ], + [ + 'id' => 'other', + 'text' => $this->client->__trans( 'Others' ), + 'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ), + 'icon' => '', + ], + ]; + + return $reasons; + } + + /** + * Plugin deactivation uninstall reason submission + * + * @return void + */ + public function uninstall_reason_submission() { + if ( ! isset( $_POST['nonce'] ) ) { + return; + } + + if ( ! isset( $_POST['reason_id'] ) ) { + wp_send_json_error(); + } + + if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'appsero-security-nonce' ) ) { + wp_send_json_error( 'Nonce verification failed' ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( 'You are not allowed for this task' ); + } + + $data = $this->get_tracking_data(); + $data['reason_id'] = sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ); + $data['reason_info'] = isset( $_REQUEST['reason_info'] ) ? trim( sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) ) : ''; + + $this->client->send_request( $data, 'deactivate' ); + + /* + * Fire after the plugin _uninstall_reason_submitted + */ + do_action( $this->client->slug . '_uninstall_reason_submitted', $data ); + + wp_send_json_success(); + } + + /** + * Handle the plugin deactivation feedback + * + * @return void + */ + public function deactivate_scripts() { + global $pagenow; + + if ( 'plugins.php' !== $pagenow ) { + return; + } + + $this->deactivation_modal_styles(); + $reasons = $this->get_uninstall_reasons(); + $custom_reasons = apply_filters( 'appsero_custom_deactivation_reasons', [], $this->client ); + ?> + +
+
+
+

client->_etrans( 'Goodbyes are always hard. If you have a moment, please let us know how we can improve.' ); ?>

+
+ +
+
    + +
  • + +
  • + +
+ +
    + +
  • + +
  • + +
+ +
+

+ client->__trans( 'We share your data with Appsero to troubleshoot problems & make product improvements. Learn more about how WeDevs\DokanMigrator\Dependencies\Appsero handles your data.' ), + esc_url( 'https://appsero.com/' ), + esc_url( 'https://appsero.com/privacy-policy' ) + ); + ?> +

+
+ + +
+
+ + + + get_template() === $this->client->slug ) { + $this->client->send_request( $this->get_tracking_data(), 'deactivate' ); + } + } + + /** + * Get user IP Address + */ + private function get_user_ip_address() { + $response = wp_remote_get( 'https://icanhazip.com/' ); + + if ( is_wp_error( $response ) ) { + return ''; + } + + $ip = trim( wp_remote_retrieve_body( $response ) ); + + if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) { + return ''; + } + + return $ip; + } + + /** + * Get site name + */ + private function get_site_name() { + $site_name = get_bloginfo( 'name' ); + + if ( empty( $site_name ) ) { + $site_name = get_bloginfo( 'description' ); + $site_name = wp_trim_words( $site_name, 3, '' ); + } + + if ( empty( $site_name ) ) { + $site_name = esc_url( home_url() ); + } + + return $site_name; + } + + /** + * Send request to appsero if user skip to send tracking data + */ + private function send_tracking_skipped_request() { + $skipped = get_option( $this->client->slug . '_tracking_skipped' ); + + $data = [ + 'hash' => $this->client->hash, + 'previously_skipped' => false, + ]; + + if ( $skipped === 'yes' ) { + $data['previously_skipped'] = true; + } else { + update_option( $this->client->slug . '_tracking_skipped', 'yes' ); + } + + $this->client->send_request( $data, 'tracking-skipped' ); + } + + /** + * Deactivation modal styles + */ + private function deactivation_modal_styles() { + ?> + + client = $client; + + $this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license'; + + $this->schedule_hook = $this->client->slug . '_license_check_event'; + + // Creating WP Ajax Endpoint to refresh license remotely + add_action( 'wp_ajax_appsero_refresh_license_' . $this->client->hash, [ $this, 'refresh_license_api' ] ); + + // Run hook to check license status daily + add_action( $this->schedule_hook, [ $this, 'check_license_status' ] ); + + // Active/Deactive corn schedule + $this->run_schedule(); + } + + /** + * Set the license option key. + * + * If someone wants to override the default generated key. + * + * @param string $key + * + * @since 1.3.0 + * + * @return License + */ + public function set_option_key( $key ) { + $this->option_key = $key; + + return $this; + } + + /** + * Get the license key + * + * @since 1.3.0 + * + * @return string|null + */ + public function get_license() { + return get_option( $this->option_key, null ); + } + + /** + * Check license + * + * @return array + */ + public function check( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/check'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Active a license + * + * @return array + */ + public function activate( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/activate'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Deactivate a license + * + * @return array + */ + public function deactivate( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/deactivate'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Send common request + * + * @return array + */ + protected function send_request( $license_key, $route ) { + $params = [ + 'license_key' => $license_key, + 'url' => esc_url( home_url() ), + 'is_local' => $this->client->is_local_server(), + ]; + + $response = $this->client->send_request( $params, $route, true ); + + if ( is_wp_error( $response ) ) { + return [ + 'success' => false, + 'error' => $response->get_error_message(), + ]; + } + + $response = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( empty( $response ) || isset( $response['exception'] ) ) { + return [ + 'success' => false, + 'error' => $this->client->__trans( 'Unknown error occurred, Please try again.' ), + ]; + } + + if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) { + $response = [ + 'success' => false, + 'error' => $response['errors']['license_key'][0], + ]; + } + + return $response; + } + + /** + * License Refresh Endpoint + */ + public function refresh_license_api() { + $this->check_license_status(); + + wp_send_json_success( + [ + 'message' => 'License refreshed successfully.', + ], + 200 + ); + } + + /** + * Add settings page for license + * + * @param array $args + * + * @return void + */ + public function add_settings_page( $args = [] ) { + $defaults = [ + 'type' => 'menu', // Can be: menu, options, submenu + 'page_title' => 'Manage License', + 'menu_title' => 'Manage License', + 'capability' => 'manage_options', + 'menu_slug' => $this->client->slug . '-manage-license', + 'icon_url' => '', + 'position' => null, + 'parent_slug' => '', + ]; + + $this->menu_args = wp_parse_args( $args, $defaults ); + + add_action( 'admin_menu', [ $this, 'admin_menu' ], 99 ); + } + + /** + * Admin Menu hook + * + * @return void + */ + public function admin_menu() { + switch ( $this->menu_args['type'] ) { + case 'menu': + $this->create_menu_page(); + break; + + case 'submenu': + $this->create_submenu_page(); + break; + + case 'options': + $this->create_options_page(); + break; + } + } + + /** + * License menu output + */ + public function menu_output() { + // process form data if submitted + if ( isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), $this->client->name ) ) { + $form_data = [ + '_nonce' => sanitize_key( wp_unslash( $_POST['_nonce'] ) ), + '_action' => isset( $_POST['_action'] ) ? sanitize_text_field( wp_unslash( $_POST['_action'] ) ) : '', + 'license_key' => isset( $_POST['license_key'] ) ? sanitize_text_field( wp_unslash( $_POST['license_key'] ) ) : '', + ]; + $this->license_form_submit( $form_data ); + } + + $license = $this->get_license(); + $action = ( $license && isset( $license['status'] ) && 'activate' === $license['status'] ) ? 'deactive' : 'active'; + $this->licenses_style(); + ?> + +
+

License Settings

+ + show_license_page_notices(); + do_action( 'before_appsero_license_section' ); + ?> + +
+ show_license_page_card_header( $license ); ?> + +
+

+ client->__trans( 'Activate %s by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?> +

+
+ + +
+
+ + + + + /> +
+ +
+
+ + show_active_license_info( $license ); + } + ?> +
+
+ + +
+ client->name ) ) { + $this->error = $this->client->__trans( 'Nonce vefification failed.' ); + + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + $this->error = $this->client->__trans( 'You don\'t have permission to manage license.' ); + + return; + } + + $license_key = ! empty( $form_data['license_key'] ) ? sanitize_text_field( wp_unslash( $form_data['license_key'] ) ) : ''; + $action = ! empty( $form_data['_action'] ) ? sanitize_text_field( wp_unslash( $form_data['_action'] ) ) : ''; + + switch ( $action ) { + case 'active': + $this->active_client_license( $license_key ); + break; + + case 'deactive': + $this->deactive_client_license(); + break; + + case 'refresh': + $this->refresh_client_license(); + break; + } + } + + /** + * Check license status on schedule + */ + public function check_license_status() { + $license = $this->get_license(); + + if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) { + $response = $this->check( $license['key'] ); + + if ( isset( $response['success'] ) && $response['success'] ) { + $license['status'] = 'activate'; + $license['remaining'] = $response['remaining']; + $license['activation_limit'] = $response['activation_limit']; + $license['expiry_days'] = $response['expiry_days']; + $license['title'] = $response['title']; + $license['source_id'] = $response['source_identifier']; + $license['recurring'] = $response['recurring']; + } else { + $license['status'] = 'deactivate'; + $license['expiry_days'] = 0; + } + + update_option( $this->option_key, $license, false ); + } + } + + /** + * Check this is a valid license + */ + public function is_valid() { + if ( null !== $this->is_valid_license ) { + return $this->is_valid_license; + } + + $license = $this->get_license(); + + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { + $this->is_valid_license = true; + } else { + $this->is_valid_license = false; + } + + return $this->is_valid_license; + } + + /** + * Check this is a valid license + */ + public function is_valid_by( $option, $value ) { + $license = $this->get_license(); + + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { + if ( isset( $license[ $option ] ) && $license[ $option ] === $value ) { + return true; + } + } + + return false; + } + + /** + * Styles for licenses page + */ + private function licenses_style() { + ?> + + +
+
+

client->_etrans( 'Activations Remaining' ); ?>

+ +

client->_etrans( 'Unlimited' ); ?>

+ +

+ client->__trans( '%1$d out of %2$d' ), $license['remaining'], $license['activation_limit'] ); ?> +

+ +
+
+

client->_etrans( 'Expires in' ); ?>

+ 21 ? '' : 'occupied'; + echo '

' . $license['expiry_days'] . ' days

'; + } else { + echo '

' . $this->client->__trans( 'Never' ) . '

'; + } + ?> +
+
+ error ) ) { + ?> +
+

error; ?>

+
+ success ) ) { + ?> +
+

success; ?>

+
+ '; + } + + /** + * Card header + */ + private function show_license_page_card_header( $license ) { + ?> +
+ + + + + + client->__trans( 'Activate License' ); ?> + + +
+ + + +
+ + +
+ error = $this->client->__trans( 'The license key field is required.' ); + + return; + } + + $response = $this->activate( $license_key ); + + if ( ! $response['success'] ) { + $this->error = $response['error'] ? $response['error'] : $this->client->__trans( 'Unknown error occurred.' ); + + return; + } + + $data = [ + 'key' => $license_key, + 'status' => 'activate', + 'remaining' => $response['remaining'], + 'activation_limit' => $response['activation_limit'], + 'expiry_days' => $response['expiry_days'], + 'title' => $response['title'], + 'source_id' => $response['source_identifier'], + 'recurring' => $response['recurring'], + ]; + + update_option( $this->option_key, $data, false ); + + $this->success = $this->client->__trans( 'License activated successfully.' ); + } + + /** + * Deactive client license + */ + private function deactive_client_license() { + $license = $this->get_license(); + + if ( empty( $license['key'] ) ) { + $this->error = $this->client->__trans( 'License key not found.' ); + + return; + } + + $response = $this->deactivate( $license['key'] ); + + $data = [ + 'key' => '', + 'status' => 'deactivate', + ]; + + update_option( $this->option_key, $data, false ); + + if ( ! $response['success'] ) { + $this->error = $response['error'] ? $response['error'] : $this->client->__trans( 'Unknown error occurred.' ); + + return; + } + + $this->success = $this->client->__trans( 'License deactivated successfully.' ); + } + + /** + * Refresh Client License + */ + private function refresh_client_license() { + $license = $this->get_license(); + + if ( ! $license || ! isset( $license['key'] ) || empty( $license['key'] ) ) { + $this->error = $this->client->__trans( 'License key not found' ); + + return; + } + + $this->check_license_status(); + + $this->success = $this->client->__trans( 'License refreshed successfully.' ); + } + + /** + * Add license menu page + */ + private function create_menu_page() { + call_user_func( + 'add_menu_page', + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + [ $this, 'menu_output' ], + $this->menu_args['icon_url'], + $this->menu_args['position'] + ); + } + + /** + * Add submenu page + */ + private function create_submenu_page() { + call_user_func( + 'add_submenu_page', + $this->menu_args['parent_slug'], + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + [ $this, 'menu_output' ], + $this->menu_args['position'] + ); + } + + /** + * Add submenu page + */ + private function create_options_page() { + call_user_func( + 'add_options_page', + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + [ $this, 'menu_output' ], + $this->menu_args['position'] + ); + } + + /** + * Schedule daily sicense checker event + */ + public function schedule_cron_event() { + if ( ! wp_next_scheduled( $this->schedule_hook ) ) { + wp_schedule_event( time(), 'daily', $this->schedule_hook ); + + wp_schedule_single_event( time() + 20, $this->schedule_hook ); + } + } + + /** + * Clear any scheduled hook + */ + public function clear_scheduler() { + wp_clear_scheduled_hook( $this->schedule_hook ); + } + + /** + * Enable/Disable schedule + */ + private function run_schedule() { + switch ( $this->client->type ) { + case 'plugin': + register_activation_hook( $this->client->file, [ $this, 'schedule_cron_event' ] ); + register_deactivation_hook( $this->client->file, [ $this, 'clear_scheduler' ] ); + break; + + case 'theme': + add_action( 'after_switch_theme', [ $this, 'schedule_cron_event' ] ); + add_action( 'switch_theme', [ $this, 'clear_scheduler' ] ); + break; + } + } + + /** + * Get input license key + * + * @return $license + */ + private function get_input_license_value( $action, $license ) { + if ( 'active' === $action ) { + return isset( $license['key'] ) ? $license['key'] : ''; + } + + if ( 'deactive' === $action ) { + $key_length = strlen( $license['key'] ); + + return str_pad( + substr( $license['key'], 0, $key_length / 2 ), + $key_length, + '*' + ); + } + + return ''; + } +} diff --git a/dokan-migrator.php b/dokan-migrator.php index 5097c89..19d6f11 100644 --- a/dokan-migrator.php +++ b/dokan-migrator.php @@ -187,30 +187,30 @@ public function __get( $prop ) { } /** - * Initiates Appsero services. - * - * @since 1.0.0 - * - * @return void - */ - public function init_appsero_tracker() { - if ( ! class_exists( '\Appsero\Client' ) ) { + * Initiates Appsero services. + * + * @since 1.0.0 + * + * @return void + */ + public function init_appsero_tracker() { + if ( ! class_exists( 'WeDevs\DokanMigrator\Dependencies\Appsero\Client' ) ) { return; } - $client = new \Appsero\Client( '2852f2fd-66ff-4649-9b00-5f9ed953f8b9', 'Dokan Migrator', DOKAN_MIGRATOR_FILE ); + $client = new WeDevs\DokanMigrator\Dependencies\Appsero\Client( '2852f2fd-66ff-4649-9b00-5f9ed953f8b9', 'Dokan Migrator', DOKAN_MIGRATOR_FILE ); $insights = $client->insights(); - $insights->add_extra( + $insights->add_extra( function() { return array( 'dokan_migrator_version' => DOKAN_MIGRATOR_PLUGIN_VERSION, - ); + ); } ); $insights->init(); - } + } /** * Make dokan migrator plugin HPOS supported.