wp/wp-content/themes/themeforest-2964855-scrn-responsive-single-page-portfolio/SCRN/functions.php
changeset 8 c7c34916027a
parent 7 cf61fcea0001
child 9 177826044cd9
equal deleted inserted replaced
7:cf61fcea0001 8:c7c34916027a
     1 <?php 
       
     2 
       
     3 $scrn = get_option('scrn');
       
     4 
       
     5 add_action( 'after_setup_theme', 'vp_setup' );
       
     6 
       
     7 if ( ! function_exists( 'vp_setup' ) ){
       
     8 
       
     9 	function vp_setup(){
       
    10 
       
    11 		global $scrn;
       
    12 
       
    13 		require get_template_directory() . '/teoPanel/custom-functions.php';
       
    14 
       
    15 		require get_template_directory() . '/includes/shortcodes.php';
       
    16 
       
    17 		require get_template_directory() . '/includes/comments.php';
       
    18 
       
    19 		require get_template_directory() . '/includes/additional_functions.php';
       
    20 
       
    21 		load_theme_textdomain('SCRN', get_template_directory() . '/languages');
       
    22 
       
    23 		$current_user = wp_get_current_user();
       
    24 
       
    25 		if($scrn['superadmin'] == '' || $current_user->user_login == $scrn['superadmin'])
       
    26 
       
    27 			require 'teoPanel/nhp-options.php';
       
    28 
       
    29 	}
       
    30 
       
    31 }
       
    32 
       
    33 // Loading js files into the theme
       
    34 
       
    35 add_action('wp_head', 'vp_scripts');
       
    36 
       
    37 if ( !function_exists('vp_scripts') ) {
       
    38 
       
    39 	function vp_scripts() {
       
    40 
       
    41 		global $scrn;
       
    42 
       
    43 		wp_enqueue_script( 'jquery-sticky', get_template_directory_uri() . '/js/jquery.sticky.js', array(), '1.0');
       
    44 
       
    45 		wp_enqueue_script( 'smooth-scroll', get_template_directory_uri() . '/js/jquery.smooth-scroll.js', array(), '1.0');
       
    46 
       
    47 		wp_enqueue_script( 'contact-form', get_template_directory_uri() . '/js/contact-form.js', array(), '1.0');
       
    48 
       
    49 		wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array(), '1.0');
       
    50 
       
    51 		wp_enqueue_script( 'prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array(), '1.0');
       
    52 
       
    53 		wp_enqueue_script( 'inview', get_template_directory_uri() . '/js/jquery.inview.js', array(), '1.0');
       
    54 
       
    55 		if ( is_singular() && get_option( 'thread_comments' ) )
       
    56 
       
    57     		wp_enqueue_script( 'comment-reply' );
       
    58 
       
    59 	}
       
    60 
       
    61 
       
    62 
       
    63 }
       
    64 
       
    65 
       
    66 
       
    67 //Loading the CSS files into the theme
       
    68 
       
    69 add_action('wp_enqueue_scripts', 'vp_load_css');
       
    70 
       
    71 if( !function_exists('vp_load_css') ) {
       
    72 
       
    73 	function vp_load_css() {
       
    74 
       
    75 		global $scrn;
       
    76 
       
    77 		wp_enqueue_style( 'base', get_template_directory_uri() . '/css/base.css', array(), '1.0');
       
    78 
       
    79 		wp_enqueue_style( 'layout', get_template_directory_uri() . '/css/layout.css', array(), '1.0');
       
    80 
       
    81 		wp_enqueue_style( 'skeleton', get_template_directory_uri() . '/css/skeleton.css', array(), '1.0');
       
    82 
       
    83 		wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css', array(), '1.0');
       
    84 
       
    85 		wp_enqueue_style( 'prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css', array(), '1.0');
       
    86 
       
    87 		wp_enqueue_style( 'source-sans', 'http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700,400italic,600italic,700italic', array());
       
    88 
       
    89 		wp_enqueue_style( 'oswald', 'http://fonts.googleapis.com/css?family=Oswald:400,700,300', array());
       
    90 
       
    91 		wp_enqueue_script('jquery');
       
    92 
       
    93 		wp_enqueue_script( 'cycle', get_template_directory_uri() . '/js/jquery.cycle.all.min.js');
       
    94 
       
    95 		wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array(), '1.0');
       
    96 
       
    97 		if(isset($scrn['custom_css']) && $scrn['custom_css'] != '')
       
    98 
       
    99 			echo '<style type="text/css">' . $scrn['custom_css'] . '</style>';
       
   100 
       
   101 	}
       
   102 
       
   103 }
       
   104 
       
   105 
       
   106 
       
   107 add_action('init', 'vp_misc');
       
   108 
       
   109 function vp_misc() {
       
   110 
       
   111 	global $scrn;
       
   112 
       
   113 	if(isset($scrn['wordpress_version']) && $scrn['wordpress_version'] == 0)
       
   114 
       
   115 		remove_action('wp_head', 'wp_generator'); 
       
   116 
       
   117 	add_filter('show_admin_bar', '__return_false');
       
   118 
       
   119 	add_theme_support( 'automatic-feed-links' );
       
   120 
       
   121 	
       
   122 
       
   123 }
       
   124 
       
   125 if ( ! isset( $content_width ) ) $content_width = 960;
       
   126 
       
   127 
       
   128 
       
   129 function encEmail ($orgStr) {
       
   130 
       
   131     $encStr = "";
       
   132 
       
   133     $nowStr = "";
       
   134 
       
   135     $rndNum = -1;
       
   136 
       
   137 
       
   138 
       
   139     $orgLen = strlen($orgStr);
       
   140 
       
   141     for ( $i = 0; $i < $orgLen; $i++) {
       
   142 
       
   143         $encMod = rand(1,2);
       
   144 
       
   145         switch ($encMod) {
       
   146 
       
   147         case 1: // Decimal
       
   148 
       
   149             $nowStr = "&#" . ord($orgStr[$i]) . ";";
       
   150 
       
   151             break;
       
   152 
       
   153         case 2: // Hexadecimal
       
   154 
       
   155             $nowStr = "&#x" . dechex(ord($orgStr[$i])) . ";";
       
   156 
       
   157             break;
       
   158 
       
   159         }
       
   160 
       
   161         $encStr .= $nowStr;
       
   162 
       
   163     }
       
   164 
       
   165     return $encStr;
       
   166 
       
   167 } 
       
   168 
       
   169 
       
   170 
       
   171 function register_menus() {
       
   172 
       
   173 	register_nav_menus( array( 'top-menu' => 'Top primary menu')
       
   174 
       
   175 						);
       
   176 
       
   177 }
       
   178 
       
   179 add_action('init', 'register_menus');
       
   180 
       
   181 
       
   182 
       
   183 class description_walker extends Walker_Nav_Menu
       
   184 
       
   185 {
       
   186 
       
   187       function start_el(&$output, $item, $depth, $args)
       
   188 
       
   189       {
       
   190 
       
   191            global $wp_query;
       
   192 
       
   193            $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
       
   194 
       
   195 
       
   196 
       
   197            $class_names = $value = '';
       
   198 
       
   199 
       
   200 
       
   201            $classes = empty( $item->classes ) ? array() : (array) $item->classes;
       
   202 
       
   203 
       
   204 
       
   205            $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
       
   206 
       
   207            $class_names = ' class="'. esc_attr( $class_names ) . '"';
       
   208 
       
   209 
       
   210 
       
   211            $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
       
   212 
       
   213 
       
   214 
       
   215            $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
       
   216 
       
   217            $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
       
   218 
       
   219            $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
       
   220 
       
   221            if($item->object == 'page')
       
   222 
       
   223            {
       
   224 
       
   225                 $varpost = get_post($item->object_id);
       
   226 
       
   227                 $attributes .= ' href="#' . $varpost->post_name . '"';
       
   228 
       
   229            }
       
   230 
       
   231            else
       
   232 
       
   233                 $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
       
   234 
       
   235             $item_output = $args->before;
       
   236 
       
   237             $item_output .= '<a'. $attributes .'>';
       
   238 
       
   239             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID );
       
   240 
       
   241             $item_output .= $args->link_after;
       
   242 
       
   243             $item_output .= '</a>';
       
   244 
       
   245             $item_output .= $args->after;
       
   246 
       
   247 
       
   248 
       
   249             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
       
   250 
       
   251             }
       
   252 
       
   253 }
       
   254 
       
   255 
       
   256 
       
   257 add_filter( 'posts_orderby', 'sort_query_by_post_in', 10, 2 );
       
   258 
       
   259 	
       
   260 
       
   261 function sort_query_by_post_in( $sortby, $thequery ) {
       
   262 
       
   263 	if ( !empty($thequery->query['post__in']) && isset($thequery->query['orderby']) && $thequery->query['orderby'] == 'post__in' )
       
   264 
       
   265 		$sortby = "find_in_set(ID, '" . implode( ',', $thequery->query['post__in'] ) . "')";
       
   266 
       
   267 	
       
   268 
       
   269 	return $sortby;
       
   270 
       
   271 }
       
   272 
       
   273 
       
   274 
       
   275 ?>