Пример #1
0
 /**
  * button
  *
  * Displays the addthis sharing button setup on their dashboard page
  */
 public static function button()
 {
     if ($addthis_id = get_theme_mod('addthis-id')) {
         wp_enqueue_script('addthis');
         \Timber::render('addthis.twig');
     }
 }
Пример #2
0
 function render_product_popup()
 {
     $intPostId = intval($_POST['post_id']);
     $objPost = new TimberPost($intPostId);
     Timber::render('partials/product-popup.twig', array('post' => $objPost));
     wp_die();
 }
 /**
  * Renders the given template with a context using timber
  *
  * @param $template
  * @param $context
  * @throws \RuntimeException
  * @author Tim Perry
  */
 protected function render($template, $context)
 {
     if (!class_exists('Timber')) {
         throw new \RuntimeException("Timber is not installed");
     }
     \Timber::render($template, $context);
 }
 public function form($instance)
 {
     $context = \Timber::get_context();
     $context['title'] = !empty($instance['title']) ? $instance['title'] : __('Test', self::I18N_DOMAIN);
     $context['widget'] = $this;
     \Timber::render('timber-test-widget-form.twig', $context);
 }
Пример #5
0
 /**
  * render
  *
  * Render cookie-consent.twig
  *
  */
 public function render()
 {
     if (!isset($_COOKIE['cookie-consent'])) {
         do_action('show_cookie_consent');
         \Timber::render('cookie-consent.twig', array('implied_consent_text' => get_theme_mod('implied-consent-text', $this->implied_consent_text), 'button_text' => get_theme_mod('button-text', $this->button_text), 'privacy_url' => get_theme_mod('privacy-url', $this->privacy_url), 'privacy_link_text' => get_theme_mod('privacy-link-text', $this->privacy_link_text)));
     }
 }
Пример #6
0
 public function load_view()
 {
     $context = Timber::get_context();
     $context['data'] = $this->data;
     $context['constants'] = get_slate_constants();
     Timber::render(theme_views . '/single.twig', $context);
 }
Пример #7
0
 /**
  *
  * {$inheritdoc}
  *
  */
 public function getCallback()
 {
     $context = \Timber::get_context();
     $context['options'] = $this->getOptions();
     $context['field_name'] = self::META_NAME_PAGE_TYPE;
     $context['current_value'] = $this->getCurrentValue();
     \Timber::render($this->dic['CMS']->getViewPath('meta_boxes/page-type.html.twig'), $context);
 }
Пример #8
0
 /**
  * render
  *
  * Render the twig $template
  *
  */
 public function render()
 {
     $this->context = $this->get_context();
     $class = new \ReflectionClass(get_called_class());
     $class = Helper::camel_to_underscored($class->getShortName());
     $this->context = apply_filters("{$class}_context", $this->context);
     do_action("render_{$class}");
     \Timber::render($this->template, $this->context);
 }
Пример #9
0
 /**
  * script
  *
  * @return void
  */
 public function script()
 {
     $track_logged_in = get_theme_mod('track-logged-in');
     if ($track_logged_in || !$track_logged_in && !is_user_logged_in()) {
         if ($google_analytics_id = urlencode(get_theme_mod('google-analytics-id'))) {
             \Timber::render('google-analytics.twig', array('google_analytics_id' => $google_analytics_id));
         }
     }
 }
Пример #10
0
 /**
  * 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());
 }
Пример #11
0
 /**
  * Render a template
  * This will render the necessary twig template
  */
 public function render($templates = null, $context = null)
 {
     if (is_null($templates)) {
         $templates = apply_filters('maera/templates', array());
     }
     if (is_null($context)) {
         $context = $this->context();
     }
     Timber::render($templates, $context, Maera()->cache->cache_duration(), Maera()->cache->cache_mode());
 }
Пример #12
0
 /**
  *
  * Callback methods for the options page
  *
  * @author Tim Perry
  *
  */
 public function menuPageCallback()
 {
     $args = array('public' => true);
     $context = \Timber::get_context();
     $context['postTypes'] = get_post_types($args, 'names');
     $context['settingsGroupName'] = self::SETTINGS_GROUP_NAME;
     $context['fieldName'] = self::OPTION_NAME_SHOW_ON;
     $context['currentValue'] = get_option(self::OPTION_NAME_SHOW_ON);
     \Timber::render($this->getPath() . '/views/options-page.twig', $context);
 }
