Advertisement
rejuancse

functions

Feb 11th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.43 KB | None | 0 0
  1. <?php
  2. define( 'calypso_CSS', get_template_directory_uri().'/css/' );
  3. define( 'calypso_JS', get_template_directory_uri().'/js/' );
  4. define( 'calypso_DIR', get_template_directory() );
  5.  
  6. /* -------------------------------------------
  7. *               Include TGM Plugins
  8. * -------------------------------------------- */
  9. require_once( calypso_DIR . '/lib/class-tgm-plugin-activation.php');
  10.  
  11. /* -------------------------------------------
  12. *               Fontawesome Helper
  13. * -------------------------------------------- */
  14.  
  15. require_once( calypso_DIR . '/lib/fontawesome-helper.php');
  16.  
  17.  
  18. /*-------------------------------------------*
  19.  *              Register Navigation
  20.  *------------------------------------------*/
  21. register_nav_menus( array(
  22.     'primary' => esc_html__( 'Primary Menu', 'calypso' ),
  23.     // 'footernav' => esc_html__( 'Footer Menu', 'calypso' ),
  24. ) );
  25.        
  26.  
  27. /*-------------------------------------------*
  28.  *              navwalker
  29.  *------------------------------------------*/
  30. require_once( calypso_DIR . '/lib/menu/admin-megamenu-walker.php');
  31. require_once( calypso_DIR . '/lib/menu/meagmenu-walker.php');
  32. require_once( calypso_DIR . '/lib/menu/mobile-navwalker.php');
  33. add_filter( 'wp_edit_nav_menu_walker', function( $class, $menu_id ){
  34.     return 'Themeum_Megamenu_Walker';
  35. }, 10, 2 );
  36.  
  37.  
  38. /*-------------------------------------------*
  39. *               Startup Register
  40. *------------------------------------------*/
  41. require_once( calypso_DIR . '/lib/main-function/themeum-register.php');
  42.  
  43.  
  44. /*-------------------------------------------------------
  45. *               Themeum Core
  46. *-------------------------------------------------------*/
  47. require_once( calypso_DIR . '/lib/main-function/themeum-core.php');
  48. require_once( calypso_DIR . '/woocommerce/jihad.php');
  49.  
  50. function shipping_zones_shortcode() {
  51.  
  52.     $delivery_zones = WC_Shipping_Zones::get_zones();
  53.  
  54.     foreach ( (array) $delivery_zones as $key => $the_zone ) {
  55.         echo ''.$the_zone['zone_name'].', ';
  56.         echo ''.$the_zone['formatted_zone_location'].', ';
  57.  
  58.         echo ''.$the_zone['zone_locations'].', ';
  59.  
  60.         echo '<pre>';
  61.         print_r($the_zone['shipping_methods']);
  62.         echo '</pre>';
  63.  
  64.         // foreach ( $the_zone['shipping_methods'] as $zone ) {
  65.         //     echo '<pre>';
  66.         //     print_r($zone->method_description);
  67.         //     echo '</pre>';
  68.         // }
  69.  
  70.     }
  71. }
  72.  
  73. add_shortcode( 'list_shipping_zones', 'shipping_zones_shortcode', 10 );
  74. /*-----------------------------------------------------
  75.  *              Custom Excerpt Length
  76.  *----------------------------------------------------*/
  77. if(!function_exists('calypso_excerpt_max_charlength')):
  78.     function calypso_excerpt_max_charlength($charlength) {
  79.         $excerpt = get_the_excerpt();
  80.         $charlength++;
  81.  
  82.         if ( mb_strlen( $excerpt ) > $charlength ) {
  83.             $subex = mb_substr( $excerpt, 0, $charlength - 5 );
  84.             $exwords = explode( ' ', $subex );
  85.             $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
  86.             if ( $excut < 0 ) {
  87.                 return mb_substr( $subex, 0, $excut );
  88.             } else {
  89.                 return $subex;
  90.             }
  91.         } else {
  92.             return $excerpt;
  93.         }
  94.     }
  95. endif;
  96.  
  97. /*-------------------------------------------
  98.  *              Custom Excerpt Length
  99.  *-------------------------------------------*/
  100. if(!function_exists('crowdfunding_excerpt_max_charlength')):
  101.     function crowdfunding_excerpt_max_charlength($str,$charlength) {
  102.         $excerpt = $str;
  103.         $charlength++;
  104.         if ( mb_strlen( $excerpt ) > $charlength ) {
  105.             $subex = mb_substr( $excerpt, 0, $charlength - 5 );
  106.             $exwords = explode( ' ', $subex );
  107.             $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
  108.             if ( $excut < 0 ) {
  109.                 return mb_substr( $subex, 0, $excut );
  110.             } else {
  111.                 return $subex;
  112.             }
  113.         } else {
  114.             return $excerpt;
  115.         }
  116.     }
  117. endif;
  118.  
  119.  
  120.  
  121. /* -------------------------------------------
  122.  *              Custom body class
  123.  * ------------------------------------------- */
  124. add_filter( 'body_class', 'calypso_body_class' );
  125. function calypso_body_class( $classes ) {
  126.     $layout = get_theme_mod( 'boxfull_en', 'fullwidth' );
  127.     $classes[] = $layout.'-bg';
  128.     return $classes;
  129. }
  130.  
  131. /* -------------------------------------------
  132.  *              Logout Redirect Home
  133.  * ------------------------------------------- */
  134. add_action( 'wp_logout', 'calypso_auto_redirect_external_after_logout');
  135. function calypso_auto_redirect_external_after_logout(){
  136.   wp_redirect( home_url('/') );
  137.   exit();
  138. }
  139.  
  140.  
  141. /* -------------------------------------------
  142.  *              Remove API
  143.  * ------------------------------------------- */
  144. function calypso_remove_api() {
  145.     remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
  146.     remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
  147. }
  148. add_action( 'after_setup_theme', 'calypso_remove_api' );
  149.  
  150.  
  151. /* -------------------------------------------
  152. *               SVG image upload
  153. * ------------------------------------------- */
  154. function calypso_mime_types( $mimes ){
  155.   $mimes['svg'] = 'image/svg+xml';
  156.   $mimes['svgz'] = 'image/svg+xml';
  157.   return $mimes;
  158. }
  159. add_filter('upload_mimes', 'calypso_mime_types');
  160.  
  161.  
  162.  
  163. /* -------------------------------------------
  164. *        WooCommerce Product Column
  165. * ------------------------------------------- */
  166. add_filter('loop_shop_columns', 'loop_columns');
  167. if (!function_exists('loop_columns')) {
  168.     function loop_columns() {
  169.         return 3; # 3 products per row
  170.    }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement