Advertisement
cipher87

Functions.php + Shop Thumbnail Resize

Jun 15th, 2018
597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.53 KB | None | 0 0
  1. <?php
  2. if ( !defined('ABSPATH') ){ die(); }
  3.  
  4. global $avia_config;
  5.  
  6. /*
  7.  * if you run a child theme and dont want to load the default functions.php file
  8.  * set the global var below in you childthemes function.php to true:
  9.  *
  10.  * example: global $avia_config; $avia_config['use_child_theme_functions_only'] = true;
  11.  * The default functions.php file will then no longer be loaded. You need to make sure then
  12.  * to include framework and functions that you want to use by yourself.
  13.  *
  14.  * This is only recommended for advanced users
  15.  */
  16.  
  17. if(isset($avia_config['use_child_theme_functions_only'])) return;
  18.  
  19. /*
  20.  * create a global var which stores the ids of all posts which are displayed on the current page. It will help us to filter duplicate posts
  21.  */
  22. $avia_config['posts_on_current_page'] = array();
  23.  
  24.  
  25. /*
  26.  * wpml multi site config file
  27.  * needs to be loaded before the framework
  28.  */
  29. require_once( 'config-wpml/config.php' );
  30.  
  31. /**
  32.  * layerslider plugin - needs to be loaded before framework because we need to add data to the options array
  33.  *
  34.  * To be backwards compatible we still support  add_theme_support('deactivate_layerslider');
  35.  * This will override the option setting "activation" of the bundled plugin !!
  36.  *
  37.  * @since 4.2.1
  38.  */
  39. require_once( 'config-layerslider/config.php' );
  40.  
  41.  
  42. /*
  43.  * These are the available color sets in your backend.
  44.  * If more sets are added users will be able to create additional color schemes for certain areas
  45.  *
  46.  * The array key has to be the class name, the value is only used as tab heading on the styling page
  47.  */
  48.  
  49.  
  50. $avia_config['color_sets'] = array(
  51.     'header_color'      => 'Logo Area',
  52.     'main_color'        => 'Main Content',
  53.     'alternate_color'   => 'Alternate Content',
  54.     'footer_color'      => 'Footer',
  55.     'socket_color'      => 'Socket'
  56.  );
  57.  
  58.  
  59.  
  60. /*
  61.  * add support for responsive mega menus
  62.  */
  63.  
  64. add_theme_support('avia_mega_menu');
  65.  
  66.  
  67.  
  68. /*
  69.  * add support for improved backend styling
  70.  */
  71.  
  72. add_theme_support('avia_improved_backend_style');
  73.  
  74.  
  75.  
  76. /*
  77.  * deactivates the default mega menu and allows us to pass individual menu walkers when calling a menu
  78.  */
  79.  
  80. add_filter('avia_mega_menu_walker', '__return_false');
  81.  
  82.  
  83. /*
  84.  * adds support for the new avia sidebar manager
  85.  */
  86.  
  87. add_theme_support('avia_sidebar_manager');
  88.  
  89.  
  90. /*
  91.  * Filters for post formats etc
  92.  */
  93. //add_theme_support('avia_queryfilter');
  94.  
  95.  
  96. /*
  97.  * Register theme text domain
  98.  */
  99. if(!function_exists('avia_lang_setup'))
  100. {
  101.     add_action('after_setup_theme', 'avia_lang_setup');
  102.    
  103.     function avia_lang_setup()
  104.     {
  105.         $lang = apply_filters('ava_theme_textdomain_path', get_template_directory()  . '/lang');
  106.         load_theme_textdomain('avia_framework', $lang);
  107.     }
  108.    
  109.     avia_lang_setup();
  110. }
  111.  
  112.  
  113. /*
  114. function that changes the icon of the  theme update tab
  115. */
  116.  
  117. if(!function_exists('avia_theme_update_filter'))
  118. {
  119.     function avia_theme_update_filter( $data )
  120.     {
  121.         if(current_theme_supports('avia_improved_backend_style'))
  122.         {
  123.             $data['icon'] = 'new/arrow-repeat-two-7@3x.png';
  124.         }
  125.         return $data;
  126.     }
  127.    
  128.     add_filter('avf_update_theme_tab', 'avia_theme_update_filter', 30, 1);
  129. }
  130.  
  131.  
  132.  
  133.  
  134. ##################################################################
  135. # AVIA FRAMEWORK by Kriesi
  136.  
  137. # this include calls a file that automatically includes all
  138. # the files within the folder framework and therefore makes
  139. # all functions and classes available for later use
  140.  
  141. require_once( 'framework/avia_framework.php' );
  142.  
  143. ##################################################################
  144.  
  145.  
  146. /*
  147.  * Register additional image thumbnail sizes
  148.  * Those thumbnails are generated on image upload!
  149.  *
  150.  * If the size of an array was changed after an image was uploaded you either need to re-upload the image
  151.  * or use the thumbnail regeneration plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/
  152.  */
  153.  
  154. $avia_config['imgSize']['widget']               = array('width'=>36,  'height'=>36);                        // small preview pics eg sidebar news
  155. $avia_config['imgSize']['square']               = array('width'=>180, 'height'=>180);                        // small image for blogs
  156. $avia_config['imgSize']['featured']             = array('width'=>1500, 'height'=>430 );                     // images for fullsize pages and fullsize slider
  157. $avia_config['imgSize']['featured_large']       = array('width'=>1500, 'height'=>630 );                     // images for fullsize pages and fullsize slider
  158. $avia_config['imgSize']['extra_large']          = array('width'=>1500, 'height'=>1500 , 'crop' => false);   // images for fullscrren slider
  159. $avia_config['imgSize']['portfolio']            = array('width'=>495, 'height'=>400 );                      // images for portfolio entries (2,3 column)
  160. $avia_config['imgSize']['portfolio_small']      = array('width'=>260, 'height'=>185 );                      // images for portfolio 4 columns
  161. $avia_config['imgSize']['gallery']              = array('width'=>845, 'height'=>684 );                      // images for portfolio entries (2,3 column)
  162. $avia_config['imgSize']['magazine']             = array('width'=>710, 'height'=>375 );                      // images for magazines
  163. $avia_config['imgSize']['masonry']              = array('width'=>705, 'height'=>705 , 'crop' => false);     // images for fullscreen masonry
  164. $avia_config['imgSize']['entry_with_sidebar']   = array('width'=>845, 'height'=>321);                       // big images for blog and page entries
  165. $avia_config['imgSize']['entry_without_sidebar']= array('width'=>1210, 'height'=>423 );                     // images for fullsize pages and fullsize slider
  166. $avia_config['imgSize'] = apply_filters('avf_modify_thumb_size', $avia_config['imgSize']);
  167.  
  168.  
  169. $avia_config['selectableImgSize'] = array(
  170.     'square'                => __('Square','avia_framework'),
  171.     'featured'              => __('Featured Thin','avia_framework'),
  172.     'featured_large'        => __('Featured Large','avia_framework'),
  173.     'portfolio'             => __('Portfolio','avia_framework'),
  174.     'gallery'               => __('Gallery','avia_framework'),
  175.     'entry_with_sidebar'    => __('Entry with Sidebar','avia_framework'),
  176.     'entry_without_sidebar' => __('Entry without Sidebar','avia_framework'),
  177.     'extra_large'           => __('Fullscreen Sections/Sliders','avia_framework'),
  178.    
  179. );
  180.  
  181.  
  182.  
  183. avia_backend_add_thumbnail_size($avia_config);
  184.  
  185. if ( ! isset( $content_width ) ) $content_width = $avia_config['imgSize']['featured']['width'];
  186.  
  187.  
  188.  
  189.  
  190. /*
  191.  * register the layout classes
  192.  *
  193.  */
  194.  
  195. $avia_config['layout']['fullsize']      = array('content' => 'av-content-full alpha', 'sidebar' => 'hidden',          'meta' => '','entry' => '');
  196. $avia_config['layout']['sidebar_left']  = array('content' => 'av-content-small',      'sidebar' => 'alpha' ,'meta' => 'alpha', 'entry' => '');
  197. $avia_config['layout']['sidebar_right'] = array('content' => 'av-content-small alpha','sidebar' => 'alpha', 'meta' => 'alpha', 'entry' => 'alpha');
  198.  
  199.  
  200.  
  201.  
  202.  
  203. /*
  204.  * These are some of the font icons used in the theme, defined by the entypo icon font. the font files are included by the new aviaBuilder
  205.  * common icons are stored here for easy retrieval
  206.  */
  207.  
  208.  $avia_config['font_icons'] = apply_filters('avf_default_icons', array(
  209.  
  210.     //post formats +  types
  211.     'standard'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue836'),
  212.     'link'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue822'),
  213.     'image'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue80f'),
  214.     'audio'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue801'),
  215.     'quote'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue833'),
  216.     'gallery'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue80e'),
  217.     'video'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue80d'),
  218.     'portfolio'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue849'),
  219.     'product'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue859'),
  220.                    
  221.     //social       
  222.     'behance'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue915'),
  223.     'dribbble'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue8fe'),
  224.     'facebook'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue8f3'),
  225.     'flickr'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue8ed'),
  226.     'gplus'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue8f6'),
  227.     'linkedin'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue8fc'),
  228.     'instagram'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue909'),
  229.     'pinterest'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue8f8'),
  230.     'skype'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue90d'),
  231.     'tumblr'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue8fa'),
  232.     'twitter'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue8f1'),
  233.     'vimeo'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue8ef'),
  234.     'rss'           => array( 'font' =>'entypo-fontello', 'icon' => 'ue853'),  
  235.     'youtube'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue921'),  
  236.     'xing'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue923'),  
  237.     'soundcloud'    => array( 'font' =>'entypo-fontello', 'icon' => 'ue913'),  
  238.     'five_100_px'   => array( 'font' =>'entypo-fontello', 'icon' => 'ue91d'),  
  239.     'vk'            => array( 'font' =>'entypo-fontello', 'icon' => 'ue926'),  
  240.     'reddit'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue927'),  
  241.     'digg'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue928'),  
  242.     'delicious'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue929'),  
  243.     'mail'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue805'),
  244.                    
  245.     //woocomemrce    
  246.     'cart'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue859'),
  247.     'details'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue84b'),
  248.  
  249.     //bbpress    
  250.     'supersticky'   => array( 'font' =>'entypo-fontello', 'icon' => 'ue808'),
  251.     'sticky'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue809'),
  252.     'one_voice'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue83b'),
  253.     'multi_voice'   => array( 'font' =>'entypo-fontello', 'icon' => 'ue83c'),
  254.     'closed'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue824'),
  255.     'sticky_closed' => array( 'font' =>'entypo-fontello', 'icon' => 'ue808\ue824'),
  256.     'supersticky_closed' => array( 'font' =>'entypo-fontello', 'icon' => 'ue809\ue824'),
  257.                    
  258.     //navigation, slider & controls
  259.     'play'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue897'),
  260.     'pause'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue899'),
  261.     'next'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue879'),
  262.     'prev'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue878'),
  263.     'next_big'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue87d'),
  264.     'prev_big'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue87c'),
  265.     'close'         => array( 'font' =>'entypo-fontello', 'icon' => 'ue814'),
  266.     'reload'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue891'),
  267.     'mobile_menu'   => array( 'font' =>'entypo-fontello', 'icon' => 'ue8a5'),
  268.                    
  269.     //image hover overlays     
  270.     'ov_external'   => array( 'font' =>'entypo-fontello', 'icon' => 'ue832'),
  271.     'ov_image'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue869'),
  272.     'ov_video'      => array( 'font' =>'entypo-fontello', 'icon' => 'ue897'),
  273.    
  274.                    
  275.     //misc         
  276.     'search'        => array( 'font' =>'entypo-fontello', 'icon' => 'ue803'),
  277.     'info'          => array( 'font' =>'entypo-fontello', 'icon' => 'ue81e'),
  278.     'clipboard'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue8d1'),
  279.     'scrolltop'     => array( 'font' =>'entypo-fontello', 'icon' => 'ue876'),
  280.     'scrolldown'    => array( 'font' =>'entypo-fontello', 'icon' => 'ue877'),
  281.     'bitcoin'       => array( 'font' =>'entypo-fontello', 'icon' => 'ue92a'),
  282.  
  283. ));
  284.  
  285.  
  286.  
  287.  
  288. /*
  289.  * a small array that contains admin notices that can, for example, be called after an update
  290.  * just set the db option avia_admin_notice to contain the key of the notice you want to display
  291.  * eg: update_option('avia_admin_notice', 'performance_update');
  292.  *
  293.  * classes: error, warning, success, info
  294.  * msg: whatever floats your boat :D
  295.  */
  296.  
  297. $avia_config['admin_notices'] = array(
  298.    
  299.     //default update success
  300.     'update_success'        => array('class'=>'success', 'msg' => __('Enfold update was successful! ','avia_framework')),
  301.    
  302.     //update to version 4.3 - performance update. display notice and link to blog post 
  303.     'performance_update'    => array('class'=>'info',    'msg' => "<strong>Attention:</strong> The last Enfold update added a lot of performance options. Make sure to read more about it <a href='https://kriesi.at/archives/enfold-4-3-performance-update' target='_blank'>here</a><br><br>If you are running a caching plugin please make sure to reset your cached files, since the CSS and JS file structure of the theme changed heavily"
  304.     ), 
  305.    
  306.     //update to version 4.4 - gdpr update. display notice and link to blog post
  307.     'gdpr_update'   => array('class'=>'info',    'msg' => "<strong>Attention:</strong> Enfold was updated for GDPR compliance. Make sure to read more about it <a href='https://kriesi.at/archives/enfold-4-4-and-the-gdpr-general-data-protection-regulation' target='_blank'>here</a>"
  308.     ), 
  309.    
  310.    
  311.     //more to come...
  312. );
  313.  
  314.  
  315.  
  316.  
  317.  
  318. add_theme_support( 'automatic-feed-links' );
  319.  
  320. ##################################################################
  321. # Frontend Stuff necessary for the theme:
  322. ##################################################################
  323.  
  324.  
  325.  
  326. /*
  327.  * Register frontend javascripts:
  328.  */
  329. if(!function_exists('avia_register_frontend_scripts'))
  330. {
  331.     if(!is_admin()){
  332.         add_action('wp_enqueue_scripts', 'avia_register_frontend_scripts');
  333.     }
  334.  
  335.     function avia_register_frontend_scripts()
  336.     {
  337.         global $avia_config;
  338.        
  339.         $theme = wp_get_theme();
  340.         if( false !== $theme->parent() )
  341.         {
  342.             $theme = $theme->parent();
  343.         }
  344.         $vn = $theme->get( 'Version' );
  345.        
  346.         $options = avia_get_option();
  347.        
  348.         $template_url       = get_template_directory_uri();
  349.         $child_theme_url    = get_stylesheet_directory_uri();
  350.  
  351.         //register js
  352.         wp_enqueue_script( 'avia-compat', $template_url.'/js/avia-compat.js' , array(), $vn, false ); //needs to be loaded at the top to prevent bugs
  353.         wp_enqueue_script( 'avia-default', $template_url.'/js/avia.js', array('jquery'), $vn, true );
  354.         wp_enqueue_script( 'avia-shortcodes', $template_url.'/js/shortcodes.js', array('jquery','avia-default'), $vn, true );
  355.  
  356.         wp_enqueue_script( 'jquery' );
  357.  
  358.  
  359.        
  360.  
  361.  
  362.         //register styles
  363.         wp_register_style( 'avia-style' ,  $child_theme_url."/style.css", array(),      $vn, 'all' ); //only include in childthemes. has no purpose in main theme
  364.         wp_register_style( 'avia-custom',  $template_url."/css/custom.css", array(),    $vn, 'all' );
  365.                                                                                          
  366.         wp_enqueue_style( 'avia-grid' ,   $template_url."/css/grid.css", array(),       $vn, 'all' );
  367.         wp_enqueue_style( 'avia-base' ,   $template_url."/css/base.css", array('avia-grid'),        $vn, 'all' );
  368.         wp_enqueue_style( 'avia-layout',  $template_url."/css/layout.css", array('avia-base'),  $vn, 'all' );
  369.         wp_enqueue_style( 'avia-scs',     $template_url."/css/shortcodes.css", array('avia-layout'), $vn, 'all' );
  370.        
  371.        
  372.         /************************************************************************
  373.         Conditional style and script calling, based on theme options or other conditions
  374.         *************************************************************************/
  375.        
  376.         //lightbox inclusion
  377.         $condition = !empty($avia_config['use_standard_lightbox']) && ( 'disabled' != $avia_config['use_standard_lightbox'] );
  378.         avia_enqueue_style_conditionally(  $condition , 'avia-popup-css', $template_url."/js/aviapopup/magnific-popup.css", array('avia-layout'), $vn, 'screen');
  379.         avia_enqueue_style_conditionally(  $condition , 'avia-lightbox', $template_url."/css/avia-snippet-lightbox.css", array('avia-layout'), $vn, 'screen');
  380.         avia_enqueue_script_conditionally( $condition , 'avia-popup-js' , $template_url.'/js/aviapopup/jquery.magnific-popup.min.js', array('jquery'), $vn, true);
  381.         avia_enqueue_script_conditionally( $condition , 'avia-lightbox-activation', $template_url."/js/avia-snippet-lightbox.js", array('avia-default'), $vn, true);
  382.        
  383.        
  384.         //mega menu inclusion (only necessary with sub menu items)
  385.         $condition = (avia_get_submenu_count('avia') > 0);
  386.         avia_enqueue_script_conditionally( $condition , 'avia-megamenu', $template_url."/js/avia-snippet-megamenu.js", array('avia-default'), $vn, true);
  387.        
  388.        
  389.         //sidebar menu inclusion (only necessary when header position is set to be a sidebar)
  390.         $condition = (isset($options['header_position']) && $options['header_position'] != "header_top");
  391.         avia_enqueue_script_conditionally( $condition , 'avia-sidebarmenu', $template_url."/js/avia-snippet-sidebarmenu.js", array('avia-default'), $vn, true);
  392.        
  393.        
  394.         //sticky header with header size calculator
  395.         $condition  = (isset($options['header_position']) && $options['header_position'] == "header_top");
  396.         $condition2 = (isset($options['header_sticky']) && $options['header_sticky'] == "header_sticky") && $condition;
  397.         avia_enqueue_script_conditionally( $condition2 , 'avia-sticky-header', $template_url."/js/avia-snippet-sticky-header.js", array('avia-default'), $vn, true);
  398.        
  399.        
  400.         //site preloader
  401.         $condition = (isset($options['preloader']) && $options['preloader'] == "preloader");
  402.         avia_enqueue_script_conditionally( $condition , 'avia-siteloader-js', $template_url."/js/avia-snippet-site-preloader.js", array('avia-default'), $vn, true, false);
  403.         avia_enqueue_style_conditionally(  $condition , 'avia-siteloader', $template_url."/css/avia-snippet-site-preloader.css", array('avia-layout'), $vn, 'screen', false);
  404.        
  405.        
  406.         //cookie consent
  407.         $condition = (isset($options['cookie_consent']) && $options['cookie_consent'] == "cookie_consent");
  408.         avia_enqueue_script_conditionally( $condition , 'avia-cookie-js' , $template_url."/js/avia-snippet-cookieconsent.js", array('avia-default'), $vn, true);
  409.         avia_enqueue_style_conditionally(  $condition , 'avia-cookie-css', $template_url."/css/avia-snippet-cookieconsent.css", array('avia-layout'), $vn, 'screen');
  410.        
  411.        
  412.         //load widget css only if we got active widgets
  413.         $condition = (avia_get_active_widget_count() > 0);
  414.         avia_enqueue_style_conditionally(  $condition , 'avia-widget-css', $template_url."/css/avia-snippet-widget.css", array('avia-layout'), $vn, 'screen');
  415.  
  416.        
  417.         //load mediaelement js
  418.         $condition  = !( isset($options['disable_mediaelement']) && $options['disable_mediaelement'] == "disable_mediaelement" ) && av_video_assets_required();
  419.         $condition2 = ( version_compare( get_bloginfo( 'version' ), '4.9', '>=' ) ) && $condition;
  420.         avia_enqueue_script_conditionally( $condition , 'wp-mediaelement');
  421.         avia_enqueue_style_conditionally( $condition2 , 'wp-mediaelement'); //With WP 4.9 we need to load the stylesheet seperately
  422.  
  423.  
  424.         //comment reply script
  425.         global $post;
  426.         $condition = !( isset($options['disable_blog']) && $options['disable_blog'] == "disable_blog" ) && $post && comments_open();
  427.         $condition = ( is_singular() && get_option( 'thread_comments' ) ) && $condition;
  428.         avia_enqueue_script_conditionally( $condition , 'comment-reply');
  429.        
  430.  
  431.  
  432.         //rtl inclusion
  433.         avia_enqueue_style_conditionally( is_rtl() , 'avia-rtl',  $template_url."/css/rtl.css", array(), $vn, 'all');
  434.        
  435.        
  436.         //disable jquery migrate if no plugins are active (enfold does not need it) or if user asked for it in optimization options
  437.         $condition = avia_count_active_plugins() == 0 || (isset($options['disable_jq_migrate']) && $options['disable_jq_migrate'] != "disable_jq_migrate");
  438.         if(!$condition) avia_disable_query_migrate();
  439.        
  440.        
  441.        
  442.         //move jquery to footer if no unkown plugins are active
  443.         if(av_count_untested_plugins() == 0 || (isset($options['jquery_in_footer']) && $options['jquery_in_footer'] == "jquery_in_footer") ){
  444.             av_move_jquery_into_footer();
  445.         }
  446.        
  447.        
  448.        
  449.         /************************************************************************
  450.         Inclusion of the dynamic stylesheet
  451.         *************************************************************************/
  452.        
  453.        
  454.         global $avia;
  455.        
  456.         $safe_name = avia_backend_safe_string($avia->base_data['prefix']);
  457.         $safe_name = apply_filters('avf_dynamic_stylesheet_filename', $safe_name);
  458.  
  459.         if( get_option('avia_stylesheet_exists'.$safe_name) == 'true' )
  460.         {
  461.             $avia_upload_dir = wp_upload_dir();
  462.            
  463.             /**
  464.              * Change the default dynamic upload url
  465.              *
  466.              * @since 4.4
  467.              */
  468.             $avia_dyn_upload_path = apply_filters('avf_dyn_stylesheet_dir_url',  $avia_upload_dir['baseurl'] . '/dynamic_avia' );
  469.             $avia_dyn_upload_path = trailingslashit( $avia_dyn_upload_path );
  470.            
  471.             if( is_ssl() )
  472.             {
  473.                 $avia_dyn_upload_path = str_replace( "http://", "https://", $avia_dyn_upload_path );
  474.             }
  475.            
  476.             /**
  477.              * Change the default dynamic stylesheet name
  478.              *
  479.              * @since 4.4
  480.              */
  481.             $avia_dyn_stylesheet_url = apply_filters( 'avf_dyn_stylesheet_file_url', $avia_dyn_upload_path . $safe_name . '.css' );
  482.  
  483.             $version_number = get_option( 'avia_stylesheet_dynamic_version' . $safe_name );
  484.             if( empty( $version_number ) )
  485.             {
  486.                 $version_number = $vn;
  487.             }
  488.            
  489.             wp_enqueue_style( 'avia-dynamic', $avia_dyn_stylesheet_url, array(), $version_number, 'all' );
  490.         }
  491.  
  492.         wp_enqueue_style( 'avia-custom');
  493.  
  494.  
  495.         if($child_theme_url !=  $template_url)
  496.         {
  497.             wp_enqueue_style( 'avia-style');
  498.         }
  499.  
  500.     }
  501. }
  502.  
  503.  
  504. if(!function_exists('avia_remove_default_video_styling'))
  505. {
  506.     if(!is_admin()){
  507.         add_action('wp_footer', 'avia_remove_default_video_styling', 1);
  508.     }
  509.  
  510.     function avia_remove_default_video_styling()
  511.     {
  512.         /**
  513.          * remove default style for videos
  514.          *
  515.          * With WP 4.9 we need to load the stylesheet seperately - therefore we must not remove it
  516.          */
  517.         if( version_compare( get_bloginfo( 'version' ), '4.9', '<' ) )
  518.         {
  519.             wp_dequeue_style( 'mediaelement' );
  520.         }
  521.        
  522.         // wp_dequeue_script( 'wp-mediaelement' );
  523.         // wp_dequeue_style( 'wp-mediaelement' );
  524.     }
  525. }
  526.  
  527.  
  528.  
  529.  
  530. /*
  531.  * Activate native wordpress navigation menu and register a menu location
  532.  */
  533. if(!function_exists('avia_nav_menus'))
  534. {
  535.     function avia_nav_menus()
  536.     {
  537.         global $avia_config, $wp_customize;
  538.  
  539.         add_theme_support('nav_menus');
  540.        
  541.         foreach($avia_config['nav_menus'] as $key => $value)
  542.         {
  543.             //wp-admin\customize.php does not support html code in the menu description - thus we need to strip it
  544.             $name = (!empty($value['plain']) && !empty($wp_customize)) ? $value['plain'] : $value['html'];
  545.             register_nav_menu($key, THEMENAME.' '.$name);
  546.         }
  547.     }
  548.  
  549.     $avia_config['nav_menus'] = array(  'avia' => array('html' => __('Main Menu', 'avia_framework')),
  550.                                         'avia2' => array(
  551.                                                     'html' => ''.__('Secondary Menu', 'avia_framework').' <br/><small>('.__('Will be displayed if you selected a header layout that supports a submenu', 'avia_framework').' <a target="_blank" href="'.admin_url('?page=avia#goto_header').'">'.__('here', 'avia_framework').'</a>)</small>',
  552.                                                     'plain'=> __('Secondary Menu - will be displayed if you selected a header layout that supports a submenu', 'avia_framework')),
  553.                                         'avia3' => array(
  554.                                                     'html' => __('Footer Menu <br/><small>(no dropdowns)</small>', 'avia_framework'),
  555.                                                     'plain'=> __('Footer Menu (no dropdowns)', 'avia_framework'))
  556.                                     );
  557.  
  558.     avia_nav_menus(); //call the function immediatly to activate
  559. }
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570. /*
  571.  *  load some frontend functions in folder include:
  572.  */
  573.  
  574. require_once( 'includes/admin/register-portfolio.php' );        // register custom post types for portfolio entries
  575. require_once( 'includes/admin/register-widget-area.php' );      // register sidebar widgets for the sidebar and footer
  576. require_once( 'includes/loop-comments.php' );                   // necessary to display the comments properly
  577. require_once( 'includes/helper-template-logic.php' );           // holds the template logic so the theme knows which tempaltes to use
  578. require_once( 'includes/helper-social-media.php' );             // holds some helper functions necessary for twitter and facebook buttons
  579. require_once( 'includes/helper-post-format.php' );              // holds actions and filter necessary for post formats
  580. require_once( 'includes/helper-markup.php' );                   // holds the markup logic (schema.org and html5)
  581. require_once( 'includes/helper-assets.php' );                   // holds asset managment functions
  582. require_once( 'includes/helper-privacy.php' );                  // holds privacy managment shortcodes and functions
  583.  
  584. if(current_theme_supports('avia_conditionals_for_mega_menu'))
  585. {
  586.     require_once( 'includes/helper-conditional-megamenu.php' );  // holds the walker for the responsive mega menu
  587. }
  588.  
  589. require_once( 'includes/helper-responsive-megamenu.php' );      // holds the walker for the responsive mega menu
  590.  
  591.  
  592.  
  593.  
  594. //adds the plugin initalization scripts that add styles and functions
  595.  
  596. require_once( 'config-bbpress/config.php' );                    //compatibility with  bbpress forum plugin
  597. require_once( 'config-templatebuilder/config.php' );            //templatebuilder plugin
  598. require_once( 'config-gravityforms/config.php' );               //compatibility with gravityforms plugin
  599. require_once( 'config-woocommerce/config.php' );                //compatibility with woocommerce plugin
  600. require_once( 'config-wordpress-seo/config.php' );              //compatibility with Yoast WordPress SEO plugin
  601. require_once( 'config-menu-exchange/config.php' );              //compatibility with Zen Menu Logic and Themify_Conditional_Menus plugin
  602.  
  603. if(!current_theme_supports('deactivate_tribe_events_calendar'))
  604. {
  605.     require_once( 'config-events-calendar/config.php' );        //compatibility with the Events Calendar plugin
  606. }
  607.  
  608. // if(is_admin())
  609. require_once( 'includes/admin/helper-compat-update.php');   // include helper functions for new versions
  610.  
  611.  
  612.  
  613.  
  614.  
  615. /*
  616.  *  dynamic styles for front and backend
  617.  */
  618. if(!function_exists('avia_custom_styles'))
  619. {
  620.     function avia_custom_styles()
  621.     {
  622.         require_once( 'includes/admin/register-dynamic-styles.php' );   // register the styles for dynamic frontend styling
  623.         avia_prepare_dynamic_styles();
  624.     }
  625.  
  626.     add_action('init', 'avia_custom_styles', 20);
  627.     add_action('admin_init', 'avia_custom_styles', 20);
  628. }
  629.  
  630.  
  631.  
  632.  
  633. /*
  634.  *  activate framework widgets
  635.  */
  636. if(!function_exists('avia_register_avia_widgets'))
  637. {
  638.     function avia_register_avia_widgets()
  639.     {
  640.         register_widget( 'avia_newsbox' );
  641.         register_widget( 'avia_portfoliobox' );
  642.         register_widget( 'avia_socialcount' );
  643.         register_widget( 'avia_partner_widget' );
  644.         register_widget( 'avia_google_maps' );
  645.         register_widget( 'avia_fb_likebox' );
  646.         register_widget( 'avia_instagram_widget' );
  647.        
  648.     }
  649.  
  650.     avia_register_avia_widgets(); //call the function immediatly to activate
  651. }
  652.  
  653.  
  654.  
  655. /*
  656.  *  add post format options
  657.  */
  658. add_theme_support( 'post-formats', array('link', 'quote', 'gallery','video','image','audio' ) );
  659.  
  660.  
  661.  
  662. /*
  663.  *  Remove the default shortcode function, we got new ones that are better ;)
  664.  */
  665. add_theme_support( 'avia-disable-default-shortcodes', true);
  666.  
  667.  
  668. /*
  669.  * compat mode for easier theme switching from one avia framework theme to another
  670.  */
  671. add_theme_support( 'avia_post_meta_compat');
  672.  
  673.  
  674. /*
  675.  * make sure that enfold widgets dont use the old slideshow parameter in widgets, but default post thumbnails
  676.  */
  677. add_theme_support('force-post-thumbnails-in-widget');
  678.  
  679.  
  680. /*
  681.  * display page titles via wordpress default output
  682.  *
  683.  * @since 3.6
  684.  */
  685. function av_theme_slug_setup()
  686. {
  687.    add_theme_support( 'title-tag' );
  688. }
  689.  
  690. add_action( 'after_setup_theme', 'av_theme_slug_setup' );
  691.  
  692. /*title fallback (up to WP 4.1)*/
  693. if ( ! function_exists( '_wp_render_title_tag' ) )
  694. {
  695.     function av_theme_slug_render_title()
  696.     {
  697.         echo "<title>" . avia_set_title_tag() ."</title>";
  698.     }
  699.     add_action( 'wp_head', 'av_theme_slug_render_title' );
  700. }
  701.    
  702.  
  703.  
  704.  
  705. /*
  706.  *  register custom functions that are not related to the framework but necessary for the theme to run
  707.  */
  708.  
  709. require_once( 'functions-enfold.php');
  710.  
  711.  
  712. /*
  713.  * add option to edit elements via css class
  714.  */
  715. // add_theme_support('avia_template_builder_custom_css');
  716.  
  717. add_filter( 'woocommerce_gallery_thumbnail_size', 'custom_woocommerce_gallery_thumbnail_size' );
  718.  
  719. function custom_woocommerce_gallery_thumbnail_size() {
  720.     return 'thumbnail';
  721. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement