PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 1.3.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v1.3.3
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | core/class-plugin.php +141 -0 1-final1.3.3 View file →
@@ -1,0 +1,141 @@
1 +<?php
2 +/**
3 + * Templately plugin.
4 + *
5 + * The main plugin handler class is responsible for initializing Templately. The
6 + * class registers and all the components required to run the plugin.
7 + *
8 + * @package Templately
9 + */
10 +
11 +namespace Templately;
12 +
13 +defined('ABSPATH') or exit;
14 +
15 +use Templately\Admin\Admin;
16 +
17 +final class Plugin {
18 + /**
19 + * Plugin Version
20 + * @var string
21 + */
22 + protected static $version;
23 + /**
24 + * Plugin Name
25 + * @var string
26 + */
27 + protected static $plugin_name;
28 + /**
29 + * Plugin Instance
30 + * @var \Templately\Plugin
31 + */
32 + private static $_instance = null;
33 + /**
34 + * Elementor Instance
35 + *
36 + * @var \Templately\Elementor
37 + */
38 + public $elementor = null;
39 + /**
40 + * Admin Instance
41 + *
42 + * @var \Templately\Admin\Admin
43 + */
44 + public $admin = null;
45 +
46 + /**
47 + * Get a single instance of Plugin
48 + * @return Plugin
49 + */
50 + public static function get_instance() {
51 + if (is_null(self::$_instance)) {
52 + self::$_instance = new self();
53 + }
54 + return self::$_instance;
55 + }
56 +
57 + /**
58 + * Plugin constructor.
59 + * Initializing Templately plugin.
60 + *
61 + * @access private
62 + */
63 + private function __construct() {
64 + if (defined('TEMPLATELY_VERSION')) {
65 + self::$version = TEMPLATELY_VERSION;
66 + } else {
67 + self::$version = '0.0.1';
68 + }
69 + Installer::init();
70 + Loader::add_action('admin_init', $this, 'migrate');
71 + self::$plugin_name = 'templately';
72 + $this->admin = Admin::get_instance();
73 + REST::get_instance();
74 + $this->elementor = Elementor::get_instance();
75 + self::run();
76 + do_action('templately_init');
77 + }
78 +
79 + /**
80 + * Run all actions and hooks
81 + *
82 + * @return void
83 + */
84 + public static function run() {
85 + /**
86 + * Loader will run actions and filters function for the plugin.
87 + */
88 + Loader::run();
89 + }
90 + /**
91 + * Migrate Users to Global Signed In if they are already logged in.
92 + * @since 1.1.5
93 + * @return void
94 + */
95 + public static function migrate(){
96 + $templately_old_version = \get_option('_templately_migrate' );
97 + if( \version_compare(TEMPLATELY_VERSION, $templately_old_version, '>') && \version_compare($templately_old_version, '1.1.4', '=') ) {
98 + if( \get_option( '_templately_connected', false ) ) {
99 + if( \current_user_can('manage_options') ) {
100 + \update_option( '_templately_user_login_choice', ['choice' => true, 'id' => \get_current_user_id() ] );
101 + }
102 + }
103 + }
104 + if( \version_compare(TEMPLATELY_VERSION, '1.2.0', '=') && ! \get_option('_templately_verification_migrate', false ) ) {
105 + if( DB::get_user_specific_login_meta( '_templately_connected', false ) ) {
106 + \update_option( '_templately_verification_migrate', true );
107 + $user_data = DB::get_user_specific_login_meta('_templately_connect_data');
108 + $user_data['is_verified'] = true;
109 + DB::update_user_specific_login_meta( '_templately_connect_data', $user_data );
110 + }
111 + }
112 +
113 + if( \version_compare(TEMPLATELY_VERSION, '1.2.2', '=') && \version_compare($templately_old_version, '1.2.2', '<') ) {
114 + DB::delete_option('_templately_dependencies');
115 + DB::delete_option('_templately_tags');
116 + DB::delete_option('_templately_categories');
117 + }
118 +
119 + if( \version_compare(TEMPLATELY_VERSION, '1.3.0', '=') && \version_compare($templately_old_version, '1.2.3', '=') ) {
120 + DB::delete_transient( 'templately_item_counts' );
121 + }
122 +
123 + // SET VERSION
124 + \update_option( '_templately_migrate', TEMPLATELY_VERSION );
125 + }
126 + /**
127 + * Get Plugin Name or You can say Text Domain
128 + * @return string
129 + */
130 + public static function get_name() {
131 + return self::$plugin_name;
132 + }
133 +
134 + /**
135 + * Get Plugin Version
136 + * @return String
137 + */
138 + public static function get_version() {
139 + return self::$version;
140 + }
141 +}