| @@ -112,16 +112,46 @@ | ||
| 112 | 112 | }); |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | add_action('wp_loaded', function () { |
| 116 | + //phpcs:ignore WordPress.Security.NonceVerification.Recommended --It's a fronted user part, not possible to verify nonce here | |
| 117 | + if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) { | |
| 118 | + | |
| 119 | + $pid = (int)$_REQUEST['preview_id']; //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here | |
| 120 | + | |
| 121 | + $po = get_post($pid); | |
| 122 | + | |
| 123 | + if($po->post_type === Template_Cpt::TYPE) { | |
| 124 | + | |
| 125 | + $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid); | |
| 126 | + | |
| 127 | + if(empty($template) || !isset($template['url'])) { | |
| 128 | + return; | |
| 129 | + } | |
| 130 | + | |
| 131 | + $param = [ | |
| 132 | + 'shopengine_template_id' => $pid, | |
| 133 | + 'preview_nonce' => wp_create_nonce('template_preview_' . $pid), | |
| 134 | + 'change_template' => '1', | |
| 135 | + ]; | |
| 136 | + | |
| 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); | |
| 139 | + | |
| 140 | + wp_safe_redirect($url); | |
| 141 | + exit; | |
| 142 | + } | |
| 143 | + } | |
| 144 | + | |
| 116 | 145 | /** |
| 117 | 146 | * migrate data |
| 118 | - */ | |
| 147 | + */ | |
| 119 | 148 | LangMigration::instance()->init(); |
| 120 | 149 | }); |
| 121 | 150 | |
| 122 | 151 | // avoid themes for loading woocommerce functions |
| 123 | - $avoid_themes = ['avada', 'avada child', 'woodmart', 'woodmart child']; | |
| 152 | + $avoid_themes = ['avada', 'avada child']; | |
| 153 | + | |
| 124 | 154 | if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) { |
| 125 | 155 | /** |
| 126 | 156 | * Ensuring woocommerce functions are loaded before theme is modifying those |
| 127 | 157 | * |