Advertisement
Guest User

woocommerce

a guest
May 3rd, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.59 KB | None | 0 0
  1. <?php
  2. global $avia_config;
  3. if(isset($avia_config['use_child_theme_functions_only'])) return;
  4.  
  5.  
  6. /*  
  7.  *  WPML option:
  8.  *  Set $decativate_legacy_wpml_handling to "false" if you already set up your page for wpml and it works fine for you as it is.
  9.  *  If you want more control over the translation set it to "true", you will then be able to create a backend option set for each language
  10.  *
  11.  */
  12.  
  13. $decativate_legacy_wpml_handling = true;
  14.  
  15.  
  16. if($decativate_legacy_wpml_handling == true)
  17. {
  18.     /*multi site config file - needs to be loaded before the framework*/
  19.     require_once( 'config-wpml/config.php' );
  20. }
  21.  
  22. ##################################################################
  23. # AVIA FRAMEWORK by Kriesi
  24.  
  25. # this include calls a file that automatically includes all
  26. # the files within the folder framework and therefore makes
  27. # all functions and classes available for later use
  28.                        
  29. require_once( 'framework/avia_framework.php' );
  30.  
  31. ##################################################################
  32.  
  33.  
  34.  
  35. //register additional image thumbnail sizes that should be generated when user uploads an image:
  36. $avia_config['imgSize']['widget']               = array('width'=>36,  'height'=>36 );                       // small preview pics eg sidebar news
  37. $avia_config['imgSize']['post-format-image']    = array('width'=>630, 'height'=>999, 'crop'=>false);        // big images for post format image and gallery posts
  38. $avia_config['imgSize']['fullsize']             = array('width'=>930, 'height'=>930, 'crop'=>false);        // big images for lightbox and portfolio single entries
  39. $avia_config['imgSize']['featured']             = array('width'=>930, 'height'=>340);                       // images for fullsize pages and fullsize slider
  40. $avia_config['imgSize']['portfolio']            = array('width'=>450, 'height'=>335);                       // images for portfolio entries (2,3,4 column)
  41.  
  42. //dynamic columns
  43. $avia_config['imgSize']['dynamic_1']            = array('width'=>446, 'height'=>151);                       // images for 2/4 (aka 1/2) dynamic portfolio columns when using 3 columns
  44. $avia_config['imgSize']['dynamic_2']            = array('width'=>609, 'height'=>210);                       // images for 2/3 dynamic portfolio columns
  45. $avia_config['imgSize']['dynamic_3']            = array('width'=>688, 'height'=>151);                       // images for 3/4 dynamic portfolio columns
  46.  
  47.  
  48.  
  49. avia_backend_add_thumbnail_size($avia_config);
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. ##################################################################
  57. # Frontend Stuff necessary for the theme:
  58. ##################################################################
  59.  
  60.  
  61. $lang = TEMPLATEPATH . '/lang';
  62. load_theme_textdomain('avia_framework', $lang);
  63.  
  64.  
  65. /* Register frontend javascripts: */
  66. if(!is_admin()){
  67.     add_action('init', 'avia_frontend_js');
  68. }
  69.  
  70. if(!function_exists('avia_frontend_js'))
  71. {
  72.     function avia_frontend_js()
  73.     {
  74.         wp_register_script( 'avia-default', AVIA_BASE_URL.'js/avia.js', array('jquery','avia-html5-video'), 1, false );
  75.         wp_register_script( 'avia-prettyPhoto',  AVIA_BASE_URL.'js/prettyPhoto/js/jquery.prettyPhoto.js', 'jquery', "3.0.1", true);
  76.         wp_register_script( 'avia-html5-video',  AVIA_BASE_URL.'js/projekktor/projekktor.min.js', 'jquery', "1", true);
  77.         wp_register_script( 'adaptavia-slider',  AVIA_BASE_URL.'js/adaptavia.js', 'jquery', "1.0.0", true);
  78.     }
  79. }
  80.  
  81.  
  82. /* Activate native wordpress navigation menu and register a menu location */
  83. add_theme_support('nav_menus');
  84. $avia_config['nav_menus'] = array('avia' => 'Main Menu', 'avia2'=> 'Sub Menu');
  85. foreach($avia_config['nav_menus'] as $key => $value){ register_nav_menu($key, THEMENAME.' '.$value); }
  86.  
  87.  
  88. //adds the plugin initalization scripts that add styles and functions
  89. require_once( 'config-woocommerce/config.php' );    //woocommerce shop plugin      
  90. require_once( 'config-bbpress/config.php' );        //bbpress forum plugin
  91.  
  92. //load some frontend functions in folder include:
  93.  
  94. require_once( 'includes/admin/register-portfolio.php' );        // register custom post types for portfolio entries
  95. require_once( 'includes/admin/register-widget-area.php' );      // register sidebar widgets for the sidebar and footer
  96. require_once( 'css/dynamic-css.php' );                          // register the styles for dynamic frontend styling
  97. require_once( 'includes/admin/register-shortcodes.php' );       // register wordpress shortcodes
  98. require_once( 'includes/loop-comments.php' );                   // necessary to display the comments properly
  99. require_once( 'includes/helper-slideshow.php' );                // holds the class that generates the 2d & 3d slideshows, as well as feature images
  100. require_once( 'includes/helper-templates.php' );                // holds some helper functions necessary for dynamic templates
  101. require_once( 'includes/admin/compat.php' );                    // compatibility functions for 3rd party plugins
  102. require_once( 'includes/admin/register-plugins.php');           // register the plugins we need
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. //activate framework widgets
  111. register_widget( 'avia_tweetbox');
  112. register_widget( 'avia_newsbox' );
  113. register_widget( 'avia_portfoliobox' );
  114. register_widget( 'avia_socialcount' );
  115. register_widget( 'avia_combo_widget' );
  116. register_widget( 'avia_partner_widget' );
  117.  
  118.  
  119.  
  120.  
  121. //add post format options
  122. add_theme_support( 'post-formats', array('link', 'quote', 'gallery' ) );  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. ######################################################################
  130. # CUSTOM THEME FUNCTIONS
  131. ######################################################################
  132.  
  133.  
  134. //call functions for the theme
  135. add_filter('the_content_more_link', 'avia_remove_more_jump_link');
  136. add_post_type_support('page', 'excerpt');
  137.  
  138.  
  139. //allow mp4, webm and ogv file uploads
  140. add_filter('upload_mimes','avia_upload_mimes');
  141. function avia_upload_mimes($mimes){ return array_merge($mimes, array ('mp4' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm')); }
  142.  
  143.  
  144. //change default thumbnail size on theme activation
  145. add_action('avia_backend_theme_activation', 'avia_set_thumb_size');
  146. function avia_set_thumb_size() {update_option( 'thumbnail_size_h', 80 ); update_option( 'thumbnail_size_w', 80 );}
  147.  
  148. //remove post thumbnails from page and posts
  149. add_theme_support( 'post-thumbnails' );
  150. add_action('posts_selection', 'avia_remove_post_thumbnails');
  151. add_action('init', 'avia_remove_post_thumbnails');
  152.  
  153.  
  154. if(!function_exists('avia_remove_post_thumbnails'))
  155. {
  156.     function avia_remove_post_thumbnails()
  157.     {
  158.         global $post_type;
  159.         $remove_when = array('post','page','portfolio','product');
  160.        
  161.         if(is_admin())
  162.         {
  163.             foreach($remove_when as $remove)
  164.             {
  165.                 if($post_type == $remove || (isset($_GET['post_type']) && $_GET['post_type'] == $remove)) { remove_theme_support( 'post-thumbnails' ); };
  166.             }
  167.         }
  168.     }
  169. }
  170.  
  171.  
  172.  
  173.  
  174. /*advanced title + breadcrumb function*/
  175. if(!function_exists('avia_title'))
  176. {
  177.     function avia_title($title = "", $product = "", $meta = true)
  178.     {
  179.         if(is_object($title)) $title = $title->post_title;
  180.         if(!$title) $title = get_the_title(avia_get_the_id());
  181.        
  182.         $extraClass = "";
  183.         if(!$meta) $extraClass = "no_padding_title";
  184.        
  185.         echo "<div class='$extraClass title_container extralight-border'>";
  186.         echo '<h1 class="page-title meta-color">'.$title.'</h1>';
  187.         echo "<div class='title_meta'>";
  188.        
  189.         /*
  190.         *   display the theme search form
  191.         *   the tempalte file that is called is searchform.php in case you want to edit it
  192.         */
  193.         if($meta === true)
  194.         {
  195.             get_search_form();
  196.          
  197.            
  198.             echo '<ul class="social_bookmarks">';
  199.                 do_action('avia_add_social_icon','header');
  200.                 if($dribbble = avia_get_option('dribbble')) echo "<li class='dribbble'><a href='http://dribbble.com/".$dribbble."'>".__('Follow us on dribbble', 'avia_framework')."</a></li>";
  201.                 if($twitter = avia_get_option('twitter')) echo "<li class='twitter'><a href='http://twitter.com/".$twitter."'>".__('Follow us on Twitter', 'avia_framework')."</a></li>";
  202.                 if($facebook = avia_get_option('facebook')) echo "<li class='facebook'><a href='".$facebook."'>".__('Join our Facebook Group', 'avia_framework')."</a></li>";
  203.                 echo '  <li class="rss"><a href="'.avia_get_option('feedburner',get_bloginfo('rss2_url')).'">RSS</a></li>';
  204.             echo '</ul>';
  205.         }
  206.         else if(function_exists($meta))
  207.         {
  208.             $meta();
  209.         }
  210.        
  211.         echo "</div>";
  212.         echo "</div>";
  213.     }
  214. }
  215.  
  216.  
  217. if(!function_exists('avia_flag'))
  218. {
  219.     /*crates the hr separator with the colored flag by using divs without images. Therefore complete color customization from the backend is possible */
  220.     function avia_flag($text = "", $class = "")
  221.     {
  222.         $output  = "";
  223.         $output .= '<div class="hr hr_flag '.$class.'">';
  224.        
  225.         if($text !== false)
  226.         {
  227.             $output .= '        <div class="primary-background flag">';
  228.             $output .= '            <span class="flag-text on-primary-color">'.$text.'</span>';
  229.             $output .= '            <span class="flag-diamond site-background"></span>';
  230.             $output .= '            <span class="mini-seperator extralight-border"></span>';
  231.             $output .= '        </div>';
  232.         }
  233.        
  234.         $output .= '        <span class="hr-seperator extralight-border"></span>';
  235.         $output .= '        <span class="primary-background seperator-addon"></span>';
  236.         $output .= '</div>';
  237.        
  238.         return $output;
  239.     }
  240. }
  241.  
  242.  
  243. if(!function_exists('avia_banner'))
  244. {
  245.     function avia_banner($position)
  246.     {
  247.         $extraClass = "";
  248.         $output = "";
  249.         $cookieHash = "";
  250.         $bannerText = avia_get_option('banner');
  251.         $cookieName = THEMENAME.'_avia_banner';
  252.         $bannerHash = md5($bannerText);
  253.         if($position) $extraClass = 'relative_pos';
  254.        
  255.         if(!empty($_COOKIE[$cookieName])) $cookieHash = $_COOKIE[$cookieName];
  256.        
  257.         $output .= "<div class='$extraClass container_wrap info_text_header' id='info_text_header' data-hash='$bannerHash' data-cookiename='$cookieName'><div class='container no_css_transition'>";
  258.         if(trim($bannerText) != "" && $bannerHash != $cookieHash)
  259.         {
  260.             $output .= "<div class='infotext'>$bannerText <a class='close_info_text rounded' href='#close'>".__('close','avia_framework')."</a></div>";
  261.         }
  262.        
  263.         $output .= "</div></div>";
  264.         echo $output;
  265.     }
  266. }
  267.  
  268. if(!function_exists('avia_shop_banner'))
  269. {
  270.     function avia_shop_banner()
  271.     {
  272.        
  273.         $pos = false;
  274.         $output = "";
  275.         $sub = $cart = $menu = "";
  276.         if(avia_woocommerce_enabled())
  277.         {
  278.             $sub = $cart = avia_woocommerce_cart_dropdown();
  279.         }
  280.        
  281.         $sub .= "<div class='sub_menu'>";
  282.         $args = array('theme_location'=>'avia2', 'fallback_cb' => '', 'echo' => 0);
  283.         if(avia_woocommerce_enabled()) $args['fallback_cb'] ='avia_shop_nav';
  284.         $menu = wp_nav_menu($args);
  285.         $sub .=  $menu;
  286.         $sub .= "</div>";
  287.        
  288.         $output .= "<div class='container_wrap info_text_header' id='shop_header'><div class='container'>";
  289.         if($cart || $menu)
  290.         {
  291.             $output .= $sub;
  292.         }
  293.         else
  294.         {
  295.             $pos = true;
  296.         }
  297.         $output .= "</div></div>";
  298.         echo $output;
  299.        
  300.         return $pos;
  301.        
  302.     }
  303. }
  304.  
  305.  
  306.  
  307. //set post excerpt to be visible on theme acivation in user backend
  308. add_action('avia_backend_theme_activation', 'avia_show_menu_description');
  309.  
  310. if(!function_exists('avia_show_menu_description'))
  311. {
  312.     function avia_show_menu_description()
  313.     {
  314.         global $current_user;
  315.         get_currentuserinfo();
  316.         $old_meta_data = $meta_data = get_user_meta($current_user->ID, 'metaboxhidden_page', true);
  317.        
  318.         if(is_array($meta_data) && isset($meta_data[0]))
  319.         {
  320.             $key = array_search('postexcerpt', $meta_data);
  321.            
  322.             if($key !== false)
  323.             {  
  324.                 unset($meta_data[$key]);
  325.                 update_user_meta( $current_user->ID, 'metaboxhidden_page', $meta_data, $old_meta_data );
  326.             }
  327.         }  
  328.         else
  329.         {
  330.                 update_user_meta( $current_user->ID, 'metaboxhidden_page', array('postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv', 'revisionsdiv') );
  331.         }
  332.     }
  333. }
  334.  
  335.  
  336.  
  337.  
  338. //import the dynamic frontpage template on theme installation
  339.  
  340. add_action('avia_backend_theme_activation', 'avia_default_dynamics');
  341. add_action('avia_ajax_reset_options_page',  'avia_default_dynamics');
  342.  
  343. if(!function_exists('avia_default_dynamics'))
  344. {
  345.     function avia_default_dynamics()
  346.     {
  347.         global $avia;
  348.         $firstInstall = get_option($avia->option_prefix.'_dynamic_elements');
  349.  
  350.         if(empty($firstInstall))
  351.         {
  352.             $custom_export = "dynamic_elements";
  353.             require_once AVIA_PHP . 'inc-avia-importer.php';
  354.            
  355.             if(isset($_GET['page']) && $_GET['page'] == 'templates')
  356.             {
  357.                 wp_redirect( $_SERVER['REQUEST_URI'] );
  358.                 exit();
  359.             }
  360.         }
  361.     }
  362. }
  363.  
  364.  
  365.  
  366.  
  367. /*wordpress 3.4 changed 404 check -  this is the mod for the avia framework to operate*/
  368. function avia_disable_404( $query = false ) {
  369.  
  370.     global $avia_config, $wp_query;
  371.    
  372.     if(!isset($avia_config['first_query_run']) && is_front_page() && is_paged())
  373.     {
  374.         $wp_query->is_paged = false;
  375.         $avia_config['first_query_run'] = true;
  376.         add_action( 'wp', 'avia_enable_404' );
  377.     }
  378. }
  379.  
  380. function avia_enable_404() {
  381.  
  382.     global $wp_query;
  383.     $wp_query->is_paged = true;
  384.    
  385. }
  386.  
  387. add_action( 'pre_get_posts', 'avia_disable_404' ,1 ,10000);
  388.  
  389. function remove_dashboard_widgets(){
  390.   global$wp_meta_boxes;
  391.   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  392.   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  393.   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  394.   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  395.   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
  396.   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
  397.   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
  398.   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  399. }
  400.  
  401. add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
  402.  
  403. function modify_footer_admin () {
  404.   echo 'Created by <a href="http://www.artsjok.be">Artsjok</a>.';
  405. }
  406.  
  407. add_filter('admin_footer_text', 'modify_footer_admin');
  408.  
  409. function fb_like( $atts, $content=null ){
  410. /* Author: Nicholas P. Iler
  411.  * URL: http://www.ilertech.com/2011/06/add-facebook-like-button-to-wordpress-3-0-with-a-simple-shortcode/
  412.  */
  413.     extract(shortcode_atts(array(
  414.             'send' => 'false',
  415.             'layout' => 'standard',
  416.             'show_faces' => 'true',
  417.             'width' => '400px',
  418.             'action' => 'like',
  419.             'font' => '',
  420.             'colorscheme' => 'light',
  421.             'ref' => '',
  422.             'locale' => 'en_US',
  423.             'appId' => '' // Put your AppId here is you have one
  424.     ), $atts));
  425.  
  426.     $fb_like_code = <<<HTML
  427.         <div id="fb-root"></div><script src="http://connect.facebook.net/$locale/all.js#appId=$appId&amp;xfbml=1"></script>
  428.         <fb:like ref="$ref" href="$content" layout="$layout" colorscheme="$colorscheme" action="$action" send="$send" width="$width" show_faces="$show_faces" font="$font"></fb:like>
  429. HTML;
  430.  
  431.     return $fb_like_code;
  432. }
  433. add_shortcode('fb', 'fb_like');
  434.  
  435. //function remove reviews
  436. remove_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30);
  437. remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_reviews_panel', 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement