Admin
2 years ago
Assets
2 years ago
Pages
3 years ago
PostTypes
3 years ago
Shortcodes
2 years ago
Sitemap
3 years ago
Templates
2 years ago
Users
3 years ago
ActionsService.php
3 years ago
CompatibilityService.php
2 years ago
HealthService.php
2 years ago
PluginService.php
3 years ago
PluginServiceProvider.php
2 years ago
RecaptchaValidationService.php
2 years ago
ThemeService.php
3 years ago
ThemeServiceProvider.php
3 years ago
TranslationsServiceProvider.php
3 years ago
PluginService.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package SureCartAppCore |
| 4 | * @author SureCart <support@surecart.com> |
| 5 | * @copyright SureCart |
| 6 | * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 |
| 7 | * @link https://surecart.com |
| 8 | */ |
| 9 | |
| 10 | namespace SureCart\WordPress; |
| 11 | |
| 12 | use SureCartCore\Application\Application; |
| 13 | |
| 14 | /** |
| 15 | * Main communication channel with the theme. |
| 16 | */ |
| 17 | class PluginService { |
| 18 | /** |
| 19 | * Application instance. |
| 20 | * |
| 21 | * @var Application |
| 22 | */ |
| 23 | protected $app = null; |
| 24 | |
| 25 | /** |
| 26 | * Constructor. |
| 27 | * |
| 28 | * @param Application $app |
| 29 | */ |
| 30 | public function __construct( $app ) { |
| 31 | $this->app = $app; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get the plugin version |
| 36 | * |
| 37 | * @return string |
| 38 | */ |
| 39 | public function version() { |
| 40 | // Load version from plugin data. |
| 41 | if ( ! \function_exists( 'get_plugin_data' ) ) { |
| 42 | require_once \ABSPATH . 'wp-admin/includes/plugin.php'; |
| 43 | } |
| 44 | |
| 45 | return \get_plugin_data( SURECART_PLUGIN_FILE, false, false )['Version']; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Has the plugin version changed? |
| 50 | * |
| 51 | * @return boolean |
| 52 | */ |
| 53 | public function versionChanged() { |
| 54 | return version_compare( $this->version(), get_option( 'surecart_migration_version', '0.0.0' ), '!=' ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Shortcute to \SureCart\Account\AccountService |
| 59 | * |
| 60 | * @return \SureCart\Account\AccountService |
| 61 | */ |
| 62 | public function account() { |
| 63 | return $this->app->reolve( 'surecart.account' ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Shortcut to \SureCart\Install\InstallService. |
| 68 | * |
| 69 | * @return \SureCart\Install\InstallService |
| 70 | */ |
| 71 | public function install() { |
| 72 | return $this->app->resolve( 'surecart.install' ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Shortcut to \SureCart\WordPress\Pages\PageService. |
| 77 | * |
| 78 | * @return \SureCart\WordPress\Pages\PageService |
| 79 | */ |
| 80 | public function pages() { |
| 81 | return $this->app->resolve( 'surecart.pages' ); |
| 82 | } |
| 83 | /** |
| 84 | * Shortcut to \SureCart\WordPress\Pages\PageService. |
| 85 | * |
| 86 | * @return \SureCart\WordPress\Pages\PageService |
| 87 | */ |
| 88 | public function activation() { |
| 89 | return $this->app->resolve( 'surecart.activation' ); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Shortcut to \SureCart\WordPress\Pages\PageService. |
| 94 | * |
| 95 | * @return \SureCart\Permissions\RolesService; |
| 96 | */ |
| 97 | public function roles() { |
| 98 | return $this->app->resolve( 'surecart.permissions.roles' ); |
| 99 | } |
| 100 | } |
| 101 |