/** * Determine the context that will be used by the content() method */ public function context() { global $wp_query; $context = Maera()->cache->get_context(); $post = new TimberPost(); $context['post'] = $post; $context['posts'] = Timber::get_posts(); // Compatibility hack or plugins that change the content. if ($this->plugins_compatibility()) { $context['content'] = maera_get_echo('the_content'); } if (is_singular()) { $context['wp_title'] .= ' - ' . $post->title(); } if (is_search()) { $context['title'] = __('Search results for ', 'maera') . get_search_query(); } if (is_archive() || is_home()) { $context['posts'] = Timber::query_posts(false, 'TimberPost'); $context['title'] = get_the_archive_title(); if (is_author()) { $author = new TimberUser($wp_query->query_vars['author']); $context['author'] = $author; } } if (class_exists('WooCommerce')) { global $product; $context['product'] = $product; } return $context; }
/** * Render the widget on the front end. * @todo TODO * @since 1.0.0 */ public function widget($args, $instance) { echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . $instance['title'] . $args['after_title']; } Maera()->views->render('site-logo.twig'); echo $args['after_widget']; }
/** * Get the twig file and pass the replacement to it. * This function is just a helper for the do_twig_replacements function. */ public function twig_replacements($replacement = false) { // If no replacement has been defined, exit. if (!$replacement) { return; } $context = Timber::get_context(); $context['element'] = $replacement; Timber::render(array('twig-str_replace.twig'), $context, Maera()->cache->cache_duration()); }
/** * Render the slider widget. * @todo TODO * @since 1.0.0 */ function widget($args, $instance) { extract($args); $query_args = array('post_type' => 'slide', 'posts_per_page' => $instance['per_page'], 'offset' => $instance['offset']); $widget = array('interval' => $instance['interval'], 'pause' => $instance['pause'], 'wrap' => $instance['wrap'], 'parallax' => $instance['parallax'], 'second_image' => $instance['second_image'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title); $context = Maera()->cache->get_context(); $context['slide'] = Timber::query_post(); $context['slides'] = Timber::get_posts($query_args); $context['widget'] = $widget; Timber::render('slider.twig', $context, Maera()->cache->cache_duration()); wp_reset_postdata(); }
/** * Render the menu widget. * @todo TODO * @since 1.0.0 */ function widget($args, $instance) { extract($args); $query_args = array('post_type' => 'restaurant_item', 'posts_per_page' => $instance['per_page']); $widget = array('title' => apply_filters('widget_title', $instance['title']), 'show_price' => $instance['show_price'], 'show_featured_images' => $instance['show_featured_images'], 'show_tags' => $instance['show_tags'], 'show_menu_link' => $instance['show_menu_link'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title); $context = Maera()->cache->get_context(); $context['menu_item'] = Timber::query_post(); $context['menu_items'] = Timber::get_posts($query_args); $context['widget'] = $widget; Timber::render('menu.twig', $context, Maera()->cache->cache_duration()); wp_reset_postdata(); }
/** * Render the widget on the front end. * @todo TODO * @since 1.0.0 */ function widget($args, $instance) { extract($args); if (isset($instance['term']) && 'any' != $instance['term']) { $tax_query = array(array('taxonomy' => $instance['taxonomy'], 'terms' => $instance['term'])); } else { $tax_query = ''; } $query_args = array('post_type' => $instance['post_type'], 'tax_query' => $tax_query, 'posts_per_page' => $instance['per_page'], 'offset' => $instance['offset']); $widget = array('title' => apply_filters('widget_title', $instance['title']), 'thumb' => $instance['thumb'], 'thumb_float' => $instance['thumb_float'], 'thumb_width' => $instance['thumb_width'], 'thumb_height' => $instance['thumb_height'], 'excerpt_length' => $instance['excerpt_length'], 'more_text' => $instance['more_text'], 'post_title_size' => $instance['post_title_size'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title); $context = Maera()->cache->get_context(); $context['post'] = Timber::query_post(); $context['posts'] = Timber::get_posts($query_args); $context['widget'] = $widget; Timber::render('widget-extended-posts.twig', $context, Maera()->cache->cache_duration()); wp_reset_query(); }
function settings_page() { ?> <div class="wrap metabox-holder"> <?php echo Maera()->admin->tabs_head('addons'); ?> <h2><?php _e('Maera Addons Installer', 'maera'); ?> </h2> <?php $downloads = $this->get_downloads(); $i = 0; // Early exit if no downloads found if (!isset($downloads['plugins']) || empty($downloads['plugins'])) { return; } $plugins = $downloads['plugins']; $themes = $downloads['themes']; ?> <?php foreach ($plugins as $download) { ?> <?php if (!$download['bundle']) { ?> <?php $data_free = (int) $download['free']; $disabled = $this->is_plugin_installed($download['title']) ? ' disabled="disabled" ' : ''; $button_text = $this->is_plugin_installed($download['title']) ? __('Installed', 'maera') : __('Install', 'maera'); $i = $i == 3 ? 0 : $i; ?> <?php if ($i == 0) { ?> <div style="clear:both; display: block; float: none;"></div> <?php } ?> <div id="<?php echo sanitize_title($download['title']); ?> " class="edd-ri-item postbox plugin"> <h3 class="hndle"><span><?php echo $download['title']; ?> </span></h3> <div class="inside"> <div class="main"> <?php if ('' != $download['thumbnail']) { ?> <img class="edd-ri-item-image" src="<?php echo $download['thumbnail'][0]; ?> "> <?php } ?> <?php if ('' != $download['description']) { ?> <p class="edd-ri-item-description"><?php echo $download['description']; ?> </p> <?php } ?> <p class="edd-ri-actions"> <span class="spinner"></span> <!-- <button class="button button-primary" data-free="<?php echo $data_free; ?> "<?php echo $disabled; ?> data-edd-ri="<?php echo $download['title']; ?> "><?php echo $button_text; ?> </button> --> <a class="button" target="_blank" href="<?php echo trailingslashit($this->api_url) . '?p=' . $download['id']; ?> "><?php _e('Details', 'maera'); ?> </a> </p> </div> </div> </div> <?php $i++; ?> <?php } ?> <?php } ?> <div id="edd_ri_license_thickbox" style="display:none;"> <h3><?php _e('Enter your license', 'maera'); ?> </h3> <form action="" method="post" id="edd_ri_license_form"> <input style="width: 100%" type="text" id="edd_ri_license"/> <button style="margin-top: 10px" type="submit" class="button button-primary"><?php _e('Submit', 'maera'); ?> </button> </form> </div> <div class="message-popup" id="MessagePopup" style="display:none;"></div> </div> <?php }
do_action('woocommerce_before_add_to_cart_button'); ?> <div class="single_variation_wrap" style="display:none;"> <?php do_action('woocommerce_before_single_variation'); ?> <div class="single_variation"></div> <div class="variations_button"> <?php woocommerce_quantity_input(); ?> <?php Maera()->views->render('single-product/add-to-cart/button.twig'); ?> </div> <input type="hidden" name="add-to-cart" value="<?php echo $product->id; ?> " /> <input type="hidden" name="product_id" value="<?php echo esc_attr($post->ID); ?> " /> <input type="hidden" name="variation_id" class="variation_id" value="" /> <?php do_action('woocommerce_after_single_variation');
/** * Get the contents of a .twig file. * This is just a helper function used by the maera_get_twig() function */ function _maera_get_twig($file) { $context = Maera()->cache->get_context(); Timber::render(array($file), $context, Maera()->cache->cache_duration()); }
<?php /** * The Template for displaying all single posts * @package maera */ Maera()->views->render(array('content-' . $post->ID . '.twig', 'content-' . $post->post_type . '.twig', 'content.twig'));
<?php /** * The template for displaying Comments. * * The area of the page that contains both current comments * and the comment form. * * @package maera */ /** * If the current post is protected by a password and * the visitor has not yet entered the password we will * return early without loading the comments. */ if (post_password_required($post)) { return; } Maera()->views->render(array('comments-' . $post->ID . '.twig', $post->post_type . '-comments.twig', 'comments.twig'));
/** * Custom implementation for get_context method. * Implements caching */ public function get_context() { if (Maera()->dev->dev_mode()) { $cached = false; } else { $cache = wp_cache_get('context', 'maera'); $cached = $cache ? true : false; } if ($cached && $cache) { return $cache; } else { $context = Maera()->timber->get_context(); wp_cache_set('context', $context, 'maera'); return $context; } }
<?php /** * The template for displaying the footer. * * @package maera */ Maera()->views->render('footer.twig');
<?php /** * Loop Add to Cart * * @author WooThemes * @package WooCommerce/Templates * @version 2.1.0 */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } global $product; $context = array('product' => $product, 'quantity' => $quantity); Maera()->views->render('loop/add-to-cart.twig', $context);
<?php /** * Search Form */ Maera()->views->render('searchform.twig');
<?php /** * The template for displaying Archive pages. * * Used to display archive-type pages if nothing more specific matches a query. * For example, puts together date-based pages if no date.php file exists. * * Learn more: http://codex.wordpress.org/Template_Hierarchy */ Maera()->views->dependencies(); Maera()->views->header(); Maera()->views->render(); Maera()->views->footer();
$data['title'] = __('Downloads', 'maera_edd'); $data['posts'] = Timber::query_posts(false, 'TimberPost'); $data['query'] = $wp_query->query_vars; // The in-cart class $data['in_cart'] = function_exists('edd_item_in_cart') && edd_item_in_cart($post->ID) && !edd_has_variable_prices($post->ID) ? 'in-cart' : ''; // The variable-priced class $data['variable_priced'] = function_exists('edd_has_variable_prices') && edd_has_variable_prices($post->ID) ? 'variable-priced' : ''; // Get a list with categories of each download (Isotope filtering) $terms = get_the_terms($post->ID, 'download_category'); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term) { $download_categories[] = $term->slug; } $data['categories'] = join(' ', $download_categories); } else { $data['categories'] = ''; } // Get a list with tags of each download (Isotope filtering) $terms = get_the_terms($post->ID, 'download_tag'); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term) { $download_tags[] = $term->slug; } $data['tags'] = join(' ', $download_tags); } else { $data['tags'] = ''; } Maera()->template->header(); Maera()->template->main('archive-download.twig', $data); Maera()->template->footer();
<?php /** * The Header for our theme. * * @package maera */ Maera()->views->render('header.twig');
/** * Filter [download] shortcode HTML * @since 1.0 */ function modify_edd_download_shortcode($display, $atts, $buy_button, $columns, $column_width, $downloads, $excerpt, $full_content, $price, $thumbnails, $query) { $button_defaults = apply_filters('edd_purchase_link_defaults', array()); $button_defaults_class = $button_defaults['class']; // We can't divide the grid to 5 columns, so we're setting them to 4. $columns = 5 == $columns ? 4 : $columns; if (1 == $columns) { $column_class = '[maera_grid_col_12]'; } else { if (2 == $columns) { $column_class = '[maera_grid_col_6]'; } else { if (3 == $columns) { $column_class = '[maera_grid_col_4]'; } else { if (4 == $columns) { $column_class = '[maera_grid_col_3]'; } else { if (6 == $columns) { $column_class = '[maera_grid_col_2]'; } } } } } ob_start(); $count = 0; $rand = rand(0, 999); if (1 != $columns) { echo '<style>.downloads-list .edd-grid-column-' . $rand . '_1{clear:left;}.downloads-list [class*="column"] + [class*="column"]:last-child{float: left;}</style>'; } $list_class = 1 == $columns ? 'list' : 'grid'; ?> <div class="downloads-list <?php echo $list_class; ?> "> <div class="[maera_grid_row_class]"> <?php while ($downloads->have_posts()) { $downloads->the_post(); $count++; $count = $count > $columns ? 1 : $count; $count_class = 1 < $columns ? 'edd-grid-column-' . $rand . '_' . $count : null; $in_cart = edd_item_in_cart(get_the_ID()) && !edd_has_variable_prices(get_the_ID()) ? 'in-cart' : ''; $variable_priced = edd_has_variable_prices(get_the_ID()) ? 'variable-priced' : ''; $hover_type = get_theme_mod('hover_type', 'edd'); $effect = 'effect-' . $hover_type; $context = Maera()->template->context(); $context['post'] = new TimberPost(get_the_ID()); $context['columns'] = $columns; $context['display_excerpt'] = $excerpt != 'no' && $full_content != 'yes' ? true : false; $context['display_full'] = 'yes' == $full_content ? true : false; $context['display_buy_btn'] = $buy_button; $context['in_cart'] = $in_cart; $context['variable_priced'] = $variable_priced; $context['column_class'] = $column_class; $context['count_class'] = $count_class; $context['count'] = $count; $context['download_classes'] = array($in_cart, $variable_priced, $column_class, $count_class, $count, $effect); $context['btn_class'] = $button_defaults_class; if (1 == $columns) { $mode = 'list'; $context['download_classes'] = array($in_cart, $variable_priced, $column_class, $count_class, $count); } else { $mode = $hover_type; $mode = 'edd' == $hover_type ? 'grid' : $mode; } Maera()->template->main('shortcode-download-content-' . $mode . '.twig', $context); } wp_reset_postdata(); ?> </div> </div> <div id="downloads-shortcode" class="download-navigation clearfix"> <?php $big = 999999; $paginate_links_args = array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $query['paged']), 'total' => $downloads->max_num_pages, 'prev_next' => false, 'show_all' => true); echo paginate_links($paginate_links_args); ?> </div> <script>jQuery( "ul.page-numbers" ).addClass( "pagination" );</script> <?php $display = ob_get_clean(); return $display; }