%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/jalalj2hb/www/wp-content/themes/pixel-linear/functions/
Upload File :
Create Path :
Current File : /home/jalalj2hb/www/wp-content/themes/pixel-linear/functions/functions.php

<?php

/**
 * Theme's Functions and Definitions
 * @file           functions.php
 * @package        Pixel-Linear 
 * @author         Pixel Theme Studio 
 * @copyright      2014 - 2015 Pixel Theme Studio Themes
 * @license        license.txt
 * @version        Release: 1.0.0
 * @link           http://codex.wordpress.org/Theme_Development#Functions_File
 * @since          available since Release 1.0
 */

add_action('after_setup_theme', 'pixlin_setup');



if (!function_exists('pixlin_setup')):



    function pixlin_setup() {



        global $content_width;



        /**

         * Global content width.

         */

        if (!isset($content_width))

            $content_width = 550;



        /**

         * Responsive is now available for translations.

         * Add your files into /languages/ directory.

		 * @see http://codex.wordpress.org/Function_Reference/load_theme_textdomain

         */

	    load_theme_textdomain('pixlin', get_template_directory().'/languages');



            $locale = get_locale();

            $locale_file = get_template_directory().'/languages/$locale.php';

            if (is_readable( $locale_file))

	            require_once( $locale_file);

						

        /**

         * Add callback for custom TinyMCE editor stylesheets. (editor-style.css)

         * @see http://codex.wordpress.org/Function_Reference/add_editor_style

         */

        add_editor_style();



        /**

         * This feature enables post and comment RSS feed links to head.

         * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Feed_Links

         */

        add_theme_support('automatic-feed-links');



        /**

         * This feature enables post-thumbnail support for a theme.

         * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails

         */



        add_theme_support('post-thumbnails');





        $options = get_option('pixlin_theme_options');    

    }



endif;



/**

 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.

 */

function pixlin_page_menu_args( $args ) {

	$args['show_home'] = true;

	return $args;

}

add_filter( 'wp_page_menu_args', 'pixlin_page_menu_args' );



/**

 * Remove div from wp_page_menu() and replace with ul.

 */

function pixlin_wp_page_menu ($page_markup) {

    preg_match('/^<div class=\"([a-z0-9-_]+)\">/i', $page_markup, $matches);

        $divclass = $matches[1];

        $replace = array('<div class="'.$divclass.'">', '</div>');

        $new_markup = str_replace($replace, '', $page_markup);

        $new_markup = preg_replace('/^<ul>/i', '<ul class="'.$divclass.'">', $new_markup);

        return $new_markup; }



add_filter('wp_page_menu', 'pixlin_wp_page_menu');



/**

 * Filter 'get_comments_number'

 * 

 * Filter 'get_comments_number' to display correct 

 * number of comments (count only comments, not 

 * trackbacks/pingbacks)

 *

 * Courtesy of Chip Bennett

 */

function pixlin_comment_count( $count ) {  

	if ( ! is_admin() ) {

		global $id;

		$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));

		return count($comments_by_type['comment']);

	} else {

		return $count;

	}

}

add_filter('get_comments_number', 'pixlin_comment_count', 0);



/**

 * wp_list_comments() Pings Callback

 * 

 * wp_list_comments() Callback function for 

 * Pings (Trackbacks/Pingbacks)

 */

function pixlin_comment_list_pings( $comment ) {

	$GLOBALS['comment'] = $comment;

?>

	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>

<?php }



/**

 * Sets the post excerpt length to 40 characters.

 * Next few lines are adopted from Coraline

 */

function pixlin_excerpt_length($length) {

    return 40;

}



add_filter('excerpt_length', 'pixlin_excerpt_length');



/**

 * Returns a "Read more" link for excerpts

 */

function pixlin_read_more() {

    return ' <a href="' . get_permalink() . '">' . __('<div class="read-more"><p>Read more &#8250;</p></div><!-- end of .read-more -->', 'pixlin') . '</a>';

}



/**

 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and pixlin_read_more_link().

 */

function pixlin_auto_excerpt_more($more) {

    return pixlin_read_more();

}



add_filter('excerpt_more', 'pixlin_auto_excerpt_more');



/**

 * Adds a pretty "Read more" link to custom post excerpts.

 */

function pixlin_custom_excerpt_more($output) {

    if (has_excerpt() && !is_attachment()) {

        $output .= pixlin_read_more();

    }

    return $output;

}



add_filter('get_the_excerpt', 'pixlin_custom_excerpt_more');



/**

 * Custom Read More Button

 */



function my_more_link( $more_link, $more_link_text ) {

    

    $read_more_text = bi_get_data('read_more_text', '' );

            

    return str_replace( $more_link_text, '<p><a href="' . get_permalink() . '" class="readmore">'.$read_more_text.' </a> </p>', $more_link );

}



add_filter( 'the_content_more_link', 'my_more_link', 10, 2 );





/**

 * This function removes inline styles set by WordPress gallery.

 */

function pixlin_remove_gallery_css($css) {

    return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);

}



add_filter('gallery_style', 'pixlin_remove_gallery_css');





/**

 * This function removes default styles set by WordPress recent comments widget.

 */

function pixlin_remove_recent_comments_style() {

	global $wp_widget_factory;

	remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );

}

add_action( 'widgets_init', 'pixlin_remove_recent_comments_style' );





/**

 * Breadcrumb Lists

 * Allows visitors to quickly navigate back to a previous section or the root page.

 *

 * Courtesy of Dimox

 *

 * bbPress compatibility patch by Dan Smith

 */

