| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | use ShopEngine\Core\Builders\Base; |
| 7 | 7 | use ShopEngine\Core\Query_Modifier; |
| 8 | 8 | use ShopEngine\Core\Template_Cpt; |
| 9 | 9 | use ShopEngine\Libs\License\License_Route; |
| 10 | -use ShopEngine\Libs\Rating\Rating; | |
| 11 | 10 | use ShopEngine\Libs\Updater\Init as Updater; |
| 12 | 11 | use ShopEngine\Modules\Manifest as Module_Manifest; |
| 13 | 12 | use ShopEngine\Widgets\Manifest; |
| 14 | 13 | |
| @@ -50,38 +49,30 @@ | ||
| 50 | 49 | |
| 51 | 50 | $error = true; |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | - $check_elementor_version = false; | |
| 55 | - | |
| 56 | 53 | // Check if Elementor installed and activated. |
| 57 | - if(!did_action('elementor/loaded')) { | |
| 54 | + if(!did_action('elementor/loaded')) { | |
| 55 | + add_action('admin_notices', [$this, 'missing_elementor']); | |
| 58 | 56 | |
| 59 | - if(!did_action('shopengine-gutenberg-addon/before_loaded')) { | |
| 57 | + $error = true; | |
| 58 | + } | |
| 60 | 59 | |
| 61 | - add_action('admin_notices', [$this, 'missing_elementor']); | |
| 62 | - | |
| 63 | - $error = true; | |
| 64 | - } | |
| 65 | - } | |
| 66 | - | |
| 67 | 60 | // Check for required Elementor version. |
| 68 | - 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']); | |
| 69 | 63 | |
| 70 | - add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 64 | + $error = true; | |
| 65 | + } | |
| 71 | 66 | |
| 72 | - $error = true; | |
| 73 | - } | |
| 67 | + if($error) { | |
| 74 | 68 | |
| 75 | - if($error) { | |
| 76 | 69 | return; |
| 77 | 70 | } |
| 78 | - | |
| 71 | + | |
| 79 | 72 | add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) { |
| 80 | - $free = esc_html__("Go To Shopengine","shopengine"); | |
| 81 | - $pro = esc_html__("Go To ShopenginePro","shopengine"); | |
| 82 | 73 | |
| 83 | - $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>'; | |
| 84 | 75 | |
| 85 | 76 | foreach ($custom_links as $custom_link): |
| 86 | 77 | array_unshift($links, $custom_link); |
| 87 | 78 | endforeach; |
| @@ -86,9 +77,9 @@ | ||
| 86 | 77 | array_unshift($links, $custom_link); |
| 87 | 78 | endforeach; |
| 88 | 79 | |
| 89 | 80 | if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) { |
| 90 | - $links[] = '<a title="' . $pro . '" href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank">' . 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>'; | |
| 91 | 82 | } |
| 92 | 83 | return $links; |
| 93 | 84 | }); |
| 94 | 85 | |
| @@ -106,11 +97,27 @@ | ||
| 106 | 97 | add_action('admin_init', function () { |
| 107 | 98 | if(class_exists('ShopEngine_Pro')) { |
| 108 | 99 | new Updater(); |
| 109 | 100 | } |
| 101 | + | |
| 110 | 102 | }); |
| 111 | 103 | |
| 104 | + global $pagenow; | |
| 112 | 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 | + | |
| 113 | 120 | add_action('wp_loaded', function () { |
| 114 | 121 | |
| 115 | 122 | if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) { |
| 116 | 123 | |
| @@ -139,12 +146,13 @@ | ||
| 139 | 146 | } |
| 140 | 147 | } |
| 141 | 148 | }); |
| 142 | 149 | |
| 150 | + | |
| 143 | 151 | // avoid themes for loading woocommerce functions |
| 144 | - $avoid_themes = ['avada', 'avada child']; | |
| 152 | + $avoid_themes = ['avada']; | |
| 145 | 153 | |
| 146 | - if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) { | |
| 154 | + if( !in_array( strtolower(wp_get_theme()), $avoid_themes) ) { | |
| 147 | 155 | /** |
| 148 | 156 | * Ensuring woocommerce functions are loaded before theme is modifying those |
| 149 | 157 | * |
| 150 | 158 | */ |
| @@ -150,20 +158,14 @@ | ||
| 150 | 158 | */ |
| 151 | 159 | require_once WC_ABSPATH . '/includes/wc-template-functions.php'; |
| 152 | 160 | } |
| 153 | 161 | |
| 162 | + // Load custom elementor controls | |
| 163 | + new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 154 | 164 | |
| 155 | - if(did_action('elementor/loaded')) { | |
| 156 | - // Load custom elementor controls | |
| 157 | - new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 158 | - | |
| 159 | - //Loading the scripts and styles | |
| 160 | - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 161 | - } | |
| 162 | - | |
| 163 | - | |
| 164 | - //Loading public scripts and styles | |
| 165 | + //Loading the scripts and styles | |
| 165 | 166 | add_action('wp_enqueue_scripts', [$this, 'js_css_public']); |
| 167 | + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 166 | 168 | |
| 167 | 169 | //woocommece theme support |
| 168 | 170 | if(!current_theme_supports('woocommerce')) { |
| 169 | 171 | add_theme_support('woocommerce'); |
| @@ -171,21 +173,14 @@ | ||
| 171 | 173 | add_theme_support('wc-product-gallery-lightbox'); |
| 172 | 174 | add_theme_support('wc-product-gallery-slider'); |
| 173 | 175 | } |
| 174 | 176 | |
| 177 | + | |
| 175 | 178 | #Registering new post-type & etc |
| 176 | 179 | Base::instance()->init(); |
| 180 | + | |
| 181 | + \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 177 | 182 | |
| 178 | - Rating::instance('shopengine') | |
| 179 | - ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' ) | |
| 180 | - ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' ) | |
| 181 | - ->set_priority( 10 ) | |
| 182 | - ->set_first_appear_day( 7 ) | |
| 183 | - ->set_condition( true ) | |
| 184 | - ->call(); | |
| 185 | - | |
| 186 | - \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 187 | - | |
| 188 | 183 | new Libs\Select_Api\Base(); |
| 189 | 184 | |
| 190 | 185 | (new Module_Manifest())->init(); |
| 191 | 186 | |
| @@ -206,20 +201,20 @@ | ||
| 206 | 201 | |
| 207 | 202 | // call service providers |
| 208 | 203 | |
| 209 | 204 | $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php'; |
| 210 | - $method = 'init'; | |
| 205 | + $method = 'init'; | |
| 211 | 206 | foreach( $service_providers as $service_provider ){ |
| 212 | 207 | |
| 213 | - if(class_exists($service_provider) && method_exists($service_provider, $method)) { | |
| 208 | + if(class_exists($service_provider) && method_exists($service_provider, $method)) { | |
| 214 | 209 | $instance = new $service_provider(); |
| 215 | - $instance->$method(); | |
| 210 | + $instance->$method(); | |
| 216 | 211 | } |
| 217 | 212 | |
| 218 | 213 | } |
| 219 | 214 | |
| 215 | + | |
| 220 | 216 | |
| 221 | - | |
| 222 | 217 | add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3); |
| 223 | 218 | } |
| 224 | 219 | |
| 225 | 220 | |
| @@ -249,14 +244,14 @@ | ||
| 249 | 244 | |
| 250 | 245 | $product_id = get_the_id(); |
| 251 | 246 | |
| 252 | 247 | $cookie_name = "shopengine_recent_viewed_product"; |
| 253 | - | |
| 248 | + | |
| 254 | 249 | if(isset($_COOKIE[$cookie_name])) { |
| 255 | - | |
| 256 | - $cookie_ids = $_COOKIE[$cookie_name]; | |
| 250 | + | |
| 251 | + $cookie_ids = $_COOKIE[$cookie_name]; | |
| 257 | 252 | $product_ids = explode(',', $cookie_ids); |
| 258 | - | |
| 253 | + | |
| 259 | 254 | if(!is_array($product_ids)) { |
| 260 | 255 | $product_ids = [$product_ids]; |
| 261 | 256 | } |
| 262 | 257 | |
| @@ -264,11 +259,11 @@ | ||
| 264 | 259 | unset($product_ids[$product_id]); |
| 265 | 260 | $product_ids[] = $product_id; |
| 266 | 261 | |
| 267 | 262 | $cookie_value = implode(',', $product_ids); |
| 268 | - | |
| 263 | + | |
| 269 | 264 | } else { |
| 270 | - $cookie_value = $product_id; | |
| 265 | + $cookie_value = $product_id; | |
| 271 | 266 | } |
| 272 | 267 | |
| 273 | 268 | setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' ); |
| 274 | 269 | |
| @@ -290,10 +285,12 @@ | ||
| 290 | 285 | * Include public function |
| 291 | 286 | * |
| 292 | 287 | * @since 1.0.0 |
| 293 | 288 | */ |
| 294 | - public function js_css_public() { | |
| 295 | - wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version()); | |
| 289 | + public function js_css_public() { | |
| 290 | + wp_enqueue_style('shopengine-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version()); | |
| 291 | + wp_enqueue_style('shopengine-simple-scrollbar-css', \ShopEngine::plugin_url() . 'assets/css/simple-scrollbar.css', false, \ShopEngine::version()); | |
| 292 | + wp_enqueue_style('shopengine-public-css', \ShopEngine::plugin_url() . 'assets/css/public-style.css', false, \ShopEngine::version()); | |
| 296 | 293 | |
| 297 | 294 | // Modal Stylesheet |
| 298 | 295 | wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version()); |
| 299 | 296 | |