field-advanced-link.php
6 years ago
field-button.php
6 years ago
field-clone.php
6 years ago
field-column.php
6 years ago
field-dynamic-message.php
6 years ago
field-file.php
6 years ago
field-flexible-content.php
6 years ago
field-forms.php
6 years ago
field-group.php
6 years ago
field-hidden.php
6 years ago
field-image.php
6 years ago
field-post-statuses.php
6 years ago
field-post-types.php
6 years ago
field-recaptcha.php
6 years ago
field-repeater.php
6 years ago
field-select.php
6 years ago
field-slug.php
6 years ago
field-taxonomies.php
6 years ago
field-taxonomy-terms.php
6 years ago
field-textarea.php
6 years ago
field-user-roles.php
6 years ago
field-dynamic-message.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | class acfe_field_dynamic_message extends acf_field{ |
| 7 | |
| 8 | function __construct(){ |
| 9 | |
| 10 | $this->name = 'acfe_dynamic_message'; |
| 11 | $this->label = __('Dynamic Message', 'acfe'); |
| 12 | $this->category = 'layout'; |
| 13 | |
| 14 | parent::__construct(); |
| 15 | |
| 16 | } |
| 17 | |
| 18 | function render_field_settings($field){ |
| 19 | |
| 20 | $field_name = 'field_name'; |
| 21 | if(isset($field['name']) && !empty($field['name'])) |
| 22 | $field_name = $field['name']; |
| 23 | |
| 24 | ob_start(); |
| 25 | ?> |
| 26 | Write your own PHP/HTML content using the following hook:<br /><br /> |
| 27 | <pre> |
| 28 | add_action('acf/render_field/name=<?php echo $field_name; ?>', 'my_acf_dynamic_message'); |
| 29 | function my_acf_dynamic_message(){ |
| 30 | |
| 31 | echo 'Hello World'; |
| 32 | |
| 33 | } |
| 34 | </pre> |
| 35 | <?php |
| 36 | |
| 37 | $message = ob_get_clean(); |
| 38 | |
| 39 | // field_type |
| 40 | acf_render_field_setting($field, array( |
| 41 | 'label' => __('Instructions','acf'), |
| 42 | 'instructions' => '', |
| 43 | 'type' => 'message', |
| 44 | 'name' => 'instructions', |
| 45 | 'message' => $message, |
| 46 | 'new_lines' => false |
| 47 | )); |
| 48 | |
| 49 | } |
| 50 | |
| 51 | } |
| 52 | |
| 53 | new acfe_field_dynamic_message(); |