Ejemplo n.º 1
0
 function show()
 {
     global $post;
     // Use nonce for verification
     echo '<input type="hidden" name="postMetaBox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
     // Opening div to style meta
     echo '<div class="opc-post-meta">';
     // Loop through each meta box array
     foreach ($this->_postMetaBox['fields'] as $field) {
         // Get the post meta
         $meta = get_post_meta($post->ID, $field['id'], true);
         // Common display value
         $value = isset($meta) ? $meta : '';
         // Create opening HTML block
         $opening = '<div class="row ' . $field['id'] . '-wrap">';
         $opening .= '<div class="block01">';
         $opening .= '<label for="' . $field['id'] . '">';
         $opening .= $field['label'];
         $opening .= '</label>';
         $opening .= '</div>';
         $opening .= '<div class="block02">';
         // Display opening HTML block
         echo $opening;
         // Loop through basic field types
         opc_display_fields($field, $value);
         // Display multiple text fields
         if ($field['type'] == 'multitext') {
             echo '<div class="options">';
             foreach ($field['options'] as $option) {
                 $meta = get_post_meta($post->ID, $option['id'], true);
                 $value = isset($meta) ? $meta : '';
                 opc_display_multitext($field, $option, $value);
             }
             echo '</div>';
         }
         // Display multiple checkboxes
         if ($field['type'] == 'multicheck') {
             echo '<div class="options">';
             foreach ($field['options'] as $option) {
                 $meta = get_post_meta($post->ID, $option['id'], true);
                 $checked = $meta ? ' checked="checked"' : '';
                 opc_display_multicheck($field, $option, $checked);
             }
             echo '</div>';
         }
         // Display description if one is there
         opc_display_description($field);
         // Create closing HTML block
         $closing = '</div>';
         $closing .= '</div>';
         // Display closing HTML block
         echo $closing;
     }
     // Closing div to style meta
     echo '</div>';
 }
Ejemplo n.º 2
0
 function show_fields($field)
 {
     // Get values for named option
     $getOption = get_option($this->_optionPage['options-group']);
     // Option ID to get specific value
     $optionID = $field['id'];
     // Common display value
     if (isset($getOption[$optionID])) {
         $value = $getOption[$optionID];
     } else {
         $value = '';
     }
     // Loop through basic field types
     opc_display_fields($field, $value);
     // Display description if one is there
     opc_display_description($field);
 }
Ejemplo n.º 3
0
 function edit_meta($term)
 {
     // Use nonce for verification
     echo '<input type="hidden" name="termMetaBox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
     // Loop through each meta box array
     foreach ($this->_termMetaBox['fields'] as $field) {
         // Create opening HTML block
         $opening = '<tr class="form-field ' . $field['id'] . '-wrap opc-term-meta">';
         $opening .= '<th scope="row">';
         $opening .= '<label for="' . $field['id'] . '">';
         $opening .= $field['label'];
         $opening .= '</label>';
         $opening .= '</th>';
         $opening .= '<td>';
         // Display opening HTML block
         echo $opening;
         // Get the term meta
         $meta = get_term_meta($term->term_id, $field['id'], true);
         // Common display value
         $value = isset($meta) ? $meta : '';
         // Loop through basic field types
         opc_display_fields($field, $value);
         // Display multiple text fields
         if ($field['type'] == 'multitext') {
             echo '<div class="options">';
             foreach ($field['options'] as $option) {
                 $meta = get_term_meta($term->term_id, $option['id'], true);
                 $value = isset($meta) ? $meta : '';
                 opc_display_multitext($field, $option, $value);
             }
             echo '</div>';
         }
         // Display multiple checkboxes
         if ($field['type'] == 'multicheck') {
             echo '<div class="options">';
             foreach ($field['options'] as $option) {
                 $meta = get_term_meta($term->term_id, $option['id'], true);
                 $checked = $meta ? ' checked="checked"' : '';
                 opc_display_multicheck($field, $option, $checked);
             }
             echo '</div>';
         }
         // Display description if one is there
         opc_display_description($field);
         // Create closing HTML block
         $closing = '</td>';
         $closing .= '</tr>';
         // Display closing HTML block
         echo $closing;
     }
 }