name = 'acf_code_field'; $this->label = __( 'ACF Code Field' ); $this->category = __( "Code Tools", 'acf' ); // Basic, Content, Choice, etc $this->defaults = array( 'default_value' => '', 'formatting' => 'br', 'maxlength' => '', 'placeholder' => '', 'rows' => '', 'mode' => 'htmlmixed', 'theme' => 'monokai', ); // 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 below) to save extra data to the $field * * @type action * @since 3.6 * @date 21/03/2016 * * @param $field - an array holding all the field's data */ function create_options($field) { // vars $key = $field['name']; ?>

'textarea', 'name' => 'fields[' . $key . '][default_value]', 'value' => $field['default_value'], ) ); ?>

'text', 'name' => 'fields[' . $key . '][placeholder]', 'value' => $field['placeholder'], ) ); ?> 'select', 'name' => 'fields[' . $key . '][mode]', 'value' => $field['mode'], 'choices' => array( 'htmlmixed' => __( "HTML Mixed", 'acf' ), 'javascript' => __( "JavaScript", 'acf' ), 'text/html' => __( "HTML", 'acf' ), 'css' => __( "CSS", 'acf' ), 'application/x-httpd-php' => __( "PHP", 'acf' ), ), 'layout' => 'horizontal', ) ); ?> 'select', 'name' => 'fields[' . $key . '][theme]', 'value' => $field['theme'], 'choices' => $util->get_codemirror_themes(), 'layout' => 'horizontal', ) ); ?> '; $e .= esc_textarea( $field['value'] ); $e .= ''; // return echo $e; $dir = trailingslashit( plugin_dir_url( __FILE__ ) ); wp_enqueue_style( 'codemirror-curr-style-' . $field['theme'], "{$dir}js/" . ACFCF_CODEMIRROR_VERSION . "/theme/{$field['theme']}.css" ); ?> defaults, $field); */ // perhaps use $field['preview_size'] to alter the $value? // Note: This function can be removed if not used return $value; } /* * format_value_for_api() * * This filter is applied 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 21/03/2016 * * @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) { // defaults? /* $field = array_merge($this->defaults, $field); */ // perhaps use $field['preview_size'] to alter the $value? // Note: This function can be removed if not used return $value; } /* * load_field() * * This filter is applied to the $field after it is loaded from the database * * @type filter * @since 3.6 * @date 21/03/2016 * * @param $field - the field array holding all the field options * * @return $field - the field array holding all the field options */ function load_field($field) { // Note: This function can be removed if not used return $field; } /* * update_field() * * This filter is applied to the $field before it is saved to the database * * @type filter * @since 3.6 * @date 21/03/2016 * * @param $field - the field array holding all the field options * @param $post_id - the field group ID (post_type = acf) * * @return $field - the modified field */ function update_field($field, $post_id) { // Note: This function can be removed if not used return $field; } } // create field new acf_code_field_v4(); ?>