Пример #1
0
/**
 * Define default meta boxes for templates
 * 
 * @param  array $hidden Hidden Meta Boxes
 * @param  string|WP_Screen $screen Current screen
 * @param  bool $use_defaults Use default Meta Boxes or not
 * 
 * @return array Hidden Meta Boxes
 */
function presscore_hidden_meta_boxes($hidden, $screen, $use_defaults)
{
    static $extra_hidden = null;
    // return saved result
    if (null !== $extra_hidden) {
        return $extra_hidden;
    }
    global $DT_META_BOXES;
    $template = dt_get_template_name();
    $meta_boxes = array();
    foreach ($DT_META_BOXES as $meta_box) {
        // if field 'only_on' is empty - show metabox everywhere
        // if current template in templates list - show metabox
        if (empty($meta_box['only_on']) || empty($meta_box['only_on']['template']) || in_array($template, (array) $meta_box['only_on']['template'])) {
            // find metabox id in hidden list
            $bad_key = array_search($meta_box['id'], $hidden);
            // show current metabox
            if (false !== $bad_key) {
                unset($hidden[$bad_key]);
            }
            continue;
        }
        $meta_boxes[] = $meta_box['id'];
    }
    // save result
    $extra_hidden = $hidden;
    if (!empty($meta_boxes)) {
        $extra_hidden = array_unique(array_merge($hidden, $meta_boxes));
    }
    return $extra_hidden;
}
 /**
  * Ajax pagination controller.
  *
  */
 function presscore_ajax_pagination_controller()
 {
     $ajax_data = array('nonce' => isset($_POST['nonce']) ? $_POST['nonce'] : false, 'post_id' => isset($_POST['postID']) ? absint($_POST['postID']) : false, 'post_paged' => isset($_POST['paged']) ? absint($_POST['paged']) : false, 'target_page' => isset($_POST['targetPage']) ? absint($_POST['targetPage']) : false, 'page_data' => isset($_POST['pageData']) ? $_POST['pageData'] : false, 'term' => isset($_POST['term']) ? $_POST['term'] : '', 'orderby' => isset($_POST['orderby']) ? $_POST['orderby'] : '', 'order' => isset($_POST['order']) ? $_POST['order'] : '', 'loaded_items' => isset($_POST['visibleItems']) ? array_map('absint', $_POST['visibleItems']) : array(), 'sender' => isset($_POST['sender']) ? $_POST['sender'] : '', 'posts_count' => isset($_POST['postsCount']) ? $_POST['postsCount'] : 0);
     if ($ajax_data['post_id'] && 'page' == get_post_type($ajax_data['post_id'])) {
         $template = dt_get_template_name($ajax_data['post_id'], true);
     } else {
         if (is_array($ajax_data['page_data'])) {
             switch ($ajax_data['page_data'][0]) {
                 case 'archive':
                     $template = 'archive';
                     break;
                 case 'search':
                     $template = 'search';
             }
         }
     }
     $response = array('success' => false, 'reason' => 'undefined template');
     do_action('presscore_before_ajax_response', $template);
     switch ($template) {
         case 'template-albums-jgrid.php':
         case 'template-albums.php':
             $response = Presscore_Inc_Albums_Post_Type::get_albums_masonry_content($ajax_data);
             break;
         case 'template-portfolio-masonry.php':
         case 'template-portfolio-list.php':
         case 'template-portfolio-jgrid.php':
             $response = Presscore_Inc_Portfolio_Post_Type::get_masonry_content($ajax_data);
             break;
         case 'template-media.php':
         case 'template-media-jgrid.php':
             $response = Presscore_Inc_Albums_Post_Type::get_media_masonry_content($ajax_data);
             break;
         case 'template-blog-masonry.php':
         case 'template-blog-list.php':
             $response = presscore_blog_ajax_loading_responce($ajax_data);
             break;
         case 'template-testimonials.php':
             $response = presscore_testimonials_ajax_loading_responce($ajax_data);
             break;
     }
     $response = apply_filters('presscore_ajax_pagination_response', $response, $ajax_data, $template);
     $response = json_encode($response);
     // responce output
     header("Content-Type: application/json");
     echo $response;
     // IMPORTANT: don't forget to "exit"
     exit;
 }
 /**
  * Ajax pagination controller.
  *
  */
 function presscore_ajax_pagination_controller()
 {
     $ajax_data = array('nonce' => isset($_POST['nonce']) ? $_POST['nonce'] : false, 'post_id' => isset($_POST['postID']) ? absint($_POST['postID']) : false, 'post_paged' => isset($_POST['paged']) ? absint($_POST['paged']) : false, 'target_page' => isset($_POST['targetPage']) ? absint($_POST['targetPage']) : false, 'page_data' => isset($_POST['pageData']) ? $_POST['pageData'] : false, 'term' => isset($_POST['term']) ? $_POST['term'] : '', 'orderby' => isset($_POST['orderby']) ? $_POST['orderby'] : '', 'order' => isset($_POST['order']) ? $_POST['order'] : '', 'loaded_items' => isset($_POST['visibleItems']) ? array_map('absint', $_POST['visibleItems']) : array(), 'sender' => isset($_POST['sender']) ? $_POST['sender'] : '', 'posts_count' => isset($_POST['postsCount']) ? $_POST['postsCount'] : 0);
     if ($ajax_data['post_id'] && 'page' == get_post_type($ajax_data['post_id'])) {
         $template = dt_get_template_name($ajax_data['post_id'], true);
     } else {
         if (is_array($ajax_data['page_data'])) {
             switch ($ajax_data['page_data'][0]) {
                 case 'archive':
                     $template = 'archive';
                     break;
                 case 'search':
                     $template = 'search';
             }
         }
     }
     do_action('presscore_before_ajax_response', $template);
     $response = array('success' => false, 'reason' => 'undefined template');
     if (in_array($template, array('template-blog-list.php', 'template-blog-masonry.php'))) {
         $response = presscore_blog_ajax_loading_responce($ajax_data);
     }
     $response = apply_filters('presscore_ajax_pagination_response', $response, $ajax_data, $template);
     wp_send_json($response);
 }
 function presscore_congif_populate_media_vars()
 {
     $config = Presscore_Config::get_instance();
     $post_id = $config->get('post_id');
     ////////////////////
     // posts filter //
     ////////////////////
     $prefix = '_dt_media_options_';
     $config->set('order', get_post_meta($post_id, "{$prefix}order", true));
     $config->set('orderby', get_post_meta($post_id, "{$prefix}orderby", true));
     $config->set('display', get_post_meta($post_id, "_dt_albums_media_display", true));
     $config->set('posts_per_page', get_post_meta($post_id, "{$prefix}ppp", true));
     //////////////
     // layout //
     //////////////
     $config->set('layout', get_post_meta($post_id, "{$prefix}layout", true), 'masonry');
     $config->set('item_padding', get_post_meta($post_id, "{$prefix}item_padding", true), 20);
     //////////////
     // images //
     //////////////
     $config->set('image_layout', get_post_meta($post_id, "{$prefix}image_layout", true), 'original');
     $config->set('thumb_proportions', get_post_meta($post_id, "{$prefix}thumb_proportions", true), array('width' => 1, 'height' => 1));
     /////////////////////////
     // titles & excerpts //
     /////////////////////////
     $config->set('show_excerpts', get_post_meta($post_id, "{$prefix}show_exerpts", true), true);
     $config->set('show_titles', get_post_meta($post_id, "{$prefix}show_titles", true), true);
     //////////////////////////
     // is content visible //
     //////////////////////////
     $config->set('post.preview.content.visible', $config->get('show_titles') || $config->get('show_excerpts'));
     //////////////////
     // load style //
     //////////////////
     $load_style = get_post_meta($post_id, "{$prefix}load_style", true);
     $load_style = $load_style ? $load_style : 'default';
     $hide_last_row = 'default' == $load_style ? get_post_meta($post_id, "{$prefix}hide_last_row", true) : false;
     $config->set('load_style', $load_style);
     $config->set('hide_last_row', $hide_last_row, false);
     $config->set('post.preview.load.effect', get_post_meta($post_id, "{$prefix}load_effect", true), 'fade_in');
     /////////////////
     // paginator //
     /////////////////
     $config->set('show_all_pages', get_post_meta($post_id, "{$prefix}show_all_pages", true), false);
     $template_name = dt_get_template_name($post_id, true);
     if ('template-media.php' == $template_name) {
         $config->set('post.preview.width.min', get_post_meta($post_id, "{$prefix}target_width", true), 370);
         $config->set('template.columns.number', get_post_meta($post_id, "{$prefix}columns_number", true), 3);
         // preview description under image or disabled
         $config->set('post.preview.description.style', $config->get('post.preview.content.visible') ? 'under_image' : 'disabled');
     } else {
         if ('template-media-jgrid.php' == $template_name) {
             $config->set('justified_grid', true);
             $config->set('layout', 'grid');
             $config->set('target_height', get_post_meta($post_id, "{$prefix}target_height", true), 250);
             // preview description on hover centered
             $config->set('post.preview.description.style', 'on_hoover_centered');
         }
     }
     ///////////////
     // content //
     ///////////////
     $config->set('full_width', get_post_meta($post_id, "{$prefix}full_width", true), false);
 }
