wp/wp-content/plugins/option-tree/assets/theme-mode/demo-meta-boxes.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 11 bf1778c34b9a
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     3
 * Initialize the custom Meta Boxes. 
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     5
add_action( 'admin_init', 'custom_meta_boxes' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * Meta Boxes demo code.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    10
 * You can find all the available option types in demo-theme-options.php.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
function custom_meta_boxes() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
   * Create a custom meta boxes array that we pass to 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
   * the OptionTree Meta Box API Class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
   */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
  $my_meta_box = array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
    'id'          => 'demo_meta_box',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
    'title'       => __( 'Demo Meta Box', 'theme-text-domain' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    'desc'        => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    'pages'       => array( 'post' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    'context'     => 'normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
    'priority'    => 'high',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
    'fields'      => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
      array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
        'label'       => __( 'Conditions', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
        'id'          => 'demo_conditions',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
        'type'        => 'tab'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
        'label'       => __( 'Show Gallery', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
        'id'          => 'demo_show_gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    37
        'type'        => 'on-off',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
        'desc'        => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), '<code>on</code>' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
        'std'         => 'off'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
        'label'       => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
        'id'          => 'demo_textblock',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
        'type'        => 'textblock',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
        'desc'        => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
        'operator'    => 'and',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
        'condition'   => 'demo_show_gallery:is(on),demo_gallery:not()'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
      array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    50
        'label'       => __( 'Gallery', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
        'id'          => 'demo_gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    52
        'type'        => 'gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
        'desc'        => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), '<code>demo_show_gallery:is(on)</code>' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
        'condition'   => 'demo_show_gallery:is(on)'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
        'label'       => __( 'More Options', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
        'id'          => 'demo_more_options',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
        'type'        => 'tab'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
        'label'       => __( 'Text', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
        'id'          => 'demo_text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
        'type'        => 'text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
        'desc'        => __( 'This is a demo Text field.', 'theme-text-domain' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    67
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
        'label'       => __( 'Textarea', 'theme-text-domain' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
        'id'          => 'demo_textarea',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
        'type'        => 'textarea',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
        'desc'        => __( 'This is a demo Textarea field.', 'theme-text-domain' )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
    )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
  );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
   * Register our meta boxes using the 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
   * ot_register_meta_box() function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
   */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    80
  if ( function_exists( 'ot_register_meta_box' ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    81
    ot_register_meta_box( $my_meta_box );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
}