array( 'applied' => array( 'column', 'above' ) ), ); const CHOICES = 'aieo_recognised_plugin_choices'; public static function choice( $plugin, $id ) { $values = self::CHOICE_VALUES[ (string) $plugin ][ (string) $id ] ?? array(); if ( array() === $values ) { return ''; } $stored = get_option( self::CHOICES, array() ); $value = is_array( $stored ) && isset( $stored[ (string) $plugin ][ (string) $id ] ) ? (string) $stored[ (string) $plugin ][ (string) $id ] : ''; return in_array( $value, $values, true ) ? $value : $values[0]; } public static function set_choice( $plugin, $id, $value ) { $values = self::CHOICE_VALUES[ (string) $plugin ][ (string) $id ] ?? array(); if ( ! in_array( (string) $value, $values, true ) ) { return false; } $stored = get_option( self::CHOICES, array() ); $stored = is_array( $stored ) ? $stored : array(); $stored[ (string) $plugin ][ (string) $id ] = (string) $value; update_option( self::CHOICES, $stored, true ); return true; } public static function all() { $plugins = array( 'fibosearch' => array( 'name' => 'FiboSearch', 'active' => function_exists( 'DGWT_WCAS' ), 'edition' => defined( 'DGWT_WCAS_SEARCH_PRO_ACTION' ) ? 'Pro' : '', 'version' => defined( 'DGWT_WCAS_VERSION' ) ? (string) DGWT_WCAS_VERSION : '', 'switch' => __( 'Use FiboSearch for the site\'s product search', 'ai-eshop-optimizer' ), 'help' => __( 'FiboSearch\'s box, with its live suggestions, is the header\'s product search: its search field, the search its search button opens, and the phone\'s. Turned off, the theme\'s own search comes back.', 'ai-eshop-optimizer' ), ), 'fibofilters' => array( 'name' => 'FiboFilters', 'active' => class_exists( '\FiboFilters\Config\Env' ), 'edition' => class_exists( '\FiboFilters\Config\Env' ) && false !== strpos( (string) \FiboFilters\Config\Env::$plugin_folder, 'pro' ) ? 'Pro' : '', 'version' => class_exists( '\FiboFilters\Config\Env' ) ? (string) \FiboFilters\Config\Env::$version : '', 'switch' => __( 'Use FiboFilters for the shop\'s filters', 'ai-eshop-optimizer' ), 'help' => __( 'FiboFilters\' filters are the product archives\' filters, in the theme\'s filters column (and its phone panel), in the shop\'s palette. Turned off, the theme\'s own filters come back.', 'ai-eshop-optimizer' ), 'choices' => array( 'applied' => array( 'label' => __( 'Chosen filters', 'ai-eshop-optimizer' ), 'options' => array( 'column' => __( 'In the filters column', 'ai-eshop-optimizer' ), 'above' => __( 'Above the products', 'ai-eshop-optimizer' ), ), 'help' => __( 'Where a computer shows the filters a visitor has chosen, each with its way to remove it: in the filters column under the filters, as the theme\'s own filters show them, or above the products. A phone shows them in its filters panel.', 'ai-eshop-optimizer' ), ), ), ), 'gravityforms' => array( 'name' => 'Gravity Forms', 'active' => function_exists( 'gravity_form' ), 'edition' => '', 'version' => class_exists( 'GFForms', false ) && isset( GFForms::$version ) ? (string) GFForms::$version : '', 'switch' => __( 'Draw Gravity Forms\' forms in the theme\'s look', 'ai-eshop-optimizer' ), 'help' => __( 'Every Gravity Forms form takes the theme\'s fields, drop-downs, checkboxes and radio buttons, buttons, labels, required marks, refusals and confirmations, in both colour schemes and with either of Gravity Forms\' form themes. Turned off, Gravity Forms\' own look comes back.', 'ai-eshop-optimizer' ), ), ); $plugins = (array) apply_filters( 'aieo_recognised_plugins', $plugins ); foreach ( $plugins as $id => $plugin ) { $plugins[ $id ]['on'] = self::on( (string) $id ); foreach ( (array) ( $plugin['choices'] ?? array() ) as $choice => $spec ) { $plugins[ $id ]['choices'][ $choice ]['value'] = self::choice( (string) $id, (string) $choice ); } } return $plugins; } } }