Uncanny_Codes_Helpers::get_all_code_prefix( $label = null, $option_code = 'UCPREFIX' )
Contents
Parameters Parameters
- $label
-
(Optional)
Default value: null
- $option_code
-
(Optional)
Default value: 'UCPREFIX'
Return Return
(array|mixed|void)
Source Source
File: src/integrations/uncanny-codes/helpers/uncanny-codes-helpers.php
public function get_all_code_prefix( $label = null, $option_code = 'UCPREFIX' ) { if ( ! $this->load_options ) { return Automator()->helpers->recipe->build_default_options_array( $label, $option_code ); } if ( ! $label ) { $label = esc_attr__( 'Prefix', 'uncanny-automator' ); } global $wpdb; $options = array(); $all_codes = $wpdb->get_results( 'SELECT DISTINCT prefix FROM ' . $wpdb->prefix . 'uncanny_codes_groups', ARRAY_A ); if ( ! $all_codes ) { return Automator()->helpers->recipe->build_default_options_array( $label, $option_code ); } foreach ( $all_codes as $code ) { if ( ! empty( $code['prefix'] ) ) { $prefix = Automator()->utilities->automator_sanitize( $code['prefix'] ); $options[ $prefix ] = $code['prefix']; } } $option = array( 'option_code' => $option_code, 'label' => $label, 'input_type' => 'select', 'required' => true, 'options' => $options, 'relevant_tokens' => array( $option_code => esc_attr__( 'Prefix', 'uncanny-automator' ), ), ); return apply_filters( 'uap_option_get_all_code_prefix', $option ); }
Expand full source code Collapse full source code View on Github