Пример #13
0
 function get_short_code($atts)
 {
     return getOutput(function () {
         $context = $this->get_timber_context();
         foreach ($this->timber_attributes as $key => $value) {
             $context[$key] = $value;
         }
         Timber::render('template.twig', $context);
     });
 }
Пример #14
0
/**
 * Render Comment
 *
 * @param object $comment
 * @param array $args
 * @param integer $depth
 */
function render_comment($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    extract($args, EXTR_SKIP);
    $args['depth'] = $depth;
    $args['comment'] = new TimberComment($comment);
    $args['date_format'] = get_option('date_format');
    $args['time_format'] = get_option('time_format');
    $args['args'] = $args;
    Timber::render('includes/comment.html.twig', $args);
}
Пример #15
0
 /**
  * form
  *
  * @param array $instance
  * @return void
  */
 public function form($instance)
 {
     $defaults = array('user' => __("User", THEMENAME), 'title' => __("Pinterest", THEMENAME), 'type' => 'board', 'image-width' => 80, 'board-height' => 320, 'board-width' => 400);
     $instance = wp_parse_args((array) $instance, $defaults);
     \Timber::render('admin.text.twig', array('label' => __("Title", THEMENAME), 'id' => $this->get_field_id('title'), 'name' => $this->get_field_name('title'), 'value' => esc_attr($instance['title']), 'class' => 'widefat'));
     \Timber::render('admin.text.twig', array('label' => __("User", THEMENAME), 'id' => $this->get_field_id('user'), 'name' => $this->get_field_name('user'), 'value' => esc_attr($instance['user']), 'class' => 'widefat'));
     \Timber::render('admin.select.twig', array('label' => __("Type", THEMENAME), 'id' => $this->get_field_id('type'), 'name' => $this->get_field_name('typw'), 'options' => array('board' => "Board", 'profile' => "Profile"), 'value' => 'board', 'class' => 'widefat'));
     \Timber::render('admin.number.twig', array('label' => __("Image width", THEMENAME), 'id' => $this->get_field_id('image-width'), 'name' => $this->get_field_name('image-width'), 'value' => esc_attr($instance['image-width'])));
     \Timber::render('admin.number.twig', array('label' => __("Image width", THEMENAME), 'id' => $this->get_field_id('image-width'), 'name' => $this->get_field_name('board-height'), 'value' => esc_attr($instance['board-height'])));
     \Timber::render('admin.number.twig', array('label' => __("Image width", THEMENAME), 'id' => $this->get_field_id('image-width'), 'name' => $this->get_field_name('board-width'), 'value' => esc_attr($instance['board-width'])));
 }
 /**
  * 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 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();
 }
Пример #18
0
 /**
  *
  *  Callback for the options page
  *
  * @author Tim Perry
  *
  */
 public function optionsPageCallback()
 {
     if (!class_exists('Timber')) {
         echo '<p>Please install and enable timber.</p>';
         return;
     }
     $context = \Timber::get_context();
     $context['settingsGroupName'] = self::SETTINGS_GROUP_NAME;
     $context['fieldNames'] = array('expiryDays' => self::OPTION_NAME_PASSWORD_EXPIRY_DAYS, 'disablePasswordResets' => self::OPTION_NAME_DISABLE_PASSWORD_RESETS);
     $context['currentValues'] = array('expiryDays' => get_option(self::OPTION_NAME_PASSWORD_EXPIRY_DAYS, 90), 'disablePasswordResets' => get_option(self::OPTION_NAME_DISABLE_PASSWORD_RESETS));
     \Timber::render($this->dic['securityPlugin']->getPath() . '/views/options-page.twig', $context);
 }
 function create_admin_page()
 {
     $data = array();
     $data['theme_dir'] = get_stylesheet_directory();
     $home = get_home_template();
     $home = pathinfo($home);
     $data['home_file']['name'] = $home['basename'];
     $data['timber_base'] = TIMBER_URL_PATH;
     $data['home_file']['path'] = trailingslashit(get_stylesheet_directory()) . $data['home_file']['name'];
     $data['home_file']['contents'] = htmlentities(file_get_contents(realpath($data['home_file']['path'])));
     $data['home_file']['location'] = str_replace(ABSPATH, '', trailingslashit(get_stylesheet_directory()));
     Timber::render('timber-admin.twig', $data);
 }
 public function embed($slug)
 {
     $post = get_posts("name={$slug}&post_type=poll");
     if (!$post || count($post) == 0) {
         throw new \RuntimeException('Poll doesn\'t exist with this slug');
     }
     $context = \Timber::get_context();
     $context['poll'] = new \TimberPost($post[0]);
     $this->inline_css();
     $views = trailingslashit(Helper::get('views')['AgreablePollPlugin']);
     \Timber::render("{$views}/widgets/poll_plugin/template.twig", $context);
     $this->inline_js();
 }
