| @@ -1,18 +1,22 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ShopEngine; |
| 4 | 4 | |
| 5 | +defined('ABSPATH') || exit; | |
| 6 | + | |
| 5 | 7 | use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest; |
| 6 | 8 | use ShopEngine\Core\Builders\Base; |
| 9 | +use ShopEngine\Compatibility\Migrations\LangMigration; | |
| 7 | 10 | use ShopEngine\Core\Query_Modifier; |
| 11 | +use ShopEngine\Core\Wc_Customizer\Register_Settings; | |
| 8 | 12 | use ShopEngine\Core\Template_Cpt; |
| 9 | 13 | use ShopEngine\Libs\License\License_Route; |
| 14 | +use ShopEngine\Libs\Rating\Rating; | |
| 10 | 15 | use ShopEngine\Libs\Updater\Init as Updater; |
| 11 | 16 | use ShopEngine\Modules\Manifest as Module_Manifest; |
| 12 | 17 | use ShopEngine\Widgets\Manifest; |
| 13 | 18 | |
| 14 | -defined('ABSPATH') || exit; | |
| 15 | 19 | |
| 16 | 20 | /** |
| 17 | 21 | * Plugin final Class. |
| 18 | 22 | * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install. |
| @@ -29,11 +33,15 @@ | ||
| 29 | 33 | */ |
| 30 | 34 | public function __construct() { |
| 31 | 35 | // load autoload method |
| 32 | 36 | Autoloader::run(); |
| 37 | + add_action( 'wp_ajax_shopengine_admin_action', [\ShopEngine\Utils\Util::class, 'shopengine_admin_action'] ); | |
| 33 | 38 | } |
| 34 | 39 | |
| 35 | - | |
| 40 | + public function utils_url() | |
| 41 | + { | |
| 42 | + return $this->plugin_url() . 'utils/'; | |
| 43 | + } | |
| 36 | 44 | /** |
| 37 | 45 | * Public function init. |
| 38 | 46 | * call function for all |
| 39 | 47 | * |
| @@ -42,8 +50,11 @@ | ||
| 42 | 50 | public function init() { |
| 43 | 51 | |
| 44 | 52 | $error = false; |
| 45 | 53 | |
| 54 | + // init notice class | |
| 55 | + \Oxaim\Libs\Notice::init(); | |
| 56 | + | |
| 46 | 57 | // check woocommerce plugin |
| 47 | 58 | if(!did_action('woocommerce_loaded')) { |
| 48 | 59 | add_action('admin_notices', [$this, 'missing_woocommerce']); |
| 49 | 60 | |
| @@ -49,30 +60,38 @@ | ||
| 49 | 60 | |
| 50 | 61 | $error = true; |
| 51 | 62 | } |
| 52 | 63 | |
| 64 | + $check_elementor_version = false; | |
| 65 | + | |
| 53 | 66 | // Check if Elementor installed and activated. |
| 54 | - if(!did_action('elementor/loaded')) { | |
| 55 | - add_action('admin_notices', [$this, 'missing_elementor']); | |
| 67 | + if(!did_action('elementor/loaded')) { | |
| 56 | 68 | |
| 57 | - $error = true; | |
| 58 | - } | |
| 69 | + if(!did_action('shopengine-gutenberg-addon/before_loaded')) { | |
| 59 | 70 | |
| 71 | + add_action('admin_notices', [$this, 'missing_elementor']); | |
| 72 | + | |
| 73 | + $error = true; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 60 | 77 | // Check for required Elementor version. |
| 61 | - if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) { | |
| 62 | - add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 78 | + if(did_action('elementor/loaded') && defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) { | |
| 63 | 79 | |
| 64 | - $error = true; | |
| 65 | - } | |
| 80 | + add_action('admin_notices', [$this, 'failed_elementor_version']); | |
| 66 | 81 | |
| 82 | + $error = true; | |
| 83 | + } | |
| 84 | + | |
| 67 | 85 | if($error) { |
| 68 | - | |
| 69 | 86 | return; |
| 70 | 87 | } |
| 71 | - | |
| 88 | + | |
| 72 | 89 | add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) { |
| 90 | + $free = esc_html__("Go To Shopengine","shopengine"); | |
| 91 | + $pro = esc_html__("Go To ShopenginePro","shopengine"); | |
| 73 | 92 | |
| 74 | - $custom_links[] = '<a href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>'; | |
| 93 | + $custom_links[] = '<a title="' . $free . '" href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>'; | |
| 75 | 94 | |
| 76 | 95 | foreach ($custom_links as $custom_link): |
| 77 | 96 | array_unshift($links, $custom_link); |
| 78 | 97 | endforeach; |
| @@ -77,14 +96,35 @@ | ||
| 77 | 96 | array_unshift($links, $custom_link); |
| 78 | 97 | endforeach; |
| 79 | 98 | |
| 80 | 99 | if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) { |
| 81 | - $links[] = '<a href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank">' . esc_html__('Go Pro', 'shopengine') . '</a>'; | |
| 100 | + $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>'; | |
| 82 | 101 | } |
| 83 | 102 | return $links; |
| 84 | 103 | }); |
| 85 | 104 | |
| 105 | + if(\ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true'){ | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * EmailKit Global Class initialization | |
| 109 | + * | |
| 110 | + */ | |
| 111 | + if( !class_exists('EmailKit') && !did_action('edit_with_emailkit_loaded') && class_exists('\Wpmet\Libs\Emailkit') ) { | |
| 112 | + | |
| 113 | + new \Wpmet\Libs\Emailkit(); | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * MetForm get free templates promotional class initialization | |
| 118 | + * | |
| 119 | + */ | |
| 120 | + if( !did_action('metform/after_load') && did_action('elementor/loaded') && class_exists('\Wpmet\Libs\Metform_Promo_Banner') ) { | |
| 121 | + | |
| 122 | + new \Wpmet\Libs\Metform_Promo_Banner(); | |
| 123 | + } | |
| 124 | + } | |
| 86 | 125 | |
| 126 | + | |
| 87 | 127 | /** |
| 88 | 128 | * Routes initialization |
| 89 | 129 | * |
| 90 | 130 | */ |
| @@ -97,62 +137,23 @@ | ||
| 97 | 137 | add_action('admin_init', function () { |
| 98 | 138 | if(class_exists('ShopEngine_Pro')) { |
| 99 | 139 | new Updater(); |
| 100 | 140 | } |
| 101 | - | |
| 141 | + new \ShopEngine\Compatibility\Migrations\Direct_Checkout; | |
| 102 | 142 | }); |
| 103 | 143 | |
| 104 | - global $pagenow; | |
| 105 | 144 | |
| 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 | - | |
| 120 | 145 | add_action('wp_loaded', function () { |
| 121 | - | |
| 122 | - if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) { | |
| 123 | - | |
| 124 | - $pid = (int)$_REQUEST['preview_id']; | |
| 125 | - | |
| 126 | - $po = get_post($pid); | |
| 127 | - | |
| 128 | - if($po->post_type === Template_Cpt::TYPE) { | |
| 129 | - | |
| 130 | - $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid); | |
| 131 | - | |
| 132 | - if(empty($template) || !isset($template['url'])) { | |
| 133 | - return; | |
| 134 | - } | |
| 135 | - | |
| 136 | - $param = [ | |
| 137 | - 'shopengine_template_id' => $pid, | |
| 138 | - 'preview_nonce' => wp_create_nonce('template_preview_' . $pid), | |
| 139 | - 'change_template' => '1', | |
| 140 | - ]; | |
| 141 | - | |
| 142 | - $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param); | |
| 143 | - | |
| 144 | - wp_safe_redirect($url); | |
| 145 | - exit; | |
| 146 | - } | |
| 147 | - } | |
| 146 | + /** | |
| 147 | + * migrate data | |
| 148 | + */ | |
| 149 | + LangMigration::instance()->init(); | |
| 148 | 150 | }); |
| 149 | 151 | |
| 150 | - | |
| 151 | 152 | // avoid themes for loading woocommerce functions |
| 152 | - $avoid_themes = ['avada']; | |
| 153 | + $avoid_themes = ['avada', 'woodmart', 'Avada', 'Woodmart']; | |
| 153 | 154 | |
| 154 | - if( !in_array( strtolower(wp_get_theme()), $avoid_themes) ) { | |
| 155 | + if( !in_array(get_template(), $avoid_themes) ) { | |
| 155 | 156 | /** |
| 156 | 157 | * Ensuring woocommerce functions are loaded before theme is modifying those |
| 157 | 158 | * |
| 158 | 159 | */ |
| @@ -158,14 +159,29 @@ | ||
| 158 | 159 | */ |
| 159 | 160 | require_once WC_ABSPATH . '/includes/wc-template-functions.php'; |
| 160 | 161 | } |
| 161 | 162 | |
| 162 | - // Load custom elementor controls | |
| 163 | - new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 164 | 163 | |
| 165 | - //Loading the scripts and styles | |
| 164 | + if(did_action('elementor/loaded')) { | |
| 165 | + // Load custom elementor controls | |
| 166 | + new \ShopEngine\Core\Elementor_Controls\Init(); | |
| 167 | + | |
| 168 | + //Loading the scripts and styles | |
| 169 | + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 170 | + | |
| 171 | + // Register widgets immediately after elementor is loaded with higher priority | |
| 172 | + if(is_plugin_active('related-products-manager-woocommerce/related-products-manager-for-woocommerce.php')) { | |
| 173 | + | |
| 174 | + add_action('elementor/widgets/register', function() { | |
| 175 | + (new Manifest())->init(); | |
| 176 | + }, 5); // Priority 5 to load early | |
| 177 | + } | |
| 178 | + | |
| 179 | + } | |
| 180 | + | |
| 181 | + | |
| 182 | + //Loading public scripts and styles | |
| 166 | 183 | add_action('wp_enqueue_scripts', [$this, 'js_css_public']); |
| 167 | - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']); | |
| 168 | 184 | |
| 169 | 185 | //woocommece theme support |
| 170 | 186 | if(!current_theme_supports('woocommerce')) { |
| 171 | 187 | add_theme_support('woocommerce'); |
| @@ -173,20 +189,152 @@ | ||
| 173 | 189 | add_theme_support('wc-product-gallery-lightbox'); |
| 174 | 190 | add_theme_support('wc-product-gallery-slider'); |
| 175 | 191 | } |
| 176 | 192 | |
| 177 | - | |
| 193 | + | |
| 194 | + $filter_string = ''; // elementskit,metform-pro | |
| 195 | + $filter_string .= ((!in_array('elementskit/elementskit.php', apply_filters('active_plugins', get_option('active_plugins')))) ? '' : ',elementskit'); | |
| 196 | + $filter_string .= (!class_exists('\MetForm\Plugin') ? '' : ',metform'); | |
| 197 | + $filter_string .= (!class_exists('\MetForm_Pro\Plugin') ? '' : ',metform-pro'); | |
| 198 | + | |
| 178 | 199 | #Registering new post-type & etc |
| 179 | 200 | Base::instance()->init(); |
| 180 | 201 | |
| 181 | - \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 182 | 202 | |
| 203 | + Rating::instance('shopengine') | |
| 204 | + ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' ) | |
| 205 | + ->set_rating_url( 'https://wordpress.org/support/plugin/shopengine/reviews/#new-post' ) | |
| 206 | + ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' ) | |
| 207 | + ->set_priority( 11 ) | |
| 208 | + ->set_first_appear_day( 7 ) | |
| 209 | + ->set_condition( true ) | |
| 210 | + ->call(); | |
| 211 | + | |
| 212 | + if ( is_admin() && \ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true' ) { | |
| 213 | + | |
| 214 | + /** | |
| 215 | + * Show WPMET stories widget in dashboard | |
| 216 | + */ | |
| 217 | + | |
| 218 | + \Wpmet\Libs\Stories::instance('shopengine') | |
| 219 | + | |
| 220 | + ->set_filter($filter_string) | |
| 221 | + ->set_plugin('ShopEngine', 'https://wpmet.com/plugin/shopengine/') | |
| 222 | + ->set_api_url('https://api.wpmet.com/public/stories/') | |
| 223 | + ->call(); | |
| 224 | + | |
| 225 | + // banner | |
| 226 | + \Wpmet\Libs\Banner::instance('shopengine') | |
| 227 | + ->set_filter(ltrim($filter_string, ',')) | |
| 228 | + ->set_api_url('https://api.wpmet.com/public/jhanda') | |
| 229 | + ->set_plugin_screens('edit-shopengine-template') | |
| 230 | + ->set_plugin_screens('edit-shopengine-template') | |
| 231 | + ->call(); | |
| 232 | + } | |
| 233 | + | |
| 234 | + add_action('init', function () { | |
| 235 | + $apps_img_path = \ShopEngine::plugin_url() . 'assets/images/apps-page/'; | |
| 236 | + /** | |
| 237 | + * Show our plugins menu for others wpmet plugins | |
| 238 | + */ | |
| 239 | + \ShopEngine\Wpmet\Libs\Plugins::instance()->init('shopengine') | |
| 240 | + ->set_parent_menu_slug('shopengine-settings') | |
| 241 | + ->set_submenu_name('Our Plugins') | |
| 242 | + ->set_section_title('Get More out of Your WooCommerce Website!') | |
| 243 | + ->set_section_description('Install other plugins from us and take your WooCommerce site to the next level for absolutely free!') | |
| 244 | + ->set_items_per_row(4) | |
| 245 | + ->set_plugins( | |
| 246 | + [ | |
| 247 | + 'elementskit-lite/elementskit-lite.php' => [ | |
| 248 | + 'name' => esc_html__('ElementsKit', 'shopengine'), | |
| 249 | + 'url' => 'https://wordpress.org/plugins/elementskit-lite/', | |
| 250 | + 'icon' => $apps_img_path. 'elementskit.gif', | |
| 251 | + 'desc' => esc_html__('All-in-one Elementor addon trusted by 1 Million+ users, makes your website builder process easier with ultimate freedom.', 'shopengine'), | |
| 252 | + 'docs' => 'https://wpmet.com/doc/elementskit/', | |
| 253 | + ], | |
| 254 | + 'getgenie/getgenie.php' => [ | |
| 255 | + 'name' => esc_html__('GetGenie', 'shopengine'), | |
| 256 | + 'url' => 'https://wordpress.org/plugins/getgenie/', | |
| 257 | + 'icon' => $apps_img_path.'getgenie.gif', | |
| 258 | + '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'), | |
| 259 | + 'docs' => 'https://getgenie.ai/docs/', | |
| 260 | + ], | |
| 261 | + 'gutenkit-blocks-addon/gutenkit-blocks-addon.php' => [ | |
| 262 | + 'name' => esc_html__('GutenKit', 'shopengine'), | |
| 263 | + 'url' => 'https://wordpress.org/plugins/gutenkit-blocks-addon/', | |
| 264 | + 'icon' => $apps_img_path. 'guten-kit.png', | |
| 265 | + 'desc' => esc_html__('Gutenberg blocks, patterns, and templates that extend the page-building experience using the WordPress block editor.', 'shopengine'), | |
| 266 | + 'docs' => 'https://wpmet.com/doc/gutenkit/', | |
| 267 | + ], | |
| 268 | + 'metform/metform.php' => [ | |
| 269 | + 'name' => esc_html__('MetForm', 'shopengine'), | |
| 270 | + 'url' => 'https://wordpress.org/plugins/metform/', | |
| 271 | + 'icon' => $apps_img_path. 'metform.png', | |
| 272 | + 'desc' => esc_html__('Drag & drop form builder for Elementor to create contact forms, multi-step forms, and more — smoother, faster, and better!', 'shopengine'), | |
| 273 | + 'docs' => 'https://wpmet.com/doc/metform/', | |
| 274 | + ], | |
| 275 | + 'emailkit/EmailKit.php' => [ | |
| 276 | + 'name' => esc_html__('EmailKit', 'shopengine'), | |
| 277 | + 'url' => 'https://wordpress.org/plugins/emailkit/', | |
| 278 | + 'icon' => $apps_img_path . 'emailkit.png', | |
| 279 | + 'desc' => esc_html__('Advanced email customizer for WooCommerce and WordPress. Build, customize, and send emails from WordPress to boost your sales!', 'shopengine'), | |
| 280 | + 'docs' => 'https://wpmet.com/doc/emailkit/', | |
| 281 | + ], | |
| 282 | + 'wp-social/wp-social.php' => [ | |
| 283 | + 'name' => esc_html__('WP Social', 'shopengine'), | |
| 284 | + 'url' => 'https://wordpress.org/plugins/wp-social/', | |
| 285 | + 'icon' => $apps_img_path . 'wp-social.png', | |
| 286 | + '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'), | |
| 287 | + 'docs' => 'https://wpmet.com/doc/wp-social/', | |
| 288 | + ], | |
| 289 | + 'wp-ultimate-review/wp-ultimate-review.php' => [ | |
| 290 | + 'name' => esc_html__('WP Ultimate Review', 'shopengine'), | |
| 291 | + 'url' => 'https://wordpress.org/plugins/wp-ultimate-review/', | |
| 292 | + 'icon' => $apps_img_path . 'ultimate-review.png', | |
| 293 | + 'desc' => esc_html__('Collect and showcase reviews on your website to build brand credibility and social proof with the easiest solution.','shopengine'), | |
| 294 | + 'docs' => 'https://wpmet.com/doc/wp-ultimate-review/', | |
| 295 | + ], | |
| 296 | + 'wp-fundraising-donation/wp-fundraising.php' => [ | |
| 297 | + 'name' => esc_html__('FundEngine', 'shopengine'), | |
| 298 | + 'url' => 'https://wordpress.org/plugins/wp-fundraising-donation/', | |
| 299 | + 'icon' => $apps_img_path . 'fundengine.png', | |
| 300 | + 'desc' => esc_html__('Create fundraising, crowdfunding, and donation websites with PayPal and Stripe payment gateway integration.', 'shopengine'), | |
| 301 | + 'docs' => 'https://wpmet.com/doc/fundengine/', | |
| 302 | + ], | |
| 303 | + 'blocks-for-shopengine/shopengine-gutenberg-addon.php' => [ | |
| 304 | + 'name' => esc_html__('Blocks for ShopEngine', 'shopengine'), | |
| 305 | + 'url' => 'https://wordpress.org/plugins/blocks-for-shopengine/', | |
| 306 | + 'icon' => $apps_img_path. 'shopengine.gif', | |
| 307 | + 'desc' => esc_html__('All in one WooCommerce solution for Gutenberg! Build your WooCommerce pages in a block editor with full customization.', 'shopengine'), | |
| 308 | + 'docs' => 'https://wpmet.com/doc/shopengine/shopengine-gutenberg/', | |
| 309 | + ], | |
| 310 | + 'genie-image-ai/genie-image-ai.php' => [ | |
| 311 | + 'name' => esc_html__('Genie Image', 'shopengine'), | |
| 312 | + 'url' => 'https://wordpress.org/plugins/genie-image-ai/', | |
| 313 | + 'icon' => $apps_img_path . 'genie-image.png', | |
| 314 | + 'desc' => esc_html__('AI-powered text-to-image generator for WordPress with OpenAI’s DALL-E 2 technology to generate high-quality images in one click. | |
| 315 | + ', 'shopengine'), | |
| 316 | + 'docs' => 'https://getgenie.ai/docs/', | |
| 317 | + ], | |
| 318 | + ] | |
| 319 | + ) | |
| 320 | + ->call(); | |
| 321 | + | |
| 322 | + // working get instance of elementor widget | |
| 323 | + (new Manifest())->init(); | |
| 324 | + } ); | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + \ShopEngine\Core\MultiLanguage\Language::instance()->init(); | |
| 329 | + | |
| 330 | + \ShopEngine\Core\Settings\Base::instance()->init(); | |
| 331 | + | |
| 332 | + | |
| 183 | 333 | new Libs\Select_Api\Base(); |
| 184 | 334 | |
| 185 | 335 | (new Module_Manifest())->init(); |
| 186 | 336 | |
| 187 | - // working get instance of elementor widget | |
| 188 | - (new Manifest())->init(); | |
| 189 | 337 | |
| 190 | 338 | Query_Modifier::instance()->init(); |
| 191 | 339 | |
| 192 | 340 | (new Conflict_Manifest())->init(); |
| @@ -195,11 +343,28 @@ | ||
| 195 | 343 | add_action('get_header', [$this, 'shopengine_track_product_views']); |
| 196 | 344 | |
| 197 | 345 | // database migrations |
| 198 | 346 | // (new \ShopEngine\Compatibility\Migrations\Migration())->init(); |
| 199 | - (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 347 | + // (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init(); | |
| 200 | 348 | |
| 349 | + | |
| 350 | + // call service providers | |
| 351 | + | |
| 352 | + $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php'; | |
| 353 | + $method = 'init'; | |
| 354 | + foreach( $service_providers as $service_provider ){ | |
| 355 | + | |
| 356 | + if(class_exists($service_provider) && method_exists($service_provider, $method)) { | |
| 357 | + $instance = new $service_provider(); | |
| 358 | + $instance->$method(); | |
| 359 | + } | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 201 | 363 | add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3); |
| 364 | + | |
| 365 | + //it will register an option in customizer for woocommerce products catelog. It's related with our Arcive Products widget. | |
| 366 | + Register_Settings::instance()->init(); | |
| 202 | 367 | } |
| 203 | 368 | |
| 204 | 369 | |
| 205 | 370 | // add async and defer attributes to enqueued scripts |
| @@ -228,14 +393,14 @@ | ||
| 228 | 393 | |
| 229 | 394 | $product_id = get_the_id(); |
| 230 | 395 | |
| 231 | 396 | $cookie_name = "shopengine_recent_viewed_product"; |
| 232 | - | |
| 397 | + | |
| 233 | 398 | if(isset($_COOKIE[$cookie_name])) { |
| 234 | - | |
| 235 | - $cookie_ids = $_COOKIE[$cookie_name]; | |
| 399 | + | |
| 400 | + $cookie_ids = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name])); | |
| 236 | 401 | $product_ids = explode(',', $cookie_ids); |
| 237 | - | |
| 402 | + | |
| 238 | 403 | if(!is_array($product_ids)) { |
| 239 | 404 | $product_ids = [$product_ids]; |
| 240 | 405 | } |
| 241 | 406 | |
| @@ -243,14 +408,14 @@ | ||
| 243 | 408 | unset($product_ids[$product_id]); |
| 244 | 409 | $product_ids[] = $product_id; |
| 245 | 410 | |
| 246 | 411 | $cookie_value = implode(',', $product_ids); |
| 247 | - | |
| 412 | + | |
| 248 | 413 | } else { |
| 249 | - $cookie_value = $product_id; | |
| 414 | + $cookie_value = $product_id; | |
| 250 | 415 | } |
| 251 | 416 | |
| 252 | - setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/'); | |
| 417 | + setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' ); | |
| 253 | 418 | |
| 254 | 419 | $count_key = 'shopengine_product_views_count'; |
| 255 | 420 | $count = get_post_meta($product_id, $count_key, true); |
| 256 | 421 | |
| @@ -269,12 +434,10 @@ | ||
| 269 | 434 | * Include public function |
| 270 | 435 | * |
| 271 | 436 | * @since 1.0.0 |
| 272 | 437 | */ |
| 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()); | |
| 438 | + public function js_css_public() { | |
| 439 | + wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version()); | |
| 277 | 440 | |
| 278 | 441 | // Modal Stylesheet |
| 279 | 442 | wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version()); |
| 280 | 443 | |
| @@ -323,11 +486,11 @@ | ||
| 323 | 486 | |
| 324 | 487 | |
| 325 | 488 | public function missing_woocommerce() { |
| 326 | 489 | |
| 327 | - if(isset($_GET['activate'])) { | |
| 328 | - unset($_GET['activate']); | |
| 329 | - } | |
| 490 | + if(!current_user_can('manage_options')) { | |
| 491 | + return; | |
| 492 | + } | |
| 330 | 493 | |
| 331 | 494 | if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) { |
| 332 | 495 | |
| 333 | 496 | $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine'); |
| @@ -343,8 +506,9 @@ | ||
| 343 | 506 | [ |
| 344 | 507 | 'id' => 'missing-woo', |
| 345 | 508 | 'type' => 'error', |
| 346 | 509 | 'dismissible' => true, |
| 510 | + 'is_required' => true, | |
| 347 | 511 | 'btn' => $btn, |
| 348 | 512 | 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '4.1.0'), |
| 349 | 513 | ] |
| 350 | 514 | ); |
| @@ -352,11 +516,11 @@ | ||
| 352 | 516 | |
| 353 | 517 | |
| 354 | 518 | public function missing_elementor() { |
| 355 | 519 | |
| 356 | - if(isset($_GET['activate'])) { | |
| 357 | - unset($_GET['activate']); | |
| 358 | - } | |
| 520 | + if(!current_user_can('manage_options')) { | |
| 521 | + return; | |
| 522 | + } | |
| 359 | 523 | |
| 360 | 524 | if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) { |
| 361 | 525 | |
| 362 | 526 | $btn['label'] = esc_html__('Activate Elementor', 'shopengine'); |
| @@ -367,15 +531,28 @@ | ||
| 367 | 531 | $btn['label'] = esc_html__('Install Elementor', 'shopengine'); |
| 368 | 532 | $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor'); |
| 369 | 533 | } |
| 370 | 534 | |
| 535 | + if(file_exists(WP_PLUGIN_DIR . '/blocks-for-shopengine/shopengine-gutenberg-addon.php')) { | |
| 536 | + | |
| 537 | + $btn2['label'] = esc_html__('Activate Blocks for ShopEngine', 'shopengine'); | |
| 538 | + $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'); | |
| 539 | + | |
| 540 | + } else { | |
| 541 | + | |
| 542 | + $btn2['label'] = esc_html__('Install Blocks for ShopEngine', 'shopengine'); | |
| 543 | + $btn2['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=blocks-for-shopengine'), 'install-plugin_blocks-for-shopengine'); | |
| 544 | + } | |
| 545 | + | |
| 371 | 546 | Utils\Notice::push( |
| 372 | 547 | [ |
| 373 | 548 | 'id' => 'missing-elementor', |
| 374 | 549 | 'type' => 'error', |
| 550 | + 'is_required' => true, | |
| 375 | 551 | 'dismissible' => true, |
| 376 | 552 | 'btn' => $btn, |
| 377 | - 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'), | |
| 553 | + 'btn2' => $btn2, | |
| 554 | + 'message' => esc_html__('To use ShopEngine, install Elementor (For the Elementor Builder) OR Blocks for ShopEngine (For Gutenberg Builder).', 'shopengine'), | |
| 378 | 555 | ] |
| 379 | 556 | ); |
| 380 | 557 | } |
| 381 | 558 | |
| @@ -380,8 +557,12 @@ | ||
| 380 | 557 | } |
| 381 | 558 | |
| 382 | 559 | |
| 383 | 560 | public function failed_elementor_version() { |
| 561 | + | |
| 562 | + if(!current_user_can('manage_options')) { | |
| 563 | + return; | |
| 564 | + } | |
| 384 | 565 | |
| 385 | 566 | $btn['label'] = esc_html__('Update Elementor', 'shopengine'); |
| 386 | 567 | $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor'); |
| 387 | 568 | |