PATH:
home
/
letacommog
/
chevaldefeu
/
wp-content
/
themes
/
betheme
/
functions
<?php /** * Offer custom meta fields. * * @package Betheme * @author Muffin group * @link https://muffingroup.com */ /** * Create new post type */ if (! function_exists('mfn_offer_post_type')) { function mfn_offer_post_type() { $offer_item_slug = mfn_opts_get('offer-slug', 'offer-item'); $labels = array( 'name' => esc_html__('Offer', 'mfn-opts'), 'singular_name' => esc_html__('Offer Item', 'mfn-opts'), 'add_new' => esc_html__('Add New', 'mfn-opts'), 'add_new_item' => esc_html__('Add New Item', 'mfn-opts'), 'edit_item' => esc_html__('Edit Item', 'mfn-opts'), 'new_item' => esc_html__('New Item', 'mfn-opts'), 'view_item' => esc_html__('View Item', 'mfn-opts'), 'search_items' => esc_html__('Search Offer Items', 'mfn-opts'), 'not_found' => esc_html__('No items found', 'mfn-opts'), 'not_found_in_trash' => esc_html__('No items found in Trash', 'mfn-opts'), ); $args = array( 'labels' => $labels, 'menu_icon' => 'dashicons-clipboard', 'public' => false, 'show_ui' => true, 'supports' => array('editor', 'thumbnail', 'title', 'page-attributes'), ); register_post_type('offer', $args); register_taxonomy('offer-types', 'offer', array( 'label' => esc_html__('Offer categories', 'mfn-opts'), 'hierarchical' => true, )); } } add_action('init', 'mfn_offer_post_type'); /** * Edit columns */ if (! function_exists('mfn_offer_edit_columns')) { function mfn_offer_edit_columns($columns) { $newcolumns = array( "cb" => '<input type="checkbox" />', "offer_thumbnail" => esc_html__('Thumbnail', 'mfn-opts'), "title" => esc_html__('Title', 'mfn-opts'), "offer_types" => esc_html__('Categories', 'mfn-opts'), "offer_order" => esc_html__('Order', 'mfn-opts'), ); $columns = array_merge($newcolumns, $columns); return $columns; } } add_filter("manage_edit-offer_columns", "mfn_offer_edit_columns"); /** * Custom columns */ if (! function_exists('mfn_offer_custom_columns')) { function mfn_offer_custom_columns($column) { global $post; switch ($column) { case "offer_thumbnail": if (has_post_thumbnail()) { the_post_thumbnail('50x50'); } break; case "offer_types": echo get_the_term_list($post->ID, 'offer-types', '', ', ', ''); break; case "offer_order": echo esc_attr($post->menu_order); break; } } } add_action("manage_posts_custom_column", "mfn_offer_custom_columns"); /** * Define Metabox Fields */ $mfn_offer_meta_box = array( 'id' => 'mfn-meta-offer', 'title' => esc_html__('Offer Item Options', 'mfn-opts'), 'page' => 'offer', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'id' => 'mfn-post-desc', 'type' => 'custom', 'title' => __('Featured Image size', 'mfn-opts'), 'sub_desc' => __('recommended', 'mfn-opts'), 'desc' => __('960px x 540px', 'mfn-opts'), 'action' => 'description', ), array( 'id' => 'mfn-post-link_title', 'type' => 'text', 'title' => __('Button text', 'mfn-opts'), 'class' => 'small-text', 'std' => 'Read more', ), array( 'id' => 'mfn-post-link', 'type' => 'text', 'title' => __('Button link', 'mfn-opts'), ), array( 'id' => 'mfn-post-target', 'type' => 'switch', 'title' => __('Open link in a new window', 'mfn-opts'), 'options' => array( '1' => 'On', '0' => 'Off' ), 'std' => '0' ), array( 'id' => 'mfn-post-thumbnail', 'type' => 'upload', 'title' => __('Thumbnail', 'mfn-opts'), 'sub_desc' => __('Thumbnail for Offer Slider Thumb Pager', 'mfn-opts'), ), ), ); /** * Add metabox to edit page */ if (! function_exists('mfn_offer_meta_add')) { function mfn_offer_meta_add() { global $mfn_offer_meta_box; add_meta_box($mfn_offer_meta_box['id'], $mfn_offer_meta_box['title'], 'mfn_offer_show_box', $mfn_offer_meta_box['page'], $mfn_offer_meta_box['context'], $mfn_offer_meta_box['priority']); } } add_action('admin_menu', 'mfn_offer_meta_add'); /** * Callback function to show fields in meta box */ if (! function_exists('mfn_offer_show_box')) { function mfn_offer_show_box() { global $MFN_Options, $mfn_offer_meta_box, $post; $MFN_Options->_enqueue(); echo '<div id="mfn-wrapper">'; echo '<input type="hidden" name="mfn-builder-nonce" value="'. wp_create_nonce('mfn-builder-nonce') .'" />'; 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>'; } } /** * Save data when post is edited */ if (! function_exists('mfn_offer_save_data')) { function mfn_offer_save_data($post_id) { global $mfn_offer_meta_box; // verify nonce if (key_exists('mfn-builder-nonce', $_POST)) { if (! wp_verify_nonce($_POST['mfn-builder-nonce'], 'mfn-builder-nonce')) { return $post_id; } } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ((key_exists('post_type', $_POST)) && ('page' == $_POST['post_type'])) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($mfn_offer_meta_box['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); if (key_exists($field['id'], $_POST)) { $new = $_POST[$field['id']]; } else { continue; } if (isset($new) && $new != $old) { update_post_meta($post_id, $field['id'], $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } } } add_action('save_post', 'mfn_offer_save_data');
[+]
..
[-] widget-flickr.php
[edit]
[-] class-love.php
[edit]
[-] widget-menu.php
[edit]
[-] meta-template.php
[edit]
[-] theme-menu.php
[edit]
[+]
admin
[-] theme-mega-menu.php
[edit]
[-] widget-login.php
[edit]
[-] meta-client.php
[edit]
[-] meta-offer.php
[edit]
[+]
importer
[-] meta-testimonial.php
[edit]
[-] widget-recent-posts.php
[edit]
[-] widget-recent-comments.php
[edit]
[-] meta-slide.php
[edit]
[-] widget-functions.php
[edit]
[-] widget-tag-cloud.php
[edit]
[-] theme-shortcodes.php
[edit]
[+]
plugins
[-] meta-page.php
[edit]
[-] meta-post.php
[edit]
[+]
builder
[-] meta-portfolio.php
[edit]
[-] meta-layout.php
[edit]
[-] theme-head.php
[edit]
[-] theme-woocommerce.php
[edit]
[-] theme-functions.php
[edit]
[-] theme-hooks.php
[edit]
[+]
tinymce