name = 'button'; $this->label = __('Button'); $this->category = __("Basic",'acf'); // Basic, Content, Choice, etc $this->defaults = array(); // do not delete! parent::__construct(); // settings $this->settings = array( 'path' => apply_filters('acf/helpers/get_path', __FILE__), 'dir' => apply_filters('acf/helpers/get_dir', __FILE__), 'version' => '1.0.0' ); } /* * create_options() * * Create extra options for your field. This is rendered when editing a field. * The value of $field['name'] can be used (like bellow) to save extra data to the $field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ function create_options( $field ) { // defaults? $field = array_merge($this->defaults, $field); // key is needed in the field names to correctly save the data $key = $field['name']; // Create Field Options HTML } /* * create_field() * * Create the HTML interface for your field * * @param $field - an array holding all the field's data * * @type action * @since 3.6 * @date 23/01/13 */ function create_field( $field ) { $field = array_merge($this->defaults, $field); $field_name = esc_attr( $field['name'] ); $use_internal = $field['value']['use_internal'] === 'false' ? false : true; $external_class = $use_internal ? 'hidden' : null; $internal_class = $use_internal ? null : 'hidden'; $switch_text = $use_internal ? 'external' : 'internal'; ?>
'post_object', 'name' => $field_name . '[page_id]', 'value' => $field['value']['page_id'] )); ?>

Switch to link

settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version'] ); wp_register_style( 'acf-input-button', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version'] ); // scripts wp_enqueue_script(array( 'acf-input-button', )); // styles wp_enqueue_style(array( 'acf-input-button', )); } /* * format_value_for_api() * * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value which was loaded from the database * @param $post_id - the $post_id from which the value was loaded * @param $field - the field array holding all the field options * * @return $value - the modified value */ function format_value_for_api( $value, $post_id, $field ) { $field = array_merge($this->defaults, $field); $button = $value; // $field_name = esc_attr( $field['label'] ); $field_name = preg_replace('/\s*/', '', $field['label']); // convert the string to all lowercase $classname = strtolower($field_name); $use_internal = $button['use_internal'] == 'true' ? true : false; $target = $use_internal ? null : ' target="_blank"'; $link = $use_internal ? get_permalink($button['page_id']) : $button['link']; $value = '' . $button['text'] . ''; return $value; } } new acf_field_button();