> List of `{ value, label }` pairs. */ public static function get_breakpoint_choices() { $labels = array( '480' => __( 'Small phones', 'tablefold' ), '600' => __( 'Phones', 'tablefold' ), '782' => __( 'Small tablets', 'tablefold' ), '960' => __( 'Tablets', 'tablefold' ), ); $choices = array(); foreach ( self::get_breakpoint_values() as $value ) { if ( isset( $labels[ $value ] ) ) { /* translators: 1: human readable device name, for example "Phones". 2: viewport width in pixels, for example "600". */ $label = sprintf( __( '%1$s – under %2$spx', 'tablefold' ), $labels[ $value ], $value ); } else { /* translators: %s: viewport width in pixels, for example "600". */ $label = sprintf( __( 'Under %spx', 'tablefold' ), $value ); } $choices[] = array( 'value' => $value, 'label' => $label, ); } return $choices; } /** * Returns the default breakpoint, validated against the accepted values. * * @since 1.0.0 * * @return string Breakpoint value in pixels. */ public static function get_default_breakpoint() { $values = self::get_breakpoint_values(); /** * Filters the breakpoint used by tables that do not specify one. * * @since 1.0.0 * * @param string $default Breakpoint value in pixels. */ $default = (string) apply_filters( 'tablefold_default_breakpoint', self::DEFAULT_BREAKPOINT ); return in_array( $default, $values, true ) ? $default : reset( $values ); } /** * Returns the accessible name given to a table that falls back to scrolling. * * The scrollable container is keyboard focusable, so it needs a name. When * the block has a caption, the caption is used instead of this generic name. * * Must not be called before the `init` hook, because it translates a string. * * @since 1.0.0 * * @return string Accessible name for the scrollable container. */ public static function get_scrollable_label() { $label = __( 'Table, scrollable sideways', 'tablefold' ); /** * Filters the accessible name of a horizontally scrollable table. * * Applies only to tables whose structure could not be stacked, and only * when the block has no caption to name it. * * @since 1.0.0 * * @param string $label Accessible name for the scrollable container. */ return (string) apply_filters( 'tablefold_scrollable_label', $label ); } }