| @@ -1,23 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ShopEngine; |
| 4 | 4 | |
| 5 | -defined('ABSPATH') || exit; | |
| 6 | - | |
| 7 | 5 | use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest; |
| 8 | 6 | use ShopEngine\Core\Builders\Base; |
| 9 | -use ShopEngine\Compatibility\Migrations\LangMigration; | |
| 10 | 7 | use ShopEngine\Core\Query_Modifier; |
| 11 | -use ShopEngine\Core\Wc_Customizer\Register_Settings; | |
| 12 | 8 | use ShopEngine\Core\Template_Cpt; |
| 13 | 9 | use ShopEngine\Libs\License\License_Route; |
| 14 | -use ShopEngine\Libs\Rating\Rating; | |
| 15 | 10 | use ShopEngine\Libs\Updater\Init as Updater; |
| 16 | 11 | use ShopEngine\Modules\Manifest as Module_Manifest; |
| 17 | -use ShopEngine\Utils\Feedback\Plugin_Unsubscribe; | |
| 18 | 12 | use ShopEngine\Widgets\Manifest; |
| 19 | 13 | |
| 14 | +defined('ABSPATH') || exit; | |
| 20 | 15 | |
| 21 | 16 | /** |
| 22 | 17 | * Plugin final Class. |
| 23 | 18 | * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install. |
| @@ -34,15 +29,11 @@ | ||
| 34 | 29 | */ |
| 35 | 30 | public function __construct() { |
| 36 | 31 | // load autoload method |
| 37 | 32 | Autoloader::run(); |
| 38 | - add_action( 'wp_ajax_shopengine_admin_action', [\ShopEngine\Utils\Util::class, 'shopengine_admin_action'] ); | |
| 39 | 33 | } |
| 40 | 34 | |
| 41 | - public function utils_url() | |
| 42 | - { | |
| 43 | - return $this->plugin_url() . 'utils/'; | |
| 44 | - } | |
| 35 | + | |
| 45 | 36 | /** |
| 46 | 37 | * Public function init. |
| 47 | 38 | * call function for all |
| 48 | 39 | * |
| @@ -51,11 +42,8 @@ | ||
| 51 | 42 | public function init() { |
| 52 | 43 | |
| 53 | 44 | $error = false; |
| 54 | 45 | |
| 55 | - // init notice class | |
| 56 | - \Oxaim\Libs\Notice::init(); | |
| 57 | - | |
| 58 | 46 | // check woocommerce plugin |
| 59 | 47 | if(!did_action('woocommerce_loaded')) { |
| 60 | 48 | add_action('admin_notices', [$this, 'missing_woocommerce']); |
| 61 | 49 | |
| @@ -61,81 +49,34 @@ | ||
| 61 | 49 | |
| 62 | 50 | $error = true; |
| 63 | 51 | } |
| 64 | 52 | |
| 65 | - $check_elementor_version = false; | |
| 66 | - | |
| 67 | 53 | // Check if Elementor installed and activated. |
| 68 | - if(!did_action('elementor/loaded')) { | |
| 54 | + if(!did_action('elementor/loaded')) { | |
| 55 | + add_action('admin_notices', [$this, 'missing_elementor']); | |
| 69 | 56 | |
| 70 | - if(!did_action('shopengine-gutenberg-addon/before_loaded')) { | |
| 57 | + $error = true; | |
| 58 | + } | |
| 71 | 59 | |
| 72 | - add_action('admin_notices', [$this, 'missing_elementor']); | |
| 73 | - | |
| 74 | - $error = true; | |
| 75 | - } | |
| 76 | - } | |
| 77 | - | |
| 78 | 60 | // Check for required Elementor version. |
| 79 | - 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']); | |
| 80 | 63 | |
| 81 | - add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 64 | + $error = true; | |
| 65 | + } | |
| 82 | 66 | |
| 83 | - $error = true; | |
| 84 | - } | |
| 67 | + if($error) { | |
| 85 | 68 | |
| 86 | - if($error) { | |
| 87 | 69 | return; |
| 88 | 70 | } |
| 89 | 71 | |
| 90 | 72 | |
| 91 | - | |
| 92 | - add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) { | |
| 93 | - $free = esc_html__("Go To Shopengine","shopengine"); | |
| 94 | - $pro = esc_html__("Go To ShopenginePro","shopengine"); | |
| 95 | - | |
| 96 | - $custom_links[] = '<a title="' . $free . '" href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>'; | |
| 97 | - | |
| 98 | - foreach ($custom_links as $custom_link): | |
| 99 | - array_unshift($links, $custom_link); | |
| 100 | - endforeach; | |
| 101 | - | |
| 102 | - if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) { | |
| 103 | - $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>'; | |
| 104 | - } | |
| 105 | - return $links; | |
| 106 | - }); | |
| 107 | - | |
| 108 | - if(\ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true'){ | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * EmailKit Global Class initialization | |
| 112 | - * | |
| 113 | - */ | |
| 114 | - if( !class_exists('EmailKit') && !did_action('edit_with_emailkit_loaded') && class_exists('\Wpmet\Libs\Emailkit') ) { | |
| 115 | - | |
| 116 | - new \Wpmet\Libs\Emailkit(); | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * MetForm get free templates promotional class initialization | |
| 121 | - * | |
| 122 | - */ | |
| 123 | - if( !did_action('metform/after_load') && did_action('elementor/loaded') && class_exists('\Wpmet\Libs\Metform_Promo_Banner') ) { | |
| 124 | - | |
| 125 | - new \Wpmet\Libs\Metform_Promo_Banner(); | |
| 126 | - } | |
| 127 | - } | |
| 128 | - | |
| 129 | - | |
| 130 | 73 | /** |
| 131 | 74 | * Routes initialization |
| 132 | 75 | * |
| 133 | 76 | */ |
| 134 | 77 | new License_Route(); |
| 135 | - | |
| 136 | - // Initialize deactivation feedback modal | |
| 137 | - new \ShopEngine\Utils\Feedback\Plugin_Unsubscribe(); | |
| 78 | + | |
| 138 | 79 | /** |
| 139 | 80 | * Run pro plugin updater here.... |
| 140 | 81 | * |
| 141 | 82 | */ |
| @@ -142,58 +83,71 @@ | ||
| 142 | 83 | add_action('admin_init', function () { |
| 143 | 84 | if(class_exists('ShopEngine_Pro')) { |
| 144 | 85 | new Updater(); |
| 145 | 86 | } |
| 146 | - new \ShopEngine\Compatibility\Migrations\Direct_Checkout; | |
| 87 | + | |
| 147 | 88 | }); |
| 148 | 89 | |
| 90 | + global $pagenow; | |
| 149 | 91 | |
| 150 | - add_action('wp_loaded', function () { | |
| 151 | - /** | |
| 152 | - * migrate data | |
| 153 | - */ | |
| 154 | - LangMigration::instance()->init(); | |
| 155 | - }); | |
| 92 | + if(is_admin() && $pagenow == 'post.php' && $_REQUEST['action'] === 'edit') { | |
| 156 | 93 | |
| 157 | - // avoid themes for loading woocommerce functions | |
| 158 | - $avoid_themes = ['avada', 'woodmart', 'Avada', 'Woodmart']; | |
| 94 | + $pid = $_REQUEST['post']; | |
| 95 | + $po = get_post($pid); | |
| 159 | 96 | |
| 160 | - if( !in_array(get_template(), $avoid_themes) ) { | |
| 161 | - /** | |
| 162 | - * Ensuring woocommerce functions are loaded before theme is modifying those | |
| 163 | - * | |
| 164 | - */ | |
| 165 | - require_once WC_ABSPATH . '/includes/wc-template-functions.php'; | |
| 97 | + if($po->post_type === Template_Cpt::TYPE) { | |
| 98 | + | |
| 99 | + $url = get_admin_url(). 'edit.php?post_type='.Template_Cpt::TYPE.'#'.Template_Cpt::TYPE; | |
| 100 | + | |
| 101 | + wp_safe_redirect( $url ); | |
| 102 | + exit; | |
| 103 | + } | |
| 166 | 104 | } |
| 167 | 105 | |
| 106 | + add_action('wp_loaded', function (){ | |
| 168 | 107 | |
| 169 | - if(did_action('elementor/loaded')) { | |
| 170 | - // Load custom elementor controls | |
| 171 | - new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 108 | + if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) { | |
| 172 | 109 | |
| 173 | - //Loading the scripts and styles | |
| 174 | - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 175 | - | |
| 176 | - // Register widgets immediately after elementor is loaded with higher priority | |
| 177 | - if(is_plugin_active('related-products-manager-woocommerce/related-products-manager-for-woocommerce.php')) { | |
| 110 | + $pid = (int) $_REQUEST['preview_id']; | |
| 178 | 111 | |
| 179 | - add_action('elementor/widgets/register', function() { | |
| 180 | - (new Manifest())->init(); | |
| 181 | - }, 5); // Priority 5 to load early | |
| 112 | + $po = get_post($pid); | |
| 113 | + | |
| 114 | + if($po->post_type === Template_Cpt::TYPE) { | |
| 115 | + | |
| 116 | + $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid); | |
| 117 | + | |
| 118 | + if(empty($template) || !isset($template['url'])){ | |
| 119 | + return; | |
| 120 | + } | |
| 121 | + | |
| 122 | + $param = [ | |
| 123 | + 'shopengine_template_id' => $pid, | |
| 124 | + 'preview_nonce' => wp_create_nonce( 'template_preview_' . $pid ), | |
| 125 | + 'change_template' => '1' | |
| 126 | + ]; | |
| 127 | + | |
| 128 | + $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param); | |
| 129 | + | |
| 130 | + wp_safe_redirect( $url ); | |
| 131 | + exit; | |
| 132 | + } | |
| 182 | 133 | } |
| 134 | + }); | |
| 183 | 135 | |
| 184 | - } | |
| 185 | 136 | |
| 186 | - // Cart validation compatibility with WC Min Max Quantity plugin | |
| 137 | + /** | |
| 138 | + * Ensuring woocommerce functions are loaded before theme is modifying those | |
| 139 | + * | |
| 140 | + */ | |
| 141 | + require_once WC_ABSPATH . '/includes/wc-template-functions.php'; | |
| 187 | 142 | |
| 188 | - if ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'woo-min-max-quantity-step-control-single/wcmmq.php' ) ) { | |
| 189 | - | |
| 190 | - add_filter( 'wcmmq_cart_validation_check', [ $this, 'shopengine_wcmmq_cart_validation_compat' ], 10, 2 ); | |
| 191 | - } | |
| 192 | 143 | |
| 144 | + // Load custom elementor controls | |
| 145 | + new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 193 | 146 | |
| 194 | - //Loading public scripts and styles | |
| 147 | + //Loading the scripts and styles | |
| 195 | 148 | add_action('wp_enqueue_scripts', [$this, 'js_css_public']); |
| 149 | + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 196 | 150 | |
| 197 | 151 | //woocommece theme support |
| 198 | 152 | if(!current_theme_supports('woocommerce')) { |
| 199 | 153 | add_theme_support('woocommerce'); |
| @@ -201,261 +155,60 @@ | ||
| 201 | 155 | add_theme_support('wc-product-gallery-lightbox'); |
| 202 | 156 | add_theme_support('wc-product-gallery-slider'); |
| 203 | 157 | } |
| 204 | 158 | |
| 205 | - | |
| 206 | - $filter_string = ''; // elementskit,metform-pro | |
| 207 | - $filter_string .= ((!in_array('elementskit/elementskit.php', apply_filters('active_plugins', get_option('active_plugins')))) ? '' : ',elementskit'); | |
| 208 | - $filter_string .= (!class_exists('\MetForm\Plugin') ? '' : ',metform'); | |
| 209 | - $filter_string .= (!class_exists('\MetForm_Pro\Plugin') ? '' : ',metform-pro'); | |
| 210 | - | |
| 159 | + | |
| 211 | 160 | #Registering new post-type & etc |
| 212 | 161 | Base::instance()->init(); |
| 213 | - | |
| 214 | 162 | |
| 215 | - Rating::instance('shopengine') | |
| 216 | - ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' ) | |
| 217 | - ->set_rating_url( 'https://wordpress.org/support/plugin/shopengine/reviews/#new-post' ) | |
| 218 | - ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' ) | |
| 219 | - ->set_priority( 11 ) | |
| 220 | - ->set_first_appear_day( 7 ) | |
| 221 | - ->set_condition( true ) | |
| 222 | - ->call(); | |
| 223 | - | |
| 224 | - if ( is_admin() && \ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true' ) { | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Show WPMET stories widget in dashboard | |
| 228 | - */ | |
| 229 | - | |
| 230 | - \Wpmet\Libs\Stories::instance('shopengine') | |
| 231 | - | |
| 232 | - ->set_filter($filter_string) | |
| 233 | - ->set_plugin('ShopEngine', 'https://wpmet.com/plugin/shopengine/') | |
| 234 | - ->set_api_url('https://api.wpmet.com/public/stories/') | |
| 235 | - ->call(); | |
| 236 | - | |
| 237 | - // banner | |
| 238 | - \Wpmet\Libs\Banner::instance('shopengine') | |
| 239 | - ->set_filter(ltrim($filter_string, ',')) | |
| 240 | - ->set_api_url('https://api.wpmet.com/public/jhanda') | |
| 241 | - ->set_plugin_screens('edit-shopengine-template') | |
| 242 | - ->set_plugin_screens('edit-shopengine-template') | |
| 243 | - ->call(); | |
| 244 | - } | |
| 245 | - | |
| 246 | - add_action('init', function () { | |
| 247 | - $apps_img_path = \ShopEngine::plugin_url() . 'assets/images/apps-page/'; | |
| 248 | - /** | |
| 249 | - * Show our plugins menu for others wpmet plugins | |
| 250 | - */ | |
| 251 | - \ShopEngine\Wpmet\Libs\Plugins::instance()->init('shopengine') | |
| 252 | - ->set_parent_menu_slug('shopengine-settings') | |
| 253 | - ->set_submenu_name('Our Plugins') | |
| 254 | - ->set_section_title('Get More out of Your WooCommerce Website!') | |
| 255 | - ->set_section_description('Install other plugins from us and take your WooCommerce site to the next level for absolutely free!') | |
| 256 | - ->set_items_per_row(4) | |
| 257 | - ->set_plugins( | |
| 258 | - [ | |
| 259 | - 'elementskit-lite/elementskit-lite.php' => [ | |
| 260 | - 'name' => esc_html__('ElementsKit', 'shopengine'), | |
| 261 | - 'url' => 'https://wordpress.org/plugins/elementskit-lite/', | |
| 262 | - 'icon' => $apps_img_path. 'elementskit.gif', | |
| 263 | - 'desc' => esc_html__('All-in-one Elementor addon trusted by 1 Million+ users, makes your website builder process easier with ultimate freedom.', 'shopengine'), | |
| 264 | - 'docs' => 'https://wpmet.com/doc/elementskit/', | |
| 265 | - ], | |
| 266 | - 'gutenkit-blocks-addon/gutenkit-blocks-addon.php' => [ | |
| 267 | - 'name' => esc_html__('GutenKit', 'shopengine'), | |
| 268 | - 'url' => 'https://wordpress.org/plugins/gutenkit-blocks-addon/', | |
| 269 | - 'icon' => $apps_img_path. 'guten-kit.png', | |
| 270 | - 'desc' => esc_html__('Gutenberg blocks, patterns, and templates that extend the page-building experience using the WordPress block editor.', 'shopengine'), | |
| 271 | - 'docs' => 'https://wpmet.com/doc/gutenkit/', | |
| 272 | - ], | |
| 273 | - 'rox-dynamic-cpt-fields-engine/rox-dynamic-cpt-fields-engine.php' => [ | |
| 274 | - 'name' => esc_html__('Rox Dynamic CPT Fields', 'shopengine'), | |
| 275 | - 'url' => 'https://wordpress.org/plugins/rox-dynamic-cpt-fields-engine/', | |
| 276 | - 'icon' => 'https://ps.w.org/rox-dynamic-cpt-fields-engine/assets/icon-256x256.jpeg?rev=3538537', | |
| 277 | - 'desc' => esc_html__('Build custom post types, fields, taxonomies, and dynamic frontend layouts for WordPress, with zero coding and full AI-generated schema.', 'shopengine'), | |
| 278 | - 'docs' => 'https://wpmet.com/doc/rox-dynamic-cpt-fields-engine/', | |
| 279 | - ], | |
| 280 | - 'rox-appointment-booking/rox-appointment-booking.php' => [ | |
| 281 | - 'name' => esc_html__('Rox Appointment Booking', 'shopengine'), | |
| 282 | - 'url' => 'https://wordpress.org/plugins/rox-appointment-booking/', | |
| 283 | - 'icon' => 'https://ps.w.org/rox-appointment-booking/assets/icon-256x256.png?rev=3575641', | |
| 284 | - 'desc' => esc_html__('Manage bookings, agents, payments, and calendars from one dashboard! A complete appointment and scheduling solution for WordPress.', 'shopengine'), | |
| 285 | - 'docs' => 'https://wpmet.com/doc/rox-appointment-booking/', | |
| 286 | - ], | |
| 287 | - 'metform/metform.php' => [ | |
| 288 | - 'name' => esc_html__('MetForm', 'shopengine'), | |
| 289 | - 'url' => 'https://wordpress.org/plugins/metform/', | |
| 290 | - 'icon' => $apps_img_path. 'metform.png', | |
| 291 | - 'desc' => esc_html__('Drag & drop form builder for Elementor to create contact forms, multi-step forms, and more — smoother, faster, and better!', 'shopengine'), | |
| 292 | - 'docs' => 'https://wpmet.com/doc/metform/', | |
| 293 | - ], | |
| 294 | - 'popup-builder-block/popup-builder-block.php' => [ | |
| 295 | - 'name' => esc_html__('PopupKit', 'shopengine'), | |
| 296 | - 'url' => 'https://wordpress.org/plugins/popup-builder-block/', | |
| 297 | - 'icon' => 'https://ps.w.org/popup-builder-block/assets/icon-256x256.png?rev=3316844', | |
| 298 | - 'desc' => esc_html__('Design popups that convert, right in your WordPress dashboard.', 'shopengine'), | |
| 299 | - 'docs' => 'https://wpmet.com/doc/popupkit/', | |
| 300 | - ], | |
| 301 | - 'table-builder-block/table-builder-block.php' => [ | |
| 302 | - 'name' => esc_html__('TableKit', 'shopengine'), | |
| 303 | - 'url' => 'https://wordpress.org/plugins/table-builder-block/', | |
| 304 | - 'icon' => 'https://ps.w.org/table-builder-block/assets/icon-256x256.png?rev=3509972', | |
| 305 | - 'desc' => esc_html__('Fully Customizable. Multi-Media Integration. Synch Any Data Files. All Within Block Editor.', 'shopengine'), | |
| 306 | - 'docs' => 'https://wpmet.com/doc/tablekit/', | |
| 307 | - ], | |
| 308 | - 'getgenie/getgenie.php' => [ | |
| 309 | - 'name' => esc_html__('GetGenie', 'shopengine'), | |
| 310 | - 'url' => 'https://wordpress.org/plugins/getgenie/', | |
| 311 | - 'icon' => $apps_img_path.'getgenie.gif', | |
| 312 | - 'desc' => esc_html__('Your personal AI assistant for content and SEO. Write content that ranks on Google with NLP keywords and SERP analysis data.', 'shopengine'), | |
| 313 | - 'docs' => 'https://getgenie.ai/docs/', | |
| 314 | - ], | |
| 315 | - 'emailkit/EmailKit.php' => [ | |
| 316 | - 'name' => esc_html__('EmailKit', 'shopengine'), | |
| 317 | - 'url' => 'https://wordpress.org/plugins/emailkit/', | |
| 318 | - 'icon' => $apps_img_path . 'emailkit.png', | |
| 319 | - 'desc' => esc_html__('Advanced email customizer for WooCommerce and WordPress. Build, customize, and send emails from WordPress to boost your sales!', 'shopengine'), | |
| 320 | - 'docs' => 'https://wpmet.com/doc/emailkit/', | |
| 321 | - ], | |
| 322 | - 'wp-social/wp-social.php' => [ | |
| 323 | - 'name' => esc_html__('WP Social', 'shopengine'), | |
| 324 | - 'url' => 'https://wordpress.org/plugins/wp-social/', | |
| 325 | - 'icon' => $apps_img_path . 'wp-social.png', | |
| 326 | - 'desc' => esc_html__('Add social share, login, and engagement counter — unified solution for all social media with tons of different styles for your website.', 'shopengine'), | |
| 327 | - 'docs' => 'https://wpmet.com/doc/wp-social/', | |
| 328 | - ], | |
| 329 | - 'blocks-for-shopengine/shopengine-gutenberg-addon.php' => [ | |
| 330 | - 'name' => esc_html__('Blocks for ShopEngine', 'shopengine'), | |
| 331 | - 'url' => 'https://wordpress.org/plugins/blocks-for-shopengine/', | |
| 332 | - 'icon' => $apps_img_path. 'shopengine.gif', | |
| 333 | - 'desc' => esc_html__('All in one WooCommerce solution for Gutenberg! Build your WooCommerce pages in a block editor with full customization.', 'shopengine'), | |
| 334 | - 'docs' => 'https://wpmet.com/doc/shopengine/shopengine-gutenberg/', | |
| 335 | - ], | |
| 336 | - ] | |
| 337 | - ) | |
| 338 | - ->call(); | |
| 339 | - | |
| 340 | - // working get instance of elementor widget | |
| 341 | - (new Manifest())->init(); | |
| 342 | - } ); | |
| 343 | - | |
| 344 | - | |
| 345 | - | |
| 346 | - \ShopEngine\Core\MultiLanguage\Language::instance()->init(); | |
| 347 | - | |
| 348 | 163 | \ShopEngine\Core\Settings\Base::instance()->init(); |
| 349 | 164 | |
| 165 | + (new Module_Manifest)->init(); | |
| 350 | 166 | |
| 351 | - new Libs\Select_Api\Base(); | |
| 167 | + // working get instance of elementor widget | |
| 168 | + (new Manifest)->init(); | |
| 352 | 169 | |
| 353 | - (new Module_Manifest())->init(); | |
| 354 | - | |
| 355 | - | |
| 356 | 170 | Query_Modifier::instance()->init(); |
| 357 | 171 | |
| 358 | - (new Conflict_Manifest())->init(); | |
| 172 | + (new Conflict_Manifest)->init(); | |
| 359 | 173 | |
| 360 | 174 | // view count |
| 361 | - add_action('get_header', [$this, 'shopengine_track_product_views']); | |
| 175 | + add_action('wp_head', [$this, 'shopengine_track_product_views']); | |
| 362 | 176 | |
| 363 | 177 | // database migrations |
| 364 | 178 | // (new \ShopEngine\Compatibility\Migrations\Migration())->init(); |
| 365 | - // (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 179 | + (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 366 | 180 | |
| 367 | - | |
| 368 | - // call service providers | |
| 369 | - | |
| 370 | - $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php'; | |
| 371 | - $method = 'init'; | |
| 372 | - foreach( $service_providers as $service_provider ){ | |
| 373 | - | |
| 374 | - if(class_exists($service_provider) && method_exists($service_provider, $method)) { | |
| 375 | - $instance = new $service_provider(); | |
| 376 | - $instance->$method(); | |
| 377 | - } | |
| 378 | - | |
| 379 | - } | |
| 380 | - | |
| 381 | 181 | add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3); |
| 382 | - | |
| 383 | - //it will register an option in customizer for woocommerce products catelog. It's related with our Arcive Products widget. | |
| 384 | - Register_Settings::instance()->init(); | |
| 385 | 182 | } |
| 386 | 183 | |
| 387 | - public function shopengine_wcmmq_cart_validation_compat( $check, $request ) { | |
| 388 | - | |
| 389 | - $cart_widget_flag = isset( $_REQUEST['shopengine_cart_widget'] ) | |
| 390 | - ? sanitize_text_field( wp_unslash( $_REQUEST['shopengine_cart_widget'] ) ) | |
| 391 | - : ''; | |
| 392 | - $cart_widget_nonce = isset( $_REQUEST['shopengine_cart_widget_nonce'] ) | |
| 393 | - ? sanitize_text_field( wp_unslash( $_REQUEST['shopengine_cart_widget_nonce'] ) ) | |
| 394 | - : ''; | |
| 395 | 184 | |
| 396 | - if ( $cart_widget_flag === '1' && wp_verify_nonce( $cart_widget_nonce, 'shopengine_cart_widget' ) ) { | |
| 397 | - return false; // Skip WC MMQ validation for verified ShopEngine cart widget requests | |
| 398 | - } | |
| 399 | - return $check; // Proceed with normal validation for other requests | |
| 400 | - } | |
| 185 | + // add async and defer attributes to enqueued scripts | |
| 186 | + public function filter_load_type($tag, $handle, $src) { | |
| 401 | 187 | |
| 188 | + if (strpos($handle, '-async') !== false) { | |
| 189 | + $tag = str_replace(' src', ' async="async" src', $tag); | |
| 190 | + } | |
| 402 | 191 | |
| 192 | + if (strpos($handle, '-defer') !== false) { | |
| 193 | + $tag = str_replace('<script ', '<script defer ', $tag); | |
| 194 | + } | |
| 403 | 195 | |
| 404 | - | |
| 405 | - | |
| 406 | - // add async and defer attributes to enqueued scripts | |
| 407 | - public function filter_load_type($tag, $handle, $src) { | |
| 408 | - | |
| 409 | - if(strpos($handle, '-async') !== false) { | |
| 410 | - $tag = str_replace(' src', ' async="async" src', $tag); | |
| 196 | + return $tag; | |
| 411 | 197 | } |
| 412 | 198 | |
| 413 | - if(strpos($handle, '-defer') !== false) { | |
| 414 | - $tag = str_replace('<script ', '<script defer ', $tag); | |
| 415 | - } | |
| 416 | - | |
| 417 | - return $tag; | |
| 418 | - } | |
| 419 | - | |
| 420 | 199 | /** |
| 421 | 200 | * Public function shopengine_track_product_views |
| 422 | 201 | * Adding Product Views Count Meta |
| 423 | 202 | */ |
| 424 | - public function shopengine_track_product_views() { | |
| 425 | - | |
| 203 | + public function shopengine_track_product_views($product_id) { | |
| 426 | 204 | if(class_exists('WooCommerce') && !is_product()) { |
| 427 | 205 | return; |
| 428 | 206 | } |
| 429 | - | |
| 430 | 207 | $product_id = get_the_id(); |
| 431 | 208 | |
| 432 | - $cookie_name = "shopengine_recent_viewed_product"; | |
| 433 | - | |
| 434 | - if(isset($_COOKIE[$cookie_name])) { | |
| 435 | - | |
| 436 | - $cookie_ids = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name])); | |
| 437 | - $product_ids = explode(',', $cookie_ids); | |
| 438 | - | |
| 439 | - if(!is_array($product_ids)) { | |
| 440 | - $product_ids = [$product_ids]; | |
| 441 | - } | |
| 442 | - | |
| 443 | - $product_ids = array_combine($product_ids, $product_ids); | |
| 444 | - unset($product_ids[$product_id]); | |
| 445 | - $product_ids[] = $product_id; | |
| 446 | - | |
| 447 | - $cookie_value = implode(',', $product_ids); | |
| 448 | - | |
| 449 | - } else { | |
| 450 | - $cookie_value = $product_id; | |
| 451 | - } | |
| 452 | - | |
| 453 | - setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' ); | |
| 454 | - | |
| 455 | 209 | $count_key = 'shopengine_product_views_count'; |
| 456 | 210 | $count = get_post_meta($product_id, $count_key, true); |
| 457 | - | |
| 458 | 211 | if($count == '') { |
| 459 | 212 | $count = 1; |
| 460 | 213 | delete_post_meta($product_id, $count_key); |
| 461 | 214 | add_post_meta($product_id, $count_key, '1'); |
| @@ -470,10 +223,12 @@ | ||
| 470 | 223 | * Include public function |
| 471 | 224 | * |
| 472 | 225 | * @since 1.0.0 |
| 473 | 226 | */ |
| 474 | - public function js_css_public() { | |
| 475 | - wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version()); | |
| 227 | + public function js_css_public() { | |
| 228 | + wp_enqueue_style('shopengine-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version()); | |
| 229 | + wp_enqueue_style('shopengine-simple-scrollbar-css', \ShopEngine::plugin_url() . 'assets/css/simple-scrollbar.css', false, \ShopEngine::version()); | |
| 230 | + wp_enqueue_style('shopengine-public-css', \ShopEngine::plugin_url() . 'assets/css/public-style.css', false, \ShopEngine::version()); | |
| 476 | 231 | |
| 477 | 232 | // Modal Stylesheet |
| 478 | 233 | wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version()); |
| 479 | 234 | |
| @@ -522,11 +277,11 @@ | ||
| 522 | 277 | |
| 523 | 278 | |
| 524 | 279 | public function missing_woocommerce() { |
| 525 | 280 | |
| 526 | - if(!current_user_can('manage_options')) { | |
| 527 | - return; | |
| 528 | - } | |
| 281 | + if(isset($_GET['activate'])) { | |
| 282 | + unset($_GET['activate']); | |
| 283 | + } | |
| 529 | 284 | |
| 530 | 285 | if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) { |
| 531 | 286 | |
| 532 | 287 | $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine'); |
| @@ -542,9 +297,8 @@ | ||
| 542 | 297 | [ |
| 543 | 298 | 'id' => 'missing-woo', |
| 544 | 299 | 'type' => 'error', |
| 545 | 300 | 'dismissible' => true, |
| 546 | - 'is_required' => true, | |
| 547 | 301 | 'btn' => $btn, |
| 548 | 302 | 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '4.1.0'), |
| 549 | 303 | ] |
| 550 | 304 | ); |
| @@ -552,11 +306,11 @@ | ||
| 552 | 306 | |
| 553 | 307 | |
| 554 | 308 | public function missing_elementor() { |
| 555 | 309 | |
| 556 | - if(!current_user_can('manage_options')) { | |
| 557 | - return; | |
| 558 | - } | |
| 310 | + if(isset($_GET['activate'])) { | |
| 311 | + unset($_GET['activate']); | |
| 312 | + } | |
| 559 | 313 | |
| 560 | 314 | if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) { |
| 561 | 315 | |
| 562 | 316 | $btn['label'] = esc_html__('Activate Elementor', 'shopengine'); |
| @@ -567,28 +321,15 @@ | ||
| 567 | 321 | $btn['label'] = esc_html__('Install Elementor', 'shopengine'); |
| 568 | 322 | $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor'); |
| 569 | 323 | } |
| 570 | 324 | |
| 571 | - if(file_exists(WP_PLUGIN_DIR . '/blocks-for-shopengine/shopengine-gutenberg-addon.php')) { | |
| 572 | - | |
| 573 | - $btn2['label'] = esc_html__('Activate Blocks for ShopEngine', 'shopengine'); | |
| 574 | - $btn2['url'] = wp_nonce_url('plugins.php?action=activate&plugin=blocks-for-shopengine/shopengine-gutenberg-addon.php&plugin_status=all&paged=1', 'activate-plugin_blocks-for-shopengine/shopengine-gutenberg-addon.php'); | |
| 575 | - | |
| 576 | - } else { | |
| 577 | - | |
| 578 | - $btn2['label'] = esc_html__('Install Blocks for ShopEngine', 'shopengine'); | |
| 579 | - $btn2['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=blocks-for-shopengine'), 'install-plugin_blocks-for-shopengine'); | |
| 580 | - } | |
| 581 | - | |
| 582 | 325 | Utils\Notice::push( |
| 583 | 326 | [ |
| 584 | 327 | 'id' => 'missing-elementor', |
| 585 | 328 | 'type' => 'error', |
| 586 | - 'is_required' => true, | |
| 587 | 329 | 'dismissible' => true, |
| 588 | 330 | 'btn' => $btn, |
| 589 | - 'btn2' => $btn2, | |
| 590 | - 'message' => esc_html__('To use ShopEngine, install Elementor (For the Elementor Builder) OR Blocks for ShopEngine (For Gutenberg Builder).', 'shopengine'), | |
| 331 | + 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'), | |
| 591 | 332 | ] |
| 592 | 333 | ); |
| 593 | 334 | } |
| 594 | 335 | |
| @@ -594,12 +335,8 @@ | ||
| 594 | 335 | |
| 595 | 336 | |
| 596 | 337 | public function failed_elementor_version() { |
| 597 | 338 | |
| 598 | - if(!current_user_can('manage_options')) { | |
| 599 | - return; | |
| 600 | - } | |
| 601 | - | |
| 602 | 339 | $btn['label'] = esc_html__('Update Elementor', 'shopengine'); |
| 603 | 340 | $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor'); |
| 604 | 341 | |
| 605 | 342 | Utils\Notice::push( |
| @@ -626,5 +363,6 @@ | ||
| 626 | 363 | } |
| 627 | 364 | |
| 628 | 365 | return self::$instance; |
| 629 | 366 | } |
| 367 | + | |
| 630 | 368 | } |