Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include Bootstrap NavWalker
- require_once('_inc/wp_bootstrap_navwalker.php');
- // Include Bootstrap Breadcrumbs
- require_once('_inc/wp_bootstrap_breadcrumbs.php');
- // Include Blog Functions
- require_once('_inc/wp_bootstrap_blog.php');
- /* Remove Admin Bar from Frontend */
- add_action('after_setup_theme', 'remove_admin_bar');
- function remove_admin_bar(){
- show_admin_bar(false);
- }
- if (function_exists('add_theme_support'))
- {
- // Add Menu Support
- add_theme_support('menus');
- // Add Thumbnail Theme Support
- add_theme_support('post-thumbnails');
- add_image_size('large', 700, '', true); // Large Thumbnail
- add_image_size('medium', 250, '', true); // Medium Thumbnail
- add_image_size('small', 125, '', true); // Small Thumbnail
- add_image_size('custom-size', 700, 200, true); // Custom Thumbnail Size call using the_post_thumbnail('custom-size');
- // Enables post and comment RSS feed links to head
- add_theme_support('automatic-feed-links');
- }
- add_action('after_setup_theme', 'wpt_setup');
- if(!function_exists('wpt_setup')):
- function wpt_setup() {
- register_nav_menu('primary', __('Primary Navigation', 'wptmenu'));
- }
- endif;
- function wpt_register_js(){
- wp_register_script('jquery.min', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', 'jquery', '', true);
- wp_register_script('jquery.bootstrap.min', get_template_directory_uri() . '/bower_components/bootstrap/dist/js/bootstrap.min.js', 'jquery', '', true);
- wp_register_script('jquery.extras.min', get_template_directory_uri() . '/js/extras.js', 'jquery', '', true);
- if(!is_admin()){
- wp_enqueue_script('jquery.min');
- wp_enqueue_script('jquery.bootstrap.min');
- wp_enqueue_script('jquery.extras.min');
- }
- }
- function wpt_register_css(){
- wp_register_style('bootstrap.min', get_template_directory_uri() . '/bower_components/bootstrap/dist/css/bootstrap.min.css');
- wp_register_style('fontawesome.min', 'http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
- wp_register_style('roboto.min', 'http://fonts.googleapis.com/css?family=Raleway:100,300,700,400');
- wp_register_style('main.min', get_template_directory_uri() . '/css/styles.css');
- wp_enqueue_style('bootstrap.min');
- wp_enqueue_style('fontawesome.min');
- wp_enqueue_style('roboto.min');
- wp_enqueue_style('main.min');
- }
- add_action('init','wpt_register_js');
- add_action('wp_enqueue_scripts', 'wpt_register_css');
- /* === GET PARENT PAGE SLUG === */
- function the_parent_slug(){
- global $post;
- if($post->post_parent == 0) return '';
- $post_data = get_post($post->post_parent);
- return $post_data->post_name;
- }
- /* === ADD RESPONSIVE CLASS TO IMAGES === */
- function add_responsive_class($content){
- $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
- $document = new DOMDocument();
- libxml_use_internal_errors(true);
- if($content != ''): $document->loadHTML(utf8_decode($content)); endif;
- $imgs = $document->getElementsByTagName('img');
- foreach($imgs as $img){
- $existing_class = $img->getAttribute('class');
- $img->setAttribute('class', 'img-responsive ' . $existing_class);
- }
- $html = $document->saveHTML();
- return $html;
- }
- add_filter('the_content', 'add_responsive_class');
- /* === ADD CLASS TO CONTENT H2 HEADINGS === */
- function add_heading_class($content){
- $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
- $document = new DOMDocument();
- libxml_use_internal_errors(true);
- if($content != ''): $document->loadHTML(utf8_encode($content)); endif;
- $headings = $document->getElementsByTagName('h2');
- foreach($headings as $heading){
- $existing_class = $heading->getAttribute('class');
- $heading->setAttribute('class', 'green-txt column-header' . $existing_class);
- }
- $html = $document->saveHTML();
- return $html;
- }
- add_filter('the_content', 'add_heading_class');
- /* === Woocommerc === */
- remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
- remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
- add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
- add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
- function my_theme_wrapper_start() {
- echo '<section id="main">';
- }
- function my_theme_wrapper_end() {
- echo '</section>';
- }
- /* === Widgets === */
- if (function_exists('register_sidebar'))
- {
- register_sidebar(array(
- 'name' => __('Welcome Sidebar', 'welcome-sidebar'),
- 'description' => __('Displays the sidebar content on the Homepage.', 'welcome-sidebar'),
- 'id' => 'welcome-sidebar',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<h2 class="green-txt column-header">',
- 'after_title' => '</h2>'
- ));
- }
- add_filter("gform_init_scripts_footer", "init_scripts");
- function init_scripts() {
- return true;
- }
- class GW_List_Field_As_Choices {
- function __construct( $args ) {
- $this->_args = wp_parse_args( $args, array(
- 'form_id' => false,
- 'list_field_id' => false,
- 'choice_field_ids' => false,
- 'label_template' => '{0}',
- 'sort' => false
- ) );
- if( ! is_array( $this->_args['choice_field_ids'] ) )
- $this->_args['choice_field_ids'] = array( $this->_args['choice_field_ids'] );
- extract( $this->_args ); // gives us $form_id, $list_field_id, $choices_field_id
- add_filter( 'gform_pre_render', array( $this, 'populate_choice_fields' ), 9 );
- add_filter( 'gform_pre_validation', array( $this, 'populate_choice_fields' ), 9 );
- add_filter( 'gform_pre_submission_filter_' . $form_id, array( $this, 'populate_choice_fields' ) );
- }
- function populate_choice_fields( $form ) {
- if( $form['id'] != $this->_args['form_id'] )
- return $form;
- $list_field = GFFormsModel::get_field( $form, $this->_args['list_field_id'] );
- $values = GFFormsModel::get_field_value( $list_field );
- // if list field doesn't have any values, let's ditch this party
- if( ! is_array( $values ) )
- return $form;
- $choices = $this->get_list_choices( $values );
- foreach( $form['fields'] as &$field ) {
- if( ! $this->is_applicable_field( $field ) )
- continue;
- // set 'choices' for choice fields
- $field['choices'] = $choices;
- // only set inputs for 'checkbox' choice fields
- if( GFFormsModel::get_input_type( $field ) == 'checkbox' ) {
- $inputs = array();
- foreach( $choices as $index => $choice ) {
- $inputs[] = array(
- 'label' => $choice['text'],
- 'id' => $field['id'] . '.' . ( $index + 1 )
- );
- }
- $field['inputs'] = $inputs;
- }
- }
- return $form;
- }
- function get_list_choices( $values ) {
- $choices = array();
- foreach( $values as $row ) {
- $label = $this->replace_template( $this->_args['label_template'], $row );
- $value = isset( $this->_args['value_template'] ) ? $this->replace_template( $this->_args['value_template'], $row ) : $label;
- $choices[] = array(
- 'text' => $label,
- 'value' => $value
- );
- }
- if( $this->_args['sort'] == true )
- usort( $choices, create_function( '$a, $b', 'return strnatcasecmp( $a["text"], $b["text"] );' ) );
- return $choices;
- }
- function replace_template( $template, $row ) {
- // combine our templates so we can find all matches at once
- preg_match_all( '/{(\w+)}/', $template, $matches, PREG_SET_ORDER );
- if( is_array( $row ) ) {
- $mega_row = array_merge( $row, array_values( $row ) );
- foreach( $matches as $match ) {
- $template = str_replace( $match[0], rgar( $mega_row, $match[1] ), $template );
- }
- } else {
- foreach( $matches as $match ) {
- $template = str_replace( $match[0], $row, $template );
- }
- }
- return $template;
- }
- function is_applicable_field( $field ) {
- $is_choice_field = is_array( rgar( $field, 'choices' ) );
- $is_registered_field = in_array( $field['id'], $this->_args['choice_field_ids'] );
- return $is_choice_field && $is_registered_field;
- }
- }
- /**
- * Uncomment the code below by removing the pound symbols (#) in front of each line. See @link in the comment section
- * at the top for additional usage instructions.
- */
- # Basic Usage
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 485,
- 'choice_field_ids' => 492,
- 'value_template' => '{First Name} | $95.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 485,
- 'choice_field_ids' => 477,
- 'value_template' => '{First Name} | $75.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 486,
- 'choice_field_ids' => 495,
- 'value_template' => '{First Name} | $95.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 486,
- 'choice_field_ids' => 496,
- 'value_template' => '{First Name} | $75.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 487,
- 'choice_field_ids' => 498,
- 'value_template' => '{First Name} | $95.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 487,
- 'choice_field_ids' => 499,
- 'value_template' => '{First Name} | $75.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 488,
- 'choice_field_ids' => 484,
- 'value_template' => '{First Name}'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 488,
- 'choice_field_ids' => 500,
- 'value_template' => '{First Name} | $95.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 488,
- 'choice_field_ids' => 501,
- 'value_template' => '{First Name} | $75.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 489,
- 'choice_field_ids' => 503,
- 'value_template' => '{First Name}'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 489,
- 'choice_field_ids' => 504,
- 'value_template' => '{First Name} | $95.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 489,
- 'choice_field_ids' => 506,
- 'value_template' => '{First Name}'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 489,
- 'choice_field_ids' => 505,
- 'value_template' => '{First Name} | $75.00'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 490,
- 'choice_field_ids' => 508,
- 'value_template' => '{First Name}'
- ) );
- new GW_List_Field_As_Choices( array(
- 'form_id' => 4,
- 'list_field_id' => 490,
- 'choice_field_ids' => 509,
- 'value_template' => '{First Name} | $75.00'
- ) );
- add_filter( 'gform_column_input_content_4_485_3', 'change485_column3_content', 10, 6 );
- function change485_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_column_input_content_4_486_3', 'change486_column3_content', 10, 6 );
- function change486_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_column_input_content_4_487_3', 'change487_column3_content', 10, 6 );
- function change487_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_column_input_content_4_488_3', 'change488_column3_content', 10, 6 );
- function change488_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_column_input_content_4_489_3', 'change489_column3_content', 10, 6 );
- function change489_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_column_input_content_4_490_3', 'change490_column3_content', 10, 6 );
- function change490_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
- //build field name, must match List field syntax to be processed correctly
- $input_field_name = 'input_' . $field->id . '[]';
- $tabindex = GFCommon::get_tabindex();
- $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
- return $new_input;
- }
- add_filter( 'gform_field_value_list', 'populate_list' );
- function populate_list( $value ) {
- $list_array = array(
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- array(
- 'First Name' => 'TBD',
- 'Last Name' => 'TBD',
- 'Email' => ''
- ),
- );
- return $list_array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement