-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-meta-fields-sample-plugin.php
49 lines (45 loc) · 1.33 KB
/
wp-meta-fields-sample-plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Plugin Name: WP Meta Fields Sample Plugin
* Plugin URI: https://maheshwaghmare.wordpress.com/
* Description: Sample plugin for `WP Meta Fields` integration.
* Version: 1.0.0
* Author: Mahesh M. Waghmare
* Author URI: https://maheshwaghmare.wordpress.com/
* Text Domain: WP Meta Fields
*
* @package WP Meta Fields
*/
require 'inc/wp-meta-fields/wp-meta-fields.php';
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', 'textdomain' ),
'description' => __( 'Simple text field for demonstration purpose.', 'textdomain' ),
'hint' => __( 'This is the Text Field for storing the text data for demonstration purpose.', 'textdomain' ),
'default' => '',
),
)
));
// To retrieve/print the value of field `prefix-1-text` use:
//
// 1. [mf meta_key='prefix-1-text']
//
// or
//
// 2. mf_meta( 'prefix-1-text' );
//
// or
//
// 3. echo mf_get_meta( 'prefix-1-text' );
//
// Other Ready Examples.
// require 'inc/wp-meta-fields/example-screen-normal.php';
// require 'inc/wp-meta-fields/example-screen-side.php';
// require 'inc/wp-meta-fields/example-screen-advanced.php';