| @@ -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 | } |