data = &$args;
if( $this->add_in_menu() ) {
add_action( 'admin_menu', array( $this, 'add_menu_in_admin_menu' ), 12 );
}
add_action( 'admin_init', array( $this, 'pick_settings_display_fields' ), 12 );
add_filter( 'whitelist_options', array( $this, 'pick_settings_whitelist_options' ), 99, 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'pick_enqueue_color_picker' ) );
}
public function add_menu_in_admin_menu() {
if( "main" == $this->get_menu_type() ) {
add_menu_page( $this->get_menu_name(), $this->get_menu_title(), $this->get_capability(), $this->get_menu_slug(), array( $this, 'pick_settings_display_function' ), $this->get_menu_icon() );
}
if( "submenu" == $this->get_menu_type() ) {
add_submenu_page( $this->get_parent_slug(), $this->get_page_title(), $this->get_menu_title(), $this->get_capability(), $this->get_menu_slug(), array( $this, 'pick_settings_display_function' ) );
}
}
public function pick_enqueue_color_picker(){
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'jquery-ui-datepicker' );
}
public function pick_settings_display_fields() {
foreach( $this->get_settings_fields() as $key => $setting ):
add_settings_section(
$key,
isset( $setting['title'] ) ? $setting['title'] : "",
array( $this, 'pick_settings_section_callback' ),
$this->get_current_page()
);
foreach( $setting['options'] as $option ) :
add_settings_field( $option['id'], $option['title'], array($this,'pick_settings_field_generator'), $this->get_current_page(), $key, $option );
endforeach;
endforeach;
}
public function pick_settings_field_generator( $option ) {
$id = isset( $option['id'] ) ? $option['id'] : "";
$type = isset( $option['type'] ) ? $option['type'] : "";
$details = isset( $option['details'] ) ? $option['details'] : "";
if( empty( $id ) ) return;
try{
//var_dump($type);
if( isset($option['type']) && $option['type'] === 'select' ) $this->generate_field_select( $option );
elseif( isset($option['type']) && $option['type'] === 'select_multi') $this->generate_field_select_multi( $option );
elseif( isset($option['type']) && $option['type'] === 'select2') $this->generate_field_select2( $option );
elseif( isset($option['type']) && $option['type'] === 'checkbox') $this->generate_field_checkbox( $option );
elseif( isset($option['type']) && $option['type'] === 'radio') $this->generate_field_radio( $option );
elseif( isset($option['type']) && $option['type'] === 'textarea') $this->generate_field_textarea( $option );
elseif( isset($option['type']) && $option['type'] === 'number' ) $this->generate_field_number( $option );
elseif( isset($option['type']) && $option['type'] === 'text' ) $this->generate_field_text( $option );
elseif( isset($option['type']) && $option['type'] === 'text_multi' ) $this->generate_field_text_multi( $option );
elseif( isset($option['type']) && $option['type'] === 'colorpicker') $this->generate_field_colorpicker( $option );
elseif( isset($option['type']) && $option['type'] === 'datepicker') $this->generate_field_datepicker( $option );
elseif( isset($option['type']) && $option['type'] === 'repeater') $this->generate_field_repeater( $option );
elseif( isset($option['type']) && $option['type'] === 'faq') $this->generate_field_faq( $option );
elseif( isset($option['type']) && $option['type'] === 'addons_grid') $this->generate_field_addons_grid( $option );
elseif( isset($option['type']) && $option['type'] === 'custom_html') $this->generate_field_custom_html( $option );
elseif( isset($option['type']) && $option['type'] === $type ) do_action( "wp_admin_settings_custom_field_$type", $option );
if( !empty( $details ) ) echo "
$details
";
}
catch(Pick_error $e) {
echo $e->get_error_message();
}
}
public function generate_field_datepicker( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$placeholder = isset( $option['placeholder'] ) ? $option['placeholder'] : "";
$value = get_option( $id );
wp_register_style( 'jquery-ui', 'http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
wp_enqueue_style( 'jquery-ui' );
echo "";
echo "";
}
public function generate_field_colorpicker( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$placeholder = isset( $option['placeholder'] ) ? $option['placeholder'] : "";
$value = get_option( $id );
echo "";
echo "";
}
public function generate_field_text( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$placeholder = isset( $option['placeholder'] ) ? $option['placeholder'] : "";
$value = get_option( $id );
echo "";
}
public function generate_field_text_multi( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$placeholder = isset( $option['placeholder'] ) ? $option['placeholder'] : "";
$values = get_option( $id );
//var_dump($values);
?>
Add
";
}
public function generate_field_textarea( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$placeholder = isset( $option['placeholder'] ) ? $option['placeholder'] : "";
$value = get_option( $id );
echo "";
}
public function generate_field_select( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$args = isset( $option['args'] ) ? $option['args'] : array();
$args = is_array( $args ) ? $args : $this->generate_args_from_string( $args );
$value = get_option( $id );
echo "";
}
public function generate_field_select_multi( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$args = isset( $option['args'] ) ? $option['args'] : array();
$args = is_array( $args ) ? $args : $this->generate_args_from_string( $args );
$option_value = get_option( $id );
echo "";
}
public function generate_field_select2( $option ){
$id = isset( $option['id'] ) ? $option['id'] : "";
$args = isset( $option['args'] ) ? $option['args'] : array();
$args = is_array( $args ) ? $args : $this->generate_args_from_string( $args, $option );
$value = get_option( $id );
$multiple = isset( $option['multiple'] ) ? $option['multiple'] : '';
wp_enqueue_style('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css' );
wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js', array('jquery') );
echo $multiple ? "