function testCommentForm() { $post_id = $this->factory->post->create(); $form = TimberHelper::get_comment_form($post_id); $form = trim($form); $this->assertStringStartsWith('<div id="respond"', $form); }
/** * Custom implementation for get_context method. */ public function get_context() { global $content_width; if (class_exists('Easy_Digital_Downloads')) { global $edd_options; } $context = Timber::get_context(); $sidebar_primary = Timber::get_widgets('sidebar_primary'); $sidebar_footer = Timber::get_widgets('sidebar_footer'); $context['theme_mods'] = get_theme_mods(); $context['site_options'] = wp_load_alloptions(); $context['teaser_mode'] = apply_filters('maera/teaser/mode', 'excerpt'); $context['thumbnail']['width'] = apply_filters('maera/image/width', 600); $context['thumbnail']['height'] = apply_filters('maera/image/height', 371); $context['menu']['primary'] = has_nav_menu('primary_navigation') ? new TimberMenu('primary_navigation') : null; $context['sidebar']['primary'] = apply_filters('maera/sidebar/primary', $sidebar_primary); $context['sidebar']['footer'] = apply_filters('maera/sidebar/footer', $sidebar_footer); $context['pagination'] = Timber::get_pagination(); $context['comment_form'] = TimberHelper::get_comment_form(); $context['comments_args'] = array('style' => 'ul', 'reply_text' => __('Reply', 'maera'), 'short_ping' => true, 'avatar_size' => 60); $context['site_logo'] = get_option('site_logo', false); $context['content_width'] = $content_width; $context['sidebar_template'] = maera_templates_sidebar(); if (class_exists('Easy_Digital_Downloads')) { $data['edd_options'] = $edd_options; $data['download_categories'] = Timber::get_terms('download_category'); $data['download_tags'] = Timber::get_terms('download_tag'); $data['default_image'] = new TimberImage(get_template_directory_uri() . '/assets/images/default.png'); } return apply_filters('maera/timber/context', $context); }
/** * Timber extras. */ function timber_extras($data) { // get secondary sidebar $sidebar_secondary = Timber::get_widgets('sidebar_secondary'); $data['sidebar']['secondary'] = apply_filters('maera/sidebar/secondary', $sidebar_secondary); $extra_widget_areas = Maera_BS_Widgets::extra_widget_areas_array(); foreach ($extra_widget_areas as $extra_widget_area => $options) { if (0 != get_theme_mod($extra_widget_area . '_toggle', 0)) { $data['sidebar'][$extra_widget_area] = Timber::get_widgets($extra_widget_area); } } $comment_form_args = array('comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x('Comment', 'noun', 'maera_bs') . '</label><textarea class="form-control" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 'id_submit' => 'comment-submit'); $data['content_width'] = Maera_BS_Structure::content_width_px(); $data['post_meta'] = Maera_BS_Meta::meta_elements(); $data['comment_form'] = TimberHelper::get_comment_form(null, $comment_form_args); return $data; }
<?php /** * The Template for displaying all single posts * * Methods for TimberHelper can be found in the /lib sub-directory * * @package WordPress * @subpackage Timber * @since Timber 0.1 */ $context = Timber::get_context(); $post = new TrunckPost(); $context['post'] = $post; $context['comment_form'] = TimberHelper::get_comment_form(); if (post_password_required($post->ID)) { Timber::render('single-password.twig', $context); } else { Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $context); }
<?php /** * @package WordPress * @subpackage Preach * @since Preach 1.1.0 */ $data = Timber::get_context(); $post = Timber::query_post(); $data['post'] = $post; $data['comment_form'] = TimberHelper::get_comment_form(); if (post_password_required($post->ID)) { Timber::render('single-password.twig', $data); } else { Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $data); }
public function add_to_context($context) { $context['regions'] = $this->get_theme_regions(); $context['menu'] = new TimberMenu(); $context['site'] = $this; $context['pagination'] = Timber::get_pagination(); $context['comment_form'] = TimberHelper::get_comment_form(); return $context; }
<?php $args = array('comment_field' => '<div class="comment-form__comment"><label for="comment">' . _x('Comment', 'noun') . '</label> <textarea id="comment" name="comment" cols="45" rows="4" aria-required="true" required="required"></textarea></div>', 'must_log_in' => '<div class="comment-form__log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url(apply_filters('the_permalink', get_permalink()))) . '</div>', 'logged_in_as' => '<div class="comment-form__logged-in">' . sprintf(__('<a href="%1$s" aria-label="Logged in as %2$s. Edit your profile.">Logged in as %2$s</a>. <a href="%3$s">Log out?</a>'), get_edit_user_link(), $user_identity, wp_logout_url(apply_filters('the_permalink', get_permalink()))) . '</div>', 'comment_notes_before' => '<div class="comment-form__notes"><span id="email-notes">' . __('Your email address will not be published.') . '</span> </div>', 'comment_notes_after' => '', 'class_form' => 'comment-form', 'class_submit' => 'comment-form__submit', 'title_reply' => '', 'title_reply_to' => __('Leave a Reply to %s'), 'title_reply_before' => '', 'title_reply_after' => '', 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />', 'submit_field' => '<div class="comment-form__submit-wrapper">%1$s %2$s</div>', 'format' => 'html5'); $context['comment_form'] = TimberHelper::get_comment_form(null, $args);