' . htmlentities( stripslashes( $value ), ENT_QUOTES, 'UTF-8' ) . ''; return $output; } } //Read-only field if ( ! function_exists( 'antreas_form_readonly' ) ) { function antreas_form_readonly( $name, $value, $args = null ) { $output = ''; $output .= '' . stripslashes( $value ) . ''; return $output; } } //Standard text field if ( ! function_exists( 'antreas_form_text' ) ) { function antreas_form_text( $name, $value, $args = null ) { if ( isset( $args['width'] ) ) { $field_width = ' style="width:' . $args['width'] . ';"'; } else { $field_width = ''; } if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } $output = ''; return $output; } } //Textarea field if ( ! function_exists( 'antreas_form_textarea' ) ) { function antreas_form_textarea( $name, $value, $args = null ) { if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } $output = ''; return $output; } } //Code field if ( ! function_exists( 'antreas_form_code' ) ) { function antreas_form_code( $name, $value, $args = null ) { $code = isset( $args['format'] ) ? $args['format'] : 'xml'; if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } wp_enqueue_script( 'antreas_script_codemirror' ); wp_enqueue_script( 'antreas_script_codemirror_' . $code ); wp_enqueue_script( 'antreas_script_editor' ); wp_enqueue_style( 'antreas_style_codemirror' ); $output = ''; return $output; } } //Checkbox field if ( ! function_exists( 'antreas_form_checkbox' ) ) { function antreas_form_checkbox( $name, $value, $list, $args = null ) { $output = ''; return $output; } } //Checklist field if ( ! function_exists( 'antreas_form_checklist' ) ) { function antreas_form_checklist( $name, $value, $list, $args = null ) { $field_class = ( isset( $args['class'] ) ? $args['class'] : '' ); $output = ''; $output = ''; $output .= selected( $value, $list_key, false ); $output .= '>' . str_replace( '&', '&', htmlentities( stripslashes( $list_value ), ENT_QUOTES, 'UTF-8' ) ) . ''; } } } $output .= ''; return $output; } } //Yes/No radio selection field if ( ! function_exists( 'antreas_form_yesno' ) ) { function antreas_form_yesno( $name, $value, $args = null ) { $checked_yes = ''; $checked_no = ' checked'; if ( $value == '1' ) { $checked_yes = ' checked'; $checked_no = ''; } $output = ''; $output .= ''; $output .= '    '; $output .= ''; return $output; } } //Dropdown list field if ( ! function_exists( 'antreas_form_select' ) ) { function antreas_form_select( $name, $value, $list, $args = null ) { if ( isset( $args['width'] ) ) { $field_width = ' style="width:' . $args['width'] . ';"'; } else { $field_width = ''; } $field_class = ( isset( $args['class'] ) ? $args['class'] : '' ); $output = ''; return $output; } } //Image list selection if ( ! function_exists( 'antreas_form_imagelist' ) ) { function antreas_form_imagelist( $name, $value, $list, $args = null ) { $output = '
'; foreach ( $list as $list_key => $list_value ) { $checked = null; $selected = null; if ( $list_key == $value ) { $checked = ' checked="checked"'; $selected = ' class="selected"'; } $output .= ''; } $output .= '
'; return $output; } } //Icon list selection if ( ! function_exists( 'antreas_form_iconlist' ) ) { function antreas_form_iconlist( $name, $value, $args = null ) { $output = '
'; $output .= ''; $list = antreas_metadata_icons(); foreach ( $list as $library_key => $library_value ) { $output .= '
' . $library_value['name'] . '
'; foreach ( $library_value['icons'] as $list_key => $list_value ) { $checked = null; $selected = ''; if ( $library_key . '-' . $list_key === $value && $value != '' ) { $checked = ' checked="checked"'; $selected = ' selected'; } $output .= ''; } } $output .= '
'; return $output; } } //Expandable list of field elements-- can contain other fields if ( ! function_exists( 'antreas_form_collection' ) ) { function antreas_form_collection( $name, $value, $list, $args = null ) { $field_class = ( isset( $args['class'] ) ? $args['class'] : '' ); $output = '
'; //Check that given value is an array. If empty, add a single row if ( empty( $value ) || $value == '' ) { $value = array( '' ); } $output .= ''; //Table header $output .= ''; foreach ( $list as $list_key => $list_value ) { $field_title = isset( $list_value['label'] ) ? $list_value['label'] : $list_value; $output .= ''; } $output .= ''; //Table contents $counter = -1; foreach ( $value as $current_key => $current_value ) { $counter++; $output .= ''; foreach ( $list as $list_key => $list_value ) { $output .= ''; } $output .= ''; $output .= ''; } $output .= ''; $output .= ''; $output .= ''; $output .= '
' . $field_title . '
'; //Save field data-- collections can be of any field type $field_name = $name . '[' . $current_key . '][' . $list_key . ']'; $field_type = isset( $list_value['type'] ) ? $list_value['type'] : 'text'; $field_args = isset( $list_value['args'] ) ? $list_value['args'] : null; $field_options = isset( $list_value['option'] ) ? $list_value['option'] : null; $field_value = isset( $current_value[ $list_key ] ) ? $current_value[ $list_key ] : ''; //Display corresponding type of field if ( $field_type == 'readonly' ) { $output .= antreas_form_readonly( $field_name, $field_value, $field_args ); } elseif ( $field_type == 'text' ) { $output .= antreas_form_text( $field_name, $field_value, $field_args ); } elseif ( $field_type == 'textarea' ) { $output .= antreas_form_textarea( $field_name, $field_value, $field_args ); } elseif ( $field_type == 'select' ) { $output .= antreas_form_select( $field_name, $field_value, $field_options, $field_args ); } elseif ( $field_type == 'checkbox' ) { $output .= antreas_form_checkbox( $field_name, $field_value, $field_args ); } elseif ( $field_type == 'yesno' ) { $output .= antreas_form_yesno( $field_name, $field_value, $field_args ); } elseif ( $field_type == 'color' ) { $output .= antreas_form_color( $field_name, $field_value ); } elseif ( $field_type == 'upload' ) { $output .= antreas_form_upload( $field_name, $field_value, null, $post ); } elseif ( $field_type == 'date' ) { $output .= antreas_form_date( $field_name, $field_value, null ); } $output .= ''; $output .= '' . __( 'Remove', 'antreas' ) . ''; $output .= '
'; $output .= '' . __( 'Add Row', 'antreas' ) . ''; $output .= '
'; $output .= '
'; return $output; } } //Color Picker field if ( ! function_exists( 'antreas_form_color' ) ) { function antreas_form_color( $name, $value, $args = null ) { if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } $output = '
'; $output .= ''; //$output .= '
'; $output .= '
'; return $output; } } //Uploader using Media Library if ( ! function_exists( 'antreas_form_upload' ) ) { function antreas_form_upload( $name, $value, $args = null, $post = null ) { if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } if ( stripslashes( $value ) != '' ) { $image = stripslashes( $value ); } else { $image = ANTREAS_ASSETS_IMG . 'backend/noimage.jpg'; } $output = ''; $output .= ''; $output .= ''; return $output; } } //Font selector field if ( ! function_exists( 'antreas_form_font' ) ) { function antreas_form_font( $name, $value, $list, $args = null ) { $font_name = ''; if ( isset( $list[ $value ] ) ) { $font_name = $list[ $value ]; $font_name = str_replace( ' (Thin)', '', $font_name ); $font_name = str_replace( ' (Light)', '', $font_name ); $font_name = str_replace( ' (Bold)', '', $font_name ); } $weight = '400'; if ( strpos( $value, ':100' ) != false ) { $weight = '100'; } if ( strpos( $value, ':300' ) != false ) { $weight = '300'; } if ( strpos( $value, ':700' ) != false ) { $weight = '700'; } $output = antreas_form_select( $name, $value, $list, array( 'class' => 'font_field' ) ); $output .= '
'; $output .= ""; $output .= '
'; $output .= '
' . __( 'This is a font preview image', 'antreas' ) . '
'; return $output; } } //Date picker field if ( ! function_exists( 'antreas_form_date' ) ) { function antreas_form_date( $name, $value, $args = null ) { if ( isset( $args['placeholder'] ) ) { $field_placeholder = ' placeholder="' . $args['placeholder'] . '"'; } else { $field_placeholder = ''; } if ( isset( $args['autocomplete'] ) ) { $field_autocomplete = ' autocomplete="' . $args['placeholder'] . '"'; } else { $field_autocomplete = ' autocomplete="off"'; } $output = ''; return $output; } } // Range slider control. if ( ! function_exists( 'antreas_form_range' ) ) { function antreas_form_range( $name, $value, $args = null ) { if ( ! $value ) { $value = $args['std']; } $output = '
'; $output .= '
'; $output .= ''; $output .= '
'; return $output; } }