dummy.php
| 1 | <?php |
| 2 | |
| 3 | class acf_field_dummy extends acf_field |
| 4 | { |
| 5 | |
| 6 | /* |
| 7 | * __construct |
| 8 | * |
| 9 | * Set name / label needed for actions / filters |
| 10 | * |
| 11 | * @since 3.6 |
| 12 | * @date 23/01/13 |
| 13 | */ |
| 14 | |
| 15 | function __construct() |
| 16 | { |
| 17 | // vars |
| 18 | $this->name = 'dummy'; |
| 19 | $this->label = __('Dummy'); |
| 20 | |
| 21 | |
| 22 | // do not delete! |
| 23 | parent::__construct(); |
| 24 | } |
| 25 | |
| 26 | |
| 27 | /* |
| 28 | * load_value() |
| 29 | * |
| 30 | * This filter is appied to the $value after it is loaded from the db |
| 31 | * |
| 32 | * @type filter |
| 33 | * @since 3.6 |
| 34 | * @date 23/01/13 |
| 35 | * |
| 36 | * @param $value - the value found in the database |
| 37 | * @param $post_id - the $post_id from which the value was loaded from |
| 38 | * @param $field - the field array holding all the field options |
| 39 | * |
| 40 | * @return $value - the value to be saved in te database |
| 41 | */ |
| 42 | |
| 43 | function load_value( $value, $post_id, $field ) |
| 44 | { |
| 45 | return $value; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | /* |
| 50 | * format_value() |
| 51 | * |
| 52 | * This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action |
| 53 | * |
| 54 | * @type filter |
| 55 | * @since 3.6 |
| 56 | * @date 23/01/13 |
| 57 | * |
| 58 | * @param $value - the value which was loaded from the database |
| 59 | * @param $post_id - the $post_id from which the value was loaded |
| 60 | * @param $field - the field array holding all the field options |
| 61 | * |
| 62 | * @return $value - the modified value |
| 63 | */ |
| 64 | |
| 65 | function format_value( $value, $post_id, $field ) |
| 66 | { |
| 67 | return $value; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | /* |
| 72 | * format_value_for_api() |
| 73 | * |
| 74 | * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field |
| 75 | * |
| 76 | * @type filter |
| 77 | * @since 3.6 |
| 78 | * @date 23/01/13 |
| 79 | * |
| 80 | * @param $value - the value which was loaded from the database |
| 81 | * @param $post_id - the $post_id from which the value was loaded |
| 82 | * @param $field - the field array holding all the field options |
| 83 | * |
| 84 | * @return $value - the modified value |
| 85 | */ |
| 86 | |
| 87 | function format_value_for_api( $value, $post_id, $field ) |
| 88 | { |
| 89 | return $value; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /* |
| 94 | * update_value() |
| 95 | * |
| 96 | * This filter is appied to the $value before it is updated in the db |
| 97 | * |
| 98 | * @type filter |
| 99 | * @since 3.6 |
| 100 | * @date 23/01/13 |
| 101 | * |
| 102 | * @param $value - the value which will be saved in the database |
| 103 | * @param $field - the field array holding all the field options |
| 104 | * @param $post_id - the $post_id of which the value will be saved |
| 105 | * |
| 106 | * @return $value - the modified value |
| 107 | */ |
| 108 | |
| 109 | function update_value( $value, $post_id, $field ) |
| 110 | { |
| 111 | return $value; |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /* |
| 116 | * load_field() |
| 117 | * |
| 118 | * This filter is appied to the $field after it is loaded from the database |
| 119 | * |
| 120 | * @type filter |
| 121 | * @since 3.6 |
| 122 | * @date 23/01/13 |
| 123 | * |
| 124 | * @param $field - the field array holding all the field options |
| 125 | * |
| 126 | * @return $field - the field array holding all the field options |
| 127 | */ |
| 128 | |
| 129 | function load_field( $field ) |
| 130 | { |
| 131 | return $field; |
| 132 | } |
| 133 | |
| 134 | |
| 135 | /* |
| 136 | * update_field() |
| 137 | * |
| 138 | * This filter is appied to the $field before it is saved to the database |
| 139 | * |
| 140 | * @type filter |
| 141 | * @since 3.6 |
| 142 | * @date 23/01/13 |
| 143 | * |
| 144 | * @param $field - the field array holding all the field options |
| 145 | * @param $post_id - the field group ID (post_type = acf) |
| 146 | * |
| 147 | * @return $field - the modified field |
| 148 | */ |
| 149 | |
| 150 | function update_field( $field, $post_id ) |
| 151 | { |
| 152 | return $field; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | /* |
| 157 | * create_field() |
| 158 | * |
| 159 | * Create the HTML interface for your field |
| 160 | * |
| 161 | * @type action |
| 162 | * @since 3.6 |
| 163 | * @date 23/01/13 |
| 164 | * |
| 165 | * @param $field - an array holding all the field's data |
| 166 | */ |
| 167 | |
| 168 | function create_field( $field ) |
| 169 | { |
| 170 | |
| 171 | } |
| 172 | |
| 173 | |
| 174 | /* |
| 175 | * create_options() |
| 176 | * |
| 177 | * Create extra options for your field. This is rendered when editing a field. |
| 178 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
| 179 | * |
| 180 | * @type action |
| 181 | * @since 3.6 |
| 182 | * @date 23/01/13 |
| 183 | * |
| 184 | * @param $field - an array holding all the field's data |
| 185 | */ |
| 186 | |
| 187 | function create_options( $field ) |
| 188 | { |
| 189 | |
| 190 | } |
| 191 | |
| 192 | |
| 193 | /* |
| 194 | * input_admin_enqueue_scripts() |
| 195 | * |
| 196 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created. |
| 197 | * Use this action to add css + javascript to assist your create_field() action. |
| 198 | * |
| 199 | * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts |
| 200 | * @type action |
| 201 | * @since 3.6 |
| 202 | * @date 23/01/13 |
| 203 | */ |
| 204 | |
| 205 | function input_admin_enqueue_scripts() |
| 206 | { |
| 207 | |
| 208 | } |
| 209 | |
| 210 | |
| 211 | /* |
| 212 | * input_admin_head() |
| 213 | * |
| 214 | * This action is called in the admin_head action on the edit screen where your field is created. |
| 215 | * Use this action to add css and javascript to assist your create_field() action. |
| 216 | * |
| 217 | * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head |
| 218 | * @type action |
| 219 | * @since 3.6 |
| 220 | * @date 23/01/13 |
| 221 | */ |
| 222 | |
| 223 | function input_admin_head() |
| 224 | { |
| 225 | |
| 226 | } |
| 227 | |
| 228 | |
| 229 | /* |
| 230 | * field_group_admin_enqueue_scripts() |
| 231 | * |
| 232 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited. |
| 233 | * Use this action to add css + javascript to assist your create_field_options() action. |
| 234 | * |
| 235 | * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts |
| 236 | * @type action |
| 237 | * @since 3.6 |
| 238 | * @date 23/01/13 |
| 239 | */ |
| 240 | |
| 241 | function field_group_admin_enqueue_scripts() |
| 242 | { |
| 243 | |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /* |
| 248 | * field_group_admin_head() |
| 249 | * |
| 250 | * This action is called in the admin_head action on the edit screen where your field is edited. |
| 251 | * Use this action to add css and javascript to assist your create_field_options() action. |
| 252 | * |
| 253 | * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head |
| 254 | * @type action |
| 255 | * @since 3.6 |
| 256 | * @date 23/01/13 |
| 257 | */ |
| 258 | |
| 259 | function field_group_admin_head() |
| 260 | { |
| 261 | |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | |
| 266 | // create field |
| 267 | new acf_field_dummy(); |
| 268 | |
| 269 | |
| 270 | /*--------------------------------------- fuctions.php ----------------------------------------------------*/ |
| 271 | |
| 272 | add_action('acf/register_fields', 'my_register_fields'); |
| 273 | |
| 274 | function my_register_fields() |
| 275 | { |
| 276 | include_once('fields/dummy.php'); |
| 277 | } |
| 278 | |
| 279 | ?> |