FlexibleContent
2 months ago
class-acf-field-accordion.php
2 months ago
class-acf-field-button-group.php
2 months ago
class-acf-field-checkbox.php
2 days ago
class-acf-field-clone.php
2 months ago
class-acf-field-color_picker.php
2 months ago
class-acf-field-date_picker.php
2 months ago
class-acf-field-date_time_picker.php
2 months ago
class-acf-field-email.php
2 months ago
class-acf-field-file.php
2 months ago
class-acf-field-flexible-content.php
1 week ago
class-acf-field-gallery.php
3 weeks ago
class-acf-field-google-map.php
2 months ago
class-acf-field-group.php
2 months ago
class-acf-field-icon_picker.php
7 months ago
class-acf-field-image.php
2 months ago
class-acf-field-link.php
2 months ago
class-acf-field-message.php
1 year ago
class-acf-field-nav-menu.php
1 week ago
class-acf-field-number.php
2 months ago
class-acf-field-oembed.php
3 weeks ago
class-acf-field-output.php
1 year ago
class-acf-field-page_link.php
3 weeks ago
class-acf-field-password.php
2 months ago
class-acf-field-post_object.php
3 weeks ago
class-acf-field-radio.php
2 days ago
class-acf-field-range.php
2 months ago
class-acf-field-relationship.php
3 weeks ago
class-acf-field-repeater.php
3 weeks ago
class-acf-field-select.php
2 days ago
class-acf-field-separator.php
1 year ago
class-acf-field-tab.php
1 year ago
class-acf-field-taxonomy.php
3 weeks ago
class-acf-field-text.php
3 weeks ago
class-acf-field-textarea.php
3 weeks ago
class-acf-field-time_picker.php
2 months ago
class-acf-field-true_false.php
2 months ago
class-acf-field-url.php
3 weeks ago
class-acf-field-user.php
3 weeks ago
class-acf-field-wysiwyg.php
2 months ago
class-acf-field.php
2 months ago
class-acf-repeater-table.php
1 year ago
index.php
1 year ago
class-acf-field-message.php
175 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! class_exists( 'acf_field_message' ) ) : |
| 4 | |
| 5 | class acf_field_message extends acf_field { |
| 6 | |
| 7 | public $show_in_rest = false; |
| 8 | |
| 9 | /** |
| 10 | * This function will setup the field type data |
| 11 | * |
| 12 | * @type function |
| 13 | * @date 5/03/2014 |
| 14 | * @since ACF 5.0.0 |
| 15 | * |
| 16 | * @param n/a |
| 17 | * @return n/a |
| 18 | */ |
| 19 | function initialize() { |
| 20 | |
| 21 | // vars |
| 22 | $this->name = 'message'; |
| 23 | $this->label = __( 'Message', 'secure-custom-fields' ); |
| 24 | $this->category = 'layout'; |
| 25 | $this->description = __( 'Used to display a message to editors alongside other fields. Useful for providing additional context or instructions around your fields.', 'secure-custom-fields' ); |
| 26 | $this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-message.png'; |
| 27 | $this->supports = array( |
| 28 | 'required' => false, |
| 29 | 'bindings' => false, |
| 30 | ); |
| 31 | $this->defaults = array( |
| 32 | 'message' => '', |
| 33 | 'esc_html' => 0, |
| 34 | 'new_lines' => 'wpautop', |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Create the HTML interface for your field |
| 41 | * |
| 42 | * @param $field - an array holding all the field's data |
| 43 | * |
| 44 | * @type action |
| 45 | * @since ACF 3.6 |
| 46 | * @date 23/01/13 |
| 47 | */ |
| 48 | function render_field( $field ) { |
| 49 | |
| 50 | // vars |
| 51 | $m = $field['message']; |
| 52 | |
| 53 | // wptexturize (improves "quotes") |
| 54 | $m = wptexturize( $m ); |
| 55 | |
| 56 | // esc_html |
| 57 | if ( $field['esc_html'] ) { |
| 58 | $m = esc_html( $m ); |
| 59 | } |
| 60 | |
| 61 | // new lines |
| 62 | if ( $field['new_lines'] == 'wpautop' ) { |
| 63 | $m = wpautop( $m ); |
| 64 | } elseif ( $field['new_lines'] == 'br' ) { |
| 65 | $m = nl2br( $m ); |
| 66 | } |
| 67 | |
| 68 | // return |
| 69 | echo acf_esc_html( $m ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * Create extra options for your field. This is rendered when editing a field. |
| 75 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
| 76 | * |
| 77 | * @param $field - an array holding all the field's data |
| 78 | * |
| 79 | * @type action |
| 80 | * @since ACF 3.6 |
| 81 | * @date 23/01/13 |
| 82 | */ |
| 83 | function render_field_settings( $field ) { |
| 84 | acf_render_field_setting( |
| 85 | $field, |
| 86 | array( |
| 87 | 'label' => __( 'Message', 'secure-custom-fields' ), |
| 88 | 'instructions' => '', |
| 89 | 'type' => 'textarea', |
| 90 | 'name' => 'message', |
| 91 | ) |
| 92 | ); |
| 93 | |
| 94 | acf_render_field_setting( |
| 95 | $field, |
| 96 | array( |
| 97 | 'label' => __( 'New Lines', 'secure-custom-fields' ), |
| 98 | 'instructions' => __( 'Controls how new lines are rendered', 'secure-custom-fields' ), |
| 99 | 'type' => 'select', |
| 100 | 'name' => 'new_lines', |
| 101 | 'choices' => array( |
| 102 | 'wpautop' => __( 'Automatically add paragraphs', 'secure-custom-fields' ), |
| 103 | 'br' => __( 'Automatically add <br>', 'secure-custom-fields' ), |
| 104 | '' => __( 'No Formatting', 'secure-custom-fields' ), |
| 105 | ), |
| 106 | ) |
| 107 | ); |
| 108 | |
| 109 | acf_render_field_setting( |
| 110 | $field, |
| 111 | array( |
| 112 | 'label' => __( 'Escape HTML', 'secure-custom-fields' ), |
| 113 | 'instructions' => __( 'Allow HTML markup to display as visible text instead of rendering', 'secure-custom-fields' ), |
| 114 | 'name' => 'esc_html', |
| 115 | 'type' => 'true_false', |
| 116 | 'ui' => 1, |
| 117 | ) |
| 118 | ); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * This function will translate field settings |
| 123 | * |
| 124 | * @type function |
| 125 | * @date 8/03/2016 |
| 126 | * @since ACF 5.3.2 |
| 127 | * |
| 128 | * @param $field (array) |
| 129 | * @return $field |
| 130 | */ |
| 131 | function translate_field( $field ) { |
| 132 | |
| 133 | // translate |
| 134 | $field['message'] = acf_translate( $field['message'] ); |
| 135 | |
| 136 | // return |
| 137 | return $field; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | /** |
| 142 | * This filter is applied to the $field after it is loaded from the database |
| 143 | * |
| 144 | * @type filter |
| 145 | * @since ACF 3.6 |
| 146 | * @date 23/01/13 |
| 147 | * |
| 148 | * @param $field - the field array holding all the field options |
| 149 | * |
| 150 | * @return $field - the field array holding all the field options |
| 151 | */ |
| 152 | function load_field( $field ) { |
| 153 | |
| 154 | // remove name to avoid caching issue |
| 155 | $field['name'] = ''; |
| 156 | |
| 157 | // remove instructions |
| 158 | $field['instructions'] = ''; |
| 159 | |
| 160 | // remove required to avoid JS issues |
| 161 | $field['required'] = 0; |
| 162 | |
| 163 | // set value other than 'null' to avoid ACF loading / caching issue |
| 164 | $field['value'] = false; |
| 165 | |
| 166 | // return |
| 167 | return $field; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | |
| 172 | // initialize |
| 173 | acf_register_field_type( 'acf_field_message' ); |
| 174 | endif; // class_exists check |
| 175 |