Пример #5
0
 private function set_template_blog_vars()
 {
     global $post;
     $prefix = '_dt_blog_options_';
     // populate options
     $this->set('display', get_post_meta($this->options['post_id'], "_dt_blog_display", true));
     $this->set('order', get_post_meta($this->options['post_id'], "{$prefix}order", true));
     $this->set('orderby', get_post_meta($this->options['post_id'], "{$prefix}orderby", true));
     switch (dt_get_template_name($this->options['post_id'], true)) {
         case 'template-blog-masonry.php':
             $this->set('layout', get_post_meta($this->options['post_id'], "{$prefix}layout", true));
             break;
         default:
             $this->set('layout', 'list');
     }
     $this->set('image_layout', get_post_meta($this->options['post_id'], "{$prefix}image_layout", true));
     $this->set('thumb_proportions', get_post_meta($this->options['post_id'], "{$prefix}thumb_proportions", true));
     $this->set('posts_per_page', get_post_meta($this->options['post_id'], "{$prefix}ppp", true));
     $this->set('columns', get_post_meta($this->options['post_id'], "{$prefix}columns", true));
     $this->set('all_the_same_width', get_post_meta($this->options['post_id'], "{$prefix}posts_same_width", true));
     $this->set('show_all_pages', get_post_meta($this->options['post_id'], "{$prefix}show_all_pages", true));
     $this->set('full_width', get_post_meta($this->options['post_id'], "{$prefix}full_width", true));
     $this->set('item_padding', get_post_meta($this->options['post_id'], "{$prefix}item_padding", true));
     if ('' === $this->options['item_padding']) {
         $this->options['item_padding'] = 20;
     }
     $this->set('target_width', get_post_meta($this->options['post_id'], "{$prefix}target_width", true));
     if ('' === $this->options['target_width']) {
         $this->options['target_width'] = 370;
     }
     // load style
     $this->set('load_style', get_post_meta($this->options['post_id'], "{$prefix}load_style", true));
 }
 function presscore_congif_populate_portfolio_vars()
 {
     $config = presscore_config();
     $config->set_post_id($config->get('post_id'));
     $post_id = $config->get_post_id();
     $prefix = '_dt_portfolio_options_';
     $config->set_meta_prefix($prefix);
     // for categorizer compatibility
     if (!$config->get('order')) {
         $config->set_meta('order', 'order');
     }
     if (!$config->get('orderby')) {
         $config->set_meta('orderby', 'orderby');
     }
     if (!$config->get('display')) {
         $display = get_post_meta($post_id, '_dt_portfolio_display', true);
         if (!isset($display['terms_ids'])) {
             $display['terms_ids'] = null;
         }
         $config->set('display', $display);
     }
     $config->map(array('template.posts_filter.terms.enabled' => array('meta', 'show_filter'), 'template.posts_filter.orderby.enabled' => array('meta', 'show_orderby'), 'template.posts_filter.order.enabled' => array('meta', 'show_order'), 'posts_per_page' => array('meta', 'ppp'), 'full_width' => array('meta', 'full_width'), 'item_padding' => array('meta', 'item_padding', 20), 'post.preview.media.width' => array('meta', 'thumb_width', 30), 'load_style' => array('meta', 'load_style', 'default'), 'all_the_same_width' => array('meta', 'posts_same_width'), 'image_layout' => array('meta', 'image_layout'), 'thumb_proportions' => array('meta', 'thumb_proportions'), 'show_titles' => array('meta', 'show_titles'), 'show_excerpts' => array('meta', 'show_exerpts'), 'post.meta.fields.date' => array('meta', 'show_date_in_post_meta'), 'post.meta.fields.categories' => array('meta', 'show_categories_in_post_meta'), 'post.meta.fields.comments' => array('meta', 'show_comments_in_post_meta'), 'post.meta.fields.author' => array('meta', 'show_author_in_post_meta'), 'show_links' => array('meta', 'show_links'), 'show_details' => array('meta', 'show_details'), 'show_zoom' => array('meta', 'show_zoom'), 'show_all_pages' => array('meta', 'show_all_pages'), 'post.preview.buttons.details.enabled' => array('value', false), 'post.preview.background.enabled' => array('value', false), 'post.preview.background.style' => array('value', false)));
     // layout
     $template_name = dt_get_template_name($post_id, true);
     switch ($template_name) {
         case 'template-portfolio-masonry.php':
             $config->map(array('layout' => array('meta', 'masonry_layout'), 'post.preview.description.style' => array('meta', 'description', 'under_image'), 'post.preview.hover.animation' => array('meta', 'hover_animation', 'fade'), 'post.preview.hover.color' => array('meta', 'hover_bg_color', 'theme'), 'post.preview.hover.content.visibility' => array('meta', 'hover_content_visibility', 'on_hoover'), 'post.preview.hover.lines.animation' => array('meta', 'lines_animation_effect', '1'), 'post.preview.hover.title.visibility' => array('meta', 'title_visibility', 'on_hoover'), 'post.preview.width.min' => array('meta', 'target_width', 370), 'template.columns.number' => array('meta', 'columns_number', 3), 'post.preview.load.effect' => array('meta', 'load_effect', 'fade_in')));
             $description_style = $config->get('post.preview.description.style');
             // content alignment
             if ('on_hoover_centered' == $description_style) {
                 $config->set_meta('post.preview.description.alignment', 'bg_post_content_alignment');
             } else {
                 if ('bg_with_lines' == $description_style) {
                     $config->set('post.preview.description.alignment', false);
                 } else {
                     $config->set_meta('post.preview.description.alignment', 'post_content_alignment');
                 }
             }
             // preview background
             if ('under_image' == $description_style) {
                 $background_under_posts = get_post_meta($post_id, "{$prefix}bg_under_masonry_posts", true);
                 $config->set('post.preview.background.enabled', !in_array($background_under_posts, array('disabled', '')));
                 $config->set('post.preview.background.style', $background_under_posts, false);
             }
             break;
         case 'template-portfolio-jgrid.php':
             $config->map(array('layout' => array('value', 'grid'), 'post.preview.description.style' => array('meta', 'jgrid_description', 'on_hoover_centered'), 'post.preview.hover.animation' => array('meta', 'jgrid_hover_animation', 'fade'), 'post.preview.hover.color' => array('meta', 'jgrid_hover_bg_color', 'theme'), 'post.preview.hover.content.visibility' => array('meta', 'jgrid_hover_content_visibility', 'on_hoover'), 'post.preview.hover.lines.animation' => array('meta', 'jgrid_lines_animation_effect', '1'), 'post.preview.hover.title.visibility' => array('meta', 'jgrid_title_visibility', 'on_hoover'), 'target_height' => array('meta', 'target_height', 250), 'post.preview.load.effect' => array('meta', 'load_effect', 'fade_in'), 'justified_grid' => array('value', true), 'all_the_same_width' => array('value', true), 'hide_last_row' => array('meta', 'hide_last_row', false)));
             $description_style = $config->get('post.preview.description.style');
             // content alignment
             if ('on_hoover_centered' == $description_style) {
                 $config->set_meta('post.preview.description.alignment', 'jgrid_bg_post_content_alignment');
             } else {
                 if ('bg_with_lines' == $description_style) {
                     $config->set('post.preview.description.alignment', false);
                 } else {
                     $config->set_meta('post.preview.description.alignment', 'jgrid_post_content_alignment');
                 }
             }
             if ('default' != $config->get('load_style')) {
                 $config->set('hide_last_row', false);
             }
             break;
             // list layout
         // list layout
         default:
             $config->map(array('layout' => array('meta', 'list_layout'), 'post.preview.hover.color' => array('meta', 'list_hover_bg_color', 'accent'), 'post.preview.background.enabled' => array('meta', 'bg_under_list_posts', false), 'post.preview.background.style' => array('value', 'with_paddings'), 'post.preview.buttons.details.enabled' => array('meta', 'show_details_buttons', true), 'post.preview.load.effect' => array('value', 'fade_in')));
     }
 }