Example #1
0
function mfn_offer_show_box()
{
    global $MFN_Options, $mfn_offer_meta_box, $post;
    $MFN_Options->_enqueue();
    // Use nonce for verification
    echo '<div id="mfn-wrapper">';
    echo '<input type="hidden" name="mfn_offer_meta_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    echo '<table class="form-table">';
    echo '<tbody>';
    foreach ($mfn_offer_meta_box['fields'] as $field) {
        $meta = get_post_meta($post->ID, $field['id'], true);
        if (!key_exists('std', $field)) {
            $field['std'] = false;
        }
        $meta = $meta || $meta === '0' ? $meta : stripslashes(htmlspecialchars($field['std'], ENT_QUOTES));
        mfn_meta_field_input($field, $meta);
    }
    echo '</tbody>';
    echo '</table>';
    echo '</div>';
}
Example #2
0
 /**
  * PRINT single ITEM
  *
  * @param array $item_std
  * @param string $item
  * @param string $section_id
  */
 function mfn_builder_item($item_type, $item = false, $parent_id = false)
 {
     $item_std = mfn_get_fields_item($item_type);
     // input names - only for existing items, not for items to clone -----------
     $n_item_type = $item ? 'mfn-item-type[]' : '';
     $n_item_size = $item ? 'mfn-item-size[]' : '';
     $n_item_parent = $item ? 'mfn-item-parent[]' : '';
     $sizes = array('1/6' => 0.1666, '1/5' => 0.2, '1/4' => 0.25, '1/3' => 0.3333, '2/5' => 0.4, '1/2' => 0.5, '3/5' => 0.6, '2/3' => 0.6667, '3/4' => 0.75, '4/5' => 0.8, '5/6' => 0.8333, '1/1' => 1);
     $item_std['size'] = $item['size'] ? $item['size'] : $item_std['size'];
     echo '<div class="mfn-element mfn-item mfn-item-' . $item_std['type'] . '" data-size="' . $sizes[$item_std['size']] . '" data-title="' . $item_std['title'] . '">';
     echo '<div class="mfn-element-content">';
     echo '<input type="hidden" class="mfn-item-type" name="' . $n_item_type . '" value="' . $item_std['type'] . '">';
     echo '<input type="hidden" class="mfn-item-size" name="' . $n_item_size . '" value="' . $item_std['size'] . '">';
     echo '<input type="hidden" class="mfn-item-parent" name="' . $n_item_parent . '" value="' . $parent_id . '" />';
     echo '<div class="mfn-element-header">';
     echo '<div class="mfn-item-size">';
     echo '<a class="mfn-element-btn mfn-item-size-dec" href="javascript:void(0);">-</a>';
     echo '<a class="mfn-element-btn mfn-item-size-inc" href="javascript:void(0);">+</a>';
     echo '<span class="mfn-element-btn mfn-item-desc">' . $item_std['size'] . '</span>';
     echo '</div>';
     echo '<div class="mfn-element-tools">';
     echo '<a class="mfn-element-btn mfn-fr mfn-element-edit dashicons dashicons-edit" title="' . __('Edit', 'mfn-opts') . '" href="javascript:void(0);"></a>';
     echo '<a class="mfn-element-btn mfn-fr mfn-element-clone mfn-item-clone dashicons dashicons-share-alt2" title="' . __('Clone', 'mfn-opts') . '" href="javascript:void(0);"></a>';
     echo '<a class="mfn-element-btn mfn-fr mfn-element-delete dashicons dashicons-no" title="' . __('Delete', 'mfn-opts') . '" href="javascript:void(0);"></a>';
     echo '</div>';
     echo '</div>';
     echo '<div class="mfn-item-content">';
     echo '<div class="mfn-item-inside">';
     echo '<div class="mfn-item-icon"></div>';
     echo '<div class="mfn-item-inside-desc">';
     echo '<span class="mfn-item-title">' . $item_std['title'] . '</span>';
     $item_label = $item && key_exists('fields', $item) && key_exists('title', $item['fields']) ? $item['fields']['title'] : '';
     echo '<span class="mfn-item-label">' . $item_label . '</span>';
     echo '</div>';
     echo '</div>';
     echo '</div>';
     echo '</div>';
     echo '<div class="mfn-element-meta">';
     echo '<table class="form-table">';
     echo '<tbody>';
     // Fields for Item
     foreach ($item_std['fields'] as $field) {
         // values for existing items
         if ($item && key_exists('fields', $item) && key_exists($field['id'], $item['fields'])) {
             $meta = $item['fields'][$field['id']];
         } else {
             $meta = false;
         }
         if (!key_exists('std', $field)) {
             $field['std'] = false;
         }
         $meta = $meta || $meta === '0' ? $meta : stripslashes(htmlspecialchars($field['std'], ENT_QUOTES));
         // field ID
         $field['id'] = 'mfn-items[' . $item_std['type'] . '][' . $field['id'] . ']';
         // field ID except accordion, faq & tabs
         if ($field['type'] != 'tabs') {
             $field['id'] .= '[]';
         }
         // PRINT Single Muffin Options FIELD
         if ($item) {
             $input_type = 'existing';
         } else {
             $input_type = 'new';
         }
         mfn_meta_field_input($field, $meta, $input_type);
     }
     echo '</tbody>';
     echo '</table>';
     echo '</div>';
     echo '</div>';
 }
