| @@ -217,22 +217,10 @@ | ||
| 217 | 217 | * @param string $theme Theme id (stored value, e.g. download_stats_today-download). |
| 218 | 218 | * @return array Param => tag/value map (first_param, custom_first_param, ...); empty when the theme has no template. |
| 219 | 219 | */ |
| 220 | 220 | public static function default_template_for_theme( $theme ) { |
| 221 | - if ( ! $theme ) { | |
| 222 | - return array(); | |
| 223 | - } | |
| 224 | - if ( ! self::$triggers_booted ) { | |
| 225 | - self::boot(); // Ensures nx_before_metabox_load fired so extensions registered nx_themes_trigger. | |
| 226 | - self::$triggers_booted = true; | |
| 227 | - // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- consuming core NotificationX (nx_) hooks. | |
| 228 | - $triggers = apply_filters( 'nx_themes_trigger', array() ); | |
| 229 | - // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 230 | - self::$triggers = is_array( $triggers ) ? $triggers : array(); | |
| 231 | - } | |
| 221 | + $list = self::theme_triggers( $theme ); | |
| 232 | 222 | |
| 233 | - $list = isset( self::$triggers[ $theme ] ) && is_array( self::$triggers[ $theme ] ) ? self::$triggers[ $theme ] : array(); | |
| 234 | - | |
| 235 | 223 | $template = array(); |
| 236 | 224 | $prefix = '@notification-template.'; |
| 237 | 225 | $len = strlen( $prefix ); |
| 238 | 226 | foreach ( $list as $entry ) { |
| @@ -253,8 +241,49 @@ | ||
| 253 | 241 | $template[ $param ] = $value; |
| 254 | 242 | } |
| 255 | 243 | } |
| 256 | 244 | return $template; |
| 245 | + } | |
| 246 | + | |
| 247 | + /** | |
| 248 | + * The default inline display locations (hook names) the admin builder | |
| 249 | + * applies when an inline theme is selected. | |
| 250 | + * | |
| 251 | + * Inline themes declare `inline_location` in their theme config; the | |
| 252 | + * builder copies it into the notification through the nx_themes_trigger | |
| 253 | + * system. A headless create never fires that trigger, so without this the | |
| 254 | + * record stores no location and the notification renders nowhere. | |
| 255 | + * | |
| 256 | + * @param string $theme Theme id (stored value, e.g. woo_inline_conv-theme-seven). | |
| 257 | + * @return array Hook names; empty when the theme declares none. | |
| 258 | + */ | |
| 259 | + public static function default_inline_location_for_theme( $theme ) { | |
| 260 | + $list = self::theme_triggers( $theme ); | |
| 261 | + if ( empty( $list['inline_location'] ) ) { | |
| 262 | + return array(); | |
| 263 | + } | |
| 264 | + return array_values( array_filter( (array) $list['inline_location'], 'is_string' ) ); | |
| 265 | + } | |
| 266 | + | |
| 267 | + /** | |
| 268 | + * The nx_themes_trigger entries for one theme, booting the trigger map once. | |
| 269 | + * | |
| 270 | + * @param string $theme Theme id. | |
| 271 | + * @return array | |
| 272 | + */ | |
| 273 | + protected static function theme_triggers( $theme ) { | |
| 274 | + if ( ! $theme || ! is_string( $theme ) ) { | |
| 275 | + return array(); | |
| 276 | + } | |
| 277 | + if ( ! self::$triggers_booted ) { | |
| 278 | + self::boot(); // Ensures nx_before_metabox_load fired so extensions registered nx_themes_trigger. | |
| 279 | + self::$triggers_booted = true; | |
| 280 | + // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- consuming core NotificationX (nx_) hooks. | |
| 281 | + $triggers = apply_filters( 'nx_themes_trigger', array() ); | |
| 282 | + // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 283 | + self::$triggers = is_array( $triggers ) ? $triggers : array(); | |
| 284 | + } | |
| 285 | + return isset( self::$triggers[ $theme ] ) && is_array( self::$triggers[ $theme ] ) ? self::$triggers[ $theme ] : array(); | |
| 257 | 286 | } |
| 258 | 287 | |
| 259 | 288 | /** |
| 260 | 289 | * Filter a raw theme map down to the ids belonging to a source. Prefers each |