PluginProbe
Smart Custom Fields / trunk
Smart Custom Fields vtrunk
1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 2.0.0 2.0.1 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 All 68 releases
smart-custom-fields / classes / fields / class.field-text.php

class.field-text.php in Smart Custom Fields trunk, at classes/fields/class.field-text.php

96 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package smart-custom-fields
4 * @author inc2734
5 * @license GPL-2.0+
6 */
7
8 /**
9 * Smart_Custom_Fields_Field_Text class.
10 */
11 class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
12
13 /**
14 * Set the required items.
15 *
16 * @return array
17 */
18 protected function init() {
19 return array(
20 'type' => 'text',
21 'display-name' => __( 'Text', 'smart-custom-fields' ),
22 'optgroup' => 'basic-fields',
23 );
24 }
25
26 /**
27 * Set the non required items.
28 *
29 * @return array
30 */
31 protected function options() {
32 return array(
33 'default' => '',
34 'instruction' => '',
35 'notes' => '',
36 );
37 }
38
39 /**
40 * Getting the field.
41 *
42 * @param int $index Field index.
43 * @param string $value The value.
44 * @return string
45 */
46 public function get_field( $index, $value ) {
47 $name = $this->get_field_name_in_editor( $index );
48 $disabled = $this->get_disable_attribute( $index );
49 return sprintf(
50 '<input type="text" name="%s" value="%s" class="widefat" %s />',
51 esc_attr( $name ),
52 esc_attr( $value ),
53 disabled( true, $disabled, false )
54 );
55 }
56
57 /**
58 * Displaying the option fields in custom field settings page.
59 *
60 * @param int $group_key Group key.
61 * @param int $field_key Field key.
62 */
63 public function display_field_options( $group_key, $field_key ) {
64 $this->display_label_option( $group_key, $field_key );
65 $this->display_name_option( $group_key, $field_key );
66 ?>
67 <tr>
68 <th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
69 <td>
70 <input type="text"
71 name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
72 class="widefat"
73 value="<?php echo esc_attr( $this->get( 'default' ) ); ?>" />
74 </td>
75 </tr>
76 <tr>
77 <th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
78 <td>
79 <textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
80 class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
81 </td>
82 </tr>
83 <tr>
84 <th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
85 <td>
86 <input type="text"
87 name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
88 class="widefat"
89 value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
90 />
91 </td>
92 </tr>
93 <?php
94 }
95 }
96