Advertisement
Guest User

asdada

a guest
Dec 22nd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 38.75 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------------------------------
  3.  
  4.     Here we have all the custom functions for the theme
  5.     Please be extremely cautious editing this file,
  6.     When things go wrong, they tend to go wrong in a big way.
  7.     You have been warned!
  8.  
  9. -------------------------------------------------------------------------------------*/
  10.  
  11. /*-----------------------------------------------------------------------------------*/
  12. /*  Set Max Content Width
  13. /* ----------------------------------------------------------------------------------*/
  14. if ( ! isset( $content_width ) )
  15.     $content_width = 1170;
  16.  
  17. /*-----------------------------------------------------------------------------------*/
  18. /*  Default Theme Constant
  19. /*-----------------------------------------------------------------------------------*/
  20.  
  21. define('AZ_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/framework/');
  22. define('AZ_THEME_NAME', 'ibuki');
  23. $options_ibuki = get_option('ibuki');
  24.  
  25.  
  26. /*-----------------------------------------------------------------------------------*/
  27. /*  No Header/Footer Global
  28. /*-----------------------------------------------------------------------------------*/
  29.  
  30. $az_options_show_header = true;
  31. $az_options_show_footer = true;
  32.  
  33. /*-----------------------------------------------------------------------------------*/
  34. /*  Enqueue Admin Style
  35. /*-----------------------------------------------------------------------------------*/
  36.  
  37. function az_admin_scripts() {
  38.     wp_enqueue_style( 'az-admin', get_template_directory_uri() . '/_include/css/admin-style.css' );
  39.     wp_register_script('select2', get_template_directory_uri() . '/_include/js/select2.js', 'jquery', '1.0.0', TRUE);
  40.     wp_enqueue_script('select2');
  41. }
  42. add_action( 'admin_enqueue_scripts', 'az_admin_scripts' );
  43.  
  44. /*-----------------------------------------------------------------------------------*/
  45. /*  Theme Setup
  46. /*-----------------------------------------------------------------------------------*/
  47.  
  48. if ( !function_exists( 'az_theme_setup' ) ) {
  49.     function az_theme_setup(){
  50.         // Load Translation Domain
  51.         load_theme_textdomain(AZ_THEME_NAME, get_template_directory() . '/languages');
  52.  
  53.         // Register Menus
  54.         register_nav_menus(array('primary_menu' => __('Primary Menu', AZ_THEME_NAME) ));
  55.         register_nav_menus(array('one_page_menu' => __('One Page Menu', AZ_THEME_NAME) ));
  56.  
  57.         // Add RSS Feed links to HTML
  58.         add_theme_support('automatic-feed-links');
  59.  
  60.         // Add Support for Post Formats
  61.         add_theme_support('post-formats', array('quote','video','audio', 'image', 'gallery','link'));
  62.  
  63.         // Configure Thumbnails
  64.         add_theme_support('post-thumbnails');
  65.  
  66.         add_image_size('latest-blog-thumb', 578, 384, true); // Blog Latest Posts Thumb Only
  67.         add_image_size('latest-masonry-blog-thumb', 578 ); // Blog Latest Posts Masonry Thumb Only
  68.  
  69.         add_image_size('listed-blog-thumb', 578, 384, true); // Blog Listed Thumb Only
  70.         add_image_size('center-blog-thumb', 1000, 500, true); // Blog Center Thumb Only
  71.         add_image_size('masonry-blog-thumb', 578 ); // Portfolio Thumb Masonry Only
  72.         add_image_size('standard-blog-thumb', 800, 390, true ); // Portfolio Thumb Grid Only
  73.  
  74.         add_image_size('team-thumb', 478, 384, true); // Team Thumb Only
  75.  
  76.         add_image_size('portfolio-thumb', 578, 384, true); // Portfolio Thumb Grid Only
  77.         add_image_size('portfolio-masonry-thumb', 578 ); // Portfolio Thumb Grid Only
  78.         add_image_size('portfolio-wall-thumb', 578, 384, true); // Portfolio Thumb Wall Only
  79.  
  80.         add_image_size('gallery-thumb', 500, 500, true); // Gallery Thumb Grid Only
  81.         add_image_size('gallery-masonry-thumb', 500 ); // Gallery Thumb Masonry Only
  82.         add_image_size('gallery-wall-thumb', 500, 500, true); // Gallery Wall Thumb Grid Only
  83.  
  84.         add_image_size('masonry-block-normal-size', 500, 500, true); // Masonry Block Normal Size Only
  85.         add_image_size('masonry-block-wide-size', 1000, 500, true); // Masonry Block Wide Size Only
  86.         add_image_size('masonry-block-tall-size', 500, 1000, true); // Masonry Block Tall Size Only
  87.         add_image_size('masonry-block-big-size', 1000, 1000, true); // Masonry Block Big Size Only
  88.     }
  89. }
  90. add_action('after_setup_theme', 'az_theme_setup');
  91.  
  92. /*-----------------------------------------------------------------------------------*/
  93. /*  Custom Login Logo
  94. /*-----------------------------------------------------------------------------------*/
  95.  
  96. if ( !function_exists( 'az_custom_login_logo' ) ) {
  97.     function az_custom_login_logo() {
  98.         echo '<style type="text/css">
  99.             h1 a { background-image:url('.get_template_directory_uri().'/_include/img/logo-admin.png) !important; height: 98px !important; width: auto !important; background-size: auto auto !important; }
  100.         </style>';
  101.     }
  102. }
  103. add_action('login_enqueue_scripts', 'az_custom_login_logo');
  104.  
  105. if ( !function_exists( 'az_wp_login_url' ) ) {
  106.     function az_wp_login_url() {
  107.         return home_url();
  108.     }
  109. }
  110. add_filter('login_headerurl', 'az_wp_login_url');
  111.  
  112. if ( !function_exists( 'az_wp_login_title' ) ) {
  113.     function az_wp_login_title() {
  114.         return get_option('blogname');
  115.     }
  116. }
  117. add_filter('login_headertitle', 'az_wp_login_title');
  118.  
  119. /*-----------------------------------------------------------------------------------*/
  120. /*  Register / Enqueue Google Fonts or Custom Fonts
  121. /*-----------------------------------------------------------------------------------*/
  122.  
  123. if ( !function_exists( 'ibuki_google_fonts' ) ) {
  124.     function ibuki_google_fonts() {
  125.         $protocol = is_ssl() ? 'https' : 'http';
  126.         wp_enqueue_style( 'ibuki-font', "$protocol://fonts.googleapis.com/css?family=Lato:400,300italic,300,100italic,100,400italic,700,700italic,900italic,900|Montserrat:400,700" );
  127.     }
  128. }
  129. add_action( 'wp_enqueue_scripts', 'ibuki_google_fonts' );
  130.  
  131. if ( !function_exists( 'az_enqueue_custom_fonts_css' ) ) {
  132.     function az_enqueue_custom_fonts_css() {
  133.         wp_register_style('custom-fonts', get_template_directory_uri() . '/_include/css/custom-fonts.css.php');
  134.         wp_enqueue_style('custom-fonts');
  135.     }
  136. }
  137.  
  138. if( !empty($options_ibuki['enable-custom-fonts']) && $options_ibuki['enable-custom-fonts'] == 1 ) {
  139.     // Enqueue Custom Fonts CSS
  140.     add_action('wp_enqueue_scripts', 'az_enqueue_custom_fonts_css', 100);
  141. }
  142.  
  143. /*-----------------------------------------------------------------------------------*/
  144. /*  Register / Enqueue JS
  145. /*-----------------------------------------------------------------------------------*/
  146.  
  147. if ( !function_exists( 'az_register_js' ) ) {
  148.     function az_register_js() {
  149.        
  150.         if (!is_admin()) {
  151.            
  152.             // Register
  153.             wp_register_script('modernizer', get_template_directory_uri() . '/_include/js/modernizr.js', 'jquery', '2.7.1');
  154.             wp_register_script('plugins', get_template_directory_uri() . '/_include/js/plugins.js', 'jquery', '1.0.0', TRUE);
  155.             wp_register_script('isotope-js', get_template_directory_uri() . '/_include/js/isotope.js', 'jquery', '1.0.0', TRUE);
  156.             wp_register_script('main', get_template_directory_uri() . '/_include/js/main.js', 'jquery', '1.0.0', TRUE);
  157.            
  158.             // Enqueue
  159.             wp_enqueue_script('jquery');
  160.             wp_enqueue_script('modernizer');
  161.             wp_enqueue_script('isotope-js');
  162.             wp_enqueue_script('plugins');
  163.             wp_enqueue_script('main');
  164.         }
  165.     }
  166. }
  167. add_action('wp_enqueue_scripts', 'az_register_js');
  168.  
  169. if ( !function_exists( 'az_page_specific_js' ) ) {
  170.     function az_page_specific_js() {
  171.         // Loads the javascript required for threaded comments
  172.         if( is_singular() && comments_open() && get_option( 'thread_comments') )
  173.             wp_enqueue_script( 'comment-reply' );
  174.     }
  175. }
  176. add_action('wp_enqueue_scripts', 'az_page_specific_js');
  177.  
  178. /*-----------------------------------------------------------------------------------*/
  179. /*  Register / Enqueue CSS
  180. /*-----------------------------------------------------------------------------------*/
  181.  
  182. //Main Styles
  183. if ( !function_exists( 'az_main_styles' ) ) {
  184.     function az_main_styles() {      
  185.         // Register
  186.         wp_register_style('bootstrap', get_template_directory_uri() . '/_include/css/bootstrap.min.css');
  187.         wp_register_style('main-styles', get_stylesheet_directory_uri() . '/style.css');
  188.              
  189.         // Enqueue
  190.         wp_enqueue_style('bootstrap');
  191.         wp_enqueue_style('main-styles');
  192.     }
  193. }
  194. add_action('wp_enqueue_scripts', 'az_main_styles');
  195.  
  196. //Gravity Forms
  197. if(class_exists('GFForms') )
  198. {
  199.     add_action('wp_enqueue_scripts', 'az_add_gravity_scripts');
  200. }
  201. function az_add_gravity_scripts()
  202. {
  203.     wp_register_style( 'az-gravity' , get_template_directory_uri(). '/_include/css/gravity-mod.css' , array('gforms_formsmain_css'), '');
  204.     wp_enqueue_style( 'az-gravity');
  205. }
  206.  
  207. /*-----------------------------------------------------------------------------------*/
  208. /*  Dynamic Styles
  209. /*-----------------------------------------------------------------------------------*/
  210.  
  211. if ( !function_exists( 'az_enqueue_dynamic_css_color' ) ) {
  212.     function az_enqueue_dynamic_css_color() {
  213.         wp_register_style('dynamic-colors', get_template_directory_uri() . '/_include/css/color.css.php', 'style');
  214.         wp_enqueue_style('dynamic-colors');
  215.     }
  216. }
  217.  
  218. if ( !function_exists( 'az_enqueue_dynamic_css_custom' ) ) {
  219.     function az_enqueue_dynamic_css_custom() {
  220.         wp_register_style('custom', get_template_directory_uri() . '/_include/css/custom.css.php', 'style');
  221.         wp_enqueue_style('custom');
  222.     }
  223. }
  224.  
  225. if( !empty($options_ibuki['enable-custom-color']) && $options_ibuki['enable-custom-color'] == 1 ) {
  226.     // Enqueue Custom Colors CSS
  227.     add_action('wp_enqueue_scripts', 'az_enqueue_dynamic_css_color');
  228. }
  229.  
  230. if( !empty($options_ibuki['enable-custom-css']) && $options_ibuki['enable-custom-css'] == 1 ) {
  231.     // Enqueue Custom CSS
  232.     add_action('wp_enqueue_scripts', 'az_enqueue_dynamic_css_custom');
  233. }
  234.  
  235.  
  236. /*-----------------------------------------------------------------------------------*/
  237. /*  Widget Area
  238. /*-----------------------------------------------------------------------------------*/
  239.  
  240. if(function_exists('register_sidebar')) {
  241.    
  242.     register_sidebar(array(
  243.         'name' => __('Blog Sidebar', AZ_THEME_NAME),
  244.         'description' => __('Widget area for blog pages.', AZ_THEME_NAME),
  245.         'id' => 'sidebar-blog',
  246.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  247.         'after_widget'  => '</div>',
  248.         'before_title'  =>
  249.         '<h3 class="widget-title">',
  250.         'after_title'   => '</h3>'
  251.         )
  252.     );
  253.    
  254.     register_sidebar(array(
  255.         'name' => __('Page Sidebar', AZ_THEME_NAME),
  256.         'description' => __('Widget area for pages.', AZ_THEME_NAME),
  257.         'id' => 'sidebar-page',
  258.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  259.         'after_widget'  => '</div>',
  260.         'before_title'  => '<h3 class="widget-title">',
  261.         'after_title'   => '</h3>'
  262.         )
  263.     );
  264.  
  265.     register_sidebar(array(
  266.         'name' => __('WooCommerce Sidebar', AZ_THEME_NAME),
  267.         'description' => __('Widget area for pages.', AZ_THEME_NAME),
  268.         'id' => 'sidebar-woocommerce',
  269.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  270.         'after_widget'  => '</div>',
  271.         'before_title'  => '<h3 class="widget-title">',
  272.         'after_title'   => '</h3>'
  273.         )
  274.     );
  275.    
  276.     register_sidebar(array(
  277.         'name' => __('Footer Area 1', AZ_THEME_NAME),
  278.         'description' => __('Widget area for footer area.', AZ_THEME_NAME),
  279.         'id' => 'footer-area-one',
  280.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  281.         'after_widget'  => '</div>',
  282.         'before_title'  => '<h3>',
  283.         'after_title'   => '</h3>'
  284.         )
  285.     );
  286.    
  287.     register_sidebar(array(
  288.         'name' => __('Footer Area 2', AZ_THEME_NAME),
  289.         'description' => __('Widget area for footer area.', AZ_THEME_NAME),
  290.         'id' => 'footer-area-two',  
  291.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  292.         'after_widget'  => '</div>',
  293.         'before_title'  => '<h3>',
  294.         'after_title'   => '</h3>'
  295.         )
  296.     );
  297.    
  298.     register_sidebar(array(
  299.         'name' => __('Footer Area 3', AZ_THEME_NAME),
  300.         'description' => __('Widget area for footer area.', AZ_THEME_NAME),
  301.         'id' => 'footer-area-three',  
  302.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  303.         'after_widget'  => '</div>',
  304.         'before_title'  => '<h3>',
  305.         'after_title'   => '</h3>'
  306.         )
  307.     );
  308.  
  309.     register_sidebar(array(
  310.         'name' => __('Footer Area 4', AZ_THEME_NAME),
  311.         'description' => __('Widget area for footer area.', AZ_THEME_NAME),
  312.         'id' => 'footer-area-four',  
  313.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  314.         'after_widget'  => '</div>',
  315.         'before_title'  => '<h3>',
  316.         'after_title'   => '</h3>'
  317.         )
  318.     );
  319. }
  320.  
  321. /*------------------------------------------------------------------------------*/
  322. /*  Widgets: Twitter - Flickr - Dribbble - Social Icons
  323. /*------------------------------------------------------------------------------*/
  324.  
  325. include('framework/widgets/flickr-widget.php');
  326. include('framework/widgets/twitter-widget.php');
  327. include('framework/widgets/dribbble-widget.php');
  328. include('framework/widgets/social-widget.php');
  329.  
  330. /*-----------------------------------------------------------------------------------*/
  331. /*  Common Fix
  332. /*-----------------------------------------------------------------------------------*/
  333.  
  334. // Twitter Filter
  335. function TwitterFilter($string)
  336. {
  337. $content_array = explode(" ", $string);
  338. $output = '';
  339.  
  340. foreach($content_array as $content)
  341. {
  342. //starts with http://
  343. if(substr($content, 0, 7) == "http://")
  344. $content = '<a href="' . $content . '">' . $content . '</a>';
  345.  
  346. //starts with www.
  347. if(substr($content, 0, 4) == "www.")
  348. $content = '<a href="http://' . $content . '">' . $content . '</a>';
  349.  
  350. if(substr($content, 0, 8) == "https://")
  351. $content = '<a href="' . $content . '">' . $content . '</a>';
  352.  
  353. if(substr($content, 0, 1) == "#")
  354. $content = '<a href="https://twitter.com/search?src=hash&q=' . $content . '">' . $content . '</a>';
  355.  
  356. if(substr($content, 0, 1) == "@")
  357. $content = '<a href="https://twitter.com/' . $content . '">' . $content . '</a>';
  358.  
  359. $output .= " " . $content;
  360. }
  361.  
  362. $output = trim($output);
  363. return $output;
  364. }
  365.  
  366. function attr($s,$attrname) { // return html attribute
  367.     preg_match_all('#\s*('.$attrname.')\s*=\s*["|\']([^"\']*)["|\']\s*#i', $s, $x);
  368.     if (count($x)>=3) return $x[2][0]; else return "";
  369. }
  370.  
  371. /*-----------------------------------------------------------------------------------*/
  372. /* Exclude Pages from search
  373. /*-----------------------------------------------------------------------------------*/
  374.  
  375. if( !function_exists( 'az_exclude_pages_in_search' ) ) {
  376.     function az_exclude_pages_in_search($query) {
  377.         if( !$query->is_admin && $query->is_search ) {
  378.             $query->set('post_type', 'post');
  379.         }
  380.     return $query;
  381.     }
  382. }
  383. //add_filter('pre_get_posts','az_exclude_pages_in_search');
  384.  
  385. /*-----------------------------------------------------------------------------------*/
  386. /*  Excerpt Length
  387. /*-----------------------------------------------------------------------------------*/
  388.  
  389. if ( ! function_exists( 'az_excerptlength_post' ) ) {
  390.     function az_excerptlength_post($length) {
  391.         return 15;
  392.     }
  393. }
  394.  
  395. if ( ! function_exists( 'az_excerptmore' ) ) {
  396.     function az_excerptmore($more) {
  397.         return ' ...';
  398.     }
  399. }
  400.  
  401. if ( ! function_exists( 'az_excerpt' ) ) { 
  402.     function az_excerpt( $length_callback = '', $more_callback = 'az_excerptmore' ) {
  403.  
  404.         global $post;
  405.        
  406.         if ( function_exists( $length_callback ) ) {
  407.             add_filter( 'excerpt_length', $length_callback );
  408.         }
  409.        
  410.         if ( function_exists( $more_callback ) ){
  411.             add_filter( 'excerpt_more', $more_callback );
  412.         }
  413.        
  414.         $output = get_the_excerpt();
  415.         $output = apply_filters( 'wptexturize', $output );
  416.         $output = apply_filters( 'convert_chars', $output );
  417.         $output = $output;
  418.        
  419.         return $output;
  420.     }  
  421. }
  422.  
  423. /*-----------------------------------------------------------------------------------*/
  424. /*  Meta Config
  425. /*-----------------------------------------------------------------------------------*/
  426.  
  427. function enqueue_media(){
  428.    
  429.     //enqueue the correct media scripts for the media library
  430.     $wp_version = floatval(get_bloginfo('version'));
  431.    
  432.     if ( $wp_version < "3.5" ) {
  433.         wp_enqueue_script(
  434.             'redux-opts-field-upload-js',
  435.             AZ_FRAMEWORK_DIRECTORY . 'assets/upload/field_upload_3_4.js',
  436.             array('jquery', 'thickbox', 'media-upload'),
  437.             time(),
  438.             true
  439.         );
  440.         wp_enqueue_style('thickbox');// thanks to https://github.com/rzepak
  441.     } else {
  442.         wp_enqueue_script(
  443.             'redux-opts-field-upload-js',
  444.             AZ_FRAMEWORK_DIRECTORY . 'assets/upload/field_upload.js',
  445.             array('jquery'),
  446.             time(),
  447.             true
  448.         );
  449.         wp_enqueue_script(
  450.             'redux-field-gallery-js',
  451.             AZ_FRAMEWORK_DIRECTORY . 'assets/gallery/field_gallery.js',
  452.             array('jquery'),
  453.             time(),
  454.             true
  455.         );
  456.  
  457.         wp_enqueue_style( 'wp-color-picker' );
  458.        
  459.         wp_enqueue_script(
  460.             'redux-field-color-js',
  461.             AZ_FRAMEWORK_DIRECTORY . 'assets/color/field_color.js',
  462.             array( 'jquery', 'wp-color-picker' ),
  463.             time(),
  464.             true
  465.         );
  466.         wp_enqueue_style(
  467.             'redux-field-color-css',
  468.             AZ_FRAMEWORK_DIRECTORY . 'assets/color/field_color.css',
  469.             time(),
  470.             true
  471.         );
  472.         wp_enqueue_media();
  473.     }
  474.    
  475. }
  476.  
  477. //Meta Styling
  478. function  az_metabox_styles() {
  479.     wp_enqueue_style('az_meta_css', AZ_FRAMEWORK_DIRECTORY .'assets/css/az_meta.css');
  480. }
  481.  
  482. //Meta Scripts
  483. function az_metabox_scripts() {
  484.     wp_register_script('az-upload', AZ_FRAMEWORK_DIRECTORY .'assets/js/az-meta.js', array('jquery','media-upload','thickbox'));
  485.     wp_enqueue_script('az-upload');
  486.     wp_localize_script('redux-opts-field-upload-js', 'redux_upload', array('url' => AZ_FRAMEWORK_DIRECTORY .'assets/upload/blank.png'));
  487. }
  488. add_action('admin_enqueue_scripts', 'az_metabox_scripts');
  489. add_action('admin_enqueue_scripts', 'az_metabox_styles');
  490. add_action('admin_enqueue_scripts', 'enqueue_media');
  491.  
  492. //Meta Core functions
  493. include("framework/meta/meta-config.php");
  494.  
  495. // Page Header Meta
  496. include("framework/meta/page-meta.php");
  497.  
  498. // Team Meta
  499. include("framework/meta/team-meta.php");
  500.  
  501. // Portfolio Meta
  502. include("framework/meta/portfolio-meta.php");
  503.  
  504. // Post Meta
  505. include("framework/meta/post-meta.php");
  506.  
  507. // Footer Meta
  508. include("framework/meta/footer-meta.php");
  509.  
  510. // Preloader Meta
  511. if( !empty($options_ibuki['enable-preloader']) && $options_ibuki['enable-preloader'] == 1) {
  512.     $preloader = (!empty($options_ibuki['preloader-selection'])) ? $options_ibuki['preloader-selection'] : '2';
  513.     if($preloader == '2'){
  514.         include("framework/meta/preloader-meta.php");
  515.     }
  516. }
  517.  
  518. // Transparent Header
  519. if( !empty($options_ibuki['use-transparent-header']) && $options_ibuki['use-transparent-header'] == 1) {
  520.     include("framework/meta/transparent-header-meta.php");
  521. }
  522.  
  523. /*-----------------------------------------------------------------------------------*/
  524. /*  Custom Output Page Title / Custom Output Caption Title
  525. /*-----------------------------------------------------------------------------------*/
  526.  
  527. if( !function_exists( 'az_custom_get_page_title' ) ) {
  528.     function az_custom_get_page_title() {
  529.         $page_title = '';
  530.         if( is_archive() ) {
  531.                 if( is_category() ) {
  532.                     $page_title = sprintf( __( 'All Posts in <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), single_cat_title('', false) );
  533.                 } elseif( is_tag() ) {
  534.                     $page_title = sprintf( __( 'All Posts in <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), single_tag_title('', false) );
  535.                 } elseif( is_date() ) {
  536.                     if( is_month() ) {
  537.                         $page_title = sprintf( __( 'Archive for <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), get_the_time( 'F, Y' ) );
  538.                     } elseif( is_year() ) {
  539.                         $page_title = sprintf( __( 'Archive for <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), get_the_time( 'Y' ) );
  540.                     } elseif( is_day() ) {
  541.                         $page_title = sprintf( __('Archive for <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), get_the_time( get_option('date_format') ) );
  542.                     } else {
  543.                         $page_title = __('Blog Archives<span class="color-text">.</span>', AZ_THEME_NAME);
  544.                     }
  545.                 } elseif( is_author() ) {
  546.                     if(get_query_var('author_name')) {
  547.                         $curauth = get_user_by( 'login', get_query_var('author_name') );
  548.                     } else {
  549.                         $curauth = get_userdata(get_query_var('author'));
  550.                     }
  551.                     $page_title = __('All Posts By <span class="color-text">&#8220;</span>'.$curauth->display_name.'<span class="color-text">&#8221;</span>', AZ_THEME_NAME);
  552.                 }
  553.             }
  554.         elseif( is_search() ) {
  555.             $page_title = sprintf( __( 'Search Results for <span class="color-text">&#8220;</span>%s<span class="color-text">&#8221;</span>', AZ_THEME_NAME ), get_search_query() );
  556.         }
  557.  
  558.         return $page_title;
  559.     }
  560. }
  561.  
  562. if( !function_exists( 'az_custom_get_caption' ) ) {
  563.     function az_custom_get_caption() {
  564.         $page_caption = '';
  565.         if( is_archive() ) {
  566.                 if( is_category() ) {
  567.                     $page_caption = sprintf( __( 'Category', AZ_THEME_NAME ) );
  568.                 } elseif( is_tag() ) {
  569.                     $page_caption = sprintf( __( 'Tag', AZ_THEME_NAME ) );
  570.                 } elseif( is_date() ) {
  571.                     if( is_month() ) {
  572.                         $page_caption = sprintf( __( 'Month', AZ_THEME_NAME ) );
  573.                     } elseif( is_year() ) {
  574.                         $page_caption = sprintf( __( 'Year', AZ_THEME_NAME ) );
  575.                     } elseif( is_day() ) {
  576.                         $page_caption = sprintf( __('Day', AZ_THEME_NAME ) );
  577.                     } else {
  578.                         $page_caption = __('Archives', AZ_THEME_NAME);
  579.                     }
  580.                 } elseif( is_author() ) {
  581.                     $page_caption = __('Author', AZ_THEME_NAME);
  582.                 }
  583.             }
  584.         elseif( is_search() ) {
  585.             $page_caption = sprintf( __( 'Search', AZ_THEME_NAME ) );
  586.         }
  587.  
  588.         return $page_caption;
  589.     }
  590. }
  591.  
  592. /*-----------------------------------------------------------------------------------*/
  593. /*  Portfolio Exclude External Projects / Lightbox From Next/Prev
  594. /*-----------------------------------------------------------------------------------*/
  595.  
  596. $excluded_projects = array();
  597. $exlcuded_projects_string = '';
  598.                                
  599. $portfolio = array( 'post_type' => 'portfolio' );
  600. $the_query = new WP_Query($portfolio);
  601.  
  602. if ( $the_query->have_posts() ) {
  603.     while ( $the_query->have_posts() ) {
  604.         $the_query->the_post();
  605.        
  606.         $custom_project_type = get_post_meta($post->ID, '_az_project_type', true);
  607.         if( $custom_project_type == "output-mode" || $custom_project_type == "fancybox-mode" ) $excluded_projects[] = $post->ID;
  608.     }
  609.  
  610.    
  611.     $exlcuded_projects_string = implode(",", $excluded_projects);
  612.    
  613.     if(!empty($exlcuded_projects_string)){
  614.         add_filter( 'get_previous_post_where', 'az_exclude_project_adj' );
  615.         add_filter( 'get_next_post_where', 'az_exclude_project_adj' );
  616.     }
  617. }
  618.  
  619. wp_reset_postdata();
  620.  
  621. function az_exclude_project_adj( $where ) {
  622.     global $wpdb;
  623.     global $exlcuded_projects_string;
  624.     return $where . " AND p.ID NOT IN ($exlcuded_projects_string)";
  625. }
  626.  
  627. /*-----------------------------------------------------------------------------------*/
  628. /*  Active Class for Portfolio
  629. /*-----------------------------------------------------------------------------------*/
  630.  
  631. if ( !function_exists( 'az_additional_active_item_classes' ) ) {
  632.     function az_additional_active_item_classes($classes = array(), $menu_item = false){
  633.         global $wp_query;
  634.  
  635.         if(in_array('current-menu-item', $menu_item->classes)){
  636.             $classes[] = 'current-menu-item';
  637.         }
  638.         if ( $menu_item->post_name == 'portfolio' && is_post_type_archive('portfolio') ) {
  639.             $classes[] = 'current-menu-item';
  640.         }
  641.         if ( $menu_item->post_name == 'portfolio' && is_singular('portfolio') ) {
  642.             $classes[] = 'current-menu-item';
  643.         }
  644.         return $classes;
  645.     }
  646. }
  647. add_filter( 'nav_menu_css_class', 'az_additional_active_item_classes', 10, 2 );
  648.  
  649. /*-----------------------------------------------------------------------------------*/
  650. /*  Navigation
  651. /*-----------------------------------------------------------------------------------*/
  652.  
  653. // Simple Navigation Blog
  654. if ( !function_exists( 'az_pagination' ) ) {
  655.    
  656.     function az_pagination() { 
  657.         global $options_ibuki;
  658.        
  659.         if( get_next_posts_link() || get_previous_posts_link() ) {
  660.             echo '
  661.                 <!-- Navigation Area -->
  662.                 <section class="post-type-navi">
  663.                     <nav class="blog-navigation">
  664.                         <div class="prev-blog">'.get_previous_posts_link( __('Older Entries<i class="prev-icon"></i>', AZ_THEME_NAME) ).'</div>
  665.                         <div class="next-blog">'.get_next_posts_link( __('New Entries<i class="next-icon"></i>', AZ_THEME_NAME) ).'</div>
  666.                     </nav>
  667.                 </section>
  668.                 <!-- End Navigation Area -->';
  669.         }
  670.     }
  671. }
  672.  
  673. /*-----------------------------------------------------------------------------------*/
  674. /*  Comment Styling
  675. /*-----------------------------------------------------------------------------------*/
  676.  
  677. if ( !function_exists( 'az_comment' ) ) {
  678.    
  679.     function az_comment($comment, $args, $depth) {
  680.    
  681.         $isByAuthor = false;
  682.  
  683.         if($comment->comment_author_email == get_the_author_meta('email')) {
  684.             $isByAuthor = true;
  685.         }
  686.  
  687.         $GLOBALS['comment'] = $comment; ?>
  688.         <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  689.             <div id="comment-<?php comment_ID(); ?>" class="comment-section">              
  690.                 <div class="comment-side">
  691.                     <?php echo get_avatar($comment,$size='50'); ?>
  692.                 </div>
  693.              
  694.                 <div class="comment-cont">
  695.                     <div class="comment-author">
  696.                         <cite class="fn"><?php comment_author_link(); ?></cite>
  697.                     </div>
  698.                    
  699.                     <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf( __('%1$s at %2$s', AZ_THEME_NAME), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link(__('Edit', AZ_THEME_NAME), ' / ','') ?> / <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></div>
  700.                    
  701.                     <?php if ( $comment -> comment_approved == '0') : ?>
  702.                         <em class="moderation"><?php _e('Your comment is awaiting moderation.', AZ_THEME_NAME) ?></em><br />
  703.                     <?php endif; ?>
  704.                    
  705.                     <div class="comment-body">
  706.                         <?php comment_text() ?>
  707.                     </div>
  708.                 </div>
  709.             </div>
  710.     <?php
  711.     }
  712. }
  713.  
  714. /*-----------------------------------------------------------------------------------*/
  715. /*  Seperated Pings Styling
  716. /*-----------------------------------------------------------------------------------*/
  717.  
  718. if ( !function_exists( 'az_comment_list_pings' ) ) {
  719.     function az_comment_list_pings($comment, $args, $depth) {
  720.         $GLOBALS['comment'] = $comment; ?>
  721.         <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?>
  722.         <?php
  723.     }
  724. }
  725.  
  726. /*-----------------------------------------------------------------------------------*/
  727. /*  Remove the page jump when clicking read more button
  728. /*-----------------------------------------------------------------------------------*/
  729.  
  730. function az_remove_more_jump_link($link) {
  731.     $offset = strpos($link, '#more-');
  732.     if ($offset) {
  733.         $end = strpos($link, '"',$offset);
  734.     }
  735.     if ($end) {
  736.         $link = substr_replace($link, '', $offset, $end-$offset);
  737.     }
  738.     return $link;
  739. }
  740. add_filter('the_content_more_link', 'az_remove_more_jump_link');
  741.  
  742. /*-----------------------------------------------------------------------------------*/
  743. /*  Social Profiles
  744. /*-----------------------------------------------------------------------------------*/
  745.  
  746. $socials_profiles = array ('500px', 'addthis', 'behance', 'bebo', 'blogger', 'deviant-art', 'digg', 'dribbble', 'email', 'envato', 'evernote', 'facebook', 'flickr', 'forrst', 'github', 'google-plus', 'grooveshark', 'instagram', 'last-fm', 'linkedin', 'myspace', 'paypal', 'photobucket', 'pinterest', 'quora', 'share-this', 'skype', 'soundcloud', 'stumbleupon', 'tumblr', 'twitter', 'viddler', 'vimeo', 'virb', 'wordpress', 'yahoo', 'yelp', 'youtube', 'zerply');
  747.  
  748. /*-----------------------------------------------------------------------------------*/
  749. /*  Extend Body Class
  750. /*-----------------------------------------------------------------------------------*/
  751.  
  752. /**
  753.  * Add browser detection and post name to body class
  754.  * Add post title to body class on single pages
  755.  *
  756.  * @link http://www.wprecipes.com/wordpress-hack-automatically-add-post-name-to-the-body-class
  757.  * @param array $classes The current body classes
  758.  * @return array The new body classes
  759.  */
  760. if ( !function_exists( 'az_body_classes' ) ) {
  761.     function az_body_classes($classes) {
  762.         if(!isset($_SERVER['HTTP_USER_AGENT'])) return false;
  763.        
  764.         // Add our browser class
  765.         global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome;
  766.    
  767.         if($is_lynx) $classes[] = 'lynx';
  768.         elseif($is_gecko) $classes[] = 'gecko';
  769.         elseif($is_opera) $classes[] = 'opera';
  770.         elseif($is_NS4) $classes[] = 'ns4';
  771.         elseif($is_safari) $classes[] = 'safari';
  772.         elseif($is_chrome) $classes[] = 'chrome';
  773.         elseif($is_IE){
  774.             $classes[] = 'ie';
  775.             if(preg_match('/MSIE ([0-9]+)([a-zA-Z0-9.]+)/', $_SERVER['HTTP_USER_AGENT'], $browser_version)) $classes[] = 'ie'.$browser_version[1];
  776.         } else $classes[] = 'unknown';
  777.  
  778.         if( strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') ) {
  779.             $classes[] = 'iphone';
  780.         }
  781.         else if ( strstr($_SERVER['HTTP_USER_AGENT'],'iPad') ) {
  782.             $classes[] = 'ipad';
  783.         }
  784.        
  785.         if ( stristr( $_SERVER['HTTP_USER_AGENT'],"mac") ) {
  786.              $classes[] = 'osx';
  787.         } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"linux") ) {
  788.              $classes[] = 'linux';
  789.         } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"windows") ) {
  790.              $classes[] = 'windows';
  791.         }
  792.         return $classes;
  793.  
  794.         // Add the post title
  795.         if( is_singular() ) {
  796.             global $post;
  797.             array_push( $classes, "{$post->post_type}-{$post->post_name}" );
  798.         }
  799.        
  800.         // Add 'az'
  801.         array_push( $classes, "az" );
  802.        
  803.         return $classes;
  804.  
  805.     }
  806. }
  807. add_filter('body_class','az_body_classes');
  808.  
  809. /*-----------------------------------------------------------------------------------*/
  810. /*  Open Graph
  811. /*-----------------------------------------------------------------------------------*/
  812.  
  813. if ( !function_exists( 'az_add_opengraph' ) ) {
  814.     function az_add_opengraph() {
  815.         global $post;
  816.  
  817.         echo "<meta property='og:site_name' content='". get_bloginfo('name') ."'/>\n";
  818.         echo "<meta property='og:url' content='" . get_permalink() . "'/>\n";
  819.  
  820.         if (is_singular()) { // If we are on a blog post/page
  821.             echo "<meta property='og:title' content='" . get_the_title() . "'/>\n";
  822.             echo "<meta property='og:type' content='article'/>\n";
  823.             if(has_post_thumbnail( $post->ID )) {
  824.                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
  825.                 echo "<meta property='og:image' content='" . esc_attr( $thumbnail[0] ) . "'/>\n";
  826.             }
  827.         } elseif(is_front_page() or is_home()) {
  828.             echo "<meta property='og:title' content='" . get_bloginfo("name") . "'/>\n";
  829.             echo "<meta property='og:type' content='website'/>\n";
  830.             if(has_post_thumbnail( $post->ID )) {
  831.                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
  832.                 echo "<meta property='og:image' content='" . esc_attr( $thumbnail[0] ) . "'/>\n";
  833.             }
  834.         }
  835.  
  836.     }
  837. }
  838. add_action( 'wp_head', 'az_add_opengraph', 2 );
  839.  
  840. /*-----------------------------------------------------------------------------------*/
  841. /*  Enable SVG on Wordpress Media
  842. /* ----------------------------------------------------------------------------------*/
  843.  
  844. // If you want you can use this function for enabled the SVG file for Media Uploader
  845.  
  846. function cc_mime_types( $mimes ){
  847.     $mimes['svg'] = 'image/svg+xml';
  848.     return $mimes;
  849. }
  850. add_filter( 'upload_mimes', 'cc_mime_types' );
  851.  
  852. /*-----------------------------------------------------------------------------------*/
  853. /*  Maintenace Mode
  854. /* ----------------------------------------------------------------------------------*/
  855.  
  856. // If you want you can use this function for set into Maintenance your Site.
  857. /*
  858. function go_maintenance_mode() {
  859.     if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
  860.         wp_die('Sorry, but we are doing Maintenance on the site, please check back soon.');
  861.     }
  862. }
  863. add_action('get_header', 'go_maintenance_mode');
  864. */
  865.  
  866. /*-----------------------------------------------------------------------------------*/
  867. /*  Include the framework
  868. /*-----------------------------------------------------------------------------------*/
  869.  
  870. $tempdir = get_template_directory();
  871. require_once($tempdir .'/framework/meta/custom-functions-meta.php');
  872. require_once($tempdir .'/framework/options/framework.php');
  873. require_once($tempdir .'/framework/options/az_framework/config.php');
  874.  
  875. /*-----------------------------------------------------------------------------------*/
  876. /*  Extend Visual Composer
  877. /*-----------------------------------------------------------------------------------*/
  878.  
  879. require_once($tempdir .'/vc_extend/extend-vc.php');
  880. require_once($tempdir .'/framework/plugin-activation/init.php');
  881.  
  882. /*-----------------------------------------------------------------------------------*/
  883. /*  Custom Walker
  884. /*-----------------------------------------------------------------------------------*/
  885.  
  886. require_once($tempdir .'/framework/onepage/custom_walker.php');
  887. require_once($tempdir .'/framework/onepage/edit_custom_walker.php');
  888.  
  889. /*-----------------------------------------------------------------------------------*/
  890. /*  WP Automatic Updates
  891. /*-----------------------------------------------------------------------------------*/
  892.  
  893. // Get user envato license as provided in theme panel
  894. $license_key = $options_ibuki['envato-license-key'];
  895.  
  896. // If envato license is defined load the auto update class and pass the license to it
  897. require_once($tempdir .'/framework/wp-automatic-updates/wp-updates-theme.php');
  898. if ( $license_key && $options_ibuki['enable-auto-updates'] == 1 ) {
  899.     new WPUpdatesThemeUpdater_878( 'http://wp-updates.com/api/2/theme', basename( get_template_directory() ), $license_key  );
  900. }
  901.  
  902. /*-----------------------------------------------------------------------------------*/
  903. /*  WooCommerce
  904. /*-----------------------------------------------------------------------------------*/
  905.  
  906. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  907. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
  908.  
  909. add_theme_support( 'woocommerce' );
  910. add_filter( 'woocommerce_enqueue_styles', '__return_false' );
  911.  
  912. // Set Thumbnail Size
  913. global $pagenow;
  914. //if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' )
  915. add_action( 'init', 'az_woocommerce_image_dimensions', 1 );
  916.  
  917. // Define image sizes
  918. function az_woocommerce_image_dimensions() {
  919.     $catalog = array(
  920.         'width' => '292',  
  921.         'height'    => '311',  
  922.         'crop'  => 1
  923.     );
  924.      
  925.     $single = array(
  926.         'width' => '600',  
  927.         'height'    => '630',  
  928.         'crop'  => 1
  929.     );
  930.      
  931.     $thumbnail = array(
  932.         'width' => '100',  
  933.         'height'    => '100',  
  934.         'crop'  => 1
  935.     );
  936.      
  937.    
  938.     update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
  939.     update_option( 'shop_single_image_size', $single ); // Single product image
  940.     update_option( 'shop_thumbnail_image_size', $thumbnail ); // Image gallery thumbs
  941. }
  942.  
  943. //change how many products are displayed per page  
  944. add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
  945.  
  946. //change the position of add to cart
  947. remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
  948.  
  949. remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
  950. add_action('woocommerce_before_shop_loop_item_title', 'product_thumbnail_with_cart', 10 );
  951. function product_thumbnail_with_cart() { ?>
  952.     <div class="product-wrap">
  953.         <?php
  954.         echo  woocommerce_get_product_thumbnail();
  955.         woocommerce_get_template( 'loop/add-to-cart.php' ); ?>
  956.     </div>
  957. <?php
  958. }
  959.  
  960. //add link to item titles
  961. add_action('woocommerce_before_shop_loop_item_title','product_item_title_link_open');
  962. add_action('woocommerce_after_shop_loop_item_title','product_item_title_link_close');
  963. function product_item_title_link_open(){
  964.     echo '<a href="'.get_permalink().'">';
  965. }
  966. function product_item_title_link_close(){
  967.     echo '</a>';
  968. }
  969.  
  970. // update the cart with ajax
  971. add_filter('add_to_cart_fragments', 'add_to_cart_fragment');
  972. function add_to_cart_fragment( $fragments ) {
  973.     global $woocommerce;
  974.     ob_start();
  975.     $fragments['a.cart-parent'] = ob_get_clean();
  976.     return $fragments;
  977. }
  978.  
  979. add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
  980. function woocommerce_header_add_to_cart_fragment( $fragments ) {
  981.     global $woocommerce;
  982.    
  983.     ob_start(); ?>
  984.     <a class="woo-cart cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>"><i class="font-icon-bag"></i><span class="woocommerce-notification-bubble"><?php echo $woocommerce->cart->cart_contents_count; ?></a>
  985.     <?php
  986.    
  987.     $fragments['a.cart-contents'] = ob_get_clean();
  988.    
  989.     return $fragments;
  990. }
  991.  
  992. //change summary html markup to fit responsive
  993. add_action( 'woocommerce_before_single_product_summary', 'summary_div', 35);
  994. add_action( 'woocommerce_after_single_product_summary',  'close_div', 4);
  995. function summary_div() {
  996.     echo "<div class='col-description'>";
  997. }
  998. function close_div() {
  999.     echo "</div>";
  1000. }
  1001.  
  1002. //wrap single product image in an extra div
  1003. add_action( 'woocommerce_before_single_product_summary', 'images_div', 2);
  1004. add_action( 'woocommerce_before_single_product_summary',  'close_div', 20);
  1005. function images_div()
  1006. {
  1007.     echo "<div class='col-image'>";
  1008. }
  1009.  
  1010. // display upsells and related products within dedicated div with different column and number of products
  1011. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20);
  1012. remove_action( 'woocommerce_after_single_product', 'woocommerce_output_related_products',10);
  1013. add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
  1014.  
  1015. function woocommerce_output_related_products() {
  1016.     $output = null;
  1017.  
  1018.     ob_start();
  1019.     woocommerce_related_products(array('columns' => 4, 'posts_per_page' => 4));
  1020.     $content = ob_get_clean();
  1021.     if($content) { $output .= $content; }
  1022.  
  1023.     echo '<div class="clear"></div>' . $output;
  1024. }
  1025.  
  1026. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement