Guest User

Untitled

a guest
Dec 3rd, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.28 KB | None | 0 0
  1. <?php
  2.  
  3. // File Security Check
  4. if ( ! defined( 'ABSPATH' ) ) {
  5.     exit;
  6. }
  7.  
  8.  
  9. if( ! function_exists( 'eco_theme_setup' ) ) :
  10.  
  11.     function eco_theme_setup() {
  12.        
  13.         // Load the theme text domain
  14.         load_theme_textdomain( 'eco', get_template_directory() . '/lang' );
  15.  
  16.         // Add default posts and comments RSS feed links to head.
  17.         add_theme_support( 'automatic-feed-links' );
  18.  
  19.         // Add title tag
  20.         add_theme_support( 'title-tag' );
  21.  
  22.         // Add post-thumbnails
  23.         add_theme_support( 'post-thumbnails' );
  24.  
  25.         add_theme_support( 'woocommerce' );
  26.        
  27.         add_image_size( 'eco-post-img-small', 370, 235, true );
  28.         add_image_size( 'eco-post-img-medium', 555, 350, true );
  29.         add_image_size( 'eco-post-img-large', 1140, 600, true );
  30.         add_image_size( 'eco-service-img-large', 1140, 600, true );
  31.  
  32.         // Set content width
  33.         if ( ! isset( $content_width ) ) {
  34.             $content_width = 600;
  35.         }  
  36.  
  37.        
  38.         // Registering menu
  39.  
  40.         if( function_exists('register_nav_menus') ) {
  41.             register_nav_menus( array(
  42.                 'primary-menu' => esc_html__('Primany Menu', 'eco'),
  43.                 'secondary-menu' => esc_html__('Secondary Menu', 'eco'),
  44.             ) );
  45.         }
  46.  
  47.     }
  48.  
  49. endif;
  50.  
  51. add_action( 'after_setup_theme', 'eco_theme_setup' );
  52.  
  53.  
  54.  
  55. /**
  56.  *
  57.  * The posts loop pagination
  58.  *
  59.  */
  60. function eco_page_posts_loop( $template )
  61. {
  62.     if( have_posts() ) :
  63.  
  64.         while( have_posts() ) : the_post();
  65.  
  66.             get_template_part('templates/content', $template );
  67.  
  68.         endwhile;
  69.  
  70.     else:
  71.         get_template_part('templates/no-post');
  72.     endif;
  73. }
  74.  
  75.  
  76. /**
  77.  * Menu fallback. Link to the menu editor if that is useful.
  78.  *
  79.  * @param  array $args
  80.  * @return string
  81.  */
  82. function eco_link_to_menu_editor( $args )
  83. {
  84.     if ( ! current_user_can( 'manage_options' ) )
  85.     {
  86.         return;
  87.     }
  88.  
  89.     // see wp-includes/nav-menu-template.php for available arguments
  90.     extract( $args );
  91.  
  92.     $link = $link_before
  93.         . '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '">' . esc_attr( $before ) . esc_attr__('Create a menu', 'eco') . esc_attr($after) . '</a>'
  94.         . $link_after;
  95.  
  96.     // We have a list
  97.     if ( FALSE !== stripos( $items_wrap, '<ul' )
  98.         or FALSE !== stripos( $items_wrap, '<ol' )
  99.     )
  100.     {
  101.         $link = "<li>" . $link ."</li>";
  102.     }
  103.  
  104.     $output = sprintf( $items_wrap, $menu_id, $menu_class, $link );
  105.     if ( ! empty ( $container ) )
  106.     {
  107.         $output  = "<". esc_attr($container) ." class='". esc_attr($container_class) ."' id='". esc_attr($container_id) ."'>$output</". esc_attr($container) .">";
  108.     }
  109.  
  110.     if ( $echo )
  111.     {
  112.         echo $output;
  113.     }
  114.  
  115.     return $output;
  116. }
  117.  
  118. // Change number or products per row to 3
  119. add_filter('loop_shop_columns', 'eco_loop_columns');
  120.  
  121. if (!function_exists('eco_loop_columns')) {
  122.     function eco_loop_columns() {
  123.         return 3; // 3 products per row
  124.     }
  125. }
  126.  
  127.  
  128. /**
  129.  *
  130.  * By adding filter to loop_shop_per_page
  131.  *
  132.  */
  133. add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9;' ), 20 );
  134.  
  135.  
  136. /**
  137.  *
  138.  * WordPress link pages
  139.  *
  140.  */
  141. function eco_wp_link_pages() {
  142.  
  143.     wp_link_pages( array(
  144.         'before'      => '<div class="page-links"><span class="page-links-title">' . esc_html__( 'Pages:', 'eco' ) . '</span>',
  145.         'after'       => '</div>',
  146.         'link_before' => '<span>',
  147.         'link_after'  => '</span>',
  148.     ) );
  149.  
  150. }
  151.  
  152.  
  153. function get_pulled_sidebar($pull_class) {
  154.    
  155.     echo '<aside class="col-md-4 '. $pull_class .' widget_col">';
  156.  
  157.                 if( is_active_sidebar('eco_sidebar') ) :
  158.                     dynamic_sidebar( 'eco_sidebar' );
  159.                 endif;
  160.                    
  161.     echo '</aside>';
  162. }
  163.  
  164. /**
  165.  *
  166.  * Add classes to post class by filting
  167.  * @return $classes
  168.  */
  169.  
  170. add_filter('post_class', 'eco_post_class');
  171.  
  172. function eco_post_class( $classes ) {
  173.  
  174.     // Is single post page
  175.     if( is_single() ) {
  176.         $classes[] = 'singleBlog';     
  177.     }
  178.  
  179.  
  180.     $classes[] = 'singlePost singleLargePost';     
  181.  
  182.     return $classes;
  183. }
  184.  
  185.  
  186.  
  187.  
  188. /**
  189.  *
  190.  * Building Comments Lists
  191.  *
  192.  */
  193. function eco_comments_list( $comment, $args, $depth ) {
  194.  
  195.     $GLOBALS['comment'] = $comment;
  196.     switch( $comment->comment_type ) :
  197.         case 'tracback' :
  198.         case 'pingback' : ?>
  199.        
  200.         <li <?php esc_attr( comment_class() ); ?> id="comment-<?php esc_attr( comment_ID() ); ?>">
  201.         <p><span class="title"><?php esc_html_e( 'Pingback:', 'eco' ); ?></span> <?php esc_url( comment_author_link() ); ?> <?php esc_url ( edit_comment_link( esc_html__( '(Edit)', 'eco' ), '<span class="edit-link">', '</span>' ) ); ?></p>
  202.  
  203.         <?php break;
  204.         default : ?>
  205.         <article <?php esc_attr( comment_class() ); ?>  id="comment-<?php esc_attr(comment_ID() ); ?>">
  206.  
  207.             <div class="comment-single">
  208.                 <div class="comment-media">
  209.                     <a href="#">
  210.                         <?php echo get_avatar( $comment, 100 ); ?>
  211.                     </a>
  212.                 </div>
  213.                 <div class="comment-body">
  214.                     <h5 class="comment-heading"><?php esc_html( comment_author() ); ?></h5>
  215.                    
  216.                     <div class="comment-meta">
  217.                         <span class="time">
  218.                             <?php echo esc_html( the_time( get_option('date_format') ) );?> <?php  esc_html( comment_time() ); ?>
  219.                             <span class="edit-link">
  220.                                 <?php esc_url( edit_comment_link( esc_html__(' | Edit', 'eco') ) ); ?>
  221.                             </span>
  222.                            
  223.                         </span>
  224.                         <span class="reply-link">
  225.                             <?php
  226.                                 comment_reply_link( array_merge( $args, array(
  227.                                     'reply_text' => esc_html__('| Reply', 'eco'),
  228.                                     'after' => ' <span> &#8595; </span>',
  229.                                     'depth' => $depth,
  230.                                     'max_depth' => $args['max_depth']
  231.                                 ) ) );
  232.                             ?>
  233.                         </span>
  234.                     </div>
  235.                    
  236.                     <div class="comment-text-body">
  237.                         <?php
  238.                             if( $comment->comment_approved  == 0 ) {
  239.                                 esc_html_e('Your comment is awating for moderation.', 'eco');
  240.                             } else {
  241.                                 comment_text();
  242.                             }
  243.                         ?>
  244.                        
  245.                     </div>
  246.  
  247.                    
  248.  
  249.                    
  250.                 </div>
  251.             </div>
  252.         </article>
  253.  
  254.         <?php // End the default styling of comment
  255.         break;
  256.     endswitch;
  257. }
  258.  
  259.  
  260.  
  261. /**
  262.  *
  263.  * Registering Google Fonts
  264.  *
  265.  */
  266. function eco_google_fonts_url() {
  267.  
  268.     $font_url = '';
  269.  
  270.     if ( 'off' !== _x( 'on', 'Google font: on or off', 'eco' ) ) {
  271.         $font_url = add_query_arg( 'family', urlencode( 'Montserrat:100,300,400,400,600,700,900&subset=latin,latin-ext' ), "//fonts.googleapis.com/css" );
  272.     }
  273.    
  274.     return $font_url;
  275.  
  276. }
  277.  
  278.  
  279.  
  280. /**
  281.  * Detect Homepage
  282.  *
  283.  * @return boolean value
  284.  */
  285. function eco_detect_homepage() {
  286.     // If front page is set to display a static page, get the URL of the posts page.
  287.     $homepage_id = get_option( 'page_on_front' );
  288.  
  289.     // current page id
  290.     $current_page_id = ( is_page( get_the_ID() ) ) ? get_the_ID() : '';
  291.  
  292.     if( $homepage_id == $current_page_id ) {
  293.         return true;
  294.     } else {
  295.         return false;
  296.     }
  297.  
  298. }
  299.  
  300.  
  301.  
  302. /**
  303.  *
  304.  * Return the primary menu col classes
  305.  *
  306.  */
  307. function eco_hs1_primary_menu_col() {
  308.  
  309.     global $eco;
  310.  
  311.     if( isset($eco['header_secondary_menu'] ) && $eco['header_secondary_menu'] == true ) {
  312.         return 'col-md-7  col-sm-6';
  313.     } else {
  314.         return 'col-md-12  col-sm-12';
  315.     }
  316. }
  317.  
  318.  
  319. /**
  320.  *
  321.  * Custom Comment Form
  322.  *
  323.  */
  324.  
  325. add_filter('comment_form_defaults', 'eco_custom_comment_form');
  326.  
  327. function eco_custom_comment_form( $defaults ) {
  328.     $defaults['title_reply'] = esc_attr__('Leave your thought', 'eco');
  329.     $defaults['comment_notes_before'] = esc_attr__(' ', 'eco');
  330.     $defaults['comment_notes_after'] = '';
  331.     $defaults['class_form'] = 'comment_form animated fadeInUp'; $defaults['comment_field'] = '<textarea name="comment" placeholder="'. esc_attr__('Leave a comment', 'eco') .'"></textarea>';
  332.  
  333.     return $defaults;
  334. }
  335.  
  336.  
  337. /**
  338.  *
  339.  * Shape custom comments field
  340.  *
  341.  */
  342.  
  343. add_filter('comment_form_default_fields', 'eco_custom_comment_form_fields');
  344.  
  345. function eco_custom_comment_form_fields() {
  346.     $commenter = wp_get_current_commenter();
  347.     $req = get_option('required_name_email');
  348.     $aria_req = ($req ? " aria-required='true'" : ' ');
  349.  
  350.     $yourNamePlaceholder  = $aria_req ? esc_attr__('Your name *', 'eco') : esc_attr__('Your name ', 'eco');
  351.     $yourEmailPlaceholder = $aria_req ? esc_attr__('Your email *', 'eco') : esc_attr__('Your email ', 'eco');
  352.  
  353.     $fields = array(
  354.         'author' => '<div class="row"><div class="col-md-6"><input
  355.                         type="text"
  356.                         id="author"
  357.                         name="author"
  358.                         placeholder="'. $yourNamePlaceholder .'"
  359.                         value="'. esc_attr( $commenter['comment_author'] ) .'"
  360.                         '. $aria_req .'
  361.                     ></div>',
  362.  
  363.         'email' => '<div class="col-md-6"><input
  364.                         type="email"
  365.                         id="email"
  366.                         name="email"
  367.                         placeholder="'. $yourEmailPlaceholder .'"
  368.                         value="'. esc_attr( $commenter['comment_author_email'] ) .'"
  369.                         '. $aria_req .'
  370.                     ></div></div>',
  371.  
  372.     );
  373.  
  374.     return $fields;
  375. }
  376.  
  377.  
  378. /**
  379.  *
  380.  * Eco Tag Cloud font size
  381.  *
  382.  */
  383. function eco_tag_cloud_widget($args) {
  384.     $args['largest'] = 12; //largest tag
  385.     $args['smallest'] = 12; //smallest tag
  386.     $args['unit'] = 'px'; //tag font unit
  387.     return $args;
  388. }
  389. add_filter( 'widget_tag_cloud_args', 'eco_tag_cloud_widget' );
  390.  
  391.  
  392.  
  393.  
  394.  
  395. /**
  396.  *
  397.  * Remove Redux Framework Notices
  398.  *
  399.  */
  400.  
  401. function eco_remove_demo_redux_notice() {
  402.     if ( class_exists('ReduxFrameworkPlugin') ) {
  403.         remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 );
  404.     }
  405.     if ( class_exists('ReduxFrameworkPlugin') ) {
  406.         remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) );    
  407.     }
  408. }
  409. add_action('init', 'eco_remove_demo_redux_notice');
  410.  
  411.  
  412. /**
  413.  * Get blog posts page URL.
  414.  *
  415.  * @return string The blog posts page URL.
  416.  */
  417. function eco_get_blog_posts_page_url() {
  418.     // If front page is set to display a static page, get the URL of the posts page.
  419.     if ( 'page' === get_option( 'show_on_front' ) ) {
  420.         return esc_url(get_permalink( get_option( 'page_for_posts' ) ));
  421.     }
  422.     // The front page IS the posts page. Get its URL.
  423.     return esc_url(get_home_url('/'));
  424. }
  425.  
  426.  
  427.  
  428. /**
  429.  * Set the floating header homepage class automatically
  430.  *
  431.  */
  432. function eco_set_header_class() {
  433.  
  434.     // Globalizing theme options variables
  435.     global $eco;
  436.  
  437.     // Get the homepage ID
  438.     $homepage_id = get_option( 'page_on_front' );
  439.  
  440.     // current page id
  441.     $current_page_id = get_the_ID();  
  442.  
  443.    
  444.     $output_classs = array();
  445.  
  446.     if( isset( $eco['header_layout'] ) && ( $eco['header_layout'] == 'header-style-3' || $eco['header_layout'] == 'header-style-4' ) ) {
  447.         if( isset($eco['transarent_header']) && $eco['transarent_header'] == true ) {
  448.  
  449.             if( $homepage_id == $current_page_id ) {
  450.                 $output_classs[] = 'eco--header--2';
  451.             } else {
  452.                 $output_classs[] = 'reverse--float--header';               
  453.             }
  454.  
  455.         }
  456.     }
  457.  
  458.  
  459.     return $output_classs;
  460. }
  461.  
  462.  
  463. /**
  464.  *
  465.  * Get the logo url
  466.  *
  467.  */
  468. function eco_set_header_logo() {
  469.     // Globalizing theme options variables
  470.     global $eco;
  471.  
  472.     // Get the homepage ID
  473.     $homepage_id = get_option( 'page_on_front' );
  474.  
  475.     // current page id
  476.     $current_page_id = get_the_ID();  
  477.  
  478.     if( $homepage_id == $current_page_id ) {
  479.         return esc_url( $eco['logo']['url'] ) ;
  480.     } else {
  481.         if( isset($eco['inner_logo']) ) {
  482.             return esc_url( $eco['inner_logo']['url'] );
  483.         } else {
  484.             return esc_url( $eco['logo']['url'] );
  485.         }
  486.     }
  487. }
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494. /**
  495.  *
  496.  * One click demo Installation for Eco theme
  497.  *
  498.  */
  499.  
  500. function eco_import_files() {
  501.   return array(
  502.     array(
  503.       'import_file_name'           => 'Eco Home - (All)',
  504.       'local_import_file'            => ECO_INC_DIR . '/demo-contents/demo1/eco_content.xml',
  505.       'local_import_widget_file'     => ECO_INC_DIR . '/demo-contents/demo1/eco_widgets.wie',
  506.       'import_redux'               => array(
  507.         array(
  508.           'file_url'    => 'http://themes.graphchilly.com/theme-demos/eco/demo-contents/demo1/eco_theme_option.json',
  509.           'option_name' => 'eco',
  510.         ),
  511.       ),
  512.       'import_preview_image_url'   => 'http://themes.graphchilly.com/theme-demos/eco/images/home1.png',
  513.       'import_notice'              => esc_html__( 'After importing the demo, you need set your preferred homepage layout from ', 'eco') .  
  514.             '<a href="'. trailingslashit(home_url('/')) .'wp-admin/options-reading.php">'. esc_html__('here', 'eco') .'</a>',
  515.     )
  516.   );
  517. }
  518. add_filter( 'pt-ocdi/import_files', 'eco_import_files' );
Advertisement
Add Comment
Please, Sign In to add comment