PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.4
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.4
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / wck-api / readme.txt

readme.txt in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.4, at assets/lib/wck-api/readme.txt

135 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 Usage Example 1
2
3 <?php
4
5 $fint = array(
6 array( 'type' => 'text', 'title' => 'Title', 'description' => 'Description for this input' ),
7 array( 'type' => 'textarea', 'title' => 'Description' ),
8 array( 'type' => 'upload', 'title' => 'Image', 'description' => 'Upload a image' ),
9 array( 'type' => 'select', 'title' => 'Select This', 'options' => array( 'Option 1', 'Option 2', 'Option 3' ) ),
10
11 array( 'type' => 'checkbox', 'title' => 'Check This', 'options' => array( 'Option 1', 'Option 2', 'Option 3' ) ),
12
13 array( 'type' => 'radio', 'title' => 'Radio This', 'options' => array( 'Radio 1', 'Radio 2', 'Radio 3' ) ),
14 );
15
16 $args = array(
17 'metabox_id' => 'rm_slider_content',
18 'metabox_title' => 'Slideshow Class',
19 'post_type' => 'slideshows',
20 'meta_name' => 'rmscontent',
21 'meta_array' => $fint
22 );
23
24 new Wordpress_Creation_Kit_PB( $args );
25
26 ?>
27
28 For Frontend use like this:
29
30 <?php $meta = get_post_meta( $post->ID, 'rmscontent', true ); ?>
31
32
33
34
35 Default Parameters
36
37 <?php $args = array(
38 'metabox_id' => '',
39 'metabox_title' => 'Meta Box',
40 'post_type' => 'post',
41 'meta_name' => '',
42 'meta_array' => array(),
43 'page_template' => '',
44 'post_id' => '',
45 'single' => false,
46 'unserialize_fields' => false,
47 'sortable' => true,
48 'context' => 'post_meta'
49 )
50 ?>
51
52 Parameters
53
54 $metabox_id
55 (string) (required) HTML 'id' attribute of the edit screen section
56
57 Default: None
58
59 $metabox_title
60 (string) (required) Title of the edit screen section, visible to user
61
62 Default: 'Meta Box'
63
64 $post_type
65 (string) (required) The type of Write screen on which to show the edit screen section ('post', 'page', 'link', or 'custom_post_type' where custom_post_type is the custom post type slug)
66
67 Default: 'post'
68
69 $meta_name
70 (string) (required) The name of the meta key used to query for data
71
72 Default: None
73
74 $meta_array
75 (array) (required) The array of fields used to create the form. See example above. Must be array( array() ). Type and Title are required.
76
77 Default: None
78
79 $page_template
80 (string) (optional) The name of the page template on wich you want the meta box to appear. If this is set than $post_type can be omitted.
81
82 Default: None
83
84 $post_id
85 (string) (optional) The id of the post you want the meta box to appear. If this is set than $post_type can be omitted.
86
87 Default: None
88
89 $single
90 (boolean) (optional) Set this to true if you don't want a repeater box and you will be able to enter just one value.
91
92 Default: false
93
94 $unserialize_fields
95 (boolean) (optional) Set this to true if you want to enable wpml compatibility
96
97 $sortable
98 (boolean) (optional) Wheater or not the fields in a repeater box are sortable.
99
100 Default: true
101
102 $context
103 (string) (optional) WCK API can add data as meta or as option depending on the context. Using 'post_meta' will add data as post meta and using 'option' will add data as option
104
105 Default: 'post_meta'
106
107 Parameters for meta_array
108
109 'title' (string) Title of the field.
110 'type' (string) The field type. Possible values: 'text', 'textarea', 'select', 'checkbox', 'radio', 'upload'.
111 'description' (string) The description of the field.
112 'required' (boolean) true if the field is required.
113 'default' (string) If you want the string to have a default value enter it here. For Checkboxes if there are multiple
114 values separate them with a ",".
115 'default-option' (boolean) true if you want Select to have a default option.
116 'options' (array) Options for field types "select", "checkbox" and "radio".
117
118
119 How to add into a plugin:
120
121 1. Copy the foldder "wordpress-creation-kit-api" into the plugin dir
122 2. Change the class name "Wordpress_Creation_Kit_PB" if multiple plugins use wordpress-creation-kit-api on the same site.
123 3. Include "wordpress-creation-kit.php" into the plugin file
124
125 /* include Custom Fields Creator API */
126 require_once('wordpress-creation-kit/wordpress-creation-kit.php');
127
128 4. Use the API as in Exampe 1, in your plugin file or functions or whatever fits the situation.
129
130
131 WPML Compatibility
132
133 When unserialize_fields is true on a meta box, besides saving the contents of the box in one serialized custom field, we create automatically a custom field for every field in every entry. We do this because WPML can't handle serialized custom fields and also we will get good control on what actions we want to perform (don't translate, copy, translate ) on each of the fields.
134
135 After the fields are translated with Icanlcalize and we have the translated post in our system, we can go on the translated post and press the "Syncronize WCK Translation" button which will create the serialized array from the individual custom fields.