Advertisement
Guest User

Lists TIC CUP

a guest
Sep 1st, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.20 KB | None | 0 0
  1. <?php
  2. // Include Bootstrap NavWalker
  3. require_once('_inc/wp_bootstrap_navwalker.php');
  4.  
  5. // Include Bootstrap Breadcrumbs
  6. require_once('_inc/wp_bootstrap_breadcrumbs.php');
  7.  
  8. // Include Blog Functions
  9. require_once('_inc/wp_bootstrap_blog.php');
  10.  
  11. /* Remove Admin Bar from Frontend */
  12. add_action('after_setup_theme', 'remove_admin_bar');
  13. function remove_admin_bar(){
  14.     show_admin_bar(false);
  15. }
  16.  
  17. if (function_exists('add_theme_support'))
  18. {
  19.     // Add Menu Support
  20.     add_theme_support('menus');
  21.  
  22.     // Add Thumbnail Theme Support
  23.     add_theme_support('post-thumbnails');
  24.     add_image_size('large', 700, '', true);         // Large Thumbnail
  25.     add_image_size('medium', 250, '', true);        // Medium Thumbnail
  26.     add_image_size('small', 125, '', true);         // Small Thumbnail
  27.     add_image_size('custom-size', 700, 200, true);  // Custom Thumbnail Size call using the_post_thumbnail('custom-size');
  28.  
  29.     // Enables post and comment RSS feed links to head
  30.     add_theme_support('automatic-feed-links');
  31. }
  32.  
  33. add_action('after_setup_theme', 'wpt_setup');
  34. if(!function_exists('wpt_setup')):
  35.     function wpt_setup() {
  36.         register_nav_menu('primary', __('Primary Navigation', 'wptmenu'));
  37.     }
  38. endif;
  39.  
  40. function wpt_register_js(){
  41.     wp_register_script('jquery.min', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', 'jquery', '', true);
  42.     wp_register_script('jquery.bootstrap.min', get_template_directory_uri() . '/bower_components/bootstrap/dist/js/bootstrap.min.js', 'jquery', '', true);
  43.     wp_register_script('jquery.extras.min', get_template_directory_uri() . '/js/extras.js', 'jquery', '', true);
  44.     if(!is_admin()){
  45.         wp_enqueue_script('jquery.min');
  46.         wp_enqueue_script('jquery.bootstrap.min');
  47.         wp_enqueue_script('jquery.extras.min');
  48.     }
  49. }
  50. function wpt_register_css(){
  51.     wp_register_style('bootstrap.min', get_template_directory_uri() . '/bower_components/bootstrap/dist/css/bootstrap.min.css');
  52.     wp_register_style('fontawesome.min', 'http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
  53.     wp_register_style('roboto.min', 'http://fonts.googleapis.com/css?family=Raleway:100,300,700,400');
  54.     wp_register_style('main.min', get_template_directory_uri() . '/css/styles.css');
  55.     wp_enqueue_style('bootstrap.min');
  56.     wp_enqueue_style('fontawesome.min');
  57.     wp_enqueue_style('roboto.min');
  58.     wp_enqueue_style('main.min');
  59. }
  60. add_action('init','wpt_register_js');
  61. add_action('wp_enqueue_scripts', 'wpt_register_css');
  62.  
  63. /* === GET PARENT PAGE SLUG === */
  64. function the_parent_slug(){
  65.     global $post;
  66.     if($post->post_parent == 0) return '';
  67.     $post_data = get_post($post->post_parent);
  68.     return $post_data->post_name;
  69. }
  70.  
  71. /* === ADD RESPONSIVE CLASS TO IMAGES === */
  72. function add_responsive_class($content){
  73.     $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
  74.     $document = new DOMDocument();
  75.     libxml_use_internal_errors(true);
  76.     if($content != ''): $document->loadHTML(utf8_decode($content)); endif;
  77.    
  78.     $imgs = $document->getElementsByTagName('img');
  79.     foreach($imgs as $img){
  80.         $existing_class = $img->getAttribute('class');
  81.         $img->setAttribute('class', 'img-responsive ' . $existing_class);
  82.     }
  83.     $html = $document->saveHTML();
  84.     return $html;
  85. }
  86. add_filter('the_content', 'add_responsive_class');
  87.  
  88. /* === ADD CLASS TO CONTENT H2 HEADINGS === */
  89. function add_heading_class($content){
  90.     $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
  91.     $document = new DOMDocument();
  92.     libxml_use_internal_errors(true);
  93.     if($content != ''): $document->loadHTML(utf8_encode($content)); endif;
  94.    
  95.     $headings = $document->getElementsByTagName('h2');
  96.     foreach($headings as $heading){
  97.         $existing_class = $heading->getAttribute('class');
  98.         $heading->setAttribute('class', 'green-txt column-header' . $existing_class);
  99.     }  
  100.     $html = $document->saveHTML();
  101.     return $html;
  102. }
  103. add_filter('the_content', 'add_heading_class');
  104.  
  105.  
  106. /* === Woocommerc === */
  107. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  108. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
  109.  
  110. add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
  111. add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
  112.  
  113. function my_theme_wrapper_start() {
  114.   echo '<section id="main">';
  115. }
  116.  
  117. function my_theme_wrapper_end() {
  118.   echo '</section>';
  119. }
  120.  
  121. /* === Widgets === */
  122. if (function_exists('register_sidebar'))
  123. {
  124.     register_sidebar(array(
  125.         'name' => __('Welcome Sidebar', 'welcome-sidebar'),
  126.         'description' => __('Displays the sidebar content on the Homepage.', 'welcome-sidebar'),
  127.         'id' => 'welcome-sidebar',
  128.         'before_widget' => '',
  129.         'after_widget' => '',
  130.         'before_title' => '<h2 class="green-txt column-header">',
  131.         'after_title' => '</h2>'
  132.     ));
  133.    
  134. }
  135.  
  136. add_filter("gform_init_scripts_footer", "init_scripts");
  137. function init_scripts() {
  138. return true;
  139. }
  140.  
  141. class GW_List_Field_As_Choices {
  142.     function __construct( $args ) {
  143.         $this->_args = wp_parse_args( $args, array(
  144.             'form_id'           => false,
  145.             'list_field_id'     => false,
  146.             'choice_field_ids'  => false,
  147.             'label_template'    => '{0}',
  148.             'sort'              => false
  149.         ) );
  150.         if( ! is_array( $this->_args['choice_field_ids'] ) )
  151.             $this->_args['choice_field_ids'] = array( $this->_args['choice_field_ids'] );
  152.         extract( $this->_args ); // gives us $form_id, $list_field_id, $choices_field_id
  153.         add_filter( 'gform_pre_render', array( $this, 'populate_choice_fields' ), 9 );
  154.         add_filter( 'gform_pre_validation', array( $this, 'populate_choice_fields' ), 9 );
  155.         add_filter( 'gform_pre_submission_filter_' . $form_id, array( $this, 'populate_choice_fields' ) );
  156.     }
  157.     function populate_choice_fields( $form ) {
  158.        
  159.         if( $form['id'] != $this->_args['form_id'] )
  160.             return $form;
  161.            
  162.         $list_field = GFFormsModel::get_field( $form, $this->_args['list_field_id'] );
  163.         $values = GFFormsModel::get_field_value( $list_field );
  164.         // if list field doesn't have any values, let's ditch this party
  165.         if( ! is_array( $values ) )
  166.             return $form;
  167.         $choices = $this->get_list_choices( $values );
  168.         foreach( $form['fields'] as &$field ) {
  169.             if( ! $this->is_applicable_field( $field ) )
  170.                 continue;
  171.             // set 'choices' for choice fields
  172.             $field['choices'] = $choices;
  173.             // only set inputs for 'checkbox' choice fields
  174.             if( GFFormsModel::get_input_type( $field ) == 'checkbox' ) {
  175.                 $inputs = array();
  176.                 foreach( $choices as $index => $choice ) {
  177.                     $inputs[] = array(
  178.                         'label' => $choice['text'],
  179.                         'id'    => $field['id'] . '.' . ( $index + 1 )
  180.                     );
  181.                 }
  182.                 $field['inputs'] = $inputs;
  183.             }
  184.            
  185.         }
  186.         return $form;
  187.     }
  188.    
  189.     function get_list_choices( $values ) {
  190.        
  191.         $choices = array();
  192.        
  193.         foreach( $values as $row ) {
  194.            
  195.             $label = $this->replace_template( $this->_args['label_template'], $row );
  196.             $value = isset( $this->_args['value_template'] ) ? $this->replace_template( $this->_args['value_template'], $row ) : $label;
  197.            
  198.             $choices[] = array(
  199.                 'text' => $label,
  200.                 'value' => $value
  201.             );
  202.            
  203.         }
  204.         if( $this->_args['sort'] == true )
  205.             usort( $choices, create_function( '$a, $b', 'return strnatcasecmp( $a["text"], $b["text"] );' ) );
  206.         return $choices;
  207.     }
  208.    
  209.     function replace_template( $template, $row ) {
  210.        
  211.         // combine our templates so we can find all matches at once
  212.         preg_match_all( '/{(\w+)}/', $template, $matches, PREG_SET_ORDER );
  213.        
  214.         if( is_array( $row ) ) {
  215.             $mega_row = array_merge( $row, array_values( $row ) );
  216.             foreach( $matches as $match ) {
  217.                 $template = str_replace( $match[0], rgar( $mega_row, $match[1] ), $template );
  218.             }
  219.            
  220.         } else {
  221.             foreach( $matches as $match ) {
  222.                 $template = str_replace( $match[0], $row, $template );
  223.             }
  224.            
  225.         }
  226.        
  227.         return $template;
  228.     }
  229.    
  230.     function is_applicable_field( $field ) {
  231.        
  232.         $is_choice_field = is_array( rgar( $field, 'choices' ) );
  233.         $is_registered_field = in_array( $field['id'], $this->_args['choice_field_ids'] );
  234.        
  235.         return $is_choice_field && $is_registered_field;
  236.     }
  237.    
  238. }
  239. /**
  240. * Uncomment the code below by removing the pound symbols (#) in front of each line. See @link in the comment section
  241. * at the top for additional usage instructions.
  242. */
  243. # Basic Usage
  244. new GW_List_Field_As_Choices( array(
  245.     'form_id' => 4,
  246.     'list_field_id' => 485,
  247.     'choice_field_ids' => 492,
  248.     'value_template' => '{First Name} | $95.00'
  249. ) );
  250.  
  251. new GW_List_Field_As_Choices( array(
  252.     'form_id' => 4,
  253.     'list_field_id' => 485,
  254.     'choice_field_ids' => 477,
  255.     'value_template' => '{First Name} | $75.00'
  256. ) );
  257.  
  258. new GW_List_Field_As_Choices( array(
  259.     'form_id' => 4,
  260.     'list_field_id' => 486,
  261.     'choice_field_ids' => 495,
  262.     'value_template' => '{First Name} | $95.00'
  263. ) );
  264.  
  265. new GW_List_Field_As_Choices( array(
  266.     'form_id' => 4,
  267.     'list_field_id' => 486,
  268.     'choice_field_ids' => 496,
  269.     'value_template' => '{First Name} | $75.00'
  270. ) );
  271.  
  272. new GW_List_Field_As_Choices( array(
  273.     'form_id' => 4,
  274.     'list_field_id' => 487,
  275.     'choice_field_ids' => 498,
  276.     'value_template' => '{First Name} | $95.00'
  277. ) );
  278.  
  279. new GW_List_Field_As_Choices( array(
  280.     'form_id' => 4,
  281.     'list_field_id' => 487,
  282.     'choice_field_ids' => 499,
  283.     'value_template' => '{First Name} | $75.00'
  284. ) );
  285.  
  286. new GW_List_Field_As_Choices( array(
  287.     'form_id' => 4,
  288.     'list_field_id' => 488,
  289.     'choice_field_ids' => 484,
  290.     'value_template' => '{First Name}'
  291. ) );
  292.  
  293. new GW_List_Field_As_Choices( array(
  294.     'form_id' => 4,
  295.     'list_field_id' => 488,
  296.     'choice_field_ids' => 500,
  297.     'value_template' => '{First Name} | $95.00'
  298. ) );
  299.  
  300. new GW_List_Field_As_Choices( array(
  301.     'form_id' => 4,
  302.     'list_field_id' => 488,
  303.     'choice_field_ids' => 501,
  304.     'value_template' => '{First Name} | $75.00'
  305. ) );
  306.  
  307. new GW_List_Field_As_Choices( array(
  308.     'form_id' => 4,
  309.     'list_field_id' => 489,
  310.     'choice_field_ids' => 503,
  311.     'value_template' => '{First Name}'
  312. ) );
  313.  
  314. new GW_List_Field_As_Choices( array(
  315.     'form_id' => 4,
  316.     'list_field_id' => 489,
  317.     'choice_field_ids' => 504,
  318.     'value_template' => '{First Name} | $95.00'
  319. ) );
  320.  
  321. new GW_List_Field_As_Choices( array(
  322.     'form_id' => 4,
  323.     'list_field_id' => 489,
  324.     'choice_field_ids' => 506,
  325.     'value_template' => '{First Name}'
  326. ) );
  327.  
  328. new GW_List_Field_As_Choices( array(
  329.     'form_id' => 4,
  330.     'list_field_id' => 489,
  331.     'choice_field_ids' => 505,
  332.     'value_template' => '{First Name} | $75.00'
  333. ) );
  334.  
  335. new GW_List_Field_As_Choices( array(
  336.     'form_id' => 4,
  337.     'list_field_id' => 490,
  338.     'choice_field_ids' => 508,
  339.     'value_template' => '{First Name}'
  340. ) );
  341.  
  342. new GW_List_Field_As_Choices( array(
  343.     'form_id' => 4,
  344.     'list_field_id' => 490,
  345.     'choice_field_ids' => 509,
  346.     'value_template' => '{First Name} | $75.00'
  347. ) );
  348.  
  349. add_filter( 'gform_column_input_content_4_485_3', 'change485_column3_content', 10, 6 );
  350. function change485_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  351.     //build field name, must match List field syntax to be processed correctly
  352.     $input_field_name = 'input_' . $field->id . '[]';
  353.     $tabindex = GFCommon::get_tabindex();
  354.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  355.     return $new_input;
  356. }
  357.  
  358. add_filter( 'gform_column_input_content_4_486_3', 'change486_column3_content', 10, 6 );
  359. function change486_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  360.     //build field name, must match List field syntax to be processed correctly
  361.     $input_field_name = 'input_' . $field->id . '[]';
  362.     $tabindex = GFCommon::get_tabindex();
  363.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  364.     return $new_input;
  365. }
  366.  
  367. add_filter( 'gform_column_input_content_4_487_3', 'change487_column3_content', 10, 6 );
  368. function change487_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  369.     //build field name, must match List field syntax to be processed correctly
  370.     $input_field_name = 'input_' . $field->id . '[]';
  371.     $tabindex = GFCommon::get_tabindex();
  372.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  373.     return $new_input;
  374. }
  375.  
  376. add_filter( 'gform_column_input_content_4_488_3', 'change488_column3_content', 10, 6 );
  377. function change488_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  378.     //build field name, must match List field syntax to be processed correctly
  379.     $input_field_name = 'input_' . $field->id . '[]';
  380.     $tabindex = GFCommon::get_tabindex();
  381.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  382.     return $new_input;
  383. }
  384.  
  385. add_filter( 'gform_column_input_content_4_489_3', 'change489_column3_content', 10, 6 );
  386. function change489_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  387.     //build field name, must match List field syntax to be processed correctly
  388.     $input_field_name = 'input_' . $field->id . '[]';
  389.     $tabindex = GFCommon::get_tabindex();
  390.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  391.     return $new_input;
  392. }
  393.  
  394. add_filter( 'gform_column_input_content_4_490_3', 'change490_column3_content', 10, 6 );
  395. function change490_column3_content( $input, $input_info, $field, $text, $value, $form_id ) {
  396.     //build field name, must match List field syntax to be processed correctly
  397.     $input_field_name = 'input_' . $field->id . '[]';
  398.     $tabindex = GFCommon::get_tabindex();
  399.     $new_input = '<input name="' . $input_field_name . '" id="email-input" type="text" value="' . $value . '" class="medium" ' . $tabindex . ' placeholder="Email" />' ;
  400.     return $new_input;
  401. }
  402.  
  403. add_filter( 'gform_field_value_list', 'populate_list' );
  404. function populate_list( $value ) {
  405.   $list_array = array(
  406.             array(
  407.                 'First Name' => 'TBD',
  408.                 'Last Name' => 'TBD',
  409.                 'Email' => ''
  410.             ),
  411.             array(
  412.                 'First Name' => 'TBD',
  413.                 'Last Name' => 'TBD',
  414.                 'Email' => ''
  415.             ),
  416.             array(
  417.                 'First Name' => 'TBD',
  418.                 'Last Name' => 'TBD',
  419.                 'Email' => ''
  420.             ),
  421.             array(
  422.                 'First Name' => 'TBD',
  423.                 'Last Name' => 'TBD',
  424.                 'Email' => ''
  425.             ),
  426.             array(
  427.                 'First Name' => 'TBD',
  428.                 'Last Name' => 'TBD',
  429.                 'Email' => ''
  430.             ),
  431.             array(
  432.                 'First Name' => 'TBD',
  433.                 'Last Name' => 'TBD',
  434.                 'Email' => ''
  435.             ),
  436.             array(
  437.                 'First Name' => 'TBD',
  438.                 'Last Name' => 'TBD',
  439.                 'Email' => ''
  440.             ),
  441.             array(
  442.                 'First Name' => 'TBD',
  443.                 'Last Name' => 'TBD',
  444.                 'Email' => ''
  445.             ),
  446.             array(
  447.                 'First Name' => 'TBD',
  448.                 'Last Name' => 'TBD',
  449.                 'Email' => ''
  450.             ),
  451.             array(
  452.                 'First Name' => 'TBD',
  453.                 'Last Name' => 'TBD',
  454.                 'Email' => ''
  455.             ),
  456.             array(
  457.                 'First Name' => 'TBD',
  458.                 'Last Name' => 'TBD',
  459.                 'Email' => ''
  460.             ),
  461.             array(
  462.                 'First Name' => 'TBD',
  463.                 'Last Name' => 'TBD',
  464.                 'Email' => ''
  465.             ),
  466.             array(
  467.                 'First Name' => 'TBD',
  468.                 'Last Name' => 'TBD',
  469.                 'Email' => ''
  470.             ),
  471.             array(
  472.                 'First Name' => 'TBD',
  473.                 'Last Name' => 'TBD',
  474.                 'Email' => ''
  475.             ),
  476.             array(
  477.                 'First Name' => 'TBD',
  478.                 'Last Name' => 'TBD',
  479.                 'Email' => ''
  480.             ),
  481.             array(
  482.                 'First Name' => 'TBD',
  483.                 'Last Name' => 'TBD',
  484.                 'Email' => ''
  485.             ),                                                
  486.   );
  487.     return $list_array;
  488. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement