| @@ -3,13 +3,11 @@ | ||
| 3 | 3 | namespace ShopEngine; |
| 4 | 4 | |
| 5 | 5 | use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest; |
| 6 | 6 | use ShopEngine\Core\Builders\Base; |
| 7 | -use ShopEngine\Compatibility\Migrations\LangMigration; | |
| 8 | 7 | use ShopEngine\Core\Query_Modifier; |
| 9 | 8 | use ShopEngine\Core\Template_Cpt; |
| 10 | 9 | use ShopEngine\Libs\License\License_Route; |
| 11 | -use ShopEngine\Libs\Rating\Rating; | |
| 12 | 10 | use ShopEngine\Libs\Updater\Init as Updater; |
| 13 | 11 | use ShopEngine\Modules\Manifest as Module_Manifest; |
| 14 | 12 | use ShopEngine\Widgets\Manifest; |
| 15 | 13 | |
| @@ -51,38 +49,30 @@ | ||
| 51 | 49 | |
| 52 | 50 | $error = true; |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | - $check_elementor_version = false; | |
| 56 | - | |
| 57 | 53 | // Check if Elementor installed and activated. |
| 58 | - if(!did_action('elementor/loaded')) { | |
| 54 | + if(!did_action('elementor/loaded')) { | |
| 55 | + add_action('admin_notices', [$this, 'missing_elementor']); | |
| 59 | 56 | |
| 60 | - if(!did_action('shopengine-gutenberg-addon/before_loaded')) { | |
| 57 | + $error = true; | |
| 58 | + } | |
| 61 | 59 | |
| 62 | - add_action('admin_notices', [$this, 'missing_elementor']); | |
| 63 | - | |
| 64 | - $error = true; | |
| 65 | - } | |
| 66 | - } | |
| 67 | - | |
| 68 | 60 | // Check for required Elementor version. |
| 69 | - if(did_action('elementor/loaded') && defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) { | |
| 61 | + if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) { | |
| 62 | + add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 70 | 63 | |
| 71 | - add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 64 | + $error = true; | |
| 65 | + } | |
| 72 | 66 | |
| 73 | - $error = true; | |
| 74 | - } | |
| 67 | + if($error) { | |
| 75 | 68 | |
| 76 | - if($error) { | |
| 77 | 69 | return; |
| 78 | 70 | } |
| 79 | - | |
| 71 | + | |
| 80 | 72 | add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) { |
| 81 | - $free = esc_html__("Go To Shopengine","shopengine"); | |
| 82 | - $pro = esc_html__("Go To ShopenginePro","shopengine"); | |
| 83 | 73 | |
| 84 | - $custom_links[] = '<a title="' . $free . '" href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>'; | |
| 74 | + $custom_links[] = '<a href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>'; | |
| 85 | 75 | |
| 86 | 76 | foreach ($custom_links as $custom_link): |
| 87 | 77 | array_unshift($links, $custom_link); |
| 88 | 78 | endforeach; |
| @@ -87,9 +77,9 @@ | ||
| 87 | 77 | array_unshift($links, $custom_link); |
| 88 | 78 | endforeach; |
| 89 | 79 | |
| 90 | 80 | if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) { |
| 91 | - $links[] = '<a title="' . $pro . '" href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank" rel="noopener">' . esc_html__('Go Pro', 'shopengine') . '</a>'; | |
| 81 | + $links[] = '<a href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank">' . esc_html__('Go Pro', 'shopengine') . '</a>'; | |
| 92 | 82 | } |
| 93 | 83 | return $links; |
| 94 | 84 | }); |
| 95 | 85 | |
| @@ -107,17 +97,32 @@ | ||
| 107 | 97 | add_action('admin_init', function () { |
| 108 | 98 | if(class_exists('ShopEngine_Pro')) { |
| 109 | 99 | new Updater(); |
| 110 | 100 | } |
| 111 | - new \ShopEngine\Compatibility\Migrations\Direct_Checkout; | |
| 101 | + | |
| 112 | 102 | }); |
| 113 | 103 | |
| 104 | + global $pagenow; | |
| 114 | 105 | |
| 106 | + if(is_admin() && $pagenow == 'post.php' && $_REQUEST['action'] === 'edit') { | |
| 107 | + | |
| 108 | + $pid = $_REQUEST['post']; | |
| 109 | + $po = get_post($pid); | |
| 110 | + | |
| 111 | + if($po->post_type === Template_Cpt::TYPE) { | |
| 112 | + | |
| 113 | + $url = get_admin_url() . 'edit.php?post_type=' . Template_Cpt::TYPE . '#' . Template_Cpt::TYPE; | |
| 114 | + | |
| 115 | + wp_safe_redirect($url); | |
| 116 | + exit; | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 115 | 120 | add_action('wp_loaded', function () { |
| 116 | - //phpcs:ignore WordPress.Security.NonceVerification.Recommended --It's a fronted user part, not possible to verify nonce here | |
| 121 | + | |
| 117 | 122 | if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) { |
| 118 | 123 | |
| 119 | - $pid = (int)$_REQUEST['preview_id']; //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here | |
| 124 | + $pid = (int)$_REQUEST['preview_id']; | |
| 120 | 125 | |
| 121 | 126 | $po = get_post($pid); |
| 122 | 127 | |
| 123 | 128 | if($po->post_type === Template_Cpt::TYPE) { |
| @@ -133,26 +138,21 @@ | ||
| 133 | 138 | 'preview_nonce' => wp_create_nonce('template_preview_' . $pid), |
| 134 | 139 | 'change_template' => '1', |
| 135 | 140 | ]; |
| 136 | 141 | |
| 137 | - $tem_url = (get_post_meta($pid, 'shopengine_template__post_meta__type' , true) == 'order') ? $po->guid : $template['url']; | |
| 138 | - $url = \ShopEngine\Utils\Helper::add_to_url($tem_url, $param); | |
| 142 | + $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param); | |
| 139 | 143 | |
| 140 | 144 | wp_safe_redirect($url); |
| 141 | 145 | exit; |
| 142 | 146 | } |
| 143 | 147 | } |
| 148 | + }); | |
| 144 | 149 | |
| 145 | - /** | |
| 146 | - * migrate data | |
| 147 | - */ | |
| 148 | - LangMigration::instance()->init(); | |
| 149 | - }); | |
| 150 | 150 | |
| 151 | 151 | // avoid themes for loading woocommerce functions |
| 152 | - $avoid_themes = ['avada', 'avada child']; | |
| 152 | + $avoid_themes = ['avada']; | |
| 153 | 153 | |
| 154 | - if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) { | |
| 154 | + if( !in_array( strtolower(wp_get_theme()), $avoid_themes) ) { | |
| 155 | 155 | /** |
| 156 | 156 | * Ensuring woocommerce functions are loaded before theme is modifying those |
| 157 | 157 | * |
| 158 | 158 | */ |
| @@ -158,20 +158,14 @@ | ||
| 158 | 158 | */ |
| 159 | 159 | require_once WC_ABSPATH . '/includes/wc-template-functions.php'; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | + // Load custom elementor controls | |
| 163 | + new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 162 | 164 | |
| 163 | - if(did_action('elementor/loaded')) { | |
| 164 | - // Load custom elementor controls | |
| 165 | - new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 166 | - | |
| 167 | - //Loading the scripts and styles | |
| 168 | - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 169 | - } | |
| 170 | - | |
| 171 | - | |
| 172 | - //Loading public scripts and styles | |
| 165 | + //Loading the scripts and styles | |
| 173 | 166 | add_action('wp_enqueue_scripts', [$this, 'js_css_public']); |
| 167 | + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 174 | 168 | |
| 175 | 169 | //woocommece theme support |
| 176 | 170 | if(!current_theme_supports('woocommerce')) { |
| 177 | 171 | add_theme_support('woocommerce'); |
| @@ -179,23 +173,14 @@ | ||
| 179 | 173 | add_theme_support('wc-product-gallery-lightbox'); |
| 180 | 174 | add_theme_support('wc-product-gallery-slider'); |
| 181 | 175 | } |
| 182 | 176 | |
| 177 | + | |
| 183 | 178 | #Registering new post-type & etc |
| 184 | 179 | Base::instance()->init(); |
| 180 | + | |
| 181 | + \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 185 | 182 | |
| 186 | - Rating::instance('shopengine') | |
| 187 | - ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' ) | |
| 188 | - ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' ) | |
| 189 | - ->set_priority( 10 ) | |
| 190 | - ->set_first_appear_day( 7 ) | |
| 191 | - ->set_condition( true ) | |
| 192 | - ->call(); | |
| 193 | - | |
| 194 | - \ShopEngine\Core\MultiLanguage\Language::instance()->init(); | |
| 195 | - | |
| 196 | - \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 197 | - | |
| 198 | 183 | new Libs\Select_Api\Base(); |
| 199 | 184 | |
| 200 | 185 | (new Module_Manifest())->init(); |
| 201 | 186 | |
| @@ -210,24 +195,10 @@ | ||
| 210 | 195 | add_action('get_header', [$this, 'shopengine_track_product_views']); |
| 211 | 196 | |
| 212 | 197 | // database migrations |
| 213 | 198 | // (new \ShopEngine\Compatibility\Migrations\Migration())->init(); |
| 214 | - // (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 199 | + (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 215 | 200 | |
| 216 | - | |
| 217 | - // call service providers | |
| 218 | - | |
| 219 | - $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php'; | |
| 220 | - $method = 'init'; | |
| 221 | - foreach( $service_providers as $service_provider ){ | |
| 222 | - | |
| 223 | - if(class_exists($service_provider) && method_exists($service_provider, $method)) { | |
| 224 | - $instance = new $service_provider(); | |
| 225 | - $instance->$method(); | |
| 226 | - } | |
| 227 | - | |
| 228 | - } | |
| 229 | - | |
| 230 | 201 | add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3); |
| 231 | 202 | } |
| 232 | 203 | |
| 233 | 204 | |
| @@ -257,14 +228,14 @@ | ||
| 257 | 228 | |
| 258 | 229 | $product_id = get_the_id(); |
| 259 | 230 | |
| 260 | 231 | $cookie_name = "shopengine_recent_viewed_product"; |
| 261 | - | |
| 232 | + | |
| 262 | 233 | if(isset($_COOKIE[$cookie_name])) { |
| 263 | - | |
| 264 | - $cookie_ids = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name])); | |
| 234 | + | |
| 235 | + $cookie_ids = $_COOKIE[$cookie_name]; | |
| 265 | 236 | $product_ids = explode(',', $cookie_ids); |
| 266 | - | |
| 237 | + | |
| 267 | 238 | if(!is_array($product_ids)) { |
| 268 | 239 | $product_ids = [$product_ids]; |
| 269 | 240 | } |
| 270 | 241 | |
| @@ -272,14 +243,14 @@ | ||
| 272 | 243 | unset($product_ids[$product_id]); |
| 273 | 244 | $product_ids[] = $product_id; |
| 274 | 245 | |
| 275 | 246 | $cookie_value = implode(',', $product_ids); |
| 276 | - | |
| 247 | + | |
| 277 | 248 | } else { |
| 278 | - $cookie_value = $product_id; | |
| 249 | + $cookie_value = $product_id; | |
| 279 | 250 | } |
| 280 | 251 | |
| 281 | - setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' ); | |
| 252 | + setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/'); | |
| 282 | 253 | |
| 283 | 254 | $count_key = 'shopengine_product_views_count'; |
| 284 | 255 | $count = get_post_meta($product_id, $count_key, true); |
| 285 | 256 | |
| @@ -298,10 +269,12 @@ | ||
| 298 | 269 | * Include public function |
| 299 | 270 | * |
| 300 | 271 | * @since 1.0.0 |
| 301 | 272 | */ |
| 302 | - public function js_css_public() { | |
| 303 | - wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version()); | |
| 273 | + public function js_css_public() { | |
| 274 | + wp_enqueue_style('shopengine-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version()); | |
| 275 | + wp_enqueue_style('shopengine-simple-scrollbar-css', \ShopEngine::plugin_url() . 'assets/css/simple-scrollbar.css', false, \ShopEngine::version()); | |
| 276 | + wp_enqueue_style('shopengine-public-css', \ShopEngine::plugin_url() . 'assets/css/public-style.css', false, \ShopEngine::version()); | |
| 304 | 277 | |
| 305 | 278 | // Modal Stylesheet |
| 306 | 279 | wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version()); |
| 307 | 280 | |
| @@ -350,8 +323,12 @@ | ||
| 350 | 323 | |
| 351 | 324 | |
| 352 | 325 | public function missing_woocommerce() { |
| 353 | 326 | |
| 327 | + if(isset($_GET['activate'])) { | |
| 328 | + unset($_GET['activate']); | |
| 329 | + } | |
| 330 | + | |
| 354 | 331 | if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) { |
| 355 | 332 | |
| 356 | 333 | $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine'); |
| 357 | 334 | $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php'); |
| @@ -374,8 +351,12 @@ | ||
| 374 | 351 | } |
| 375 | 352 | |
| 376 | 353 | |
| 377 | 354 | public function missing_elementor() { |
| 355 | + | |
| 356 | + if(isset($_GET['activate'])) { | |
| 357 | + unset($_GET['activate']); | |
| 358 | + } | |
| 378 | 359 | |
| 379 | 360 | if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) { |
| 380 | 361 | |
| 381 | 362 | $btn['label'] = esc_html__('Activate Elementor', 'shopengine'); |