{"id":9027,"date":"2010-05-02T23:15:37","date_gmt":"2010-05-02T23:15:37","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/easy-custom-fields\/"},"modified":"2012-07-11T14:45:41","modified_gmt":"2012-07-11T14:45:41","slug":"easy-custom-fields","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/easy-custom-fields\/","author":1128199,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.6","stable_tag":"trunk","tested":"3.3.2","requires":"2.9.2","requires_php":"","requires_plugins":"","header_name":"Easy Custom Fields","header_author":"Thorsten Ott","header_description":"","assets_banners_color":"","last_updated":"2012-07-11 14:45:41","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/wordpress.org\/extend\/plugins\/easy-custom-fields\/","header_author_uri":"http:\/\/automattic.com","rating":0,"author_block_rating":0,"active_installs":60,"downloads":9499,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":{"1":"Simple and advance post meta fields generated by this class."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[2010,25485,4586,25484],"plugin_category":[],"plugin_contributors":[77494,78260],"plugin_business_model":[],"class_list":["post-9027","plugin","type-plugin","status-publish","hentry","plugin_tags-custom-fields","plugin_tags-custom-post-fields","plugin_tags-post-meta","plugin_tags-post_meta","plugin_contributors-automattic","plugin_contributors-tott","plugin_committers-tott"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/easy-custom-fields.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Features:<\/p>\n\n<ul>\n<li>simply generate post boxes with multiple fields \/ groups<\/li>\n<li>easily validate\/sanitize input and output data<\/li>\n<li>easy access to field data via $easy_cf-&gt;field_id-&gt;get() or $easy_cf-&gt;field_id-&gt;get( NULL, $raw=true );<\/li>\n<li>get error messages for validation failures via admin notices<\/li>\n<li>custom post type aware<\/li>\n<li>extendable to your needs by extending Easy_CF_Field and Easy_CF_Validator classes (see advanced usage)<\/li>\n<\/ul>\n\n<p>As this script is mainly meant as basis for developers it needs minor coding skills to add this functionality\nto your theme.<\/p>\n\n<p>In order to make use of this class simply initialize it from the functions.php file of your theme as described below.<\/p>\n\n<h4>Simple Usage<\/h4>\n\n<pre><code>require_once( WP_PLUGIN_DIR . '\/easy-custom-fields\/easy-custom-fields.php' );\n$field_data = array (\n    'testgroup' =&gt; array (              \/\/ unique group id\n        'fields' =&gt; array(              \/\/ array \"fields\" with field definitions\n            'field1'    =&gt; array(),     \/\/ globally unique field id\n            'field2'    =&gt; array(),\n            'field3'    =&gt; array(),\n        ),\n    ),\n);\n$easy_cf = new Easy_CF($field_data);\n<\/code><\/pre>\n\n<h4>Advanced Usage<\/h4>\n\n<pre><code>require_once( WP_PLUGIN_DIR . '\/easy-custom-fields\/easy-custom-fields.php' );\n$field_data = array (\n    'testgroup' =&gt; array (\n        'fields' =&gt; array(\n            'field1'    =&gt; array(),\n            'field2'    =&gt; array(),\n            'field3'    =&gt; array(),\n        ),\n    ),\n    'advanced_testgroup' =&gt; array (                                     \/\/ unique group id\n        'fields' =&gt; array(                                              \/\/ array \"fields\" with field definitions \n            'advanced_field'    =&gt; array(                               \/\/ globally unique field id\n                'label'         =&gt; 'Advanced Field Description',        \/\/ Field Label\n                'hint'          =&gt; 'Long Advanced Field description',   \/\/ A descriptive hint for the field\n                'type'          =&gt; 'textarea',                          \/\/ Custom Field Type (see Ref: field_type)\n                'class'         =&gt; 'aclass',                            \/\/ CSS Wrapper class for the field\n                'input_class'   =&gt; 'theEditor',                         \/\/ CSS class for the input field\n                'error_msg'     =&gt; 'The Advanced Field is wrong' ),     \/\/ Error message to show when validate fails\n                'validate'      =&gt; 'validatorname',                     \/\/ Custom Validator (see Ref: validator)\n            'advanced_email' =&gt; array(\n                'label' =&gt; 'Email',\n                'hint' =&gt; 'Enter your email',\n                'validate' =&gt; 'email', )\n        ),\n        'title' =&gt; 'Product Description',   \/\/ Group Title\n        'context' =&gt; 'advanced',            \/\/ context as in http:\/\/codex.wordpress.org\/Function_Reference\/add_meta_box\n        'pages' =&gt; array( 'post', 'page' ), \/\/ pages as in http:\/\/codex.wordpress.org\/Function_Reference\/add_meta_box\n    ),\n);\n\nif ( !class_exists( \"Easy_CF_Validator_Email\" ) ) {\n\n    class Easy_CF_Validator_Email extends Easy_CF_Validator {\n        public function get( $value='' ) {\n            return esc_attr( $value );\n        }\n\n        public function set( $value='' ) {\n            $value = esc_attr( trim( stripslashes( $value ) ) );\n            return $value;\n        }\n\n        public function validate( $value='' ) {\n            if ( empty( $value ) || is_email( $value ) ) \n                return true;\n            else\n                return false;\n        }\n    }\n}\n\nif ( !class_exists( \"Easy_CF_Field_Textarea\" ) ) {\n    class Easy_CF_Field_Textarea extends Easy_CF_Field {\n        public function print_form() {\n            $class = ( empty( $this-&gt;_field_data['class'] ) ) ? $this-&gt;_field_data['id'] . '_class' :  $this-&gt;_field_data['class'];\n            $input_class = ( empty( $this-&gt;_field_data['input_class'] ) ) ? $this-&gt;_field_data['id'] . '_input_class' :  $this-&gt;_field_data['input_class'];\n\n            $id = ( empty( $this-&gt;_field_data['id'] ) ) ? $this-&gt;_field_data['id'] :  $this-&gt;_field_data['id'];\n            $label = ( empty( $this-&gt;_field_data['label'] ) ) ? $this-&gt;_field_data['id'] :  $this-&gt;_field_data['label'];\n            $value = $this-&gt;get();\n            $hint = ( empty( $this-&gt;_field_data['hint'] ) ) ? '' :  '&lt;p&gt;&lt;em&gt;' . $this-&gt;_field_data['hint'] . '&lt;\/em&gt;&lt;\/p&gt;';\n\n            $label_format =\n                '&lt;div class=\"%s\"&gt;'.\n                '&lt;p&gt;&lt;label for=\"%s\"&gt;&lt;strong&gt;%s&lt;\/strong&gt;&lt;\/label&gt;&lt;\/p&gt;'.\n                '&lt;p&gt;&lt;textarea class=\"%s\" style=\"width: 100%%;\" type=\"text\" name=\"%s\"&gt;%s&lt;\/textarea&gt;&lt;\/p&gt;'.\n                '%s'.\n                '&lt;\/div&gt;';\n            printf( $label_format, $class, $id, $label, $input_class, $id, $value, $hint );\n        }\n    }\n}\n\n$easy_cf = new Easy_CF($field_data);\n<\/code><\/pre>\n\n<h4>Note<\/h4>\n\n<p>If you're not using auto_init then meta boxes need to be added individually using\nadd_meta_box( $group_id, $group_title, array( &amp;$easy_cf, 'meta_box_cb' ), $page, $group_context );\nand the save methods need to be initialized after adding all meta boxes using\n$easy_cf-&gt;add_save_method();<\/p>","raw_excerpt":"This is a set of extendable classes to allow easy handling of custom post fields.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/9027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=9027"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/tott"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=9027"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=9027"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=9027"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=9027"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=9027"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=9027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}