PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/Controllers/TemplateController.php +12 -3 4.4.2 → 4.4.5 View file →
@@ -240,9 +240,15 @@
240 240 }
241 241
242 242 public function get_template_by_name( \WP_REST_Request $request ) {
243 243 $template_name = sanitize_text_field( $request->get_param( 'template_name' ) );
244 - $template_data = $this->model::find_by_name( $template_name );
244 + $variant = yaymail_sanitize_template_variant( $request->get_param( 'variant' ) );
245 + $template_data = $this->model::find_by_name( $template_name, '', $variant );
246 + if ( '' !== $variant && empty( $template_data['id'] ) ) {
247 + // Variant posts are created on first open, seeded from the default design.
248 + new YayMailTemplate( $template_name, '', $variant );
249 + $template_data = $this->model::find_by_name( $template_name, '', $variant );
250 + }
245 251
246 252 if ( null === $template_data ) {
247 253 $all_emails = yaymail_get_emails();
248 254 if ( in_array(
@@ -393,8 +399,11 @@
393 399 return $this->exec( [ $this, 'change_global_header_footer_status' ], $request );
394 400 }
395 401
396 402 public function change_global_header_footer_status( \WP_REST_Request $request ) {
397 - $status = sanitize_text_field( $request->get_param( 'status' ) );
398 - return SettingModel::update( [ 'global_header_footer_enabled' => $status ] );
403 + $status = filter_var( $request->get_param( 'status' ), FILTER_VALIDATE_BOOLEAN );
404 + $platform = sanitize_text_field( $request->get_param( 'platform' ) ?? 'yaymail' );
405 + $platform_obj = \YayMail\Platform\PlatformRegistry::get( $platform ) ?? \YayMail\Platform\PlatformRegistry::get( 'yaymail' );
406 + $key = $platform_obj ? $platform_obj->ghf_option_key( 'enabled' ) : 'global_header_footer_enabled';
407 + return SettingModel::update( [ $key => $status ] );
399 408 }
400 409 }