Пример #21
0
 function options_page()
 {
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $ctx = \Timber::get_context();
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $ctx['form'] = Option::get_instance()->get();
     } else {
         $ctx['form'] = $_POST;
         Option::get_instance()->update($_POST);
     }
     \Timber::render('Admin.html', $ctx);
 }
Пример #22
0
 /**
  * fb_opengraph
  *
  */
 public static function fb_opengraph()
 {
     $post = new \TimberPost();
     $title = $post->title;
     $description = is_single() ? str_replace('', "'", $post->get_preview(60, true, false, true)) : get_bloginfo('description', 'display');
     $img = has_post_thumbnail($post->id) ? wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large')[0] : (get_theme_mod('og_img') ? get_theme_mod('og_img') : esc_url(get_theme_mod('logo')));
     $type = is_author() ? 'profile' : (is_single() ? 'article' : 'website');
     $url = get_permalink();
     $url = rtrim(esc_url(apply_filters('og_url', $url)));
     if (!substr($url, -1) === '/') {
         $url .= '/';
         // slash fixes Facebook Debugger "Circular Redirect Path"
     }
     $open_graph = array('site_name' => esc_attr(apply_filters('og_site_name', get_bloginfo())), 'title' => esc_attr(apply_filters('og_title', $title)), 'description' => esc_attr(apply_filters('og_description', $description)), 'type' => esc_attr(apply_filters('og_type', $type)), 'url' => $url, 'image' => esc_url(apply_filters('og_image', $img)));
     \Timber::render('open-graph.twig', array('open_graph' => $open_graph));
 }
Пример #23
0
 /**
  * render_meta_box_content
  *
  * @param $post
  */
 public function render_meta_box_content($post)
 {
     // add a nonce - https://codex.wordpress.org/WordPress_Nonces
     wp_nonce_field($this->meta_name, sprintf("%s_nonce", $this->meta_name));
     foreach ($this->fields as &$field) {
         $field['value'] = get_post_meta($post->ID, $field['name'], true);
         switch ($field['type']) {
             case 'text':
                 \Timber::render('admin.text.twig', $field);
                 break;
             case 'number':
                 \Timber::render('admin.number.twig', $field);
                 break;
                 // TODO add more types!
         }
     }
 }
 /**
  * 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();
 }
Пример #25
0
 /**
  * Example form, try it in a template file: $evistaFormAPI->exampleForm();
  */
 public function exampleForm()
 {
     $form = new ExampleForm();
     // Populate field
     $form->populateFields();
     // Validation
     if (count($errors = $form->validate()) > 0) {
         //var_dump($errors);
         // var_dump("errors");
     }
     // When posted, redirect to some other page
     if (isset($_POST['nonce'])) {
         echo 'All right';
     }
     // Render form
     $templateFile = $form->getTemplate();
     \Timber::render($templateFile, $form->getTemplateVars());
 }
Пример #26
0
 public static function apply_admin_customizations()
 {
     if (class_exists('Jigsaw')) {
         Jigsaw::add_column('highlights', 'Thumb', function ($pid) {
             $data = array();
             $data['post'] = new TimberPost($pid);
             Timber::render('admin/portfolio-square-preview.twig', $data);
         }, -1000);
         Jigsaw::add_column('portfolio', 'Preview', function ($pid) {
             $data = array();
             $data['post'] = new TimberPost($pid);
             Timber::render('admin/portfolio-square-preview.twig', $data);
         }, -1000);
         if (method_exists('Jigsaw', 'add_css')) {
             Jigsaw::add_css('/wp-content/themes/blades/css/admin.css');
         }
     }
 }
