123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?php
- if ( ! class_exists( 'acf_field_message' ) ) :
- class acf_field_message extends acf_field {
- public $show_in_rest = false;
-
- function initialize() {
-
- $this->name = 'message';
- $this->label = __( 'Message', 'acf' );
- $this->category = 'layout';
- $this->defaults = array(
- 'message' => '',
- 'esc_html' => 0,
- 'new_lines' => 'wpautop',
- );
- }
-
- function render_field( $field ) {
-
- $m = $field['message'];
-
- $m = wptexturize( $m );
-
- if ( $field['esc_html'] ) {
- $m = esc_html( $m );
- }
-
- if ( $field['new_lines'] == 'wpautop' ) {
- $m = wpautop( $m );
- } elseif ( $field['new_lines'] == 'br' ) {
- $m = nl2br( $m );
- }
-
- echo acf_esc_html( $m );
- }
-
- function render_field_settings( $field ) {
- acf_render_field_setting(
- $field,
- array(
- 'label' => __( 'Message', 'acf' ),
- 'instructions' => '',
- 'type' => 'textarea',
- 'name' => 'message',
- )
- );
- acf_render_field_setting(
- $field,
- array(
- 'label' => __( 'New Lines', 'acf' ),
- 'instructions' => __( 'Controls how new lines are rendered', 'acf' ),
- 'type' => 'select',
- 'name' => 'new_lines',
- 'choices' => array(
- 'wpautop' => __( 'Automatically add paragraphs', 'acf' ),
- 'br' => __( 'Automatically add <br>', 'acf' ),
- '' => __( 'No Formatting', 'acf' ),
- ),
- )
- );
- acf_render_field_setting(
- $field,
- array(
- 'label' => __( 'Escape HTML', 'acf' ),
- 'instructions' => __( 'Allow HTML markup to display as visible text instead of rendering', 'acf' ),
- 'name' => 'esc_html',
- 'type' => 'true_false',
- 'ui' => 1,
- )
- );
- }
-
- function translate_field( $field ) {
-
- $field['message'] = acf_translate( $field['message'] );
-
- return $field;
- }
-
- function load_field( $field ) {
-
- $field['name'] = '';
-
- $field['instructions'] = '';
-
- $field['required'] = 0;
-
- $field['value'] = false;
-
- return $field;
- }
- }
-
- acf_register_field_type( 'acf_field_message' );
- endif;
|