function pixlin_breadcrumb_lists() {



    $chevron = '<span class="divider">/</span>';

    $name = __('Home','pixlin'); //text for the 'Home' link

    $currentBefore = '<li class="active">';

    $currentAfter = '</li>';



    _e('<ul class="breadcrumb">','pixlin');



    global $post;

    $home = home_url();

    echo '<li><a href="' . $home . '">' . $name . '</a></li>';



    if (is_category()) {

        global $wp_query;

        $cat_obj = $wp_query->get_queried_object();

        $thisCat = $cat_obj->term_id;

        $thisCat = get_category($thisCat);

        $parentCat = get_category($thisCat->parent);

        if ($thisCat->parent != 0)

            echo(get_category_parents($parentCat, TRUE, ''));

        echo $currentBefore . 'Archive by category &#39;';

        single_cat_title();

        echo '&#39;' . $currentAfter;

    } elseif (is_day()) {

        echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $chevron . '</li>  ';

        echo '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ';

        echo $currentBefore . get_the_time('d') . $currentAfter;

    } elseif (is_month()) {

        echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ';

        echo $currentBefore . get_the_time('F') . $currentAfter;

    } elseif (is_year()) {

        echo $currentBefore . get_the_time('Y') . $currentAfter;

    } elseif (is_single()) {

        $pid = $post->ID;

        $pdata = get_the_category($pid);

        $adata = get_post($pid);

        if(!empty($pdata)){

            echo '<li>' .get_category_parents($pdata[0]->cat_ID, TRUE, ' '). '</li> ';

            echo $currentBefore;

        }

        echo $adata->post_title;

        echo $currentAfter;

    } elseif (is_page() && !$post->post_parent) {

        echo $currentBefore;

        the_title();

        echo $currentAfter;

    } elseif (is_page() && $post->post_parent) {

        $parent_id = $post->post_parent;

        $breadcrumb_lists = array();

        while ($parent_id) {

            $page = get_page($parent_id);

            $breadcrumb_lists[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';

            $parent_id = $page->post_parent;

        }

        $breadcrumb_lists = array_reverse($breadcrumb_lists);

        foreach ($breadcrumb_lists as $crumb)

            echo $crumb . ' ' . $chevron . ' ';

        echo $currentBefore;

        the_title();

        echo $currentAfter;

    } elseif (is_search()) {

        echo $currentBefore . __('Search results for &#39;','pixlin') . get_search_query() . __('&#39;','pixlin') . $currentAfter;

    } elseif (is_tag()) {

        echo $currentBefore . __('Posts tagged &#39;','pixlin');

        single_tag_title();

        echo '&#39;' . $currentAfter;

    } elseif (is_author()) {

        global $author;

        $userdata = get_userdata($author);

        echo $currentBefore . __('Articles posted by ','pixlin') . $userdata->display_name . $currentAfter;

    } elseif (is_404()) {

        echo $currentBefore . __('Error 404','pixlin') . $currentAfter;

    }



    if (get_query_var('paged')) {

        if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())

            _e(' (','pixlin');

        echo __('Page','pixlin') . ' ' . get_query_var('paged');

        if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())

            _e(')','pixlin');

    }



    _e('</ul>','pixlin');

}





    /**

     * A safe way of adding javascripts to a WordPress generated page.

     */

    if (!is_admin())

        add_action('wp_enqueue_scripts', 'pixlin_js');



    if (!function_exists('pixlin_js')) {



        function pixlin_js() {

			// JS at the bottom for fast page loading. 

			// except for Modernizr which enables HTML5 elements & feature detects.

			wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/modernizr.custom.js', array('jquery'), '2.6.2', false);

            wp_enqueue_script('magnific', get_template_directory_uri() . '/js/magnific.min.js', array('jquery'), '0.9.4', false);

        }



    }



    /**

     * A comment reply.

     */

        function pixlin_enqueue_comment_reply() {

    if ( is_singular() && comments_open() && get_option('thread_comments')) { 

            wp_enqueue_script('comment-reply'); 

        }

    }



    add_action( 'wp_enqueue_scripts', 'pixlin_enqueue_comment_reply' );

	

    /**

     * Where the post has no post title, but must still display a link to the single-page post view.

     */

    add_filter('the_title', 'pixlin_title');



    function pixlin_title($title) {

        if ($title == '') {

            return __('Untitled','pixlin');

        } else {

            return $title;

        }

    }



    /**

     * WordPress Widgets start right here.

     */

    function pixlin_widgets_init() {
		
		
		 register_sidebar(array(

            'name' => __('Left Sidebar', 'pixlin'),

            'description' => __('Left Sidebar Contents', 'pixlin'),

            'id' => 'left-sidebar',

            'before_title' => '<div class="sidebar-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="sidebar-wrapper %2$s">',

            'after_widget' => '</div>'

        ));
		
		 register_sidebar(array(

            'name' => __('Right Sidebar', 'pixlin'),

            'description' => __('Right Sidebar Contents', 'pixlin'),

            'id' => 'right-sidebar',

            'before_title' => '<div class="sidebar-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="sidebar-wrapper %2$s">',

            'after_widget' => '</div>'

        ));




          register_sidebar(array(

            'name' => __('Footer Column 1', 'pixlin'),

            'description' => __('footer.php', 'pixlin'),

            'id' => 'footer-col1',

            'before_title' => '<div class="footer-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',

            'after_widget' => '</div>'

        ));



          register_sidebar(array(

            'name' => __('Footer Column 2', 'pixlin'),

            'description' => __('footer.php', 'pixlin'),

            'id' => 'footer-col2',

            'before_title' => '<div class="footer-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',

            'after_widget' => '</div>'

        ));



         register_sidebar(array(

            'name' => __('Footer Column 3', 'pixlin'),

            'description' => __('footer.php', 'pixlin'),

            'id' => 'footer-col3',

            'before_title' => '<div class="footer-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',

            'after_widget' => '</div>'

        ));
		
		
		register_sidebar(array(

            'name' => __('Footer Column 4', 'pixlin'),

            'description' => __('footer.php', 'pixlin'),

            'id' => 'footer-col4',

            'before_title' => '<div class="footer-title"><h3>',

            'after_title' => '</h3></div>',

            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',

            'after_widget' => '</div>'

        ));
		
		
		
		register_sidebar(array(
            'name' => __('Box One', 'pixlin'),
            'description' => __('Three Box Content', 'pixlin'),
            'id' => 'box-1',
            'before_title' => '<div class="box-title"><h3>',
            'after_title' => '</h3></div>',
            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
            'after_widget' => '</div>'
        ));
		
		register_sidebar(array(
            'name' => __('Box Two', 'pixlin'),
            'description' => __('Three Box Content', 'pixlin'),
            'id' => 'box-2',
            'before_title' => '<div class="box-title"><h3>',
            'after_title' => '</h3></div>',
            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
            'after_widget' => '</div>'
        ));
		
		register_sidebar(array(
            'name' => __('Box Three', 'pixlin'),
            'description' => __('Three Box Content', 'pixlin'),
            'id' => 'box-3',
            'before_title' => '<div class="box-title"><h3>',
            'after_title' => '</h3></div>',
            'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
            'after_widget' => '</div>'
        ));

    }

	

    add_action('widgets_init', 'pixlin_widgets_init');

Zerion Mini Shell 1.0