function facade_theme_options_global_segment()
{
    // Validate access
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient privileges to access this page.', 'facade'));
    }
    // Save post data
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        foreach ($_POST as $key => $value) {
            update_option('facade_' . $key, $value);
        }
        echo '<div id="message" class="updated" style="padding:15px">' . __('Content saved', 'facade') . '</div>';
    }
    // Render template
    $fallback = ICL_LANGUAGE_CODE ?: '';
    $context = ['currentTab' => $_GET['tab'] ?: $fallback];
    Timber::render('admin/global-segment.twig', $context);
}
Пример #28
0
 /**
  * Render the carousel template
  *
  */
 public static function render($atts)
 {
     $atts = shortcode_atts(array('height' => 500, 'width' => 1140), $atts);
     // uniquely identify each slider on the page
     static $id = 0;
     $id++;
     // TODO enqueue bootstrap JS?
     $slides = array();
     foreach (parent::get_posts() as $slide) {
         $slide = new \TimberPost($slide);
         $slide->height = $atts['height'];
         $slide->width = $atts['width'];
         $slides[] = $slide;
     }
     $carousel['id'] = sprintf("%s-carousel-%s", self::$post_type, $id);
     $carousel['slides'] = $slides;
     if (count($slides)) {
         \Timber::render('carousel.twig', $carousel);
     }
 }
 public static function do_load_more_posts()
 {
     $args = $_GET['args'];
     $template = $_GET['template'];
     if (preg_match('/,/', $args['post_type'])) {
         $post_types = explode(',', $args['post_type']);
         $args['post_type'] = $post_types;
     }
     $data = Timber::get_context();
     $posts = Timber::get_posts($args);
     if (empty($posts)) {
         echo 0;
         die;
     }
     $i = 1;
     foreach ($posts as $post) {
         $data['post'] = $post;
         $data['loop']['index'] = $i;
         Timber::render('partials/' . $template . '.twig', $data);
         $i = $i + 1;
     }
     die;
 }
 public function render($venue = null)
 {
     $css_string = @file_get_contents(Helper::path('/resources/assets/styles.css'));
     $js_string = @file_get_contents(Helper::path('/resources/assets/app.js'));
     $webpack_port = null;
     $environment = getenv('WP_ENV');
     if ($environment === 'development') {
         try {
             $webpack_port = $this->get_webpack_port(Helper::path(''));
         } catch (\Exception $e) {
             // If exception the developer hasn't run webpack so may not be
             // 'developing' this particular plugin, force 'production'
             $environment = 'production';
         }
     }
     $views = trailingslashit(Helper::get('views')['template']);
     $context = \Timber::get_context();
     $context['body_class'] = $context['body_class'] . ' agreable-venues-plugin';
     $context['env'] = $environment;
     // $context['common_css_path'] = Helper::asset('styles.css');
     $context['js_string'] = $js_string;
     $context['css_string'] = $css_string;
     $context['css_path'] = '/resources/assets/styles.css';
     $context['js_path'] = '/resources/assets/app.js';
     $context['webpack_plugin_port'] = $webpack_port;
     $brand_str = strtolower(get_field('venues_brand', 'option'));
     $brands = !empty($brand_str) ? array_map('trim', explode(',', $brand_str)) : array();
     $context['initial_state'] = array('app' => array('site' => array('sitename' => get_bloginfo('name'), 'env' => $environment, 'terms' => get_field('venues_promo_terms', 'option')), 'firebase' => array('api_key' => get_field('venues_firebase_api_key', 'option'), 'auth_domain' => get_field('venues_firebase_auth_domain', 'option'), 'db_url' => get_field('venues_firebase_db_url', 'option'), 'storage_bucket' => get_field('venues_firebase_storage_bucket', 'option'), 'brands' => $brands), 'map' => array('mapboxToken' => get_field('venues_map_mapbox_token', 'option'), 'mapboxMapId' => get_field('venues_map_mapbox_mapid', 'option'), 'slug' => get_field('agreable_venues_plugin_map_slug', 'option'), 'tileUrl' => get_field('venues_map_tiles_url', 'option'), 'locationDetails' => get_field('map_initial_locations', 'option')), 'display_vouchers' => get_field('field_578dff0210320', 'option')));
     $context['calais_domain'] = 'https://calaisapi.com';
     if (isset($venue)) {
         // If on single venue page we set all meta data accordingly.
         $context['wp_title'] = htmlentities($venue->get('name'));
         $context['post'] = $this->get_post_meta_data($venue);
     }
     \Timber::render("{$views}template.twig", $context);
 }