/** * Process the CSS needed for the grid * * @access public * @since 1.0.0 * @param $css_output String - The incoming CSS output coming from other things using this filter * @param $post_id Int - The post ID of the brick * @param $first_content_type String - The first content type chosen for this brick * @param $second_content_type String - The second content type chosen for this brick * @return $html_output String - A string holding the css the brick */ function mp_stacks_brick_content_output_css_postgrid($css_output, $post_id, $first_content_type, $second_content_type) { if ($first_content_type != 'postgrid' && $second_content_type != 'postgrid') { return $css_output; } //Download per row $postgrid_per_row = mp_core_get_post_meta($post_id, 'postgrid_per_row', '3'); //Post Spacing (padding) $postgrid_post_spacing = mp_core_get_post_meta($post_id, 'postgrid_post_spacing', '20'); //Post Inner Margin (padding) $postgrid_post_inner_margin = mp_core_get_post_meta($post_id, 'postgrid_post_inner_margin', '0'); //Padding inside the featured images $postgrid_featured_images_inner_margin = mp_core_get_post_meta($post_id, 'postgrid_featured_images_inner_margin', '10'); //Image Overlay Color and Opacity $postgrid_images_overlay_color = mp_core_get_post_meta($post_id, 'postgrid_images_overlay_color', '#FFF'); $postgrid_images_overlay_opacity = mp_core_get_post_meta($post_id, 'postgrid_images_overlay_opacity', '0'); //Max Image Width $postgrid_feat_img_max_width = mp_core_get_post_meta($post_id, 'postgrid_feat_img_max_width', '0'); $img_max_width_css = empty($postgrid_feat_img_max_width) ? NULL : '#mp-brick-' . $post_id . ' .mp-stacks-grid-item-image-holder{ max-width: ' . $postgrid_feat_img_max_width . 'px;}'; //Use the Excerpt's Color as the default fallback for all text in the grid $default_text_color = mp_core_get_post_meta($post_id, 'postgrid_excerpt_color'); //Padding for items directly under the image $postgrid_post_below_image_area_inner_margin = mp_core_get_post_meta($post_id, 'postgrid_post_below_image_area_inner_margin', '0'); //Get CSS Output $css_output .= ' #mp-brick-' . $post_id . ' .mp-stacks-grid-item{' . mp_core_css_line('color', $default_text_color) . mp_core_css_line('width', round(100 / $postgrid_per_row, 1), '%') . mp_core_css_line('padding', $postgrid_post_spacing, 'px') . '} #mp-brick-' . $post_id . ' .mp-stacks-grid-item-inner{' . mp_core_css_line('padding', $postgrid_post_inner_margin, 'px') . ' }' . $img_max_width_css . ' #mp-brick-' . $post_id . ' .mp-stacks-grid-item-inner .mp-stacks-grid-item-below-image-holder{' . mp_core_css_line('padding', $postgrid_post_below_image_area_inner_margin, 'px') . ' } /*Below image, remove the padding-top (spacing) from the first text item*/ #mp-brick-' . $post_id . ' .mp-stacks-grid-item-inner .mp-stacks-grid-item-below-image-holder [class*="link"]:first-child [class*="holder"]{ ' . ($postgrid_post_below_image_area_inner_margin != '0' ? 'padding-top:0px!important;' : NULL) . ' } /*Over image, remove the padding-top (spacing) from the first text item*/ #mp-brick-' . $post_id . ' .mp-stacks-grid .mp-stacks-grid-item .mp-stacks-grid-item-inner .mp-stacks-grid-over-image-text-container-table-cell [class*="holder"]:first-child{ padding-top:0px; }'; $css_output .= apply_filters('mp_stacks_postgrid_css', $css_output, $post_id); $css_output .= ' #mp-brick-' . $post_id . ' .mp-stacks-grid-over-image-text-container, #mp-brick-' . $post_id . ' .mp-stacks-grid-over-image-text-container-top, #mp-brick-' . $post_id . ' .mp-stacks-grid-over-image-text-container-middle, #mp-brick-' . $post_id . ' .mp-stacks-grid-over-image-text-container-bottom{' . mp_core_css_line('padding', $postgrid_featured_images_inner_margin, 'px') . '}'; //Get the css output the the isotope button navigation $css_output .= mp_stacks_grid_isotope_nav_btns_css($post_id, 'postgrid'); //Get the css output for the image overlay for mobile $css_output .= mp_stacks_grid_overlay_mobile_css($post_id, 'postgrid_image_overlay_animation_keyframes'); //Get the bg color for each post $css_output .= mp_stacks_grid_bg_color_css($post_id, mp_core_get_post_meta($post_id, 'postgrid_taxonomy_terms', array()), 'taxonomy_bg_color'); return $css_output; }
/** * If this brick has previously saved the old 'text' content-type, keep using that. * * @since 1.0.0 * @link http://mintplugins.com/doc/ * @param array $default_content_types See link for description. * @return array $default_content_types */ function mp_stacks_default_content_types_doubletext($default_content_types) { //If there is a post id in the URL (ie this has been saved) if (isset($_GET['post'])) { $post_id = $_GET['post']; //Check what is currently saved in each content type slot $ct_1 = mp_core_get_post_meta($post_id, 'brick_first_content_type'); $ct_2 = mp_core_get_post_meta($post_id, 'brick_second_content_type'); //If this content-type was previously saved as a 'text', it's an "old" brick. if ($ct_1 == 'text' || $ct_2 == 'text') { $default_content_types = array('none' => 'None', 'text' => 'Text', 'image' => 'Image', 'video' => 'Video'); } else { $default_content_types = array('none' => 'None', 'singletext' => 'Text', 'image' => 'Image', 'video' => 'Video'); } } return $default_content_types; }
/** * If Menu Order URL variable is set, Make a new field for it on edit pages * * @since 1.0.0 * @link http://mintplugins.com/doc/ * @return array $plugin_array */ function mp_stacks_display_brick_mp_stack_order_input_field() { global $post; if ($post->post_type == 'mp_brick') { //When a new brick is being saved. if (isset($_GET['mp_stack_order_new']) && isset($_GET['mp_stack_id'])) { // Set up nonce for verification wp_nonce_field(plugin_basename(__FILE__), 'mp_stacks_mp_stack_order_nonce'); //Create a field for the new brick's stack and its order position within that stack echo '<input type="hidden" class="mp_stack_order" name="mp_stack_order[' . $_GET['mp_stack_id'] . ']" value="' . $_GET['mp_stack_order_new'] . '">'; } elseif (isset($_GET['post']) && isset($_GET['mp_stack_id'])) { $post_id = $_GET['post']; $stack_id = $_GET['mp_stack_id']; $stack_order = mp_core_get_post_meta($post_id, 'mp_stack_order_' . $stack_id); //Create a field for the new brick's stack and its order position within that stack echo '<input type="hidden" class="mp_stack_order" value="' . $stack_order . '">'; } } }
/** * Return a CSS line for border by giving just a post id and a meta prefix. The post must have the meta for each of the settings for this to work as expected. * * @access public * @since 1.0.0 * @param $post_id The id of the post where the related meta is saved. * @param $meta_prefix The prefix to put before each post meta string. * @return void */ function mp_core_stroke_css($post_id, $meta_prefix) { //Get the stroke settings $stroke_size = mp_core_get_post_meta($post_id, $meta_prefix . 'stroke_size', 0); $stroke_color = mp_core_get_post_meta($post_id, $meta_prefix . 'stroke_color', '#FFF'); $stroke_color = mp_core_hex2rgb($stroke_color); $stroke_opacity = mp_core_get_post_meta($post_id, $meta_prefix . 'stroke_opacity', '100'); $stroke_opacity = $stroke_opacity / 100; //Set the the RGBA string including the alpha $stroke_color = 'rgba( ' . $stroke_color[0] . ', ' . $stroke_color[1] . ', ' . $stroke_color[2] . ', ' . $stroke_opacity . ')'; //Create the css border string $css_output = 'border: solid ' . $stroke_size . 'px ' . $stroke_color . ';'; return $css_output; }
/** * Add the JS for the excerpt to PostGrid's HTML output * * @access public * @since 1.0.0 * @param $existing_filter_output String - Any output already returned to this filter previously * @param $post_id String - the ID of the Brick where all the meta is saved. * @param $meta_prefix String - the prefix to put before each meta_field key to differentiate it from other plugins. :EG "postgrid" * @return $new_grid_output - the existing grid output with additional thigns added by this function. */ function mp_stacks_postgrid_excerpt_animation_js($existing_filter_output, $post_id, $meta_prefix) { if ($meta_prefix != 'postgrid') { return $existing_filter_output; } //Get JS output to animate the excerpts on mouse over and out $excerpt_animation_js = mp_core_js_mouse_over_animate_child('#mp-brick-' . $post_id . ' .mp-stacks-grid-item', '.mp-stacks-postgrid-item-excerpt-holder', mp_core_get_post_meta($post_id, 'postgrid_excerpt_animation_keyframes', array())); return $existing_filter_output .= $excerpt_animation_js; }
/** * The "Load More" button, "Infinite Scroll", or "Pagination" depending on what the user has decided. * * @access public * @since 1.0.0 * @param Void * @param $post_id Int - The ID of the Brick * @param $load_more_args array - Values needed to output the load more/pagination * @return String - The HTML needed to make the load more button/pagination. */ function mp_stacks_grid_load_more_html_output($load_more_html_output, $post_id, $load_more_args) { //Assemble args for the load more output $default_load_more_args = array('meta_prefix' => NULL, 'total_posts' => 0, 'posts_per_page' => 0, 'paged' => 0, 'post_offset' => 0, 'orderby' => NULL); $args = wp_parse_args($load_more_args, $default_load_more_args); //Load More Behaviour? $load_more_behaviour = mp_core_get_post_meta($post_id, $args['meta_prefix'] . '_load_more_behaviour', 'ajax_load_more'); //Load More Button Text $load_more_button_text = mp_core_get_post_meta($post_id, $args['meta_prefix'] . '_load_more_button_text', __('Load More', 'mp_stacks')); //Check spacing (padding) around posts to see if we need to add some specially to our load more button(s) $post_spacing = mp_core_get_post_meta($post_id, $args['meta_prefix'] . '_post_spacing', '20'); $load_more_spacing = $post_spacing == 0 ? 'padding:20px;' : 'padding-bottom:' . $post_spacing . 'px'; //If we are using the ajax_load_more_style if ($load_more_behaviour == 'ajax_load_more') { //If there are no more posts in this taxonomy if ($args['total_posts'] <= $args['post_offset']) { //Return without a button return NULL; } //Button return '<div class="mp-stacks-grid-load-more-container" style="' . $load_more_spacing . '"><a mp_stacks_grid_post_id="' . $post_id . '" mp_stacks_grid_brick_offset="' . $args['post_offset'] . '" mp_stacks_grid_orderby="' . $args['orderby'] . '" mp_stacks_grid_loading_text="' . __('Loading...', 'mp_stacks') . '" mp_stacks_grid_ajax_prefix=' . $args['meta_prefix'] . ' class="button mp-stacks-grid-load-more-button">' . $load_more_button_text . '</a>' . mp_stacks_grid_loading_more_animation('none') . '</div>'; } else { if ($load_more_behaviour == 'infinite_scroll') { //If there are no more posts in this taxonomy if ($args['total_posts'] <= $args['post_offset']) { //Return without a button return NULL; } //JS for the Load More Button $load_more_output = '<div class="mp-stacks-grid-load-more-container" style="' . $load_more_spacing . '"><a mp_stacks_grid_post_id="' . $post_id . '" mp_stacks_grid_brick_offset="' . $args['post_offset'] . '" mp_stacks_grid_orderby="' . $args['orderby'] . '" mp_stacks_grid_loading_text="' . __('Loading...', 'mp_stacks') . '" mp_stacks_grid_ajax_prefix=' . $args['meta_prefix'] . ' class="button mp-stacks-grid-load-more-button">' . $load_more_button_text . '</a>' . mp_stacks_grid_loading_more_animation('none') . '</div>'; //If we are not doing ajax if (!defined('DOING_AJAX')) { //Add the JS Which activates Infinite Scroll using Waypoints $load_more_output .= '<script type="text/javascript"> jQuery(document).ready(function($){ $(\'#mp-brick-' . $post_id . ' .mp-stacks-grid-after\').waypoint(function( direction ) { if (direction === \'up\') return; $(\'#mp-brick-' . $post_id . ' .mp-stacks-grid-load-more-button\').trigger(\'click\' ); }, { offset: \'bottom-in-view\' }); }); </script>'; } return $load_more_output; } else { if ($load_more_behaviour == 'pagination') { //Figure out how many pages there based on the count and posts per page $pages = ceil($args['total_posts'] / $args['posts_per_page']); $page_counter = 1; $load_more_output = '<div class="mp-stacks-grid-load-more-container" style="' . $load_more_spacing . '"><nav id="posts-navigation" class="row pagination mp-core-pagination" style="float:none;"> <ul class="page-numbers">'; //Set the base URL based on the current url by removing any brick pagination $base_url = explode('?', mp_core_get_current_url()); $url_args = isset($base_url[1]) ? '?' . $base_url[1] : NULL; $base_url = explode('brick/', mp_core_get_current_url()); $base_url = $base_url[0]; //Create the page number links by looping through each posts per page while ($page_counter <= $pages) { //If we have more than 4 pages (and it is't just 5 where this isn't useful), use show the first 3 page numbers, then show a ..., then show the last page number if ($pages > 4 && $pages != 5) { //If we aren't on the last page or the first page if ($page_counter != $pages && $page_counter != 1) { //If we are more than 3 pages before the current page and we are not on the first or last page if ($page_counter == $args['paged'] - 3) { //Just show 3 dots $load_more_output .= '<li><span class="page-numbers dots">...</span></li>'; $page_counter = $page_counter + 1; continue; } //If we are 3 pages after the current page AND we aren't on the first or last page if ($page_counter == $args['paged'] + 3) { //Just show 3 dots $load_more_output .= '<li><span class="page-numbers dots">...</span></li>'; $page_counter = $page_counter + 1; continue; } else { if ($page_counter > $args['paged'] + 3) { $page_counter = $page_counter + 1; continue; } } } } if ($page_counter == $args['paged']) { $load_more_output .= '<li><span class="page-numbers current">' . $page_counter . '</span></li>'; } else { $load_more_output .= '<li><a class="page-numbers" href="' . $base_url . 'brick/' . $args['brick_slug'] . '/page/' . $page_counter . '/' . $url_args . '">' . $page_counter . '</a></li>'; } $page_counter = $page_counter + 1; } $load_more_output .= '</ul> </nav></div>'; return $load_more_output; } else { if ($load_more_behaviour == 'none') { return NULL; } } } } }
/** * Filter Function which returns conditional responsive css margins for a brick * Parameter: CSS output * Parameter: Post ID */ function mp_stacks_default_brick_margins($css_output, $post_id) { //Check alignment $brick_alignment = mp_core_get_post_meta($post_id, 'brick_alignment', 'leftright'); //Check if there is a content type in slot #2 $mp_stacks_second_content_type = mp_core_get_post_meta($post_id, 'brick_second_content_type', 'none'); //Check c1's above margins $brick_min_above_c1 = mp_core_get_post_meta($post_id, 'brick_min_above_c1', 0); //If there is no second content-type OR this is a left/right alignmnet, don't apply the 20px bottom margin if ($mp_stacks_second_content_type == 'none' || $brick_alignment == 'leftright') { //Check c1's below margins (default to 0) $brick_min_below_c1 = mp_core_get_post_meta($post_id, 'brick_min_below_c1', 0); } else { //Check c1's below margins (default to 10) $brick_min_below_c1 = mp_core_get_post_meta($post_id, 'brick_min_below_c1', 20); } //Check c2's above margins $brick_min_above_c2 = mp_core_get_post_meta($post_id, 'brick_min_above_c2', 0); //Check c2's below margins $brick_min_below_c2 = mp_core_get_post_meta($post_id, 'brick_min_below_c2', 0); //Add custom margin to the 1st content type $css_output .= '#mp-brick-' . $post_id . ' .mp-brick-content-types > .mp-brick-content-types-inner > .mp-brick-content-type-container .mp-brick-first-content-type { margin-top:' . $brick_min_above_c1 . 'px; margin-bottom:' . $brick_min_below_c1 . 'px; }'; //If there is a second content type if ($mp_stacks_second_content_type != 'none') { //For Mobile, add custom margin below the 1st content type - if none, default to 20 $css_output .= '#mp-brick-' . $post_id . '[max-width~=\'600px\'] .mp-brick-content-types > .mp-brick-content-types-inner > .mp-brick-content-type-container .mp-brick-first-content-type {'; //If there is no value to add below the first content-type, default to 20 $css_output .= !empty($brick_min_below_c1) ? 'margin-bottom:' . $brick_min_below_c1 . 'px' : 'margin-bottom:20px'; $css_output .= '}'; } //Add custom margin to the 2nd content type $css_output .= '#mp-brick-' . $post_id . ' .mp-brick-content-types > .mp-brick-content-types-inner > .mp-brick-content-type-container .mp-brick-second-content-type { margin-top:' . $brick_min_above_c2 . 'px; margin-bottom:' . $brick_min_below_c2 . 'px; }'; //Return CSS Output return $css_output; }
/** * Run the Grid Loop and Return the HTML Output, Load More Button, and Animation Trigger for the Grid * * @access public * @since 1.0.0 * @param Void * @param $post_id Int - The ID of the Brick * @param $post_offset Int - The number of posts deep we are into the loop (if doing ajax). If not doing ajax, set this to 0; * @return Array - HTML output from the Grid Loop, The Load More Button, and the Animation Trigger in an array for usage in either ajax or not. */ function mp_stacks_postgrid_output($post_id, $post_offset = NULL) { global $wp_query; //Start up the PHP session if there isn't one already if (!isset($_SESSION)) { session_start(); } //If we are NOT doing ajax get the parent's post id from the wp_query. if (!defined('DOING_AJAX')) { $queried_object_id = $wp_query->queried_object_id; $_SESSION['mp_stacks_downloadgrid_queryobjid_' . $post_id] = $queried_object_id; } else { $queried_object_id = $_SESSION['mp_stacks_downloadgrid_queryobjid_' . $post_id]; } //Get this Brick Info $post = get_post($post_id); $postgrid_output = NULL; //Get Original Download Taxonomy Term to Loop through (old way) $postgrid_taxonomy_term = mp_core_get_post_meta($post_id, 'postgrid_taxonomy_term', ''); //Get taxonomy term repeater (new way) $postgrid_taxonomy_terms = mp_core_get_post_meta($post_id, 'postgrid_taxonomy_terms', ''); //Download per row $postgrid_per_row = mp_core_get_post_meta($post_id, 'postgrid_per_row', '3'); //Download per page $postgrid_per_page = mp_core_get_post_meta($post_id, 'postgrid_per_page', '9'); //Set the args for the new query $postgrid_args = array('order' => 'DESC', 'paged' => 0, 'post_status' => 'publish', 'posts_per_page' => $postgrid_per_page, 'tax_query' => array('relation' => 'OR')); $orderby = mp_stacks_grid_order_by($post_id, 'postgrid'); //Set the order by options for the wp query switch ($orderby) { case 'date_newest_to_oldest': $postgrid_args['orderby'] = 'date'; $postgrid_args['order'] = 'DESC'; break; case 'date_oldest_to_newest': $postgrid_args['orderby'] = 'date'; $postgrid_args['order'] = 'ASC'; break; case 'most_comments': $postgrid_args['orderby'] = 'comment_count'; break; case 'random': $postgrid_args['orderby'] = 'rand'; break; } //If there are tax terms selected to show (the "new" way with multiple terms) if (is_array($postgrid_taxonomy_terms) && !empty($postgrid_taxonomy_terms[0]['taxonomy_term'])) { //Loop through each term the user added to this postgrid foreach ($postgrid_taxonomy_terms as $postgrid_taxonomy_term) { //If we should show related posts if ($postgrid_taxonomy_term['taxonomy_term'] == 'related_posts') { $tags = wp_get_post_terms($queried_object_id, apply_filters('mp_stacks_postgrid_related_posts_tax_slug', 'post_tag', $post_id)); if (is_object($tags)) { $tags_array = $tags; } elseif (is_array($tags)) { $tags_array = isset($tags[0]) ? $tags[0] : NULL; } $tag_slugs = wp_get_post_terms($queried_object_id, apply_filters('mp_stacks_postgrid_related_posts_tax_slug', 'post_tag', $post_id), array("fields" => "slugs")); //Add the related tags as a tax_query to the WP_Query $postgrid_args['tax_query'][] = array('taxonomy' => apply_filters('mp_stacks_postgrid_related_posts_tax_slug', 'post_tag', $post_id), 'field' => 'slug', 'terms' => $tag_slugs); } else { //Add this term to the tax_query $postgrid_args['tax_query'][] = array('taxonomy' => apply_filters('mp_stacks_postgrid_main_tax_slug', 'category', $post_id), 'field' => 'id', 'terms' => $postgrid_taxonomy_term['taxonomy_term'], 'operator' => 'IN'); } } } else { if (!empty($postgrid_taxonomy_term)) { //Get PostGrid Metabox Repeater Array $termid_taxname = explode('*', $postgrid_taxonomy_term); if (!isset($termid_taxname[1]) || !isset($termid_taxname[0])) { return; } //Add this term to the tax_query $postgrid_args['tax_query'][] = array('taxonomy' => $termid_taxname[1], 'field' => 'id', 'terms' => $termid_taxname[0], 'operator' => 'IN'); } else { return false; } } //If we are using Offset if (!empty($post_offset)) { //Add offset args to the WP_Query $postgrid_args['offset'] = $post_offset; } else { if (isset($wp_query->query['mp_brick_pagination_slugs'])) { //Get the brick slug $pagination_brick_slugs = explode('|||', $wp_query->query['mp_brick_pagination_slugs']); $pagination_brick_page_numbers = explode('|||', $wp_query->query['mp_brick_pagination_page_numbers']); $brick_pagination_counter = 0; //Loop through each brick in the url which has pagination foreach ($pagination_brick_slugs as $brick_slug) { //If this brick is the one we want to paginate if ($brick_slug == $post->post_name) { //Add page number to the WP_Query $postgrid_args['paged'] = $pagination_brick_page_numbers[$brick_pagination_counter]; //Set the post offset variable to start at the end of the current page $post_offset = isset($postgrid_args['paged']) ? $postgrid_args['paged'] * $postgrid_per_page - $postgrid_per_page : 0; } //Increment the counter which aligns $pagination_brick_page_numbers to $pagination_brick_slugs $brick_pagination_counter = $brick_pagination_counter + 1; } } } //Show Download Images? $postgrid_featured_images_show = mp_core_get_post_meta_checkbox($post_id, 'postgrid_featured_images_show', true); //Download Image width and height $postgrid_featured_images_width = mp_core_get_post_meta($post_id, 'postgrid_featured_images_width', '300'); $postgrid_featured_images_height = mp_core_get_post_meta($post_id, 'postgrid_featured_images_height', '200'); //Get the options for the grid placement - we pass this to the action filters for text placement $grid_placement_options = apply_filters('mp_stacks_postgrid_placement_options', NULL, $post_id); //Get the JS for animating items - only needed the first time we run this - not on subsequent Ajax requests. if (!defined('DOING_AJAX')) { //Here we set javascript for this grid $postgrid_output .= apply_filters('mp_stacks_grid_js', NULL, $post_id, 'postgrid'); } //Add HTML that sits before the "grid" div $postgrid_output .= !defined('DOING_AJAX') ? apply_filters('mp_stacks_grid_before', NULL, $post_id, 'postgrid', $postgrid_taxonomy_terms) : NULL; //Get Download Output $postgrid_output .= !defined('DOING_AJAX') ? '<div class="mp-stacks-grid ' . apply_filters('mp_stacks_grid_classes', NULL, $post_id, 'postgrid') . '">' : NULL; //Create new query for stacks $postgrid_query = new WP_Query(apply_filters('postgrid_args', $postgrid_args)); $total_posts = $postgrid_query->found_posts; //Loop through the stack group if ($postgrid_query->have_posts()) { while ($postgrid_query->have_posts()) { $postgrid_query->the_post(); $grid_post_id = get_the_ID(); //Reset Grid Classes String $source_counter = 0; $post_source_num = NULL; $grid_item_inner_bg_color = NULL; //If there are multiple tax terms selected to show if (is_array($postgrid_taxonomy_terms) && !empty($postgrid_taxonomy_terms[0]['taxonomy_term'])) { //Loop through each "repeat" source the user added to this postgrid foreach ($postgrid_taxonomy_terms as $postgrid_taxonomy_term) { //If we should show related posts if ($postgrid_taxonomy_term['taxonomy_term'] == 'related_posts') { //Store the source this post belongs to $post_source_num = $source_counter; //Add the bg color for this post if (!empty($postgrid_taxonomy_term['taxonomy_bg_color'])) { $grid_item_inner_bg_color = $postgrid_taxonomy_term['taxonomy_bg_color']; } } else { if (has_term($postgrid_taxonomy_term['taxonomy_term'], 'category', $grid_post_id)) { //Store the source this post belongs to $post_source_num = $source_counter; //Set the bg color for this post if (!empty($postgrid_taxonomy_term['taxonomy_bg_color'])) { $grid_item_inner_bg_color = $postgrid_taxonomy_term['taxonomy_bg_color']; } } } $source_counter = $source_counter + 1; } } //Add our custom classes to the grid-item $class_string = 'mp-stacks-grid-source-' . $post_source_num . ' mp-stacks-grid-item mp-stacks-grid-item-' . $grid_post_id . ' '; //Add all posts that would be added from the post_class wp function as well $class_string = join(' ', get_post_class($class_string, $grid_post_id)); $class_string = apply_filters('mp_stacks_grid_item_classes', $class_string, $post_id, 'postgrid'); //Get the Grid Item Attributes $grid_item_attribute_string = apply_filters('mp_stacks_grid_attribute_string', NULL, $postgrid_taxonomy_terms, $grid_post_id, $post_id, 'postgrid', $post_source_num); $postgrid_output .= '<div class="' . $class_string . '" ' . $grid_item_attribute_string . '>'; $postgrid_output .= '<div class="mp-stacks-grid-item-inner" ' . (!empty($grid_item_inner_bg_color) ? 'mp-default-bg-color="' . $grid_item_inner_bg_color . '"' : NULL) . '>'; //Add htmloutput directly inside this grid item $postgrid_output .= apply_filters('mp_stacks_grid_inside_grid_item_top', NULL, $postgrid_taxonomy_terms, $post_id, 'postgrid', $grid_post_id, $post_source_num); //Microformats $postgrid_output .= ' <article class="microformats hentry" style="display:none;"> <h2 class="entry-title">' . get_the_title() . '</h2> <span class="author vcard"><span class="fn">' . get_the_author() . '</span></span> <time class="published" datetime="' . get_the_time('Y-m-d H:i:s') . '">' . get_the_date() . '</time> <time class="updated" datetime="' . get_the_modified_date('Y-m-d H:i:s') . '">' . get_the_modified_date() . '</time> <div class="entry-summary">' . mp_core_get_excerpt_by_id($grid_post_id) . '</div> </article>'; //If we should show the featured images if ($postgrid_featured_images_show) { $postgrid_output .= '<div class="mp-stacks-grid-item-image-holder">'; $postgrid_output .= '<div class="mp-stacks-grid-item-image-overlay"></div>'; //Output the link for this postgrid post. $postgrid_output .= '<a href="' . apply_filters('mp_stacks_postgrid_grid_post_permalink', get_permalink(), $grid_post_id, $post_id) . '" class="mp-stacks-grid-image-link ' . apply_filters('mp_stacks_postgrid_grid_postlink_classes', NULL, $grid_post_id) . '">'; //Get the featured image and crop according to the user's specs if ($postgrid_featured_images_height > 0 && !empty($postgrid_featured_images_height)) { $featured_image = mp_core_the_featured_image($grid_post_id, $postgrid_featured_images_width, $postgrid_featured_images_height); } else { $featured_image = mp_core_the_featured_image($grid_post_id, $postgrid_featured_images_width); } $postgrid_output .= '<img src="' . $featured_image . '" class="mp-stacks-grid-item-image" title="' . the_title_attribute('echo=0') . '" alt="' . the_title_attribute('echo=0') . '" />'; //Top Over $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-top">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table-cell">'; //Filter Hook to output HTML into the "Top" and "Over" position on the featured Image $postgrid_output .= apply_filters('mp_stacks_postgrid_top_over', NULL, $grid_post_id, $grid_placement_options); $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; //Middle Over $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-middle">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table-cell">'; //Filter Hook to output HTML into the "Middle" and "Over" position on the featured Image $postgrid_output .= apply_filters('mp_stacks_postgrid_middle_over', NULL, $grid_post_id, $grid_placement_options); $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; //Bottom Over $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-bottom">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table">'; $postgrid_output .= '<div class="mp-stacks-grid-over-image-text-container-table-cell">'; //Filter Hook to output HTML into the "Bottom" and "Over" position on the featured Image $postgrid_output .= apply_filters('mp_stacks_postgrid_bottom_over', NULL, $grid_post_id, $grid_placement_options); $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; $postgrid_output .= '</div>'; $postgrid_output .= '</a>'; $postgrid_output .= '</div>'; } //Filter Hook to output HTML into the "Below" position on the featured Image $postgrid_below = apply_filters('mp_stacks_postgrid_below', NULL, $grid_post_id, $post_id, $grid_placement_options); if (!empty($postgrid_below)) { //Below Image Area Container: $postgrid_output .= '<div class="mp-stacks-grid-item-below-image-holder">'; //Filter Hook to output HTML into the "Below" position on the featured Image $postgrid_output .= $postgrid_below; $postgrid_output .= '</div>'; } $postgrid_output .= '</div></div>'; //Increment Offset $post_offset = $post_offset + 1; } } //If we're not doing ajax, add the stuff to close the postgrid container and items needed after if (!defined('DOING_AJAX')) { $postgrid_output .= '</div>'; } //jQuery Trigger to reset all postgrid animations to their first frames $animation_trigger = '<script type="text/javascript">jQuery(document).ready(function($){ $(document).trigger("mp_core_animation_set_first_keyframe_trigger"); });</script>'; //Assemble args for the load more output $load_more_args = array('meta_prefix' => 'postgrid', 'total_posts' => $total_posts, 'posts_per_page' => $postgrid_per_page, 'paged' => $postgrid_args['paged'], 'post_offset' => $post_offset, 'brick_slug' => $post->post_name); return array('postgrid_output' => $postgrid_output, 'load_more_button' => apply_filters('mp_stacks_postgrid_load_more_html_output', $load_more_html = NULL, $post_id, $load_more_args), 'animation_trigger' => $animation_trigger, 'postgrid_after' => '<div class="mp-stacks-grid-item-clearedfix"></div><div class="mp-stacks-grid-after"></div>'); }
/** * Set the orderby string based on the URL or the Brick's Meta settings. * * @access public * @since 1.0.0 * @param $post_id String - the ID of the Brick where all the meta is saved. * @param $meta_prefix String - the prefix to put before each meta_field key to differentiate it from other plugins. :EG "postgrid" * @return $return_html String The html for the dropdown where the user chooses the orderby options */ function mp_stacks_grid_orderby_output($post_id, $meta_prefix) { $return_html = NULL; //Before we get to the isotope output, check if there are any orderby options first $orderby_options = mp_core_get_post_meta_multiple_checkboxes($post_id, $meta_prefix . '_isotope_orderby_options', array()); //If orderby options have been set if (is_array($orderby_options) && !empty($orderby_options)) { //Get any orderby params from the URL that might exist $url_order_by = isset($_GET['mp_orderby_' . $post_id]) ? sanitize_text_field($_GET['mp_orderby_' . $post_id]) : NULL; //If there isn't a URL orderby param, get the default orderby setting $default_orderby = empty($url_order_by) ? mp_core_get_post_meta($post_id, $meta_prefix . '_default_orderby', 'date') : $url_order_by; //Add an orderby dropdown menu before the first isotope dropdown $return_html .= '<select class="button mp-stacks-grid-orderby-select" id="mp-isotope-sort-select-' . $post_id . '" class="mp-stacks-grid-orderby-select" value="' . $default_orderby . '">'; //Nicely named orderby options $nicelynamed_orderby_options = apply_filters($meta_prefix . '_isotope_orderby_options', array(), $meta_prefix); //Add each orderby option to the output foreach ($orderby_options as $orderby_option) { $return_html .= '<option orderby_url="' . mp_core_add_query_arg(array('mp_orderby_' . $post_id => $orderby_option), mp_core_get_current_url()) . '" value="' . $orderby_option . '" ' . ($default_orderby == $orderby_option ? ' selected' : NULL) . ' >' . __('Order By: ', 'mp_stacks') . $nicelynamed_orderby_options[$orderby_option] . '</option>'; } $return_html .= '</select>'; } return $return_html; }