$ok, 'label' => $label, 'detail' => $detail, 'url' => $url, 'action' => $action, ); } public static function designer_page(): array { $label = __( 'Designer page', 'printblob' ); $page = Settings::designer_page(); $fix = Settings::url(); if ( ! $page ) { $url = Shirt_Colors::designer_url(); $found = (int) url_to_postid( $url ); return $found && has_block( 'printblob/designer', $found ) /* translators: %s: page title. */ ? self::row( true, $label, sprintf( __( '“%s”, the first published page with the designer block.', 'printblob' ), get_the_title( $found ) ), $url, __( 'View', 'printblob' ) ) : self::row( false, $label, __( 'No page is set and no published page has the designer block. Products with the designer still show it on their own page.', 'printblob' ), $fix, __( 'Choose a page', 'printblob' ) ); } $title = get_the_title( $page ); if ( 'publish' !== get_post_status( $page ) ) { /* translators: %s: page title. */ return self::row( false, $label, sprintf( __( '“%s” is not published.', 'printblob' ), $title ), (string) get_edit_post_link( $page, 'raw' ), __( 'Edit the page', 'printblob' ) ); } if ( ! has_block( 'printblob/designer', $page ) ) { /* translators: %s: page title. */ return self::row( false, $label, sprintf( __( '“%s” has no PrintBlob designer block.', 'printblob' ), $title ), (string) get_edit_post_link( $page, 'raw' ), __( 'Add the block', 'printblob' ) ); } /* translators: %s: page title. */ return self::row( true, $label, sprintf( __( '“%s” is published and shows the designer.', 'printblob' ), $title ), (string) get_permalink( $page ), __( 'View', 'printblob' ) ); } public static function colours(): array { $label = __( 'Colours', 'printblob' ); $taxonomy = Settings::color_attribute(); $terms_at = admin_url( 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=product' ); if ( ! taxonomy_exists( $taxonomy ) ) { return self::row( false, $label, __( 'The colour attribute chosen in the settings does not exist.', 'printblob' ), admin_url( 'edit.php?post_type=product&page=product_attributes' ), __( 'Product attributes', 'printblob' ) ); } $colours = Shirt_Colors::all(); $total = count( $colours ); if ( 0 === $total ) { return self::row( false, $label, __( 'The colour attribute has no colours yet.', 'printblob' ), $terms_at, __( 'Add colours', 'printblob' ) ); } $valued = count( array_filter( $colours, static fn( array $colour ): bool => '' !== (string) sanitize_hex_color( (string) get_term_meta( $colour['id'], Shirt_Colors::META_KEY, true ) ) ) ); $photos = count( array_filter( $colours, static fn( array $colour ): bool => $colour['image'] > 0 ) ); $detail = sprintf( /* translators: 1: number of colours, 2: how many have a colour value, 3: how many have their own photo. */ _n( '%1$d colour: %2$d with a colour value, %3$d with its own photo.', '%1$d colours: %2$d with a colour value, %3$d with their own photo.', $total, 'printblob' ), $total, $valued, $photos ); return self::row( $valued === $total, $label, $detail, $terms_at, $valued === $total ? __( 'Edit colours', 'printblob' ) : __( 'Give each colour a value', 'printblob' ) ); } public static function sizes(): array { $label = __( 'Sizes', 'printblob' ); $taxonomy = Settings::size_attribute(); if ( ! taxonomy_exists( $taxonomy ) ) { return self::row( false, $label, __( 'The size attribute chosen in the settings does not exist. Without one, customers choose no size.', 'printblob' ), admin_url( 'edit.php?post_type=product&page=product_attributes' ), __( 'Product attributes', 'printblob' ) ); } $count = (int) wp_count_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, ) ); /* translators: %d: number of sizes. */ return self::row( $count > 0, $label, sprintf( _n( '%d size.', '%d sizes.', $count, 'printblob' ), $count ), admin_url( 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=product' ), $count > 0 ? __( 'Edit sizes', 'printblob' ) : __( 'Add sizes', 'printblob' ) ); } public static function products(): array { $label = __( 'Products with the designer', 'printblob' ); $products = Product_Settings::designer_products( 5 ); if ( 0 === $products['total'] ) { return self::row( false, $label, __( 'No product has the designer on. Edit a product, open its PrintBlob designer tab and turn the designer on.', 'printblob' ), admin_url( 'edit.php?post_type=product' ), __( 'Products', 'printblob' ) ); } $links = implode( ', ', array_map( static fn( int $id ): string => '' . esc_html( get_the_title( $id ) ) . '', $products['ids'] ) ); /* translators: %d: number of products. */ return self::row( true, $label, sprintf( esc_html( _n( '%d product:', '%d products:', $products['total'], 'printblob' ) ), $products['total'] ) . ' ' . $links, null ); } public static function mockup(): array { $label = __( 'Default mockup', 'printblob' ); $id = (int) get_option( Mockups::DEFAULT_OPTION ); $ok = $id && Mockups::POST_TYPE === get_post_type( $id ) && 'publish' === get_post_status( $id ); return $ok /* translators: %s: mockup title. */ ? self::row( true, $label, sprintf( __( '“%s”, which products use unless they choose another.', 'printblob' ), get_the_title( $id ) ), Mockups::screen_url(), __( 'Mockups', 'printblob' ) ) : self::row( false, $label, __( 'The bundled product mockup is missing. It is made again the next time a shop manager opens the dashboard.', 'printblob' ), admin_url(), __( 'Dashboard', 'printblob' ) ); } public static function print_folder(): array { $result = get_transient( self::PRINT_FOLDER_CHECK ); if ( ! is_array( $result ) ) { $result = Design_Store::site_health_result(); set_transient( self::PRINT_FOLDER_CHECK, $result, DAY_IN_SECONDS ); } return self::row( 'good' === $result['status'], __( 'Print files', 'printblob' ), (string) $result['label'], admin_url( 'site-health.php' ), __( 'Site Health', 'printblob' ) ); } /** * The rows Quick setup can set up, in the order a shop sets them up. * * @return array */ public static function setup_rows(): array { return array( self::mockup(), self::colours(), self::sizes(), self::products(), self::designer_page() ); } /** * The status rows: the set-up rows (setup_rows() when not given), then the print folder's. * * @param array[]|null $setup setup_rows(), where the caller has them. * @return array */ public static function rows( ?array $setup = null ): array { return array_merge( $setup ?? self::setup_rows(), array( self::print_folder() ) ); } /** * The newest orders with a design, and how many came this month. * * @return array{latest:\WC_Order[], month:int} */ public static function orders( int $limit = 5 ): array { $latest = array(); foreach ( Design_Store::order_ids() as $id ) { $order = wc_get_order( $id ); if ( $order instanceof \WC_Order ) { $latest[] = $order; } if ( count( $latest ) >= $limit ) { break; } } $start = ( new \DateTimeImmutable( 'first day of this month midnight', wp_timezone() ) )->getTimestamp(); return array( 'latest' => $latest, 'month' => count( Design_Store::orders_where( array( 'date_created' => '>=' . $start ) ) ), ); } public static function mark( bool $ok ): string { return Admin_Menu::mark_html( $ok, $ok ? __( 'Done', 'printblob' ) : __( 'To do', 'printblob' ) ); } public static function render(): void { Admin_Menu::allow(); $orders = self::orders(); $setup = self::setup_rows(); ?>

    $order->get_id(), $orders['latest'] ) ); ?>
  • get_order_number() ) ); ?> · get_date_created() ? wc_format_datetime( $order->get_date_created() ) : '' ); ?> · get_status() ) ); ?> ·