function mfn_builder_item($item_std, $item = false)
{
    $item_std['size'] = $item['size'] ? $item['size'] : $item_std['size'];
    $name_type = $item ? 'name="mfn-item-type[]"' : '';
    $name_size = $item ? 'name="mfn-item-size[]"' : '';
    $label = $item && key_exists('title', $item['fields']) ? $item['fields']['title'] : '';
    $classes = array('1/4' => 'mfn-item-1-4', '1/3' => 'mfn-item-1-3', '1/2' => 'mfn-item-1-2', '2/3' => 'mfn-item-2-3', '3/4' => 'mfn-item-3-4', '1/1' => 'mfn-item-1-1');
    echo '<div class="mfn-item mfn-item-' . $item_std['type'] . ' ' . $classes[$item_std['size']] . '">';
    echo '<div class="mfn-item-content">';
    echo '<input type="hidden" class="mfn-item-type" ' . $name_type . ' value="' . $item_std['type'] . '">';
    echo '<input type="hidden" class="mfn-item-size" ' . $name_size . ' value="' . $item_std['size'] . '">';
    echo '<div class="mfn-item-size">';
    echo '<a href="javascript:void(0);" class="mfn-item-btn mfn-item-size-dec">-</a>';
    echo '<a href="javascript:void(0);" class="mfn-item-btn mfn-item-size-inc">+</a>';
    echo '<span class="mfn-item-desc">' . $item_std['size'] . '</span>';
    echo '</div>';
    echo '<span class="mfn-item-label">' . $item_std['title'] . ' <small>' . $label . '</small></span>';
    echo '<div class="mfn-item-tool">';
    echo '<a href="javascript:void(0);" class="mfn-item-btn mfn-item-delete">delete</a>';
    echo '<a href="javascript:void(0);" class="mfn-item-btn mfn-item-edit">edit</a>';
    echo '</div>';
    echo '</div>';
    echo '<div class="mfn-item-meta">';
    echo '<table class="form-table">';
    echo '<tbody>';
    foreach ($item_std['fields'] as $field) {
        if ($item) {
            $meta = $item['fields'][$field['id']];
        } else {
            $meta = false;
        }
        if (!key_exists('std', $field)) {
            $field['std'] = false;
        }
        $meta = $meta || $meta === '0' ? $meta : stripslashes(htmlspecialchars($field['std'], ENT_QUOTES));
        $field['id'] = 'mfn-items[' . $item_std['type'] . '][' . $field['id'] . ']';
        if (!in_array($item_std['type'], array('accordion', 'faq', 'tabs'))) {
            // except accordion & faq & tabs
            $field['id'] .= '[]';
        }
        mfn_meta_field_input($field, $meta);
    }
    echo '</tbody>';
    echo '</table>';
    echo '</div>';
    echo '</div>';
}
 function mfn_builder_section($item_std, $section_std, $section = false, $section_id = false)
 {
     // input's 'name' only for existing sections, not for section to clone
     $name_row_id = $section ? 'name="mfn-row-id[]"' : '';
     $label = $section && key_exists('attr', $section) && key_exists('title', $section['attr']) ? $section['attr']['title'] : '';
     echo '<div class="mfn-element mfn-row">';
     echo '<div class="mfn-element-content">';
     // Section ID
     echo '<input type="hidden" class="mfn-row-id" ' . $name_row_id . ' value="' . $section_id . '" />';
     echo '<div class="mfn-element-header">';
     echo '<div class="mfn-item-add">';
     echo '<a class="mfn-item-add-btn" href="javascript:void(0);">' . __('Add Item', 'mfn-opts') . '</a>';
     echo '<ul class="mfn-item-add-list">';
     // List of available Items
     foreach ($item_std as $item) {
         echo '<li><a class="' . $item['type'] . '" href="javascript:void(0);">' . $item['title'] . '</a></li>';
     }
     echo '</ul>';
     echo '</div>';
     echo '<span class="mfn-item-label">' . $label . '</span>';
     echo '<div class="mfn-element-tools">';
     echo '<a class="mfn-element-btn mfn-element-edit" title="' . __('Edit', 'mfn-opts') . '" href="javascript:void(0);">E</a>';
     echo '<a class="mfn-element-btn mfn-element-clone mfn-row-clone" title="' . __('Clone', 'mfn-opts') . '" href="javascript:void(0);">C</a>';
     echo '<a class="mfn-element-btn mfn-element-delete" title="' . __('Delete', 'mfn-opts') . '" href="javascript:void(0);">D</a>';
     echo '</div>';
     echo '</div>';
     // .mfn-element-droppable
     echo '<div class="mfn-droppable mfn-sortable clearfix">';
     // Existing Items for Section
     if ($section && key_exists('items', $section) && is_array($section['items'])) {
         foreach ($section['items'] as $item) {
             mfn_builder_item($item_std[$item['type']], $item, $section_id);
         }
     }
     echo '</div>';
     echo '</div>';
     echo '<div class="mfn-element-meta">';
     echo '<table class="form-table" style="display: table;">';
     echo '<tbody>';
     // Fields for Section
     foreach ($section_std as $field) {
         // values for existing sections
         if ($section) {
             $meta = $section['attr'][$field['id']];
         } else {
             $meta = false;
         }
         if (!key_exists('std', $field)) {
             $field['std'] = false;
         }
         $meta = $meta || $meta === '0' ? $meta : stripslashes(htmlspecialchars($field['std'], ENT_QUOTES));
         // field ID
         $field['id'] = 'mfn-rows[' . $field['id'] . ']';
         // field ID except accordion, faq & tabs
         if ($field['type'] != 'tabs') {
             $field['id'] .= '[]';
         }
         // PRINT Single Muffin Options FIELD
         mfn_meta_field_input($field, $meta);
     }
     echo '</tbody>';
     echo '</table>';
     echo '</div>';
     echo '</div>';
 }