• The best import export plugin
  • Supports very large files
  • Simple interface & flexible API
  • Import, Export, Migrate, Bulk Edit

Easy Custom Fields

by Thorsten Ott

0 Ratings

Active Installations

70+

Last Update

12 years

Quality

D

Plugin Description

Description
Features:
simply generate post boxes with multiple fields / groups
easily validate/sanitize input and output data
easy access to field data via $easy_cf->field_id->get() or $easy_cf->field_id->get( NULL, $raw=true );
get error messages for validation failures via admin notices
custom post type aware
extendable to your needs by extending Easy_CF_Field and Easy_CF_Validator classes (see advanced usage)
As this script is mainly meant as basis for developers it needs minor coding skills to add this functionality
to your theme.
In order to make use of this class simply initialize it from the functions.php file of your theme as described below.
Simple Usage
require_once( WP_PLUGIN_DIR . ‘/easy-custom-fields/easy-custom-fields.php’ );
$field_data = array (
‘testgroup’ => array ( // unique group id
‘fields’ => array( // array “fields” with field definitions
‘field1’ => array(), // globally unique field id
‘field2’ => array(),
‘field3’ => array(),
),
),
);
$easy_cf = new Easy_CF($field_data);
Advanced Usage
require_once( WP_PLUGIN_DIR . ‘/easy-custom-fields/easy-custom-fields.php’ );
$field_data = array (
‘testgroup’ => array (
‘fields’ => array(
‘field1’ => array(),
‘field2’ => array(),
‘field3’ => array(),
),
),
‘advanced_testgroup’ => array ( // unique group id
‘fields’ => array( // array “fields” with field definitions
‘advanced_field’ => array( // globally unique field id
‘label’ => ‘Advanced Field Description’, // Field Label
‘hint’ => ‘Long Advanced Field description’, // A descriptive hint for the field
‘type’ => ‘textarea’, // Custom Field Type (see Ref: field_type)
‘class’ => ‘aclass’, // CSS Wrapper class for the field
‘input_class’ => ‘theEditor’, // CSS class for the input field
‘error_msg’ => ‘The Advanced Field is wrong’ ), // Error message to show when validate fails
‘validate’ => ‘validatorname’, // Custom Validator (see Ref: validator)
‘advanced_email’ => array(
‘label’ => ‘Email’,
‘hint’ => ‘Enter your email’,
‘validate’ => ’email’, )
),
‘title’ => ‘Product Description’, // Group Title
‘context’ => ‘advanced’, // context as in https://codex.wordpress.org/Function_Reference/add_meta_box
‘pages’ => array( ‘post’, ‘page’ ), // pages as in https://codex.wordpress.org/Function_Reference/add_meta_box
),
);

if ( !class_exists( “Easy_CF_Validator_Email” ) ) {

class Easy_CF_Validator_Email extends Easy_CF_Validator {
public function get( $value=” ) {
return esc_attr( $value );
}

public function set( $value=” ) {
$value = esc_attr( trim( stripslashes( $value ) ) );
return $value;
}

public function validate( $value=” ) {
if ( empty( $value ) || is_email( $value ) )
return true;
else
return false;
}
}
}

if ( !class_exists( “Easy_CF_Field_Textarea” ) ) {
class Easy_CF_Field_Textarea extends Easy_CF_Field {
public function print_form() {
$class = ( empty( $this->_field_data[‘class’] ) ) ? $this->_field_data[‘id’] . ‘_class’ : $this->_field_data[‘class’];
$input_class = ( empty( $this->_field_data[‘input_class’] ) ) ? $this->_field_data[‘id’] . ‘_input_class’ : $this->_field_data[‘input_class’];

$id = ( empty( $this->_field_data[‘id’] ) ) ? $this->_field_data[‘id’] : $this->_field_data[‘id’];
$label = ( empty( $this->_field_data[‘label’] ) ) ? $this->_field_data[‘id’] : $this->_field_data[‘label’];
$value = $this->get();
$hint = ( empty( $this->_field_data[‘hint’] ) ) ? ” : ‘

‘ . $this->_field_data[‘hint’] . ‘

‘;

$label_format =

‘.

‘.

‘.
‘%s’.

‘;
printf( $label_format, $class, $id, $label, $input_class, $id, $value, $hint );
}
}
}

$easy_cf = new Easy_CF($field_data);
Note
If you’re not using auto_init then meta boxes need to be added individually using
add_meta_box( $group_id, $group_title, array( &$easy_cf, ‘meta_box_cb’ ), $page, $group_context );
and the save methods need to be initialized after adding all meta boxes using
$easy_cf->add_save_method();

Similar Plugins

  • Report Bug
The content on this website originates from various sources. All rights to the original content remain with the respective author. If you believe that your copyrights have been infringed by the use of content on this website, please contact us at info@plugin-guru.com. We will remove the content in question immediately.

This is the heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Collections

Create your first Collection

To create a collection, simply click on the symbol on the desired plugin.

You can see this symbol when you move the mouse over the plugin. 

Current Level

Plugin Magican

You have reached 0 views on your collections and are currently Plugin Magican. You magically help people find the right plugins and are a great asset to the community

0 of 500 views reached