Exemplo n.º 1
0
/**
 * Filters the WordPress comment_form() function that was added in WordPress 3.0.  This allows
 * the theme to preserve some backwards compatibility with its old comment form.  It also allows
 * users to build custom comment forms by filtering 'comment_form_defaults' in their child theme.
 *
 * @since 1.0
 * @param array $defaults The default comment form arguments.
 * @return array $args The filtered comment form arguments.
 */
function momtaz_comment_form_args($defaults)
{
    $args = array();
    // Remove the notes after the form.
    $args['comment_notes_after'] = '';
    // Get current commenter's name, email, and URL.
    $commenter = wp_get_current_commenter();
    // Is the "Name" and "Email" fields are required?
    $required = (bool) get_option('require_name_email');
    /*** Comment Form Fields **************************************************/
    $args['fields'] = Nmwdhj\create_elements(array('author' => array('atts' => array('required' => (bool) $required), 'value' => $commenter['comment_author'], 'label' => __('Name', 'momtaz'), 'type' => 'input_text', 'nid' => 'author'), 'email' => array('atts' => array('required' => (bool) $required), 'value' => $commenter['comment_author_email'], 'label' => __('Email', 'momtaz'), 'type' => 'input_email', 'nid' => 'email'), 'url' => array('value' => $commenter['comment_author_url'], 'label' => __('Website', 'momtaz'), 'type' => 'input_url', 'nid' => 'url')));
    // Shared
    foreach ($args['fields'] as $k => $e) {
        if ($e->get_attr('required')) {
            $label = $e->get_option('label');
            if (!empty($label)) {
                $label .= '<span class="required">*</span>';
                $e->set_option('label', $label);
            }
        }
        $e->set_options(array('wrapper_atts' => array('class' => 'form-section layout-columned'), 'label_atts' => array('class' => 'form-label'), 'wrapper' => 'div'), true);
        $e->set_atts(array('class' => 'form-field regular-textbox', 'size' => 40));
        $args['fields'][$k] = $e->get_output();
    }
    // Comment Text
    $args['comment_field'] = Nmwdhj\create_element(array('type' => 'textarea', 'nid' => 'comment', 'atts' => array('class' => 'form-field large-textbox', 'required' => true, 'rows' => 10, 'cols' => 60), 'wrapper' => 'div', 'wrapper_atts' => array('class' => 'form-section layout-full')))->get_output();
    $args = wp_parse_args($args, $defaults);
    return $args;
}
Exemplo n.º 2
0
 /**
  * Add an element
  *
  * @return Fieldset
  * @throws \Nmwdhj\Exception
  * @since 1.3
  */
 public function add($element, array $args = array())
 {
     if (!$element instanceof Element) {
         $element = \Nmwdhj\create_element($element);
     }
     $args = array_merge(array('key' => $element->get_name(), 'priority' => 10), (array) $args);
     if (empty($args['key'])) {
         throw new Exception('Cannot add nameless element to form');
     }
     if ($this->has($args['key'])) {
         throw new Exception('An element with the same name is found');
     }
     $this->elements->offsetSet($args['key'], $element, $args['priority']);
     return $this;
 }
Exemplo n.º 3
0
<?php

/**
 * Search Form Template
 *
 * The search form template displays the search form.
 *
 * @package Momtaz
 * @subpackage Template
 * @since Momtaz Theme 1.0
 */
static $search_num = 0;
++$search_num;
?>

<div id="search-form-container-<?php 
echo $search_num;
?>
" class="search-form-container">

	<?php 
Nmwdhj\create_element(array('type' => 'form', 'atts' => array('method' => 'GET', 'role' => 'search', 'class' => 'search-form', 'action' => home_url('/'))))->add(array('name' => 's', 'type' => 'input_search', 'value' => get_search_query(), 'atts' => array('required' => true, 'class' => 'search-text', 'title' => _x('Search for:', 'label', 'momtaz'), 'placeholder' => _x('Search this site...', 'placeholder', 'momtaz'))), array('key' => 'search', 'priority' => 10))->add(array('type' => 'input_submit', 'value' => __('Search', 'momtaz'), 'atts' => array('class' => 'search-submit')), array('key' => 'submit', 'priority' => 5))->output();
?>

</div> <!-- .search-form-container -->