Git Product home page Git Product logo

custom-meta-boxes's Introduction

This project is no longer actively maintained, please refer to CMB2 for meta-boxes.

HM Custom Meta Boxes for WordPress
A framework for easily adding custom fields to the WordPress post edit page
A Human Made project.

It includes several field types including WYSIWYG, media upload and dates (see wiki for a full list). It also supports repeatable and grouped fields.

This project is aimed at developers and is easily extended and customized. It takes a highly modular, Object Orientated approach, with each field as an extension of the CMB_Field abstract class.

The framework also features a basic layout engine for fields, allowing you to align fields to a simple 12 column grid.

Overview

Usage

Help

  • For more information, including example code for usage of each field and instructions on how to create your own fields, refer to the Wiki.
  • Not covered in the Wiki? Need more help? Get in touch. [email protected] or ping @mikeselander
  • Found a bug? Feature requests? Create an issue - Thanks!

About

This plugin is maintained by Human Made Limited

It began as a fork of Custom Meta Boxes, but is no longer compatible.

Minimum Requirements:

  • PHP >= 5.4
  • WP >= 4.1

Known Issues

  • Some fields do not work well as repeatable fields.
  • Some fields do not work well in repeatable groups.

Contribution Guidelines

See CONTRIBUTING.md

Changelog

1.1

Enhancements

  • Added group field filter
  • Cleaned up file upload styles
  • Added Hindi translation (props @ajitbohra)
  • Move all field classes to their own files
  • Add min/max attributes to number input (props @shadvb)
  • Use site language with Google Maps field (props @barryceelen)

Bug Fixes

  • Filter all arguments, not just select ones
  • Only attempt to call getimagesize() if the icon is local (props @joehoyle)
  • Add Dutch and German translations (props @barryceelen)
  • Align the file button vertically (props @ocean90)
  • Fix for multiple wysiwyg fields not displaying in groups (props @tareiking)
  • Fix incorrect gmap grouped field structure (props @dan-westall)
  • Fix enqueuing of cmb-scripts (props @barryceelen)

1.0.3

  • Fix repeatable fields bugs (props @barryceelen )
  • Fix gmaps field bug where key doesn't pass in correctly (props: @shadyvb )
  • PHPUnit tests for repeatable fields
  • Fix all minor WordPress VIP PHPCS errors/warnings
  • Write and complete inline documentation/doc blocks

1.0.2

  • Add google maps field
  • Add hide_on field argument
  • Add Composer support
  • Enhancement - enable for attachments
  • Fix bug with unattached images on custom post types
  • Fix error in WYSIWYG
  • Fix fields not getting correctly initialized if meta box is collapsed on page load
  • Fix bug with page-template restricted meta boxes showing if the post hasn't been saved at all.
  • Hook CMB in later - most post types & taxonomies should be registered then.
  • Fix Issue where different default values are used on save and init.

1.0.1

  • Fix bug - AJAX post select field displaying incorrect content.

1.0

  • Initial stable version of the fork.

custom-meta-boxes's People

Contributors

ajitbohra avatar banago avatar barryceelen avatar billerickson avatar dan-westall avatar danielck avatar dashaluna avatar destos avatar garyjones avatar joehoyle avatar mattheu avatar mehulkaklotar avatar mikeselander avatar norcross avatar paulgibbs avatar randyhoyt avatar richardswain avatar roborourke avatar shadyvb avatar simondowdles avatar stompweb avatar swissspidy avatar sxalexander avatar tareiking avatar tareq1988 avatar tcrsavage avatar tfrommen avatar tomaszbakula avatar willmot avatar yoren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-meta-boxes's Issues

Update readme with correct field types

what are the values for the type for the inline radio and color picker fields?

I found the $map array in the custom-meta-boxes file, but it doesn't have those fields. But the readme say they're supported.
I tried radio_inline, but that throws an error.

Current Version working?

Hello!

I just wanted to try your custom meta boxes. I included the file custom-meta-boxes.php and the example-functions.php.
After doing that, the example metaboxes show up correctly. But when i click the "Add New" button of one of the two example repeatable fields, i get the following error in the console:

Uncaught query function not defined for Select2 s2id_group-1[input4][]-0
File: select2.js Line 871

This is using the latest select 2.

Edit: Also, if disabling all repeatables, values in all other fields are not saved

I would really appreciate any help :)

Repeatable Image upload

Image upload fields need to be reinitialized when adding new fields -in repeatable image upload fields or within repeatable groups

Taxonomy Select Terms Not Saved

Hi

I have populated the taxonomy select with my given category, upon saving the post this term is not saved against the post.

When saved through the default Wordpress interface this saves correctly.

Possible bug?

Cheers

John

Adding new fields type.

Hi devs,

I need to add a new custom field type, a map namely. I can see it is quite easy to do so, a) add a class that extends the abstract class and then map the new type.

No, I can easily do this on the files, but it would be great not to mess with the project files so that they are easy to update.

Any plan to add an extend API to the library?

How to add this to a theme?

This not be the right place to ask, but would really appreciate if someone could let me know how to include this in my theme.

The method I followed from the original script did not work here.

class_attr incorrectly santizes classes

function class_attr( $classes = '' ) {
in classes.fields.php uses esc_attr_e, which removes spaces from the string.

This means that when used with multiple classes as in class CMB_Time_Field (and multiple other places)

<input <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_timepicker' ); ?> type="text" name="<?php esc_attr_e( $this->name ); ?>" value="<?php esc_attr_e( $this->value ); ?>"/>

It returns incorrect class: cmb_text_smallcmb_timepicker (with space stripped out).

Solution would be to run esc_attr_e within a loop and not on the imploded class.

Sorry for not providing a patch, I'm not sure how much would this change affect whole code and I'm still reading through the code base.

Sortable WYSIWYG not reinitialised correctly.

If sort is started when editor is on html mode, visual editor is initialised incorreclty when sort is stopped, resulting in both quicktags buttons, and a tinyMCE editor with incorrect theme

Delete / remove repeatable field contained within a 'group'

From my observations, I have noticed that the delete / remove button for repeatable fields doesn't appear when that field is contained within a group.

Also, groups that are set to repeatable also do not have the delete / remove option.

The sortable functionality still appears to work in both circumstances.

Has anyone else noticed this issue?

Datetime_unix bug when removing the date

When removing the previously entered date is remove and save, php throws an error on page load visible in the field.

Update: the bug also happens when no value is entered and we try to save the post.

Problem with group

Hi I have a problem with the new features to group fields and to repeateble. My wordpress give me a Warning:

"Invalid argument supplied for foreach() in C:\xampp\htdocs\tresculturas\wp-content\themes\revista_tresculturas\lib\metabox\init.php on line 109"

I download the file.zip from "humanmade custom-meta-box", and include after the init.php from jaredatch custom-meta-box, because there is not init.php in "humanmade custom-meta-box".

Can you give an idea?

Thanks and sorry for my english.

CMB_URL wrong when CMB in (child) theme

When including CMD in a child theme (eg: /lib/metaboxes) the line 37 in custom-meta-boxes.php sets the wrong URL.

define( 'CMB_URL', plugin_dir_url( __FILE__ ) );

Content of CMB_URL is plugin url + path to file

http://domain.dev/wp-content/plugins/[serverroot]/path/to/wordpress/wp-content/themes/theme/lib/metabox/

You probably did this because of usage in plugins?

Repeatable groups Not saving.

Repeatable groups are not saving. I am using URL and Text Fields only. If I turn repeatable off I can save 1 row of information.

Sortable Fields & Groups

This would be a great feature to have, and has been requested several times, so I am creating this issue to keep all info on this in one place.

Required features

  • Sortable repeatable fields
  • Sortable repeatable groups
  • Sortable repeatable fields in groups (that may be sortable & repeatable)
  • Handle TinyMCE

We did look into this ages ago - but I think there were some issues with get_post_meta not returning meta in the order of meta_id. I have done some very basic testing, and it seems OK, but I think @joehoyle unit tested this and found that it was not always correct. Perhaps we can check this again, and confirm the issue?

Also the UI for this could be complex - particularly for groups. Any thoughts would be appreciated.

WYSIWYG Field type issues inside repeatable groups

Hi, playing around with this doing some tests and checking it out. So far like what I'm seeing.

I'm seeing some issues with the WYSIWYG Field type when it's placed inside a repeatable group. When adding a new group, if it loads on the "Visual" tab it loads incorrectly and isn't editable - looks like http://mas.im/OIFU . If it loads on the "Text" tab, it loads fine and switching over to the "Visual" tab works as intended.

Things seems to break down when adding additional groups. The WYSIWYG editor tabs no longer work.

Am I building this incorrectly?

$meta_boxes[] = array(
    'title' => 'Interview Data',
    'pages' => 'interview',
    'context'    => 'normal',
    'priority'   => 'high',
    'show_names' => true, // Show field names on the left
    'fields' => array(

        array(
                'id'   => $prefix . 'interviewee-display-name',
            'name' => 'Interviewee Info',
            'type' => 'group', 
            'style' => 'background: #f1f1f1; border-radius: 4px; border: 1px solid #e2e2e2; margin-bottom: 10px; padding: 10px', 
            'repeatable' => false, 
            'fields' => array(
                array( 
                    'id'   => $prefix . 'interviewee-display-name',
                    'name' => 'Interviewee Display Name (Shown below thumbnail)',
                    'type' => 'text' 
                ),
                array(
                    'id'    => $prefix . 'interviewee-email',
                    'name'  => 'Interviewee Email (Used to fetch gravatar thumbnail)',
                    'type'  => 'text'
                ),
            ) 
        ),

        array( 
            'id' => $prefix . 'qa-items', 
            'name' => 'Interview Q/A Items', 
            'type' => 'group', 
            'cols' => 12, 
            'repeatable' => true,
            'fields' => array( 
                array(
                    'name'    => 'Q/A Item Type',
                    'id'      => $prefix . 'q-a-item-type',
                    'type'    => 'radio',
                    'options' => array(
                        'q'  => 'Question',
                        'a'  => 'Answer',
                    ),
                ),
                array(
                    'name'    => 'Q/A Item Content',
                    'id'      => $prefix . 'q-a-item-content',
                    'type'    => 'wysiwyg',
                    'options' => array(
                        'textarea_rows' => 12,
                        'teeny'         => false,
                        'media_buttons' => true,
                    ),
                )
            )
        )
    )
);

Not Working at all

Hi, I looked at the documentation of the original and is has examples of how to display metabox fields created in a template on the front-end

This fork does not work with that method of displaying the fields. I have created several meta boxes only to realise that I have to use something else because I can't seem find any documentation of how to display single fields, repeat groups or anything for that matter.

Can someone please help with general ways of displaying fields including repeating fields and groups in a template apart from that its a excellent improvement to the original.

Thanks

Trying to add a repeatable group - documentation seems poor.

Hi,

I'm trying to create a repeatable group of fields, but the wiki is letting me down on this.

I've tried two ways with mixed results. The first (which seems very wrong) is to add the "field" to the top level of the meta_boxes array.

  $meta_boxes[] = array(
      'title' => 'Winter Rates',
      'pages' => 'properties',
      'context' => 'normal',
      'priority' => 'high',
      'type' => 'group',
      'repeatable' => true,
      'fields' => getSeasonalFields()
  );

This just behaves the same as adding "repeatable" to each field. Not what I assumed a repeatable group would do.

Next I tried adding the group as a field.

function seasonal_rate(array $meta_boxes) {
  $meta_boxes[] = array(
      'title' => 'Winter Rates',
      'pages' => 'properties',
      'context' => 'normal',
      'priority' => 'high',
      'fields' => seasonalGroups()
  );
}

Which grabs...

function seasonalGroups() {

  $fields = seasonalFields();

  $groups = array(
      'id' => 'room_rates',
      'name' => 'Room Rates',
      'type' => 'group',
      'cols' => 12,
      'fields' => $fields
  );
  return $groups;
}

However this throws an exception:

Fatal error: Class name must be a valid object or a string in class.cmb-meta-box.php on line 86

Am I even close?

Post Select Usage Examples

I was wondering if anyone could provide some examples for how to use the post_select field type in a page template.

I'm trying to extract the permalink, title, and excerpt from the selected posts and I'm not having much luck.

Any guidance would be much appreciated.

Post select field breakes when repeatable

Hi guys,

Just found out that the post select field with use_ajax => true does not work in a repeatable mode. This might be an JavaScript issues since the html element is created on the fly.

Capability type 'edit_posts'

In ./core/side-post.php, the following code determines if the custom meta box will be shown for the connections:

        function can_edit_connections() {
                try {
                        return current_user_can( $this->get_ptype()->cap->edit_posts );
                } catch ( P2P_Exception $e ) {
                        trigger_error( $e->getMessage(), E_USER_WARNING );
                        return false;
                }
        }

Doesn't it make more sense to use "read_post" instead of "edit_posts"? That way, links can still be created to another post type that the editing user doesn't necessarily have access rights to.

Right now I'm using this code as a submodule. Is there another way of showing the custom meta box without this change, when the user only has read_post capability and not edit_posts for the linked post type?

Notice: Undefined index: name in class.cmb-meta-box.php on line 266

When adding a repeatable group and trying to save data (with WP_DEBUG set to true) I'm greeted with this little beauty

Notice: Undefined index: name in class.cmb-meta-box.php on line 266

It's actually using the 'Test Meta-Box' from your demo thus:

$meta_boxes[] = array(
    'title' => 'Test Meta-Box',
    'pages' => 'post',
    'context'    => 'normal',
    'priority'   => 'high',
    'show_names' => true, // Show field names on the left
    'fields' => array(
        array( 'id' => 'group', 'repeatable' => true, 'type' => 'group', 'fields' => array(
            array( 'id' => 'input24', 'name' => 'Text (12 cols, sub field)', 'type' => 'taxonomy_select', 'cols' => 12, 'taxonomy' => 'category', 'repeatable' => false ),
            array( 'id' => 'input22', 'name' => 'Text (12 cols, sub field)', 'type' => 'text', 'cols' => 12, 'taxonomy' => 'category', 'repeatable' => false ),
        ) ) 
    )
);

If I give the 'group' and 'name' attribute such as

'fields' => array(
            array( 'id' => 'group', 'name' => 'ADDED_THIS_HERE', 'repeatable' => true, 'type' => 'group', 'fields' => array(
                array( 'id' => 'input24', 'name' => 'Text (12 cols, sub field)', 'type' => 'taxonomy_select', 'cols' => 12, 'taxonomy' => 'category', 'repeatable' => false ),
                array( 'id' => 'input22', 'name' => 'Text (12 cols, sub field)', 'type' => 'text', 'cols' => 12, 'taxonomy' => 'category', 'repeatable' => false ),
            ) ) 
        )

Then the error no longer happens, but, as expected, it's not saved.

Sorting Repeatable Groups

I'm banging my head on the wall here, any help would be appreciated. When I input data into the repeatable groups, how is it sorting by default? In as far as I can tell, they just order randomly. Is there a way to control this?

I'm working on a way to sort them on my custom post type template, but would be nice for them to be sorted on the post creation page as well. Although, my overall php is weak and I'm having some trouble getting the groups to sort how I want on my template, but getting close.

image inserted via media uploader sometimes gets added to previous box

@mattheu in a repeatable group of fields with title and WYSIWYG, I inserted an image via the media uploader, with the focus/cursor inside the WYSIWYG, but the image gets added to the previous field instead of the one currently being edited.
This issue seems to be fixed by first saving the post between adding a new group

Missing select2.js and select2.css files

Hi,
I get the next console error:

GET http://www.tfingi.dev/wp-content/themes/tfingi/functions/custom_meta_boxes/js/select2/select2.js?ver=3.5.1 404 (Not Found)
GET http://www.tfingi.dev/wp-content/themes/tfingi/functions/custom_meta_boxes/js/select2/select2.css?ver=3.5.1 404 (Not Found) 

Date Picker Style Bug

A border is applied on hover causing it to jump around when trying to select a date. Not very nice!

Meta Boxes for different object types, not just posts

I was just wondering if you have any plans to continue with the work started on the cmb_add_meta_box branch?

I'm really interested in the idea of extending an abstract CMB_Meta_Boxes class to allow for adding meta data to pretty much anything within WordPress, such as taxonomy terms (possibly using your termmeta project as the storage for the metadata), users, or wp-admin pages for example (using the wp_options table for storage). I can really see this pushing Custom-Meta-Boxes way ahead of other similar projects by offering a standardised way of attaching custom fields/metadata to pretty much any object within WordPress, and not just posts.

It would be great to open up a discussion on where you see this heading, and if you have any plans for continuing along this route?

Nested repeatable group

Is it possible to have a repeatable group that contains within it, another repeatable group? Not to get too "Inception" here, but I have a project that could use such a thing. I didn't see any mention anywhere in the repo about this.

Querying Grouped Meta

Hi

The facility to repeat groups of fields is fantastic however how is one supposed to Query this data?

For example I have 6 keys in the meta table for a single post with key "course-dates", each key contains 2 entries "coursedates-start" and "course-dates-end".

            <?php   
            $dates = get_post_custom ( $post->ID ); 
            $date = $dates['course-dates'];
            foreach ( $date as $d ) {
            $rpt = unserialize( $d );
            echo $rpt['course-dates-start'].' - '.$rpt['course-dates-end'];
            echo '<br/>';
            }
            ?>

I managed to get them all printed out but how can I query the data from all keys to find say the next start date?

Cant see any Wordpress provided function to help? Any direction appreciated

Regards

John

Post select field values from custom post type

I'm using the below code to save the name of a post in the post type "task", the post names show up in the drop down select box but are saving as a number(?). If I set the ajax selection to true the select box is empty. Is this a bug or am I doing something wrong?

array(
'id' => 'time_task_post',
'name' => 'Choose Task:',
'type' => 'post_select',
'use_ajax' => false,
'query' => array(
'post_type' => array( 'task' )
)
),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.