' . esc_html__( 'Settings', 'swatchline' ) . '' ); return $links; } /** @param mixed $value */ public function sanitize_size( $value ): string { return (string) Settings::clamp( absint( $value ), 16, 96, 36 ); } /** * @param array $settings * @param string $section */ public function settings( $settings, $section = '' ): array { if ( self::SECTION !== $section ) { return (array) $settings; } return self::fields(); } public static function fields(): array { $defaults = Settings::defaults(); $intro = __( 'Choose each attribute\'s swatch type (Colour, Image, Label or Dropdown) under Products → Attributes, and each value\'s colour or image under its Configure terms. These settings are how all swatches look.', 'swatchline' ); if ( ! defined( 'SWATCHLINE_PRO_VERSION' ) ) { $intro .= ' ' . __( 'Swatchline Pro adds swatches on shop pages, per-product swatches, dual colours and swatch filters.', 'swatchline' ); } $fields = array( array( 'title' => __( 'Swatches', 'swatchline' ), 'type' => 'title', 'desc' => $intro, 'id' => 'swatchline_options', ), array( 'title' => __( 'Shape', 'swatchline' ), 'desc_tip' => __( 'The shape of colour and image swatches. Label swatches are always rounded boxes.', 'swatchline' ), 'id' => 'swatchline_shape', 'type' => 'select', 'class' => 'wc-enhanced-select', 'default' => $defaults['swatchline_shape'], 'options' => array( 'circle' => __( 'Circle', 'swatchline' ), 'rounded' => __( 'Rounded square', 'swatchline' ), 'square' => __( 'Square', 'swatchline' ), ), ), array( 'title' => __( 'Swatch size', 'swatchline' ), 'desc' => __( 'pixels', 'swatchline' ), 'desc_tip' => __( 'The width and height of colour and image swatches on the product page, from 16 to 96.', 'swatchline' ), 'id' => 'swatchline_size', 'type' => 'number', 'default' => $defaults['swatchline_size'], 'custom_attributes' => array( 'min' => 16, 'max' => 96, 'step' => 1, ), ), array( 'title' => __( 'Label style', 'swatchline' ), 'desc_tip' => __( 'How the chosen label swatch stands out.', 'swatchline' ), 'id' => 'swatchline_label_style', 'type' => 'select', 'class' => 'wc-enhanced-select', 'default' => $defaults['swatchline_label_style'], 'options' => array( 'outline' => __( 'Outlined: a darker border', 'swatchline' ), 'filled' => __( 'Filled: dark with light text', 'swatchline' ), ), ), array( 'title' => __( 'Tooltips', 'swatchline' ), 'desc' => __( 'Show the value\'s name above a swatch on hover and keyboard focus', 'swatchline' ), 'id' => 'swatchline_tooltip', 'type' => 'checkbox', 'default' => $defaults['swatchline_tooltip'], 'checkboxgroup' => 'start', ), array( 'desc' => __( 'Include a larger preview of image swatches', 'swatchline' ), 'id' => 'swatchline_tooltip_image', 'type' => 'checkbox', 'default' => $defaults['swatchline_tooltip_image'], 'checkboxgroup' => 'end', ), array( 'title' => __( 'Chosen value', 'swatchline' ), 'desc' => __( 'Show the chosen value next to the attribute\'s name ("Colour: Sage")', 'swatchline' ), 'id' => 'swatchline_show_selected', 'type' => 'checkbox', 'default' => $defaults['swatchline_show_selected'], ), array( 'title' => __( 'Custom attributes', 'swatchline' ), 'desc' => __( 'Show attributes added on a single product as label swatches', 'swatchline' ), 'desc_tip' => __( 'Attributes typed on a product\'s Attributes tab have no terms to give colours or images. Without this they stay dropdowns.', 'swatchline' ), 'id' => 'swatchline_custom_attributes', 'type' => 'checkbox', 'default' => $defaults['swatchline_custom_attributes'], ), array( 'type' => 'sectionend', 'id' => 'swatchline_options', ), ); /** * The fields of WooCommerce → Settings → Products → Swatches (WooCommerce settings API). * * @param array $fields */ return (array) apply_filters( 'swatchline_settings', $fields ); } }