> */ public static function group_labels() { return array( 'profiles' => array( 'title' => __( 'Accessibility Features', 'birchtoad' ), 'desc' => __( 'Pick a profile that matches how you browse', 'birchtoad' ), ), 'content' => array( 'title' => __( 'Content Adjustments', 'birchtoad' ), 'desc' => __( 'Change how text looks and reads', 'birchtoad' ), ), 'color' => array( 'title' => __( 'Color Adjustments', 'birchtoad' ), 'desc' => __( 'Change contrast, saturation and colors', 'birchtoad' ), ), 'orientation' => array( 'title' => __( 'Orientation Adjustments', 'birchtoad' ), 'desc' => __( 'Change navigation, motion and focus', 'birchtoad' ), ), ); } /** * Every feature, keyed by its own key. * * Keys are permanent. A stored visitor choice and a saved site setting are both keyed on * them, so renaming one silently discards what people already chose. * * Each entry carries: * Paid features are NOT in this list. They are added by the __premium_only build through * the birchtoad_features filter, so the free package does not contain their definitions, * their labels or their keys at all. A paid feature defined here and hidden at runtime by * a license check is the trialware shape WordPress.org guideline 5 rejects, however well * the check works. * * Each entry carries: * group string one of self::groups() * type string toggle | range | choice | colorset | select * label string translated, shown to the visitor * order int position within its group * on bool whether a fresh install offers it to visitors * range array min, max, step, default (type range only) * choices array value => label (type choice only) * exclusive bool choosing one value releases the others (type choice) * * @return array */ public static function all() { if ( null !== self::$cache ) { return self::$cache; } $features = array( // Profiles. Every one of these is a named bundle of the adjustments below and can do // nothing a visitor cannot do by hand. // Content. 'content_scale' => array( 'group' => 'content', 'order' => 10, 'type' => 'range', 'label' => __( 'Content Scaling', 'birchtoad' ), 'pro' => false, 'on' => true, 'range' => array( 'min' => 70, 'max' => 200, 'step' => 5, 'default' => 100, 'unit' => '%', ), ), 'font_size' => array( 'group' => 'content', 'order' => 20, 'type' => 'range', 'label' => __( 'Adjust Font Sizing', 'birchtoad' ), 'pro' => false, 'on' => true, 'range' => array( 'min' => 70, 'max' => 200, 'step' => 5, 'default' => 100, 'unit' => '%', ), ), 'line_height' => array( 'group' => 'content', 'order' => 30, 'type' => 'range', 'label' => __( 'Adjust Line Height', 'birchtoad' ), 'pro' => false, 'on' => true, 'range' => array( 'min' => 100, 'max' => 250, 'step' => 10, 'default' => 100, 'unit' => '%', ), ), 'letter_spacing' => array( 'group' => 'content', 'order' => 40, 'type' => 'range', 'label' => __( 'Adjust Letter Spacing', 'birchtoad' ), 'pro' => false, 'on' => true, 'range' => array( 'min' => 0, 'max' => 10, 'step' => 1, 'default' => 0, 'unit' => '', ), ), 'word_spacing' => array( 'group' => 'content', 'order' => 45, 'type' => 'range', 'label' => __( 'Adjust Word Spacing', 'birchtoad' ), 'pro' => false, 'on' => true, 'range' => array( 'min' => 0, 'max' => 10, 'step' => 1, 'default' => 0, 'unit' => '', ), ), 'readable_font' => array( 'group' => 'content', 'order' => 50, 'type' => 'toggle', 'label' => __( 'Readable Font', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'highlight_titles' => array( 'group' => 'content', 'order' => 60, 'type' => 'toggle', 'label' => __( 'Highlight Titles', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'highlight_links' => array( 'group' => 'content', 'order' => 70, 'type' => 'toggle', 'label' => __( 'Highlight Links', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'text_align' => array( 'group' => 'content', 'order' => 90, 'type' => 'choice', 'label' => __( 'Text Align', 'birchtoad' ), 'pro' => false, 'on' => true, 'exclusive' => true, 'default' => 'none', 'choices' => array( 'none' => __( 'Site default', 'birchtoad' ), 'left' => __( 'Align Left', 'birchtoad' ), 'center' => __( 'Align Center', 'birchtoad' ), 'right' => __( 'Align Right', 'birchtoad' ), 'justify' => __( 'Justify', 'birchtoad' ), ), ), // Color. 'contrast_theme' => array( 'group' => 'color', 'order' => 10, 'type' => 'choice', 'label' => __( 'Contrast Theme', 'birchtoad' ), 'pro' => false, 'on' => true, 'exclusive' => true, 'default' => 'none', 'choices' => array( 'none' => __( 'Site default', 'birchtoad' ), 'light' => __( 'Light Contrast', 'birchtoad' ), 'dark' => __( 'Dark Contrast', 'birchtoad' ), ), ), 'high_contrast' => array( 'group' => 'color', 'order' => 20, 'type' => 'toggle', 'label' => __( 'High Contrast', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'saturation' => array( 'group' => 'color', 'order' => 30, 'type' => 'choice', 'label' => __( 'Saturation', 'birchtoad' ), 'pro' => false, 'on' => true, 'exclusive' => true, 'default' => 'none', 'choices' => array( 'none' => __( 'None', 'birchtoad' ), 'high' => __( 'High', 'birchtoad' ), 'low' => __( 'Low', 'birchtoad' ), 'mono' => __( 'Monochrome', 'birchtoad' ), ), ), // Orientation. 'reading_guide' => array( 'group' => 'orientation', 'order' => 30, 'type' => 'toggle', 'label' => __( 'Reading Guide', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'stop_animations' => array( 'group' => 'orientation', 'order' => 40, 'type' => 'toggle', 'label' => __( 'Stop Animations', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'highlight_hover' => array( 'group' => 'orientation', 'order' => 60, 'type' => 'toggle', 'label' => __( 'Highlight Hover', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'highlight_focus' => array( 'group' => 'orientation', 'order' => 70, 'type' => 'toggle', 'label' => __( 'Highlight Focus', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'hide_images' => array( 'group' => 'orientation', 'order' => 80, 'type' => 'toggle', 'label' => __( 'Hide Images', 'birchtoad' ), 'pro' => false, 'on' => true, ), 'cursor' => array( 'group' => 'orientation', 'order' => 100, 'type' => 'choice', 'label' => __( 'Cursor', 'birchtoad' ), 'pro' => false, 'on' => true, 'exclusive' => true, 'default' => 'none', 'choices' => array( 'none' => __( 'None', 'birchtoad' ), 'white' => __( 'Big White Cursor', 'birchtoad' ), 'black' => __( 'Big Black Cursor', 'birchtoad' ), ), ), ); /** * Filters the feature registry. * * This is how the paid build adds anything of its own without the core ever checking a * license. * * @param array $features The registry. */ $features = apply_filters( 'birchtoad_features', $features ); // Keep the panel's running order stable whatever order things were registered in. uasort( $features, function ( $a, $b ) { $groups = array_flip( self::groups() ); $ga = isset( $groups[ $a['group'] ] ) ? $groups[ $a['group'] ] : 99; $gb = isset( $groups[ $b['group'] ] ) ? $groups[ $b['group'] ] : 99; if ( $ga !== $gb ) { return $ga - $gb; } $oa = isset( $a['order'] ) ? $a['order'] : 50; $ob = isset( $b['order'] ) ? $b['order'] : 50; return $oa - $ob; } ); self::$cache = $features; return self::$cache; } /** * The features this edition can run. * * Identical to all(), because a feature this edition cannot run is not in the registry in * the first place. Kept as its own call so the intent stays readable at the call sites. * * @return array */ public static function available() { return self::all(); } /** * One feature, or null. * * @param string $key Feature key. * @return array|null */ public static function get( $key ) { $all = self::all(); return isset( $all[ $key ] ) ? $all[ $key ] : null; } /** * Clears the per-request cache. Used by the tests and after a settings import. * * @return void */ public static function flush() { self::$cache = null; } }