| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace UltimateStoreKit\Includes\Builder; |
| 4 | 4 | |
| 5 | +if (! defined('ABSPATH')) { | |
| 6 | + exit; // Exit if accessed directly | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | class Builder_Template_Helper { |
| 6 | 10 | |
| 7 | 11 | public static function isTemplateEditMode() { |
| 8 | 12 | if ( get_post_type() == Meta::POST_TYPE ) { |
| @@ -8,8 +12,9 @@ | ||
| 8 | 12 | if ( get_post_type() == Meta::POST_TYPE ) { |
| 9 | 13 | return true; |
| 10 | 14 | } |
| 11 | 15 | |
| 16 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check on whether a builder template is being edited. | |
| 12 | 17 | if ( isset( $_REQUEST[ Meta::POST_TYPE ] ) ) { |
| 13 | 18 | return true; |
| 14 | 19 | } |
| 15 | 20 | } |
| @@ -26,9 +31,9 @@ | ||
| 26 | 31 | 'category' => 'Category Page', |
| 27 | 32 | 'tag' => 'Tag Page', |
| 28 | 33 | 'cart' => 'Cart Page', |
| 29 | 34 | 'checkout' => 'Checkout', |
| 30 | - 'order-received' => 'Order Received', | |
| 35 | + 'order-received' => 'Order Received (Thank You Page)', | |
| 31 | 36 | ]; |
| 32 | 37 | |
| 33 | 38 | $my_account = [ |
| 34 | 39 | 'login' => 'Login & Register', |
| @@ -54,9 +59,12 @@ | ||
| 54 | 59 | if ( $wcItems = WC()->query->get_query_vars() ) { |
| 55 | 60 | foreach ( $wcItems as $key => $item ) { |
| 56 | 61 | $label = ucwords( str_replace( '-', ' ', $key ) ); |
| 57 | 62 | if ( in_array( $key, $order_flow_endpoints, true ) ) { |
| 58 | - $shop_item[ $key ] = $label; | |
| 63 | + // Keep hand-written labels (e.g. order-received) intact. | |
| 64 | + if ( ! isset( $shop_item[ $key ] ) ) { | |
| 65 | + $shop_item[ $key ] = $label; | |
| 66 | + } | |
| 59 | 67 | } else { |
| 60 | 68 | $my_account[ $key ] = $label; |
| 61 | 69 | } |
| 62 | 70 | } |
| @@ -122,18 +130,15 @@ | ||
| 122 | 130 | } |
| 123 | 131 | |
| 124 | 132 | $separator = static::separator(); |
| 125 | 133 | $template = strtolower( "{$postType}{$separator}{$slug}" ); |
| 126 | - $enabledTemplate = strtolower( Meta::TEMPLATE_ID . $template ); | |
| 127 | - | |
| 128 | 134 | /** |
| 129 | 135 | * important area for debugging |
| 130 | 136 | */ |
| 131 | 137 | |
| 132 | - return get_option( $enabledTemplate ); | |
| 138 | + return Meta::get_template_option( $template ); | |
| 133 | 139 | } |
| 134 | 140 | |
| 135 | 141 | public static function getTemplateId( $templateType ) { |
| 136 | - $metaIndex = strtolower( Meta::TEMPLATE_ID . $templateType ); | |
| 137 | - return intval( get_option( $metaIndex ) ); | |
| 142 | + return intval( Meta::get_template_option( $templateType ) ); | |
| 138 | 143 | } |
| 139 | 144 | } |