| @@ -68,8 +68,21 @@ | ||
| 68 | 68 | return $plugin_work['yaymail']; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | +if ( ! function_exists( 'yaymail_sanitize_template_variant' ) ) { | |
| 73 | + /** | |
| 74 | + * Variant slugs are stored as post meta and used as lookup keys, so only [a-z0-9_-] survives. | |
| 75 | + * Anything else (including null) means the default design. | |
| 76 | + */ | |
| 77 | + function yaymail_sanitize_template_variant( $variant ) { | |
| 78 | + if ( ! is_string( $variant ) ) { | |
| 79 | + return ''; | |
| 80 | + } | |
| 81 | + return preg_match( '/^[a-z0-9_-]{1,40}$/', $variant ) ? $variant : ''; | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 72 | 85 | if ( ! function_exists( 'yaymail_version' ) ) { |
| 73 | 86 | function yaymail_version() { |
| 74 | 87 | if ( defined( 'YAYMAIL_VERSION' ) ) { |
| 75 | 88 | return YAYMAIL_VERSION; |
| @@ -199,28 +212,8 @@ | ||
| 199 | 212 | * @return BaseElement[] |
| 200 | 213 | */ |
| 201 | 214 | function yaymail_get_all_elements() { |
| 202 | 215 | return ElementsLoader::get_instance()->get_all(); |
| 203 | - } | |
| 204 | -} | |
| 205 | - | |
| 206 | -if ( ! function_exists( 'yaymail_get_email_available_elements' ) ) { | |
| 207 | - | |
| 208 | - /** | |
| 209 | - * Get all available elements of given email | |
| 210 | - * | |
| 211 | - * @param string $email_id | |
| 212 | - * | |
| 213 | - * @return BaseElement[] | |
| 214 | - */ | |
| 215 | - function yaymail_get_email_available_elements( $email_id ) { | |
| 216 | - $find_email = yaymail_get_email( $email_id ); | |
| 217 | - | |
| 218 | - if ( ! $find_email ) { | |
| 219 | - return []; | |
| 220 | - } | |
| 221 | - | |
| 222 | - return $find_email->get_elements(); | |
| 223 | 216 | } |
| 224 | 217 | } |
| 225 | 218 | |
| 226 | 219 | if ( ! function_exists( 'yaymail_get_email_elements_data' ) ) { |