Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // File Security Check
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if( ! function_exists( 'eco_theme_setup' ) ) :
- function eco_theme_setup() {
- // Load the theme text domain
- load_theme_textdomain( 'eco', get_template_directory() . '/lang' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- // Add title tag
- add_theme_support( 'title-tag' );
- // Add post-thumbnails
- add_theme_support( 'post-thumbnails' );
- add_theme_support( 'woocommerce' );
- add_image_size( 'eco-post-img-small', 370, 235, true );
- add_image_size( 'eco-post-img-medium', 555, 350, true );
- add_image_size( 'eco-post-img-large', 1140, 600, true );
- add_image_size( 'eco-service-img-large', 1140, 600, true );
- // Set content width
- if ( ! isset( $content_width ) ) {
- $content_width = 600;
- }
- // Registering menu
- if( function_exists('register_nav_menus') ) {
- register_nav_menus( array(
- 'primary-menu' => esc_html__('Primany Menu', 'eco'),
- 'secondary-menu' => esc_html__('Secondary Menu', 'eco'),
- ) );
- }
- }
- endif;
- add_action( 'after_setup_theme', 'eco_theme_setup' );
- /**
- *
- * The posts loop pagination
- *
- */
- function eco_page_posts_loop( $template )
- {
- if( have_posts() ) :
- while( have_posts() ) : the_post();
- get_template_part('templates/content', $template );
- endwhile;
- else:
- get_template_part('templates/no-post');
- endif;
- }
- /**
- * Menu fallback. Link to the menu editor if that is useful.
- *
- * @param array $args
- * @return string
- */
- function eco_link_to_menu_editor( $args )
- {
- if ( ! current_user_can( 'manage_options' ) )
- {
- return;
- }
- // see wp-includes/nav-menu-template.php for available arguments
- extract( $args );
- $link = $link_before
- . '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '">' . esc_attr( $before ) . esc_attr__('Create a menu', 'eco') . esc_attr($after) . '</a>'
- . $link_after;
- // We have a list
- if ( FALSE !== stripos( $items_wrap, '<ul' )
- or FALSE !== stripos( $items_wrap, '<ol' )
- )
- {
- $link = "<li>" . $link ."</li>";
- }
- $output = sprintf( $items_wrap, $menu_id, $menu_class, $link );
- if ( ! empty ( $container ) )
- {
- $output = "<". esc_attr($container) ." class='". esc_attr($container_class) ."' id='". esc_attr($container_id) ."'>$output</". esc_attr($container) .">";
- }
- if ( $echo )
- {
- echo $output;
- }
- return $output;
- }
- // Change number or products per row to 3
- add_filter('loop_shop_columns', 'eco_loop_columns');
- if (!function_exists('eco_loop_columns')) {
- function eco_loop_columns() {
- return 3; // 3 products per row
- }
- }
- /**
- *
- * By adding filter to loop_shop_per_page
- *
- */
- add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9;' ), 20 );
- /**
- *
- * WordPress link pages
- *
- */
- function eco_wp_link_pages() {
- wp_link_pages( array(
- 'before' => '<div class="page-links"><span class="page-links-title">' . esc_html__( 'Pages:', 'eco' ) . '</span>',
- 'after' => '</div>',
- 'link_before' => '<span>',
- 'link_after' => '</span>',
- ) );
- }
- function get_pulled_sidebar($pull_class) {
- echo '<aside class="col-md-4 '. $pull_class .' widget_col">';
- if( is_active_sidebar('eco_sidebar') ) :
- dynamic_sidebar( 'eco_sidebar' );
- endif;
- echo '</aside>';
- }
- /**
- *
- * Add classes to post class by filting
- * @return $classes
- */
- add_filter('post_class', 'eco_post_class');
- function eco_post_class( $classes ) {
- // Is single post page
- if( is_single() ) {
- $classes[] = 'singleBlog';
- }
- $classes[] = 'singlePost singleLargePost';
- return $classes;
- }
- /**
- *
- * Building Comments Lists
- *
- */
- function eco_comments_list( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch( $comment->comment_type ) :
- case 'tracback' :
- case 'pingback' : ?>
- <li <?php esc_attr( comment_class() ); ?> id="comment-<?php esc_attr( comment_ID() ); ?>">
- <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>
- <?php break;
- default : ?>
- <article <?php esc_attr( comment_class() ); ?> id="comment-<?php esc_attr(comment_ID() ); ?>">
- <div class="comment-single">
- <div class="comment-media">
- <a href="#">
- <?php echo get_avatar( $comment, 100 ); ?>
- </a>
- </div>
- <div class="comment-body">
- <h5 class="comment-heading"><?php esc_html( comment_author() ); ?></h5>
- <div class="comment-meta">
- <span class="time">
- <?php echo esc_html( the_time( get_option('date_format') ) );?> <?php esc_html( comment_time() ); ?>
- <span class="edit-link">
- <?php esc_url( edit_comment_link( esc_html__(' | Edit', 'eco') ) ); ?>
- </span>
- </span>
- <span class="reply-link">
- <?php
- comment_reply_link( array_merge( $args, array(
- 'reply_text' => esc_html__('| Reply', 'eco'),
- 'after' => ' <span> ↓ </span>',
- 'depth' => $depth,
- 'max_depth' => $args['max_depth']
- ) ) );
- ?>
- </span>
- </div>
- <div class="comment-text-body">
- <?php
- if( $comment->comment_approved == 0 ) {
- esc_html_e('Your comment is awating for moderation.', 'eco');
- } else {
- comment_text();
- }
- ?>
- </div>
- </div>
- </div>
- </article>
- <?php // End the default styling of comment
- break;
- endswitch;
- }
- /**
- *
- * Registering Google Fonts
- *
- */
- function eco_google_fonts_url() {
- $font_url = '';
- if ( 'off' !== _x( 'on', 'Google font: on or off', 'eco' ) ) {
- $font_url = add_query_arg( 'family', urlencode( 'Montserrat:100,300,400,400,600,700,900&subset=latin,latin-ext' ), "//fonts.googleapis.com/css" );
- }
- return $font_url;
- }
- /**
- * Detect Homepage
- *
- * @return boolean value
- */
- function eco_detect_homepage() {
- // If front page is set to display a static page, get the URL of the posts page.
- $homepage_id = get_option( 'page_on_front' );
- // current page id
- $current_page_id = ( is_page( get_the_ID() ) ) ? get_the_ID() : '';
- if( $homepage_id == $current_page_id ) {
- return true;
- } else {
- return false;
- }
- }
- /**
- *
- * Return the primary menu col classes
- *
- */
- function eco_hs1_primary_menu_col() {
- global $eco;
- if( isset($eco['header_secondary_menu'] ) && $eco['header_secondary_menu'] == true ) {
- return 'col-md-7 col-sm-6';
- } else {
- return 'col-md-12 col-sm-12';
- }
- }
- /**
- *
- * Custom Comment Form
- *
- */
- add_filter('comment_form_defaults', 'eco_custom_comment_form');
- function eco_custom_comment_form( $defaults ) {
- $defaults['title_reply'] = esc_attr__('Leave your thought', 'eco');
- $defaults['comment_notes_before'] = esc_attr__(' ', 'eco');
- $defaults['comment_notes_after'] = '';
- $defaults['class_form'] = 'comment_form animated fadeInUp'; $defaults['comment_field'] = '<textarea name="comment" placeholder="'. esc_attr__('Leave a comment', 'eco') .'"></textarea>';
- return $defaults;
- }
- /**
- *
- * Shape custom comments field
- *
- */
- add_filter('comment_form_default_fields', 'eco_custom_comment_form_fields');
- function eco_custom_comment_form_fields() {
- $commenter = wp_get_current_commenter();
- $req = get_option('required_name_email');
- $aria_req = ($req ? " aria-required='true'" : ' ');
- $yourNamePlaceholder = $aria_req ? esc_attr__('Your name *', 'eco') : esc_attr__('Your name ', 'eco');
- $yourEmailPlaceholder = $aria_req ? esc_attr__('Your email *', 'eco') : esc_attr__('Your email ', 'eco');
- $fields = array(
- 'author' => '<div class="row"><div class="col-md-6"><input
- type="text"
- id="author"
- name="author"
- placeholder="'. $yourNamePlaceholder .'"
- value="'. esc_attr( $commenter['comment_author'] ) .'"
- '. $aria_req .'
- ></div>',
- 'email' => '<div class="col-md-6"><input
- type="email"
- id="email"
- name="email"
- placeholder="'. $yourEmailPlaceholder .'"
- value="'. esc_attr( $commenter['comment_author_email'] ) .'"
- '. $aria_req .'
- ></div></div>',
- );
- return $fields;
- }
- /**
- *
- * Eco Tag Cloud font size
- *
- */
- function eco_tag_cloud_widget($args) {
- $args['largest'] = 12; //largest tag
- $args['smallest'] = 12; //smallest tag
- $args['unit'] = 'px'; //tag font unit
- return $args;
- }
- add_filter( 'widget_tag_cloud_args', 'eco_tag_cloud_widget' );
- /**
- *
- * Remove Redux Framework Notices
- *
- */
- function eco_remove_demo_redux_notice() {
- if ( class_exists('ReduxFrameworkPlugin') ) {
- remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 );
- }
- if ( class_exists('ReduxFrameworkPlugin') ) {
- remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) );
- }
- }
- add_action('init', 'eco_remove_demo_redux_notice');
- /**
- * Get blog posts page URL.
- *
- * @return string The blog posts page URL.
- */
- function eco_get_blog_posts_page_url() {
- // If front page is set to display a static page, get the URL of the posts page.
- if ( 'page' === get_option( 'show_on_front' ) ) {
- return esc_url(get_permalink( get_option( 'page_for_posts' ) ));
- }
- // The front page IS the posts page. Get its URL.
- return esc_url(get_home_url('/'));
- }
- /**
- * Set the floating header homepage class automatically
- *
- */
- function eco_set_header_class() {
- // Globalizing theme options variables
- global $eco;
- // Get the homepage ID
- $homepage_id = get_option( 'page_on_front' );
- // current page id
- $current_page_id = get_the_ID();
- $output_classs = array();
- if( isset( $eco['header_layout'] ) && ( $eco['header_layout'] == 'header-style-3' || $eco['header_layout'] == 'header-style-4' ) ) {
- if( isset($eco['transarent_header']) && $eco['transarent_header'] == true ) {
- if( $homepage_id == $current_page_id ) {
- $output_classs[] = 'eco--header--2';
- } else {
- $output_classs[] = 'reverse--float--header';
- }
- }
- }
- return $output_classs;
- }
- /**
- *
- * Get the logo url
- *
- */
- function eco_set_header_logo() {
- // Globalizing theme options variables
- global $eco;
- // Get the homepage ID
- $homepage_id = get_option( 'page_on_front' );
- // current page id
- $current_page_id = get_the_ID();
- if( $homepage_id == $current_page_id ) {
- return esc_url( $eco['logo']['url'] ) ;
- } else {
- if( isset($eco['inner_logo']) ) {
- return esc_url( $eco['inner_logo']['url'] );
- } else {
- return esc_url( $eco['logo']['url'] );
- }
- }
- }
- /**
- *
- * One click demo Installation for Eco theme
- *
- */
- function eco_import_files() {
- return array(
- array(
- 'import_file_name' => 'Eco Home - (All)',
- 'local_import_file' => ECO_INC_DIR . '/demo-contents/demo1/eco_content.xml',
- 'local_import_widget_file' => ECO_INC_DIR . '/demo-contents/demo1/eco_widgets.wie',
- 'import_redux' => array(
- array(
- 'file_url' => 'http://themes.graphchilly.com/theme-demos/eco/demo-contents/demo1/eco_theme_option.json',
- 'option_name' => 'eco',
- ),
- ),
- 'import_preview_image_url' => 'http://themes.graphchilly.com/theme-demos/eco/images/home1.png',
- 'import_notice' => esc_html__( 'After importing the demo, you need set your preferred homepage layout from ', 'eco') .
- '<a href="'. trailingslashit(home_url('/')) .'wp-admin/options-reading.php">'. esc_html__('here', 'eco') .'</a>',
- )
- );
- }
- add_filter( 'pt-ocdi/import_files', 'eco_import_files' );
Advertisement
Add Comment
Please, Sign In to add comment