wp/wp-content/themes/IN-MOTION-package-u1/in-motion/functions.php
changeset 0 d970ebf37754
child 1 f6eb5a861d2f
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 <?php
       
     2 	/* to remove notifications for upgrade wordpress */
       
     3 	add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
       
     4 
       
     5 	load_theme_textdomain('pego_tr',get_template_directory() . '/languages');
       
     6 		
       
     7 	$themedir = get_template_directory_uri();
       
     8 		
       
     9 	function my_scripts() {
       
    10 		global $themedir;
       
    11 		wp_enqueue_script('slides-min-jquery', $themedir . '/js/slides.min.jquery.js','','',true); 					
       
    12 		wp_enqueue_script('jquery-ui-min', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js','','',true);
       
    13 		wp_enqueue_script('jquery-easing', $themedir . '/js/jquery.easing.1.3.js','','',true);
       
    14 		wp_enqueue_script('jquery-iconmenu', $themedir . '/js/jquery.iconmenu.js','','',true);		
       
    15 		wp_enqueue_script('jquery-nav-min', $themedir . '/js/jquery.nav.min.js','','',true);						
       
    16 		wp_enqueue_script('jquery-nav', $themedir . '/js/jquery.nav.js','','',true);									
       
    17 		wp_enqueue_script('plugins', $themedir . '/js/plugins.js','','',true); 										
       
    18 		wp_enqueue_script('jquery-quicksand', $themedir . '/js/jquery.quicksand.js','','',true); 						
       
    19 		wp_enqueue_script('main', $themedir . '/js/main.js','','',true); 												
       
    20 		wp_enqueue_script('script', $themedir . '/js/script.js','','',true);				
       
    21 		wp_enqueue_script('jquery-tipsy', $themedir . '/js/jquery.tipsy.js','','',true);  
       
    22 		wp_enqueue_script('jquery-validate-pack', $themedir . '/js/jquery.validate.pack.js','','',true);	
       
    23 		wp_enqueue_script('jquery-mousewheel', $themedir . '/fancybox/jquery.mousewheel-3.0.4.pack.js','','',true); 	
       
    24 		wp_enqueue_script('jquery-fancybox-pack', $themedir . '/fancybox/jquery.fancybox-1.3.4.pack.js','','',true);		
       
    25 	}	 
       
    26 	add_action('init', 'my_scripts');
       
    27 	
       
    28 	
       
    29 	/* specify content width */
       
    30 	if ( ! isset( $content_width ) ) $content_width = 960;
       
    31 	
       
    32 	
       
    33 	/* code for menus */
       
    34 	if (function_exists('register_nav_menus')) {
       
    35 		register_nav_menus (
       
    36 			array (
       
    37 				'main_nav' => 'Main Navigation Menu'
       
    38 			)
       
    39 		);
       
    40 	}
       
    41 	
       
    42 	// Declare sidebar widget zone
       
    43     if (function_exists('register_sidebar')) {
       
    44     	register_sidebar(array(
       
    45     		'name' => 'Sidebar-1 Widgets',
       
    46     		'id'   => 'sidebar-1-widgets',
       
    47     		'description'   => 'These are widgets for the sidebar.',
       
    48     		'before_widget' => '<div id="%1$s" class="widget %2$s">',
       
    49     		'after_widget'  => '</div></div>',
       
    50     		'before_title'  => '<h3 class="sidebar-style">',
       
    51     		'after_title'   => '</h3><div class="lh15">'
       
    52     	));
       
    53     }
       
    54 
       
    55 	/* start footer widgets */
       
    56 	function new_widgets_init() {		
       
    57 		register_sidebar(array(
       
    58 			'name' => 'Footer First Column Sidebar',
       
    59 			'id' => 'first-footer-column-sidebar',
       
    60 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
       
    61 			'after_widget' => '</div>',
       
    62 			'before_title' => '<h4 class="widget-title">',
       
    63 			'after_title' => '</h4>',
       
    64 		));
       
    65 		register_sidebar(array(
       
    66 			'name' => 'Footer Second Column Sidebar',
       
    67 			'id' => 'second-footer-column-sidebar',
       
    68 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
       
    69 			'after_widget' => '</div>',
       
    70 			'before_title' => '<h4 class="widget-title">',
       
    71 			'after_title' => '</h4>',
       
    72 		));
       
    73 		register_sidebar(array(
       
    74 			'name' => 'Footer  Third Column Sidebar',
       
    75 			'id' => 'third-footer-column-sidebar',
       
    76 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
       
    77 			'after_widget' => '</div>',
       
    78 			'before_title' => '<h4 class="widget-title">',
       
    79 			'after_title' => '</h4>',
       
    80 		));
       
    81 		register_sidebar(array(
       
    82 			'name' => 'Footer  Fourth  Column 	Sidebar',
       
    83 			'id' => 'fourth-footer-column-sidebar',
       
    84 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
       
    85 			'after_widget' => '</div>',
       
    86 			'before_title' => '<h4 class="widget-title">',
       
    87 			'after_title' => '</h4>',
       
    88 		));
       
    89 	}
       
    90 	add_action( 'init', 'new_widgets_init' );
       
    91 	/* end footer widgets */
       
    92 	
       
    93 	
       
    94 	add_theme_support('post-thumbnails');
       
    95 	
       
    96 	
       
    97 	
       
    98 	if(!function_exists('getPageTitle'))
       
    99 		{
       
   100 			function getPageTitle($pageId)
       
   101 			{
       
   102 				if(!is_numeric($pageId))
       
   103 				{
       
   104 					return;
       
   105 				}
       
   106 				global $wpdb;
       
   107 				$sql_query = 'SELECT DISTINCT * FROM ' . $wpdb->posts .
       
   108 				' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
       
   109 				$posts = $wpdb->get_results($sql_query);
       
   110 				if(!empty($posts))
       
   111 				{
       
   112 					foreach($posts as $post)
       
   113 				{
       
   114 					return nl2br($post->post_title);
       
   115 				}
       
   116 			}
       
   117 		}
       
   118 	}
       
   119 	
       
   120 	
       
   121 	function getPostViews($postID){
       
   122 		$count_key = 'post_views_count';
       
   123 		$count = get_post_meta($postID, $count_key, true);
       
   124 		if($count==''){
       
   125 			delete_post_meta($postID, $count_key);
       
   126 			add_post_meta($postID, $count_key, '0');
       
   127 			return "0 View";
       
   128 		}
       
   129 		return $count;
       
   130 	}
       
   131 	function setPostViews($postID) {
       
   132 		$count_key = 'post_views_count';
       
   133 		$count = get_post_meta($postID, $count_key, true);
       
   134 		if($count==''){
       
   135 			$count = 0;
       
   136 			delete_post_meta($postID, $count_key);
       
   137 			add_post_meta($postID, $count_key, '0');
       
   138 		}else{
       
   139 			$count++;
       
   140 			update_post_meta($postID, $count_key, $count);
       
   141 		}
       
   142 	}	
       
   143 	function SearchFilter($query) {
       
   144 	if ($query->is_search) {
       
   145 	$query->set('post_type', 'post');
       
   146 	}
       
   147 	return $query;
       
   148 	}
       
   149 	 
       
   150 	add_filter('pre_get_posts','SearchFilter');
       
   151 	
       
   152 	include("functions/widget-posts.php");
       
   153 	include("functions/widget-twitter.php");
       
   154 	include("functions/widget-Flickr.php");
       
   155 	include("functions/widget-video.php");
       
   156 	include("functions/custom-post.php");
       
   157 	include("functions/custom-portfolio.php");
       
   158 	include("functions/custom-page.php");
       
   159 	include("functions/shortcodes.php");
       
   160 	include("functions/contact.php");
       
   161 	
       
   162 	
       
   163 	function menu($page_number){
       
   164 			   echo	'<ul  class="menu menu-inside">';
       
   165             $page_args = array('sort_order' => 'ASC', 'sort_column' => 'menu_order');
       
   166             $pages = get_pages($page_args); 
       
   167             $menu_items=1;
       
   168             foreach ($pages as $single_page) {
       
   169             		$trenutni="";
       
   170 						if ($page_number == $menu_items) { $trenutni="class='current'";}	
       
   171             		//if(($menu_items==1)&&(!is_single())){ $trenutni=" current";}
       
   172             		
       
   173             		$pageTemplate= get_post_meta($single_page->ID , 'page_template' , true);
       
   174             		if((($pageTemplate=='Blog')&&(is_single()))||(($pageTemplate=='Blog')&&(is_search()))||(($pageTemplate=='Blog')&&(is_archive())))
       
   175             		{ 
       
   176             			$trenutni="class='current'";
       
   177             		}	 
       
   178             		
       
   179             	   $pageInMenu= get_post_meta($single_page->ID, 'show_page_in_menu' , true);
       
   180             	   $url_tab = "#"; 
       
   181             	   if (!is_front_page()){
       
   182             	   	 $url_tab = get_option("siteurl")."#";
       
   183             	   }
       
   184             	   $menu_items++;
       
   185             		if ($pageInMenu == 'Yes') {
       
   186                   	echo '<li '.$trenutni.'><a class="boxes" href="' . $url_tab . $single_page->post_name . '">' . $single_page->post_title . '</a></li> ';
       
   187                   }
       
   188             }   
       
   189 				echo 	'</ul>';
       
   190 	}
       
   191 	
       
   192 	function topHeaderDisplay()
       
   193 	{
       
   194 		echo '<div id="top-header">';
       
   195 			echo '<div id="logo2">';
       
   196 						if ( function_exists( 'get_option_tree' ) ) {
       
   197 							$logo = get_option_tree( 'logo' );
       
   198 						}
       
   199 						if ( $logo ) { 							
       
   200 							echo '<a href="'.home_url().'" title="Go Home"><img src="'. get_option_tree( 'logo' ) .'" /></a>';
       
   201 						} 									
       
   202 				 
       
   203 			echo '</div>';
       
   204       	$socials2='';
       
   205 			if ( function_exists( 'get_option_tree' ) ) {
       
   206     		    	if (get_option_tree( 'social_icons')) {
       
   207     		    				$socials2= get_option_tree( 'social_icons', $option_tree, false, true, -1 );
       
   208     		    				$img_num = 1;
       
   209     		    				if(!empty($socials2)){ 
       
   210     		    				echo '<div class="all-socials">';
       
   211 								echo '<ul class="tt-wrapper2">';
       
   212 								
       
   213 							
       
   214 								foreach( $socials2 as $social ) {
       
   215 									echo '<li><a href="'.$social['link'].'" target="_blank" title="'.$social['title'].'" style="background: transparent url('.$social['image'].') no-repeat top left;"><span>'.$social['title'].'</span></a></li>';
       
   216 								}
       
   217 								echo '</ul></div>';
       
   218 					} } }
       
   219 		echo '</div>';		
       
   220 	}
       
   221 	
       
   222 	
       
   223 	
       
   224 	
       
   225 	
       
   226 /* start for comments */
       
   227 if ( ! function_exists( 'inmotion_comment' ) ) :
       
   228 function inmotion_comment( $comment, $args, $depth ) {
       
   229 	$GLOBALS['comment'] = $comment;
       
   230 	switch ( $comment->comment_type ) :
       
   231 		case 'pingback' :
       
   232 		case 'trackback' :
       
   233 	?>
       
   234 	<li class="post pingback">
       
   235 		<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
       
   236 	<?php
       
   237 			break;
       
   238 		default :
       
   239 	?>
       
   240 	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
       
   241 		<article id="comment-<?php comment_ID(); ?>" class="comment">
       
   242 			<footer class="comment-meta">
       
   243 				<div class="comment-author vcard">
       
   244 					<?php
       
   245 						$avatar_size = 39;
       
   246 						if ( '0' != $comment->comment_parent )
       
   247 							$avatar_size = 39;
       
   248 
       
   249 						echo get_avatar( $comment, $avatar_size );
       
   250 
       
   251 						/* translators: 1: comment author, 2: date and time */
       
   252 						printf( '%1$s <span class="date-and-time">%2$s</span>',
       
   253 							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
       
   254 							sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
       
   255 								esc_url( get_comment_link( $comment->comment_ID ) ),
       
   256 								get_comment_time( 'c' ),
       
   257 								/* translators: 1: date, 2: time */
       
   258 								sprintf( '%1$s at %2$s', get_comment_date(), get_comment_time() )
       
   259 							)
       
   260 						);
       
   261 					?>
       
   262 
       
   263 					<?php edit_comment_link( __( 'Edit', 'pego_tr' ), '<span class="edit-link">', '</span>' ); ?>
       
   264 				</div><!-- .comment-author .vcard -->
       
   265 
       
   266 				<?php if ( $comment->comment_approved == '0' ) : ?>
       
   267 					<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'pego_tr' ); ?></em>
       
   268 					<br />
       
   269 				<?php endif; ?>
       
   270 
       
   271 			</footer>
       
   272 
       
   273 			<div class="comment-content"><?php comment_text(); ?></div>
       
   274 
       
   275 			<div class="reply">
       
   276 				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'pego_tr' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
       
   277 			</div><!-- .reply -->
       
   278 		</article><!-- #comment-## -->
       
   279 
       
   280 	<?php
       
   281 			break;
       
   282 	endswitch;
       
   283 }
       
   284 endif; // ends check for inmotion_comment()
       
   285 	
       
   286 /* end for comments */
       
   287 	
       
   288 ?>