controls
5 months ago
extras
5 months ago
helpers
5 months ago
pa-display-conditions
5 months ago
templates
5 months ago
acf-helper.php
5 months ago
addons-cross-cp.php
5 months ago
addons-integration.php
5 months ago
assets-manager.php
5 months ago
class-pa-core.php
5 months ago
cm-pointer.php
5 months ago
helper-functions.php
5 months ago
live-editor-modal.php
5 months ago
module-base.php
5 months ago
pa-nav-menu-walker.php
5 months ago
papro-promotion.php
5 months ago
premium-template-tags.php
5 months ago
promotion-pointer.php
5 months ago
class-pa-core.php
203 lines
| 1 | <?php |
| 2 | /** |
| 3 | * PA Core. |
| 4 | */ |
| 5 | |
| 6 | namespace PremiumAddons\Includes; |
| 7 | |
| 8 | if ( ! class_exists( 'PA_Core' ) ) { |
| 9 | |
| 10 | /** |
| 11 | * Intialize and Sets up the plugin |
| 12 | */ |
| 13 | class PA_Core { |
| 14 | |
| 15 | /** |
| 16 | * Member Variable |
| 17 | * |
| 18 | * @var instance |
| 19 | */ |
| 20 | private static $instance = null; |
| 21 | |
| 22 | /** |
| 23 | * Sets up needed actions/filters for the plug-in to initialize. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * @access public |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function __construct() { |
| 31 | |
| 32 | // Load plugin textdomain. |
| 33 | add_action( 'init', array( $this, 'i18n' ) ); |
| 34 | |
| 35 | // Run plugin and require the necessary files. |
| 36 | add_action( 'plugins_loaded', array( $this, 'pa_init' ) ); |
| 37 | |
| 38 | add_action( 'init', array( $this, 'init' ), -999 ); |
| 39 | |
| 40 | // Register Activation hooks. |
| 41 | register_activation_hook( PREMIUM_ADDONS_FILE, array( $this, 'handle_activation' ) ); |
| 42 | register_uninstall_hook( PREMIUM_ADDONS_FILE, array( __CLASS__, 'uninstall' ) ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Installs translation text domain and checks if Elementor is installed |
| 47 | * |
| 48 | * @since 1.0.0 |
| 49 | * @access public |
| 50 | * |
| 51 | * @return void |
| 52 | */ |
| 53 | public function pa_init() { |
| 54 | |
| 55 | // Load plugin necessary files. |
| 56 | \PremiumAddons\Admin\Includes\Admin_Helper::get_instance(); |
| 57 | |
| 58 | Addons_Integration::get_instance(); |
| 59 | |
| 60 | include_once PREMIUM_ADDONS_PATH . 'includes/promotion-pointer.php'; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Set transient for admin review notice |
| 65 | * |
| 66 | * @since 3.1.7 |
| 67 | * @access public |
| 68 | * |
| 69 | * @return void |
| 70 | */ |
| 71 | public function handle_activation() { |
| 72 | |
| 73 | $cache_key = 'pa_review_notice'; |
| 74 | |
| 75 | $expiration = DAY_IN_SECONDS * 7; |
| 76 | |
| 77 | set_transient( $cache_key, true, $expiration ); |
| 78 | |
| 79 | $install_time = get_option( 'pa_install_time' ); |
| 80 | |
| 81 | if ( ! $install_time ) { |
| 82 | |
| 83 | $current_time = gmdate( 'j F, Y', time() ); |
| 84 | |
| 85 | update_option( 'pa_complete_wizard', true ); |
| 86 | update_option( 'pa_install_time', $current_time ); |
| 87 | |
| 88 | $api_url = 'https://feedbackpa.leap13.com/wp-json/install/v2/add'; |
| 89 | |
| 90 | $response = wp_safe_remote_request( |
| 91 | $api_url, |
| 92 | array( |
| 93 | 'headers' => array( |
| 94 | 'Content-Type' => 'application/json', |
| 95 | ), |
| 96 | 'body' => wp_json_encode( |
| 97 | array( |
| 98 | 'time' => $current_time, |
| 99 | ) |
| 100 | ), |
| 101 | 'timeout' => 20, |
| 102 | 'method' => 'POST', |
| 103 | 'httpversion' => '1.1', |
| 104 | ) |
| 105 | ); |
| 106 | |
| 107 | set_transient( 'pa_activation_redirect', true, 30 ); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | public static function uninstall() { |
| 112 | |
| 113 | delete_option( 'pa_complete_wizard' ); |
| 114 | delete_option( 'pa_install_time' ); |
| 115 | delete_option( 'pa_review_notice' ); |
| 116 | |
| 117 | $api_url = 'https://feedbackpa.leap13.com/wp-json/uninstall/v2/add'; |
| 118 | |
| 119 | $current_time = gmdate( 'j F, Y', time() ); |
| 120 | |
| 121 | $response = wp_safe_remote_request( |
| 122 | $api_url, |
| 123 | array( |
| 124 | 'headers' => array( |
| 125 | 'Content-Type' => 'application/json', |
| 126 | ), |
| 127 | 'body' => wp_json_encode( |
| 128 | array( |
| 129 | 'time' => $current_time, |
| 130 | ) |
| 131 | ), |
| 132 | 'timeout' => 20, |
| 133 | 'method' => 'POST', |
| 134 | 'httpversion' => '1.1', |
| 135 | ) |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Load plugin translated strings using text domain |
| 141 | * |
| 142 | * @since 2.6.8 |
| 143 | * @access public |
| 144 | * |
| 145 | * @return void |
| 146 | */ |
| 147 | public function i18n() { |
| 148 | |
| 149 | load_plugin_textdomain( 'premium-addons-for-elementor' ); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Init |
| 154 | * |
| 155 | * @since 3.4.0 |
| 156 | * @access public |
| 157 | * |
| 158 | * @return void |
| 159 | */ |
| 160 | public function init() { |
| 161 | |
| 162 | if ( is_user_logged_in() && \PremiumAddons\Admin\Includes\Admin_Helper::check_premium_templates() ) { |
| 163 | require_once PREMIUM_ADDONS_PATH . 'includes/templates/templates.php'; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | * Creates and returns an instance of the class |
| 170 | * |
| 171 | * @since 2.6.8 |
| 172 | * @access public |
| 173 | * |
| 174 | * @return object |
| 175 | */ |
| 176 | public static function get_instance() { |
| 177 | |
| 178 | if ( ! isset( self::$instance ) ) { |
| 179 | |
| 180 | self::$instance = new self(); |
| 181 | |
| 182 | } |
| 183 | |
| 184 | return self::$instance; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if ( ! function_exists( 'pa_core' ) ) { |
| 190 | |
| 191 | /** |
| 192 | * Returns an instance of the plugin class. |
| 193 | * |
| 194 | * @since 1.0.0 |
| 195 | * @return object |
| 196 | */ |
| 197 | function pa_core() { |
| 198 | return PA_Core::get_instance(); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | pa_core(); |
| 203 |