/** * Function which returns the CSS output for the bricks in a stack * Parameter: Stack ID */ function mp_stack_css($stack_id, $echo = false, $include_style_tags = true) { //Set the args for the new query $mp_stacks_args = array('post_type' => "mp_brick", 'posts_per_page' => -1, 'meta_key' => 'mp_stack_order_' . $stack_id, 'orderby' => 'meta_value_num', 'order' => 'ASC', 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'mp_stacks', 'field' => 'id', 'terms' => array($stack_id), 'operator' => 'IN'))); //Create new query for stacks $mp_stack_query = new WP_Query(apply_filters('mp_stacks_args', $mp_stacks_args)); $head_output = NULL; $css_output = $include_style_tags ? '<style type="text/css">' : NULL; //Loop through the stack group if ($mp_stack_query->have_posts()) { while ($mp_stack_query->have_posts()) { $mp_stack_query->the_post(); $post_id = get_the_ID(); //Build Brick CSS Output $css_output .= mp_brick_css($post_id, $stack_id); $head_output .= mp_brick_head_output($post_id, $stack_id); } $css_output .= $include_style_tags ? '</style>' : NULL; if ($echo == true) { echo $css_output; echo $head_output; } else { return $css_output . $head_output; } } }
/** * Deprecated. Output css for all bricks on this page into the footer of the theme * Parameter: none * Global Variable: array $mp_bricks_on_page This array contains all the ids of every brick previously called on this page */ function mp_stacks_footer_css() { //Get all the stack ids used on this page global $mp_bricks_on_page; if (!empty($mp_bricks_on_page)) { echo '<style type="text/css">'; //Show css for each foreach ($mp_bricks_on_page as $brick_id) { echo mp_brick_css($brick_id, 'footer_css'); } echo '</style>'; //If there is at least 1 brick on this page, enqueue the stuff we need if (isset($brick_id)) { //Enqueue hook for add-on scripts do_action('mp_stacks_enqueue_scripts', $mp_bricks_on_page); } } }