searchwp\source\attribute\options
Desde: 4.0.0
Tabla de contenidos
Modificar las Opciones de Atributo para una Fuente.
Parámetros
| Tipo | Parámetro | Predeterminado | Desde | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Matriz | $options |
Opciones de Atributo Definidas | 4.0.0 |
|||||||||||||||
| Matriz |
$args
|
4.0.0 |
||||||||||||||||
Ejemplos
Todos los ganchos deben agregarse a su plugin personalizado de SearchWP Customizations Plugin.
Añadir Opciones de Atributo de metadatos 'extra'
| <?php | |
| // Add 'extra' metadata Attribute Options in SearchWP. | |
| add_filter( 'searchwp\source\attribute\options', function( $options, $args ){ | |
| if( $args['attribute'] !== 'meta' ){ | |
| return $options; | |
| } | |
| $these_keys = [ 'my_custom_key' ]; | |
| foreach( $these_keys as $this_key ){ | |
| // Add this field if it's not added already. | |
| if( ! in_array( | |
| $this_key, | |
| array_map( function( $option ){ return $option->get_value(); }, $options ) | |
| ) ){ | |
| // Each option must be a \SearchWP\Option. | |
| $options[] = new \SearchWP\Option( $this_key, 'Extra Metadata: ' . $this_key ); | |
| } | |
| } | |
| return $options; | |
| }, 10, 2 ); |

