diff --git a/examples/example-screen-advanced.php b/examples/example-screen-advanced.php index 22aae71..7d97f09 100644 --- a/examples/example-screen-advanced.php +++ b/examples/example-screen-advanced.php @@ -2,382 +2,386 @@ /** * Meta Fields (Screen - Advanced) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields-advanced', - 'title' => __( 'Example - All Fields Advanced' ), - 'screen' => array( 'post' ), - 'context' => 'advanced', - 'priority' => 'default', - 'fields' => array( - 'prefix-advanced-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-advanced-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-advanced-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-advanced-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields-advanced', + 'title' => __( 'Example - All Fields Advanced' ), + 'screen' => array( 'post' ), + 'context' => 'advanced', + 'priority' => 'default', + 'fields' => array( + 'prefix-advanced-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-advanced-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-advanced-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-advanced-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-advanced-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-advanced-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-advanced-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ) -) ); +); /** * Meta Fields (Grouped) (Screen - Advanced) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields-advanced-grouped', - 'title' => __( 'Example - All Fields (Grouped) Advanced' ), - 'screen' => array( 'post' ), - 'context' => 'advanced', - 'priority' => 'default', - 'groups' => array( - array( - 'title' => 'Group 1', - 'description' => 'Group Description', - 'fields' => array( - 'prefix-advanced-group-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-advanced-group-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-advanced-group-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields-advanced-grouped', + 'title' => __( 'Example - All Fields (Grouped) Advanced' ), + 'screen' => array( 'post' ), + 'context' => 'advanced', + 'priority' => 'default', + 'groups' => array( + array( + 'title' => 'Group 1', + 'description' => 'Group Description', + 'fields' => array( + 'prefix-advanced-group-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-advanced-group-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-advanced-group-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-advanced-group-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-advanced-group-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-advanced-group-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ), - ), - array( - 'title' => 'Group 2', - 'description' => 'Group 2 Description', - 'fields' => array( - 'prefix-advanced-group-2-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-advanced-group-2-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-advanced-group-2-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-advanced-group-2-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + array( + 'title' => 'Group 2', + 'description' => 'Group 2 Description', + 'fields' => array( + 'prefix-advanced-group-2-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-advanced-group-2-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-advanced-group-2-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-advanced-group-2-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-advanced-group-2-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-advanced-group-2-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-advanced-group-2-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), - ) - ) + ), + ), ) -)); \ No newline at end of file +); diff --git a/examples/example-screen-normal.php b/examples/example-screen-normal.php index ccc3062..f358d4e 100644 --- a/examples/example-screen-normal.php +++ b/examples/example-screen-normal.php @@ -2,382 +2,386 @@ /** * Meta Fields (Screen - Normal) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields', - 'title' => __( 'Example - All Fields' ), - 'screen' => array( 'post' ), - 'context' => 'normal', - 'priority' => 'default', - 'fields' => array( - 'prefix-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields', + 'title' => __( 'Example - All Fields' ), + 'screen' => array( 'post' ), + 'context' => 'normal', + 'priority' => 'default', + 'fields' => array( + 'prefix-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ) -) ); +); /** * Meta Fields (Grouped) (Screen - Normal) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields-grouped', - 'title' => __( 'Example - All Fields (Grouped)' ), - 'screen' => array( 'post' ), - 'context' => 'normal', - 'priority' => 'default', - 'groups' => array( - array( - 'title' => 'Group 1', - 'description' => 'Group Description', - 'fields' => array( - 'prefix-group-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-group-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-group-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-group-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-group-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-group-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-group-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-group-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-group-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-group-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-group-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-group-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-group-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-group-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields-grouped', + 'title' => __( 'Example - All Fields (Grouped)' ), + 'screen' => array( 'post' ), + 'context' => 'normal', + 'priority' => 'default', + 'groups' => array( + array( + 'title' => 'Group 1', + 'description' => 'Group Description', + 'fields' => array( + 'prefix-group-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-group-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-group-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-group-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-group-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-group-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-group-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-group-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-group-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-group-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-group-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-group-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-group-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-group-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-group-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-group-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ), - ), - array( - 'title' => 'Group 2', - 'description' => 'Group 2 Description', - 'fields' => array( - 'prefix-group-2-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-group-2-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-group-2-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-group-2-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-group-2-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-group-2-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-group-2-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-group-2-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-group-2-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-group-2-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-group-2-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-group-2-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-group-2-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-group-2-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + array( + 'title' => 'Group 2', + 'description' => 'Group 2 Description', + 'fields' => array( + 'prefix-group-2-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-group-2-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-group-2-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-group-2-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-group-2-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-group-2-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-group-2-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-group-2-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-group-2-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-group-2-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-group-2-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-group-2-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-group-2-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-group-2-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-group-2-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-group-2-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), - ) - ) + ), + ), ) -)); \ No newline at end of file +); diff --git a/examples/example-screen-side.php b/examples/example-screen-side.php index 7385dc8..5f93503 100644 --- a/examples/example-screen-side.php +++ b/examples/example-screen-side.php @@ -2,382 +2,386 @@ /** * Meta Fields (Screen - Side) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields-side', - 'title' => __( 'Example - All Fields Side' ), - 'screen' => array( 'post' ), - 'context' => 'side', - 'priority' => 'default', - 'fields' => array( - 'prefix-side-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-side-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-side-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-side-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-side-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-side-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-side-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-side-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-side-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-side-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-side-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-side-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-side-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-side-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields-side', + 'title' => __( 'Example - All Fields Side' ), + 'screen' => array( 'post' ), + 'context' => 'side', + 'priority' => 'default', + 'fields' => array( + 'prefix-side-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-side-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-side-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-side-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-side-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-side-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-side-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-side-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-side-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-side-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-side-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-side-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-side-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-side-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-side-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-side-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ) -) ); +); /** * Meta Fields (Grouped) (Screen - Side) */ -mf_add_meta_box( array( - 'id' => 'example-all-fields-side-grouped', - 'title' => __( 'Example - All Fields Side (Grouped)' ), - 'screen' => array( 'post' ), - 'context' => 'side', - 'priority' => 'default', - 'groups' => array( - array( - 'title' => 'Group 1', - 'description' => 'Group Description', - 'fields' => array( - 'prefix-side-group-1-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-side-group-1-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-side-group-1-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-side-group-1-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', +mf_add_meta_box( + array( + 'id' => 'example-all-fields-side-grouped', + 'title' => __( 'Example - All Fields Side (Grouped)' ), + 'screen' => array( 'post' ), + 'context' => 'side', + 'priority' => 'default', + 'groups' => array( + array( + 'title' => 'Group 1', + 'description' => 'Group Description', + 'fields' => array( + 'prefix-side-group-1-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-side-group-1-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-side-group-1-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-side-group-1-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-side-group-1-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-side-group-1-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-side-group-1-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), ), - ), - array( - 'title' => 'Group 2', - 'description' => 'Group 2 Description', - 'fields' => array( - 'prefix-side-group-2-text' => array( - 'type' => 'text', - 'title' => 'Text Field', - 'description' => 'Text Field field description goes here.', - 'hint' => 'Text Field field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-textarea' => array( - 'type' => 'textarea', - 'title' => 'Textarea', - 'description' => 'Textarea field description goes here.', - 'hint' => 'Textarea field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-password' => array( - 'type' => 'password', - 'title' => 'Password', - 'description' => 'Password field description goes here.', - 'hint' => 'Password field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-color' => array( - 'type' => 'color', - 'title' => 'Color', - 'description' => 'Color field description goes here.', - 'hint' => 'Color field description goes here.', - 'default' => '#f3f3f3', - ), - 'prefix-side-group-2-date' => array( - 'type' => 'date', - 'title' => 'Date', - 'description' => 'Date field description goes here.', - 'hint' => 'Date field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-datetime-local' => array( - 'type' => 'datetime-local', - 'title' => 'Date Time Local', - 'description' => 'Date Time Local field description goes here.', - 'hint' => 'Date Time Local field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-email' => array( - 'type' => 'email', - 'title' => 'Email', - 'description' => 'Email field description goes here.', - 'hint' => 'Email field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-month' => array( - 'type' => 'month', - 'title' => 'Month', - 'description' => 'Month field description goes here.', - 'hint' => 'Month field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-number' => array( - 'type' => 'number', - 'title' => 'Number', - 'description' => 'Number field description goes here.', - 'hint' => 'Number field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-time' => array( - 'type' => 'time', - 'title' => 'Time', - 'description' => 'Time field description goes here.', - 'hint' => 'Time field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-week' => array( - 'type' => 'week', - 'title' => 'Week', - 'description' => 'Week field description goes here.', - 'hint' => 'Week field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-url' => array( - 'type' => 'url', - 'title' => 'Url', - 'description' => 'Url field description goes here.', - 'hint' => 'Url field description goes here.', - 'default' => '', - ), - 'prefix-side-group-2-checkbox' => array( - 'type' => 'checkbox', - 'title' => 'Checkbox', - 'description' => 'Checkbox field description goes here.', - 'hint' => 'Checkbox field description goes here.', - 'default' => true, - ), - 'prefix-side-group-2-radio' => array( - 'type' => 'radio', - 'title' => 'Radio', - 'description' => 'Radio field description goes here.', - 'hint' => 'Radio field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + array( + 'title' => 'Group 2', + 'description' => 'Group 2 Description', + 'fields' => array( + 'prefix-side-group-2-text' => array( + 'type' => 'text', + 'title' => 'Text Field', + 'description' => 'Text Field field description goes here.', + 'hint' => 'Text Field field description goes here.', + 'default' => '', ), - ), - 'prefix-side-group-2-select' => array( - 'type' => 'select', - 'title' => 'Select', - 'description' => 'Select field description goes here.', - 'hint' => 'Select field description goes here.', - 'default' => 'one', - 'choices' => array( - 'one' => 'One', - 'two' => 'Two', - 'three' => 'Three', + 'prefix-side-group-2-textarea' => array( + 'type' => 'textarea', + 'title' => 'Textarea', + 'description' => 'Textarea field description goes here.', + 'hint' => 'Textarea field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-password' => array( + 'type' => 'password', + 'title' => 'Password', + 'description' => 'Password field description goes here.', + 'hint' => 'Password field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-color' => array( + 'type' => 'color', + 'title' => 'Color', + 'description' => 'Color field description goes here.', + 'hint' => 'Color field description goes here.', + 'default' => '#f3f3f3', + ), + 'prefix-side-group-2-date' => array( + 'type' => 'date', + 'title' => 'Date', + 'description' => 'Date field description goes here.', + 'hint' => 'Date field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-datetime-local' => array( + 'type' => 'datetime-local', + 'title' => 'Date Time Local', + 'description' => 'Date Time Local field description goes here.', + 'hint' => 'Date Time Local field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-email' => array( + 'type' => 'email', + 'title' => 'Email', + 'description' => 'Email field description goes here.', + 'hint' => 'Email field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-month' => array( + 'type' => 'month', + 'title' => 'Month', + 'description' => 'Month field description goes here.', + 'hint' => 'Month field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-number' => array( + 'type' => 'number', + 'title' => 'Number', + 'description' => 'Number field description goes here.', + 'hint' => 'Number field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-time' => array( + 'type' => 'time', + 'title' => 'Time', + 'description' => 'Time field description goes here.', + 'hint' => 'Time field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-week' => array( + 'type' => 'week', + 'title' => 'Week', + 'description' => 'Week field description goes here.', + 'hint' => 'Week field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-url' => array( + 'type' => 'url', + 'title' => 'Url', + 'description' => 'Url field description goes here.', + 'hint' => 'Url field description goes here.', + 'default' => '', + ), + 'prefix-side-group-2-checkbox' => array( + 'type' => 'checkbox', + 'title' => 'Checkbox', + 'description' => 'Checkbox field description goes here.', + 'hint' => 'Checkbox field description goes here.', + 'default' => true, + ), + 'prefix-side-group-2-radio' => array( + 'type' => 'radio', + 'title' => 'Radio', + 'description' => 'Radio field description goes here.', + 'hint' => 'Radio field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), + ), + 'prefix-side-group-2-select' => array( + 'type' => 'select', + 'title' => 'Select', + 'description' => 'Select field description goes here.', + 'hint' => 'Select field description goes here.', + 'default' => 'one', + 'choices' => array( + 'one' => 'One', + 'two' => 'Two', + 'three' => 'Three', + ), ), ), - ) - ) + ), + ), ) -)); +); diff --git a/examples/examples.php b/examples/examples.php index 4b2c94b..3b582c9 100644 --- a/examples/examples.php +++ b/examples/examples.php @@ -6,4 +6,4 @@ // Examples. require 'inc/wp-meta-fields/example-screen-side.php'; require 'inc/wp-meta-fields/example-screen-normal.php'; -require 'inc/wp-meta-fields/example-screen-advanced.php'; \ No newline at end of file +require 'inc/wp-meta-fields/example-screen-advanced.php'; diff --git a/src/wp-meta-fields.css b/src/wp-meta-fields.css index b673362..bbb41a2 100644 --- a/src/wp-meta-fields.css +++ b/src/wp-meta-fields.css @@ -1,49 +1,49 @@ #postbox-container-2 .wp-meta-fields-title { - padding: 1em 12px; + padding: 1em 12px; } #postbox-container-2 .wp-meta-fields-title h3 + p { margin: 7px 0 0 0; } #postbox-container-2 .wp-meta-fields-title h3 { margin: 0 0 0 0; - font-weight: normal; + font-weight: normal; } #postbox-container-2 .wp-meta-fields-title p { - margin: 0; + margin: 0; } #postbox-container-2 .wp-meta-fields-table textarea, #postbox-container-2 .wp-meta-fields-table input[type="url"], #postbox-container-2 .wp-meta-fields-table input[type="text"] { width: 100%; - width: calc( 100% - 40px ); + width: calc( 100% - 40px ); } #postbox-container-2 .wp-meta-fields-table { - border-right: none; - /* border-bottom: none; */ - border-left: none; - border-top: 1px solid #f0f0f0; - border-bottom: none; + border-right: none; + /* border-bottom: none; */ + border-left: none; + border-top: 1px solid #f0f0f0; + border-bottom: none; } #postbox-container-2 .wp-meta-fields-row td { - border-right: 1px solid #f0f0f0; - border-bottom: 1px solid #f0f0f0; + border-right: 1px solid #f0f0f0; + border-bottom: 1px solid #f0f0f0; } #postbox-container-2 .wp-meta-fields-heading { - background: #F9F9F9; - border-right: 1px solid #E1E1E1; - padding: 13px 15px; - width: 25%; - color: #333; - font-weight: bold; + background: #F9F9F9; + border-right: 1px solid #E1E1E1; + padding: 13px 15px; + width: 25%; + color: #333; + font-weight: bold; } #postbox-container-2 .wp-meta-fields-content { - padding: 13px 15px; - position: relative; + padding: 13px 15px; + position: relative; } #postbox-container-2 .wp-meta-fields-content .description { - margin: 5px 0 0 0; + margin: 5px 0 0 0; } /** * Side @@ -52,47 +52,47 @@ #side-sortables .wp-meta-fields-table input[type="url"], #side-sortables .wp-meta-fields-table input[type="text"] { width: 100%; - width: calc( 100% - 40px ); + width: calc( 100% - 40px ); } #side-sortables .wp-meta-fields-table tr { - display: flex; - flex-direction: column; - border-bottom: 1px solid #f0f0f0; + display: flex; + flex-direction: column; + border-bottom: 1px solid #f0f0f0; } #side-sortables .wp-meta-fields-table { - border: none; + border: none; } #side-sortables .wp-meta-fields-content, #side-sortables .wp-meta-fields-heading { - padding: 5px 10px; + padding: 5px 10px; } /** * Hint */ .wp-meta-fields-hint { - display: block; + display: block; } .wp-meta-fields-hint i { cursor: pointer; - position: absolute; - right: 10px; - top: 10px; + position: absolute; + right: 10px; + top: 10px; } /** * Disable Duplicates. */ .wp-meta-fields-duplicate { - background: #f1f1f1; + background: #f1f1f1; } .wp-meta-fields-duplicate input, .wp-meta-fields-duplicate select, .wp-meta-fields-duplicate textarea { - pointer-events: none; - background: rgba( 255, 255, 255, 0.5 ); - border-color: rgba( 222, 222, 222, 0.75 ); - box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.04 ); - color: rgba( 51, 51, 51, 0.5 ); + pointer-events: none; + background: rgba( 255, 255, 255, 0.5 ); + border-color: rgba( 222, 222, 222, 0.75 ); + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.04 ); + color: rgba( 51, 51, 51, 0.5 ); } diff --git a/src/wp-meta-fields.js b/src/wp-meta-fields.js index e69de29..8b13789 100644 --- a/src/wp-meta-fields.js +++ b/src/wp-meta-fields.js @@ -0,0 +1 @@ + diff --git a/src/wp-meta-fields.php b/src/wp-meta-fields.php index 168e471..cdf13e2 100644 --- a/src/wp-meta-fields.php +++ b/src/wp-meta-fields.php @@ -52,7 +52,7 @@ public static function get_instance() { */ public function __construct() { add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); - add_action( 'load-post.php', array( $this, 'init_metabox' ) ); + add_action( 'load-post.php', array( $this, 'init_metabox' ) ); add_action( 'load-post-new.php', array( $this, 'init_metabox' ) ); // Shortcode. @@ -60,15 +60,18 @@ public function __construct() { } function shortcode_markup_meta( $atts = array(), $content = '' ) { - $atts = shortcode_atts( array( - 'meta_key' => '', - 'post_id' => '', - ), $atts ); - - if( empty( $atts['meta_key'] ) ) { + $atts = shortcode_atts( + array( + 'meta_key' => '', + 'post_id' => '', + ), + $atts + ); + + if ( empty( $atts['meta_key'] ) ) { return ''; } - + return $this->meta( $atts['meta_key'], $atts['post_id'] ); } @@ -82,7 +85,7 @@ function shortcode_markup_meta( $atts = array(), $content = '' ) { */ function enqueue_scripts( $hook = '' ) { - if( empty( $this->meta_boxes ) ) { + if ( empty( $this->meta_boxes ) ) { return; } @@ -90,8 +93,8 @@ function enqueue_scripts( $hook = '' ) { wp_enqueue_style( 'wp-post-meta-fields', $this->get_uri( __FILE__ ) . 'wp-meta-fields.css', null, '1.0.0', 'all' ); $css = ''; - foreach (wp_list_pluck( $this->meta_boxes, 'id' ) as $key => $meta_box_id) { - $css .= '#'.$meta_box_id . ' .inside { margin: 0; padding: 0; }'; + foreach ( wp_list_pluck( $this->meta_boxes, 'id' ) as $key => $meta_box_id ) { + $css .= '#' . $meta_box_id . ' .inside { margin: 0; padding: 0; }'; } wp_add_inline_style( 'wp-post-meta-fields', $css ); @@ -137,14 +140,14 @@ public function init_metabox() { */ function save_meta_box( $post_id ) { - if( empty( $this->meta_boxes ) ) { + if ( empty( $this->meta_boxes ) ) { return; } // Checks save status. $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); - $is_valid_nonce = ( isset( $_POST['wp_meta_fields_nonce'] ) && wp_verify_nonce( $_POST['wp_meta_fields_nonce'], basename( __FILE__ ) ) ) ? true : false; + $is_valid_nonce = ( isset( $_POST['wp_meta_fields_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wp_meta_fields_nonce'] ) ), basename( __FILE__ ) ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { @@ -152,46 +155,44 @@ function save_meta_box( $post_id ) { } $all_fields_by_type = array(); - $all_fields = array(); - foreach ($this->meta_boxes as $key => $meta_box) { - if( isset( $meta_box['fields'] ) ) { + $all_fields = array(); + foreach ( $this->meta_boxes as $key => $meta_box ) { + if ( isset( $meta_box['fields'] ) ) { - foreach ($meta_box['fields'] as $field_id => $field) { + foreach ( $meta_box['fields'] as $field_id => $field ) { $all_fields_by_type[ $field['type'] ][] = $field_id; } $current_fields = array_keys( $meta_box['fields'] ); - $all_fields = array_merge($all_fields, $current_fields ); - } else if( isset( $meta_box['groups'] ) ) { - if( ! empty( $meta_box['groups'] ) ) { - foreach ($meta_box['groups'] as $key => $group_meta_box) { + $all_fields = array_merge( $all_fields, $current_fields ); + } elseif ( isset( $meta_box['groups'] ) ) { + if ( ! empty( $meta_box['groups'] ) ) { + foreach ( $meta_box['groups'] as $key => $group_meta_box ) { $current_fields = array_keys( $group_meta_box['fields'] ); - $all_fields = array_merge($all_fields, $current_fields ); + $all_fields = array_merge( $all_fields, $current_fields ); - foreach ($group_meta_box['fields'] as $field_id => $field) { + foreach ( $group_meta_box['fields'] as $field_id => $field ) { $all_fields_by_type[ $field['type'] ][] = $field_id; } - } } } } - foreach ($_POST as $current_meta_key => $current_meta_value) { - if( in_array($current_meta_key, $all_fields)) { + foreach ( $_POST as $current_meta_key => $current_meta_value ) { + if ( in_array( $current_meta_key, $all_fields ) ) { update_post_meta( $post_id, $current_meta_key, $current_meta_value ); } } - if( isset( $all_fields_by_type['checkbox'] ) ) { + if ( isset( $all_fields_by_type['checkbox'] ) ) { - foreach ($all_fields_by_type['checkbox'] as $key => $checkbox) { - if( ! in_array( $checkbox, array_keys( $_POST ) ) ) { + foreach ( $all_fields_by_type['checkbox'] as $key => $checkbox ) { + if ( ! in_array( $checkbox, array_keys( $_POST ) ) ) { update_post_meta( $post_id, $checkbox, 'no' ); } } } - // /** // * Get meta options // */ @@ -236,13 +237,13 @@ function save_meta_box( $post_id ) { */ function setup_meta_box() { - if( empty( $this->meta_boxes ) ) { + if ( empty( $this->meta_boxes ) ) { return; } $this->check_duplicates(); - foreach ($this->meta_boxes as $key => $meta_box) { + foreach ( $this->meta_boxes as $key => $meta_box ) { add_meta_box( $meta_box['id'], // Id. $meta_box['title'], // Title. @@ -250,7 +251,7 @@ function setup_meta_box() { $meta_box['screen'], // Post_type. $meta_box['context'], // Context. $meta_box['priority'], // Priority. - $meta_box // Callback Args. + $meta_box // Callback Args. ); } @@ -268,12 +269,12 @@ function markup_meta_box( $post, $meta_box ) { $fields = isset( $meta_box['args']['fields'] ) ? $meta_box['args']['fields'] : array(); - if( ! empty( $fields ) ) { + if ( ! empty( $fields ) ) { ?>
%1$s
is duplicate from meta box %2$s. Please use unique meta key.', 'wp-meta-fields' ), $meta_key, $meta_box['title'] ); ?>%1$s
is duplicate from meta box %2$s. Please use unique meta key.', 'wp-meta-fields' ) ), esc_html( $meta_key ), esc_html( $meta_box['title'] ) ); ?>