' . "\n", esc_url( admin_url( 'admin-ajax.php?action=storesuit_manifest&v=' . $version ) ) );
printf( '' . "\n", esc_attr( self::THEME ) );
printf( '' . "\n", esc_url( plugins_url( 'assets/app-icon-192.png', STORESUIT_FILE ) ) );
printf( '' . "\n", esc_attr( self::short_name() ) );
}
private static function shop() : string {
return trim( wp_specialchars_decode( (string) get_bloginfo( 'name' ), ENT_QUOTES ) );
}
private static function name() : string {
return ( self::shop() !== '' ? self::shop() . ' ยท StoreRuler' : 'StoreRuler' );
}
private static function short_name() : string {
return ( self::shop() !== '' && mb_strlen( self::shop() ) <= 12 ? self::shop() : 'StoreRuler' );
}
public static function data() : array {
$icons = array_map( static fn( $icon ) => array(
'src' => plugins_url( 'assets/' . $icon[0], STORESUIT_FILE ),
'sizes' => $icon[1],
'type' => 'image/png',
'purpose' => $icon[2],
), self::ICONS );
// A new sale by hand is the paid build's; the order desk is in both.
$shortcuts = array();
$shortcuts[] = array(
'name' => I18n::t( 'Order desk' ),
'url' => admin_url( 'admin.php?page=storesuit-orders' ),
);
return array(
'id' => admin_url( 'admin.php?page=storesuit' ),
'name' => self::name(),
'short_name' => self::short_name(),
'description' => I18n::t( 'Sales, orders, stock and money of your store in one place.' ),
'start_url' => admin_url( 'admin.php?page=storesuit' ),
'scope' => admin_url(),
'display' => 'standalone',
'background_color' => self::BACKGROUND,
'theme_color' => self::THEME,
'lang' => str_replace( '_', '-', get_user_locale() ),
'dir' => ( is_rtl() ? 'rtl' : 'ltr' ),
'icons' => $icons,
'shortcuts' => $shortcuts,
);
}
public static function manifest() : void {
// A versioned address (head()) may be kept by this browser only; the plain address is never kept, as before.
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Only chooses the caching header of this public, read-only document.
if ( isset( $_GET['v'] ) ) {
header_remove( 'Expires' );
header_remove( 'Pragma' );
header( 'Cache-Control: private, max-age=31536000' );
} else {
nocache_headers();
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
header( 'Content-Type: application/manifest+json; charset=utf-8' );
header( 'X-Content-Type-Options: nosniff' );
echo wp_json_encode( self::data(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON document.
exit;
}
}