printed date), note, final (wording of the * last rung, or null), outcome { label, date }. */ const SAMPLES_FILTER = 'careback_track_preview_samples'; /** * The sample cards: an order on its way, and the one that used to render * wrong. */ public static function samples( Settings $settings ) { $order = array( 'heading' => Track_Labels::get( 'heading_order', $settings ), 'stages' => Track_Stage_Policy::ORDER_LADDER, 'at' => 3, 'dates' => array( 0 => '01.09.2026', 2 => '02.09.2026', 3 => '03.09.2026' ), 'note' => '', 'final' => null, 'outcome' => array(), ); // The one the operator most needs to see: a journey that ended early. // Everything the parcel actually passed is solid, everything it never // reached is dimmed and dashed, and the ending sits below the ladder // instead of pretending to be a further rung of it. $cancelled = array( 'heading' => Track_Labels::get( 'heading_order', $settings ), 'stages' => Track_Stage_Policy::ORDER_LADDER, 'at' => -1, 'reached' => 0, 'dates' => array( 0 => '28.08.2026' ), 'note' => '', 'final' => null, 'outcome' => array( 'label' => Track_Labels::get( 'order_cancelled', $settings ), 'date' => '29.08.2026', ), ); /** * Filters the sample cards of the tracking page preview. * * @param array $samples The cards, in the order they are drawn. * @param Settings $settings Plugin settings. */ return (array) apply_filters( self::SAMPLES_FILTER, array( $order, $cancelled ), $settings ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- careback_track_preview_samples, the final prefix. } /** * The preview as a document of its own, for the frame on Setup: the * tracking page's markup on the sample cards, with the page's stylesheet * and the preview's own (assets/css/track.css, preview.css) linked as files. * * @param Settings $settings Plugin settings. * @return string */ public static function document( Settings $settings ) { $body = ''; foreach ( self::samples( $settings ) as $sample ) { $body .= self::card( (array) $sample, $settings ); } $labels = Track_Labels::all( $settings ); $lang = esc_attr( str_replace( '_', '-', (string) get_locale() ) ); $form = '
'; // The lang attribute is not decoration here: hyphens:auto in the // stylesheet needs to know which language it is breaking, and a German // label hyphenated by English rules is worse than one not hyphenated. return '' . Setup::preview_stylesheets( array( 'careback-track' => 'track.css', 'careback-preview' => 'preview.css', ) ) . '' . esc_html( $sample['heading'] ) . '
' . '' . esc_html( $sample['outcome']['label'] ); if ( ! empty( $sample['outcome']['date'] ) ) { $html .= '' . esc_html( $sample['outcome']['date'] ) . ''; } $html .= '
'; } if ( '' !== $sample['note'] ) { $html .= '' . esc_html( $sample['note'] ) . '
'; } return $html . '