*/ private static $files = array(); public static function numbers(): array { return self::read( 'designer.json' ); } public static function tee(): array { return self::read( 'mockups/tee.json' ); } /** @return array{colours:array, sizes:string[], price:string, print_price:string} */ public static function shirt(): array { return self::read( 'mockups/shirt.json' ); } /** * The font faces the designer offers, each with its family, label, weight, style and url (woff2): the bundled ones * (assets/fonts/fonts.json) as the printblob_fonts filter leaves them. * * @return array[] */ public static function fonts(): array { $url = plugins_url( 'assets/fonts/', FILE ); $fonts = array(); foreach ( self::read( 'fonts/fonts.json' ) as $face ) { $face['url'] = $url . $face['file']; unset( $face['file'] ); $fonts[] = $face; } /** * Filters the font faces offered in the designer. Each face: family, label, weight, style, url (woff2). * * @param array[] $fonts Font faces. */ return array_values( (array) apply_filters( 'printblob_fonts', $fonts ) ); } /** A printed length in centimetres as pixels of the print file. */ public static function print_pixels( float $cm ): int { return (int) round( $cm / 2.54 * self::numbers()['print_dpi'] ); } private static function read( string $file ): array { if ( ! isset( self::$files[ $file ] ) ) { self::$files[ $file ] = (array) wp_json_file_decode( dirname( FILE ) . '/assets/' . $file, array( 'associative' => true ) ); } return self::$files[ $file ]; } }