انجمن


ارور قالب در هنگام فعال کردن  (۱ نوشته)

  • proud212

    آفلاین
    عضو
    تعداد نوشته‌ها: ۴۲
    تشکر شده: ۲ بار
    # نوشته شده: ۱۱ سال پیش
    ۱۸ فروردین ۱۳۹۲ - ۱۵:۲۶

    3 تا قالب دارم که هنگام فعال کردن ارور
    Fatal error: Cannot redeclare _check_active_widget() (previously declared in D:\xampp\htdocs\MIND\wordpress\wp-content\themes\saap\functions.php:1183) in D:\xampp\htdocs\MIND\wordpress\wp-content\themes\saap \admin\functions\functions.php on line 23
    میده
    توی فایل مذکر هم میرم به ایرادی بر نمیخورم

    <?php
    
    /* ------------------------------------------------
    	Theme Setup
    ------------------------------------------------ */
    
    if ( ! isset( $content_width ) ) $content_width = 640;
    
    add_action( 'after_setup_theme', 'qns_setup' );
    
    if ( ! function_exists( 'qns_setup' ) ):
    
    function qns_setup() {
    
    	add_theme_support( 'post-thumbnails' );
    
    	if ( function_exists( 'add_theme_support' ) ) {
    		add_theme_support( 'post-thumbnails' );
    	        set_post_thumbnail_size( "100", "100" );
    	}
    
    	if ( function_exists( 'add_image_size' ) ) {
    		add_image_size( 'lookbook-thumb', 198, 216, true );
    		add_image_size( 'lookbook-widget', 200, 200, true );
    		add_image_size( 'lookbook-large', 563, 600, true );
    		add_image_size( 'shop-thumb', 80, 80, true );
    		add_image_size( 'recent-posts-widget', 66, 66, true );
    		add_image_size( 'slideshow-big', 960, 420, true );
    		add_image_size( 'blog-thumb-small', 563, 294, true );
    		add_image_size( 'blog-thumb-large', 563, 294, true );
    		add_image_size( 'gallery-thumb-large', 500, 500, true );
    
    	}
    
    	add_theme_support( 'automatic-feed-links' );
    
    	load_theme_textdomain( 'qns', get_template_directory() . '/languages' );
    
    	$locale = get_locale();
    	$locale_file = get_template_directory() . "/languages/$locale.php";
    	if ( is_readable( $locale_file ) ) require_once( $locale_file );
    
    	register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'qns' ),
    	) );
    
    }
    endif;
    
    /* ------------------------------------------------
    	Comments Template
    ------------------------------------------------ */
    
    if( ! function_exists( 'qns_comments' ) ) {
    	function qns_comments($comment, $args, $depth) {
    	   $path = get_template_directory_uri();
    	   $GLOBALS['comment'] = $comment;
    	   ?>
    
    		<li class="comment-entry clearfix">
    
    			<!-- BEGIN .comment-left -->
    			<div class="comment-left">
    				<div class="comment-image">
    					<?php echo get_avatar( $comment, 60 ); ?>
    				</div>
    			<!-- END .comment-left -->
    			</div>
    
    			<!-- BEGIN .comment-right -->
    			<div class="comment-right">
    
    				<?php if ( $comment->comment_approved == '0' ) : ?>
    					<div class="msg success clearfix"><p><?php _e( 'Your comment is awaiting moderation.', 'qns' ); ?></p></div>
    				<?php endif; ?>
    
    				<p class="comment-info"><?php printf( __( '%s', 'qns' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    				<span>
    					<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
    						<?php printf( __( '%1$s at %2$s', 'qns' ), get_comment_date(),  get_comment_time() ); ?>
    					</a>
    				</span></p>
    				<div class="comment-text"><?php comment_text(); ?></div>
    				<p>
    					<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    					<?php edit_comment_link( __( '(Edit)', 'qns' ), ' ' ); ?>
    				</p>
    
    			<!-- END .comment-right -->
    			</div>		
    
    	<?php
    	}
    }
    
    /* ------------------------------------------------
       Options Panel
    ------------------------------------------------ */
    
    require_once ('admin/index.php');
    
    /* ------------------------------------------------
    	Register Sidebars
    ------------------------------------------------ */
    
    function qns_widgets_init() {
    
    	// Area 1, located at the top of the sidebar.
    	register_sidebar( array(
    		'name' => __( 'Primary Widget Area', 'qns' ),
    		'id' => 'primary-widget-area',
    		'description' => __( 'The primary widget area', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="tag-title-wrap clearfix"><h3 class="tag-title-small">',
    		'after_title' => '</h3></div>',
    	) );
    
    	// Area 2, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Footer Widget Area One', 'qns' ),
    		'id' => 'footer-widget-area-one',
    		'description' => __( 'Footer widget area one', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="widget-title clearfix"><h6>',
    		'after_title' => '</h6></div>',
    	) );
    
    	// Area 3, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Footer Widget Area Two', 'qns' ),
    		'id' => 'footer-widget-area-two',
    		'description' => __( 'Footer widget area two', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="widget-title clearfix"><h6>',
    		'after_title' => '</h6></div>',
    	) );
    
    	// Area 4, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Footer Widget Area Three', 'qns' ),
    		'id' => 'footer-widget-area-three',
    		'description' => __( 'Footer widget area three', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="widget-title clearfix"><h6>',
    		'after_title' => '</h6></div>',
    	) );
    
    	// Area 5, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Footer Widget Area Four', 'qns' ),
    		'id' => 'footer-widget-area-four',
    		'description' => __( 'Footer widget area four', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="widget-title clearfix"><h6>',
    		'after_title' => '</h6></div>',
    	) );
    
    	// Area 6, located only on WooCommerce pages. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'WooCommerce Widget Area', 'qns' ),
    		'id' => 'woocommerce-widget-area',
    		'description' => __( 'Widgets in this area will only be displayed on WooCommerce store pages', 'qns' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => '<div class="tag-title-wrap clearfix"><h3 class="tag-title-small">',
    		'after_title' => '</h3></div>',
    	) );
    
    }
    
    add_action( 'widgets_init', 'qns_widgets_init' );
    
    /* ------------------------------------------------
    	Register Menu
    ------------------------------------------------ */
    
    if( !function_exists( 'qns_register_menu' ) ) {
    	function qns_register_menu() {
    
    		register_nav_menus(
    		    array(
    				'primary' => __( 'Primary Navigation','qns' ),
    				'secondary' => __( 'Secondary Navigation','qns' ),
    				'footer' => __( 'Footer Navigation','qns' )
    		    )
    		  );
    
    	}
    
    	add_action('init', 'qns_register_menu');
    }
    
    /* ------------------------------------------------
    	Add Description Field to Menu
    ------------------------------------------------ */
    
    class description_walker extends Walker_Nav_Menu
    {
          function start_el(&$output, $item, $depth, $args)
          {
               global $wp_query;
               $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    
               $class_names = $value = '';
    
               $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    
               $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
               $class_names = ' class="'. esc_attr( $class_names ) . '"';
    
               $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
               $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
               $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
               $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
               $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    
               $prepend = '<strong>';
               $append = '</strong>';
               $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
    
               if($depth != 0) {
    				$description = $append = $prepend = "";
               }
    
                $item_output = $args->before;
                $item_output .= '<a'. $attributes .'>';
                $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
                $item_output .= $description.$args->link_after;
                $item_output .= '</a>';
                $item_output .= $args->after;
    
                $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    		}
    }
    
    /* ------------------------------------------------
    	Get Post Type
    ------------------------------------------------ */
    
    function is_post_type($type){
        global $wp_query;
        if($type == get_post_type($wp_query->post->ID)) return true;
        return false;
    }
    
    /* ------------------------------------------------
       Register Dependant Javascript Files
    ------------------------------------------------ */
    
    add_action('wp_enqueue_scripts', 'qns_load_js');
    
    if( ! function_exists( 'qns_load_js' ) ) {
    	function qns_load_js() {
    
    		if ( is_admin() ) {
    
    		}
    
    		else {
    
    			// Load JS
    			wp_register_script( 'jquery_ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js', array( 'jquery' ), '1.8', true );
    			wp_register_script( 'hoverIntent', get_template_directory_uri() . '/js/hoverIntent.js', array( 'jquery' ), '1.0', true );
    			wp_register_script( 'prettyphoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array( 'jquery' ), '1.1.9', true );
    			wp_register_script( 'superfish', get_template_directory_uri() . '/js/superfish.js', array( 'jquery' ), '1.4.8', true );
    			wp_register_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array( 'jquery' ), '2.1', true );
    			wp_register_script( 'froogaloop', get_template_directory_uri() . '/js/froogaloop.js', array( 'jquery' ), '1.0', true );
    			wp_register_script( 'fitvid', get_template_directory_uri() . '/js/jquery.fitvid.js', array( 'jquery' ), '1.0', true );
    			wp_register_script( 'jcarousel', get_template_directory_uri() . '/js/jquery.jcarousel.min.js', array( 'jquery' ), '1.0', true );
    			wp_register_script( 'cloudzoom', get_template_directory_uri() . '/js/cloud-zoom.1.0.2.js', array( 'jquery' ), '1.0.2', true );
    			wp_register_script( 'selectivizr', get_template_directory_uri() . '/js/selectivizr-min.js', array( 'jquery' ), '1.0.2', true );
    			wp_register_script( 'custom', get_template_directory_uri() . '/js/scripts.js', array( 'jquery' ), '1', true );
    			wp_register_script( 'my-ajax-handle', plugin_dir_url( __FILE__ ) . 'ajax.js', array( 'jquery' ) );
    
    			wp_enqueue_script( array( 'jquery_ui', 'hoverintent', 'prettyphoto', 'superfish', 'flexslider', 'fitvid', 'froogaloop', 'jcarousel', 'cloudzoom', 'selectivizr', 'custom', 'my-ajax-handle' ) );
    			wp_localize_script( 'my-ajax-handle', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    
    			global $is_IE;
    
    			if( $is_IE ) wp_enqueue_script( 'selectivizr' );
    			if( is_single() ) wp_enqueue_script( 'comment-reply' );
    
    			// Load CSS
    			wp_enqueue_style('superfish', get_template_directory_uri() .'/css/superfish.css');
    			wp_enqueue_style('prettyPhoto', get_template_directory_uri() .'/css/prettyPhoto.css');
    			wp_enqueue_style('flexslider', get_template_directory_uri() .'/css/flexslider.css');
    			wp_enqueue_style('color', get_template_directory_uri() .'/css/colour.css');
    			wp_enqueue_style('responsive', get_template_directory_uri() .'/css/responsive.css');
    
    		}
    	}
    }
    
    if( !function_exists( 'custom_js' ) ) {
    
        function custom_js() {
    
    		global $data; //fetch options stored in $data
    
    		echo '<script>';
    
    		// Set slideshow autoplay on/off
    		if ( $data['slideshow_autoplay'] ) :
    			echo 'var slideshow_autoplay = true;';
    		else :
    			echo 'var slideshow_autoplay = false;';
    		endif;
    
    		// Set slideshow speed
    		if ( $data['slideshow_speed'] ) :
    			echo 'var slideshow_speed = ' . $data['slideshow_speed'] . ';';
    		else :
    			echo 'var slideshow_speed = 7000;';
    		endif;
    
    		// Check if slideshow contains video
    		if ( $data['slideshow_video'] ) :
    			echo 'var slideshow_video = true;';
    		else :
    			echo 'var slideshow_video = false;';
    		endif;
    
    		echo 'var goText = "' . __('Go to...','qns') . '";';
    
    		echo "</script>\n\n";	
    
        }
    
    }
    
    add_action('wp_footer', 'custom_js');
    
    /* ------------------------------------------------
       Load Files
    ------------------------------------------------ */
    
    // Meta Boxes
    include 'functions/lookbook_meta.php';
    include 'functions/slides_meta.php';
    
    // Shortcodes
    include 'functions/shortcodes/accordion.php';
    include 'functions/shortcodes/googlemap.php';
    include 'functions/shortcodes/gallery.php';
    include 'functions/shortcodes/toggle.php';
    include 'functions/shortcodes/list.php';
    include 'functions/shortcodes/button.php';
    include 'functions/shortcodes/columns.php';
    include 'functions/shortcodes/video.php';
    include 'functions/shortcodes/title.php';
    include 'functions/shortcodes/message.php';
    include 'functions/shortcodes/dropcap.php';
    include 'functions/shortcodes/tabs.php';
    
    // Widgets
    include 'functions/widgets/widget-contact.php';
    include 'functions/widgets/widget-flickr.php';
    include 'functions/widgets/widget-tags.php';
    include 'functions/widgets/widget-recent-posts.php';
    include 'functions/widgets/widget-lookbook.php';
    
    /* ------------------------------------------------
    	Custom CSS
    ------------------------------------------------ */
    
    function custom_css() {
    
    	global $data; //fetch options stored in $data
    
    	// Set Font Family
    	if ( !$data['custom_font'] ) {
    		$custom_font = "'Cardo', serif"; }
    	else {
    		$custom_font =  $data['custom_font'];
    	}
    
    	// Output Custom CSS
    	$output = '<style type="text/css">
    
    		h1, h2, h3, h4, h5, h6, #ui-datepicker-div .ui-datepicker-title, .dropcap, .ui-tabs .ui-tabs-nav li,
    		#title-wrapper h1, #main-menu li, #main-menu li span, .caption, .accommodation_img_price, .single_variation .price, .flex-caption p {
    		font-family: ' . $custom_font . ';
    	}
    
    	' . $data['custom_css'];
    
    	if ( $data['image_logo_width'] ) {
    		$site_title_width = $data['image_logo_width'];
    	}
    	else {
    		$site_title_width = '220';
    	}
    
    	$output .= '#site-title {
    		width: ' . $site_title_width . 'px;
    	}';
    
    	if ( $data['body_background'] and $data['body_background_image'] ) {
    
    		if ( $data['background_repeat'] ) {
    			$background_repeat = $data['background_repeat'];
    		}
    		else {
    			$background_repeat = 'repeat';
    		}
    
    		$output .= 'body {
    			background: url(' . $data['body_background_image'] . ') ' . $data['body_background'] . ' fixed ' . $data['background_repeat'] . ' !important;
    		}';
    	}
    
    	elseif ( $data['body_background'] ) {
    		$output .= 'body {
    			background: ' . $data['body_background'] . ' !important;
    		}';
    	}
    
    	elseif ( $data['body_background_image'] ) {
    		$output .= 'body {
    			background: url(' . $data['body_background_image'] . ') fixed ' . $data['background_repeat'] . ' !important;
    		}';
    	}
    
    	if ( $data['link_hover_color'] ) {
    		$output .= '#main-content a:hover,
    			#main-content-right a:hover,
    			#sidebar a:hover,
    			#sidebar-left a:hover {
    				color: ' . $data['link_hover_color'] . ' !important;
    				-webkit-transition: all 0.3s ease-in-out;
    				-moz-transition: all 0.3s ease-in-out;
    				-o-transition: all 0.3s ease-in-out;
    				-ms-transition: all 0.3s ease-in-out;
    				transition: all 0.3s ease-in-out;
    			}';
    	}
    
    	if ( $data['main_color'] ) {
    		$output .= '.woocommerce .quantity .minus, .woocommerce .quantity .plus {background: ' . $data['main_color'] . ' !important;}
    		.woocommerce .qty-small .quantity .minus, .woocommerce .qty-small .quantity .plus {background: ' . $data['main_color'] . ' !important;}';
    	} else {
    		$output .= '.woocommerce .quantity .minus, .woocommerce .quantity .plus {background: #424242 !important;}
    		.woocommerce .qty-small .quantity .minus, .woocommerce .qty-small .quantity .plus {background: #424242 !important;}';
    	}	
    
    	if ( $data['main_color'] ) {
    		$output .= '.cart-top {
    			background: url(' . get_template_directory_uri() . '/images/tagbottom.png) no-repeat bottom center ' . $data['main_color'] . ';
    		}
    
    		#main-menu li.current_page_item a, #main-menu li a:hover, #main-menu li.sfHover a,
    		.tag-title-large, .price_slider_wrapper .ui-slider .ui-slider-handle, #main-menu li.current-menu-item a, #main-menu .current-menu-ancestor a,
    		#main-menu .current-menu-parent a {
    			background: ' . $data['main_color'] . ';
    		}
    
    		span.onsale {
    			background: ' . $data['main_color'] . ' !important;
    		}
    
    		#main-menu li.current_page_item a,
    		#main-menu li a:hover,
    		#main-menu li.sfHover a,
    		#main-menu,
    		#main-menu li:last-child a:hover,
    		#main-menu li ul,
    		#main-menu li.current-menu-item a,
    		#main-menu .current-menu-ancestor a,
    		#main-menu .current-menu-parent a,
    		#boxed-wrapper {
    			border-color: ' . $data['main_color'] . ';
    		}
    
    		#site-title, #site-title a {
    			color: ' . $data['main_color'] . ';
    		}
    
    		#main-menu li.current_page_item a:before,
    		#main-menu li a:hover:before,
    		#main-menu li.sfHover a:before,
    		#main-menu li.current-menu-item a:before,
    		#main-menu .current-menu-ancestor a:before,
    		#main-menu .current-menu-parent a:before {
    			border-color: ' . $data['main_color'] . ' transparent transparent transparent;
    		}
    
    		#main-menu li.current_page_item a:before, #main-menu li a:hover:before, #main-menu li.sfHover a:before, #main-menu li.current-menu-item a:before, #main-menu li.current-menu-ancestor a:before, #main-menu li.current-menu-parent a:before {
    			border-color: ' . $data['main_color'] . ' transparent transparent !important;
    		}
    
    		.current-menu-parent a {
    			background: ' . $data['main_color'] . ' !important;
    			border-color: ' . $data['main_color'] . ' !important;
    		}
    
    		#main-menu li.current_page_item, #main-menu li.sfHover a, #main-menu li.current-menu-item a, #main-menu li.current-menu-ancestor a, #main-menu li.current-menu-parent a, {
    			background: ' . $data['main_color'] . ' !important;
    			border-left: ' . $data['main_color'] . ' 1px solid !important;
    		}
    
    		.tag-title-large:before {
    			border-color: ' . $data['main_color'] . ' transparent ' . $data['main_color'] . ' transparent;
    		}
    
    		#twitter_icon:hover, #facebook_icon:hover, #googleplus_icon:hover, #skype_icon:hover, #flickr_icon:hover, #linkedin_icon:hover, #vimeo_icon:hover, #youtube_icon:hover, #rss_icon:hover {
    			background-color: ' . $data['main_color'] . ';
    		}
    
    		.tag-title-small {
    			background: ' . $data['main_color'] . ';
    		}
    
    		.tag-title-small:before {
    			border-color: ' . $data['main_color'] . ' transparent ' . $data['main_color'] . ' transparent;
    		}
    
    		/* Main colour in format for IE, "703f3f3f" is the colour #3f3f3f, the "70" added to the front gives 70% */
    		.ie8 .flex-caption p {
    			filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#703f3f3f,endColorstr=#703f3f3f);
    		}
    
    		.flex-direction-nav .flex-prev, .flex-direction-nav .flex-next {
    			background: url(' . get_template_directory_uri() . '/images/slide-arrows.png) ' . $data['main_color'] . ' no-repeat;
    		}
    
    		.flex-direction-nav .flex-prev {
    			background-position: 7px 6px;
    		}
    
    		.flex-direction-nav .flex-next {
    			background-position: -51px 6px;
    		}
    
    		.chosen a {
    			background: url(' . get_template_directory_uri() . '/images/close.png) no-repeat ' . $data['main_color'] . ';
    			background-position: right center;
    		}
    
    		.wp-pagenavi span.current {
    			background: ' . $data['main_color'] . ';
    		}
    
    		.page-content table, #sidebar table, #sidebar-left table, #footer table {
    			border-top: ' . $data['main_color'] . ' 5px solid;
    		}';
    
    	}
    
    	if ( $data['sidebar_title_color'] ) {
    		$output .= '#sidebar .tag-title-small,
    			#sidebar-left .tag-title-small {
    			background: ' . $data['sidebar_title_color'] . ';
    		}
    
    		#sidebar .tag-title-small:before,
    		#sidebar-left .tag-title-small:before {
    			border-color: ' . $data['sidebar_title_color'] . ' transparent ' . $data['sidebar_title_color'] . ' transparent;
    		}
    
    		';
    	}
    
    	if ( $data['main_colorrgba'] ) {
    		$output .= '.flex-caption p {
    			background: ' . $data['main_colorrgba'] . ' !important;
    		}';
    	}
    
    	if ( $data['image_logo_width'] ) {
    		$site_title_width = $data['image_logo_width'];
    	}
    	else {
    		$site_title_width = '220';
    	}
    
    	if ( $data['hide-shop-buttons'] ) {
    		$output .= '.product-button, .variations_button, .qty-product-single, .single_add_to_cart_button, .cart-top {display: none;}
    		.topbar-right {padding: 0;}';
    	}
    
    	if ( $data['hide-shop-prices'] ) {
    		$output .= '.product-price, .product-price-single {display: none;}';
    	}
    
    	$output .= '#site-title, #header-left {
    		width: ' . $site_title_width . 'px;
    	}';
    
    	$output .= '</style>';
    
      return $output;
    }
    
    function admin_style() {
    	wp_enqueue_style('admin-css', get_template_directory_uri().'/css/admin.css');
    }
    
    /* -------------------------------------------------------
    	Remove width / height attributes from gallery images
    ------------------------------------------------------- */
    
    add_filter('wp_get_attachment_link', 'remove_img_width_height', 10, 1);
    
    function remove_img_width_height($html) {
        $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
        return $html;
    }
    
    /* ------------------------------------------------
    	Remove rel attribute from the category list
    ------------------------------------------------ */
    
    function remove_category_list_rel($output)
    {
      $output = str_replace(' rel="category"', '', $output);
      return $output;
    }
    add_filter('wp_list_categories', 'remove_category_list_rel');
    add_filter('the_category', 'remove_category_list_rel');
    
    /* -----------------------------------------------------
    	Remove <p> / <br> tags from nested shortcode tags
    ----------------------------------------------------- */
    
    add_filter('the_content', 'shortcode_fix');
    function shortcode_fix($content)
    {
        $array = array (
            '<p>[' => '[',
            ']</p>' => ']',
            ']<br />' => ']'
        );
    
        $content = strtr($content, $array);
    
    	return $content;
    }
    
    /* ------------------------------------------------
    	Excerpt Length
    ------------------------------------------------ */
    
    function qns_excerpt_length( $length ) {
    
    	if ( is_post_type( "lookbook" )) {
    		return 20;
    	} 
    
    	else {
    		return 45;
    	}
    
    }
    add_filter( 'excerpt_length', 'qns_excerpt_length' );
    
    /* ------------------------------------------------
    	Excerpt More Link
    ------------------------------------------------ */
    
    function qns_continue_reading_link() {
    
    	$btn_text = __('Read More','qns');
    
    	// Don't Display Read More Button On Search Results / Archive Pages
    	if ( is_post_type( "lookbook" )) {
    		return "";
    	}
    
    	else {
    		return ' <p class="blog-button clearfix"><a href="'. get_permalink() . '"' . __( ' class="button1">' . $btn_text . ' &raquo;</a></p>', 'qns' );
    	}
    
    	if ( !is_search() && !is_archive() ) {
    		return ' <p class="blog-button clearfix"><a href="'. get_permalink() . '"' . __( ' class="button1">' . $btn_text . ' &raquo;</a></p>', 'qns' );
    	}
    
    }
    
    function qns_auto_excerpt_more( $more ) {
    	return qns_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'qns_auto_excerpt_more' );
    
    /* ------------------------------------------------
    	The Title
    ------------------------------------------------ */
    
    function qns_filter_wp_title( $title, $separator ) {
    
    	if ( is_feed() )
    		return $title;
    
    	global $paged, $page;
    
    	if ( is_search() ) {
    		$title = sprintf( __( 'Search results for %s', 'qns' ), '"' . get_search_query() . '"' );
    		if ( $paged >= 2 )
    			$title .= " $separator " . sprintf( __( 'Page %s', 'qns' ), $paged );
    		$title .= " $separator " . home_url( 'name', 'display' );
    		return $title;
    	}
    
    	$title .= get_bloginfo( 'name', 'display' );
    
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title .= " $separator " . $site_description;
    
    	if ( $paged >= 2 || $page >= 2 )
    		$title .= " $separator " . sprintf( __( 'Page %s', 'qns' ), max( $paged, $page ) );
    
    	return $title;
    }
    add_filter( 'wp_title', 'qns_filter_wp_title', 10, 2 );
    
    /* ------------------------------------------------
    	Sidebar Position
    ------------------------------------------------ */
    
    function sidebar_position( $position ) {
    
    	global $data; //fetch options stored in $data
    
    	if ( $data['sidebar_position'] ) {
    		$sidebar = $data['sidebar_position'];
    	}
    
    	else {
    		$sidebar = 'right';
    	}
    
    	if ( $sidebar == 'left' && $position == 'primary-content' ) {
    		$output = 'id="main-content-right"';
    	}
    
    	if ( $sidebar == 'right' && $position == 'primary-content' ) {
    		$output = 'id="main-content"';
    	}
    
    	if ( $sidebar == 'left' && $position == 'secondary-content' ) {
    		$output = 'id="sidebar-left"';
    	}
    
    	if ( $sidebar == 'right' && $position == 'secondary-content' ) {
    		$output = 'id="sidebar"';
    	}
    
    	if ( $sidebar == 'none' && $position == 'primary-content' ) {
    		$output = 'id="full-content"';
    	}
    
    	if ( $sidebar == 'none' && $position == 'secondary-content' ) {
    		$output = 'id="sidebar"';
    	}
    
    	return $output;
    
    }
    
    /* ------------------------------------------------
    	Menu Fallback
    ------------------------------------------------ */
    
    function wp_page_menu_qns( $args = array() ) {
    	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
    	$args = wp_parse_args( $args, $defaults );
    	$args = apply_filters( 'wp_page_menu_qns_args', $args );
    
    	$menu = '';
    
    	$list_args = $args;
    
    	// Show Home in the menu
    	if ( ! empty($args['show_home']) ) {
    		if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
    			$text = __('Home','qns');
    		else
    			$text = $args['show_home'];
    		$class = '';
    		if ( is_front_page() && !is_paged() )
    			$class = 'class="current_page_item"';
    		$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
    		// If the front page is a page, add it to the exclude list
    		if (get_option('show_on_front') == 'page') {
    			if ( !empty( $list_args['exclude'] ) ) {
    				$list_args['exclude'] .= ',';
    			} else {
    				$list_args['exclude'] = '';
    			}
    			$list_args['exclude'] .= get_option('page_on_front');
    		}
    	}
    
    	$list_args['echo'] = false;
    	$list_args['title_li'] = '';
    	$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
    
    	if ( $menu )
    		$menu = '<ul id="main-menu" class="fl">' . $menu . '</ul>';
    
    	$menu = $menu . "\n";
    	$menu = apply_filters( 'wp_page_menu_qns', $menu, $args );
    	if ( $args['echo'] )
    		echo $menu;
    	else
    		return $menu;
    }
    
    /* ------------------------------------------------
    	Password Protected Post Form
    ------------------------------------------------ */
    
    add_filter( 'the_password_form', 'qns_password_form' );
    
    function qns_password_form() {
    
    	global $post;
    	$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    	$form = '<div class="msg fail clearfix"><p class="nopassword">' . __( 'This post is password protected. To view it please enter your password below', 'qns' ) . '</p></div>
    <form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post"><label for="' . $label . '">' . __( 'Password', 'qns' ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><div class="clearboth"></div><input id="submit" type="submit" value="' . esc_attr__( "Submit" ) . '" name="submit"></form>';
    	return $form;
    
    }
    
    /* ------------------------------------------------
    	Google Fonts
    ------------------------------------------------ */
    
    function google_fonts() {
    
    	global $data; //fetch options stored in $data
    
    	$output = '';
    
    	if ( !$data['custom_font_code'] ) {
    		$output .= "<link href='http://fonts.googleapis.com/css?family=Cardo:400,400italic,700' rel='stylesheet' type='text/css'>";
    	}
    
    	else {
    		$output .= $data['custom_font_code'];
    	}
    
    	return $output;
    
    }
    
    /* ------------------------------------------------
    	Email Validation
    ------------------------------------------------ */
    
    function valid_email($email) {
    
    	$result = TRUE;
    
    	if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
        	$result = FALSE;
    	}
    
    	return $result;
    
    }
    
    /* ------------------------------------------------
    	Add PrettyPhoto for Attached Images
    ------------------------------------------------ */
    
    add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
    function sant_prettyadd ($content) {
         $content = preg_replace("/<a/","<a
    rel=\"prettyPhoto[slides]\"",$content,1);
         return $content;
    }
    
    /* ------------------------------------------------
    	Social Icons
    ------------------------------------------------ */
    
    function no_icons() {
    
    	global $data; //fetch options stored in $data
    
    	if( $data['social_twitter'] ) { $twitter = $data['social_twitter']; }
    	else { $twitter = ''; }
    
    	if( $data['social_facebook'] ) { $facebook = $data['social_facebook']; }
    	else { $facebook = ''; }
    
    	if( $data['social_googleplus'] ) { $googleplus = $data['social_googleplus']; }
    	else { $googleplus = ''; }
    
    	if( $data['social_skype'] ) { $skype = $data['social_skype']; }
    	else { $skype = ''; }
    
    	if( $data['social_flickr'] ) { $flickr = $data['social_flickr']; }
    	else { $flickr = ''; }
    
    	if( $data['social_linkedin'] ) { $linkedin = $data['social_linkedin']; }
    	else { $linkedin = ''; }
    
    	if( $data['social_vimeo'] ) { $vimeo = $data['social_vimeo']; }
    	else { $vimeo = ''; }
    
    	if( $data['social_youtube'] ) { $youtube = $data['social_youtube']; }
    	else { $youtube = ''; }
    
    	if( $data['social_rss'] ) { $rss = $data['social_rss']; }
    	else { $rss = ''; }
    
    	if ( $twitter == '' && $facebook == '' && $googleplus == '' && $skype == '' && $flickr == '' && $linkedin == '' && $vimeo == '' && $youtube == '' && $rss == '' ) {
    		return true;
    	}
    }
    
    function display_social() {
    
    	global $data; //fetch options stored in $data
    
    	if( $data['social_twitter'] ) { $twitter = $data['social_twitter']; }
    	else { $twitter = ''; }
    
    	if( $data['social_facebook'] ) { $facebook = $data['social_facebook']; }
    	else { $facebook = ''; }
    
    	if( $data['social_googleplus'] ) { $googleplus = $data['social_googleplus']; }
    	else { $googleplus = ''; }
    
    	if( $data['social_skype'] ) { $skype = $data['social_skype']; }
    	else { $skype = ''; }
    
    	if( $data['social_flickr'] ) { $flickr = $data['social_flickr']; }
    	else { $flickr = ''; }
    
    	if( $data['social_linkedin'] ) { $linkedin = $data['social_linkedin']; }
    	else { $linkedin = ''; }
    
    	if( $data['social_vimeo'] ) { $vimeo = $data['social_vimeo']; }
    	else { $vimeo = ''; }
    
    	if( $data['social_youtube'] ) { $youtube = $data['social_youtube']; }
    	else { $youtube = ''; }
    
    	if( $data['social_rss'] ) { $rss = $data['social_rss']; }
    	else { $rss = ''; }
    
    	$output = '';
    
    	if ( no_icons() !== true ) {
    		$output .= '<ul class="social-icons fl">';
    	}	
    
    	if( $twitter !== '' ) {
    		$output .= '<li><a href="' . $twitter . '"><span id="twitter_icon"></span></a></li>';
    	}
    
    	if( $facebook !== '' ) {
    		$output .= '<li><a href="' . $facebook . '"><span id="facebook_icon"></span></a></li>';
    	}
    
    	if( $googleplus !== '' ) {
    		$output .= '<li><a href="' . $googleplus . '"><span id="googleplus_icon"></span></a></li>';
    	}
    
    	if( $skype !== '' ) {
    		$output .= '<li><a href="' . $skype . '"><span id="skype_icon"></span></a></li>';
    	 }
    
    	if( $flickr !== '' ) {
    		$output .= '<li><a href="' . $flickr . '"><span id="flickr_icon"></span></a></li>';
    	}
    
    	if( $linkedin !== '' ) {
    		$output .= '<li><a href="' . $linkedin . '"><span id="linkedin_icon"></span></a></li>';
    	}
    
    	if( $vimeo !== '' ) {
    		$output .= '<li><a href="' . $vimeo . '"><span id="vimeo_icon"></span></a></li>';
    	}
    
    	if( $youtube !== '' ) {
    		$output .= '<li><a href="' . $youtube . '"><span id="youtube_icon"></span></a></li>';
    	}
    
    	if( $rss !== '' ) {
    		$output .= '<li><a href="' . $rss . '"><span id="rss_icon"></span></a></li>';
    	}
    
    	if ( no_icons() !== true ) {
    		$output .= '</ul>';
    	}
    
    	return $output;
    
    }
    
    /* ------------------------------------------------
    	WooCommerce Settings
    ------------------------------------------------ */
    
    /*-----------------------------------------------------------------------------------*/
    /* Hook in on activation */
    /*-----------------------------------------------------------------------------------*/
    
    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'boutique_shop_woocommerce_image_dimensions', 1);
    
    /*-----------------------------------------------------------------------------------*/
    /* Define image sizes / hard crop */
    /*-----------------------------------------------------------------------------------*/
    
    function boutique_shop_woocommerce_image_dimensions() {
    
    // Image sizes
    update_option( 'woocommerce_thumbnail_image_width', '300' ); // Image gallery thumbs
    update_option( 'woocommerce_thumbnail_image_height', '405' );
    update_option( 'woocommerce_single_image_width', '300' ); // Featured product image
    update_option( 'woocommerce_single_image_height', '405' );
    update_option( 'woocommerce_catalog_image_width', '300' ); // Product category thumbs
    update_option( 'woocommerce_catalog_image_height', '405' );
    
    // Hard Crop [0 = false, 1 = true]
    update_option( 'woocommerce_thumbnail_image_crop', 1 );
    update_option( 'woocommerce_single_image_crop', 1 );
    update_option( 'woocommerce_catalog_image_crop', 1 );
    
    }
    
    /* ------------------------------------------------
    	Remove width/height dimensions from <img> tags
    ------------------------------------------------ */
    
    add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
    add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
    
    function remove_thumbnail_dimensions( $html ) {
        $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
        return $html;
    }
    
    /* ------------------------------------------------
    	Disable WooCommerce Breadcrumbs
    ------------------------------------------------ */
    
    remove_action('woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
    
    /* ------------------------------------------------
    	This theme supports WooCommerce, woo!
    ------------------------------------------------ */
    
    add_theme_support( 'woocommerce' );
    
    /* ------------------------------------------------
    	Disable Product Count on Shop Pages
    ------------------------------------------------ */
    
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
    
    /* ------------------------------------------------
    	Set Number of Items to be Displayed Per Page
    ------------------------------------------------ */
    
    if ( $data['shop_per_page'] ) :
    	$shop_per_page = $data['shop_per_page'];
    else :
    	$shop_per_page = '9';
    endif;
    
    add_filter('loop_shop_per_page', create_function('$cols', 'return ' . $shop_per_page . ';'));
    
    /* ------------------------------------------------
    	Lookbook Like Button
    ------------------------------------------------ */
    
    // Ajax Add Actions
    add_action( 'wp_ajax_the_ajax_hook', 'the_action_function' );
    add_action( 'wp_ajax_nopriv_the_ajax_hook', 'the_action_function' ); // need this to serve non logged in users
    
    // Action Function
    function the_action_function($post_id){
    	$post_id = $_POST['post_id'];
    	$prev_value = get_post_meta($post_id , 'qns_lookbook_likes', true);
    	$new_value = $prev_value + 1;
    
    	// Check for cookie so users can only vote once
    	if( isset($_COOKIE['lookbook_like'. $post_id]) ) {
    		echo '<span class="like-count">' . get_post_meta($post_id , 'qns_lookbook_likes', true) . '</span>';
    	}
    	else {
    		update_post_meta($post_id, 'qns_lookbook_likes', $new_value, $prev_value);
    		setcookie('lookbook_like'. $post_id, $post_id, time()+3600*24*30, '/');
    		echo '<span class="like-count">' . get_post_meta($post_id , 'qns_lookbook_likes', true) . ' ' . __('Thanks!','qns') . '</span>';
    	}
    
    die();
    
    }
    
    /* ------------------------------------------------
    	Lookbook Category Display
    ------------------------------------------------ */
    
    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag()) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post','lookbook','nav_menu_item');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    این هم کد فانکشن

    اگه کسی کمک کنه ممنون میشم

درباره‌ی این موضوع



برچسب‌ها

هیچ برچسبی نیست.