festival_lgbt /wp-content/themes/eclipse/core/core-functions.php

Language PHP Lines 394
MD5 Hash c15e4aee766d338146c05925c9cd5ba9
Repository https://github.com/Bochet/festival_lgbt.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<?php
/**
* CyberChimps response Core Functions
*
* Authors: Tyler Cunningham
* Copyright: Š 2012
* {@link http://cyberchimps.com/ CyberChimps LLC}
*
* Released under the terms of the GNU General Public License.
* You should have received a copy of the GNU General Public License,
* along with this software. In the main directory, see: /licensing/
* If not, see: {@link http://www.gnu.org/licenses/}.
*
* @package response
* @since 1.0
*/

/**
* Load styles.
*/ 

function eclipse_styles() {
	global $options, $ec_themeslug, $wp_styles;
	
	// set paths to stylesheet dir
	$core_path =  get_template_directory_uri() ."/core/css";
	$path = get_template_directory_uri() ."/css";
	
	// register stylesheets
	wp_register_style( 'foundation', $core_path.'/foundation.css' );
	wp_register_style( 'foundation_apps', $core_path.'/app.css', array( 'foundation' ) );
	wp_register_style( 'shortcode', $path.'/shortcode.css' );
	wp_register_style( 'eclipse_style', $path.'/style.css', array( 'foundation' ) );
	wp_register_style( 'elements', $path.'/elements.css', array( 'foundation', 'eclipse_style' ) );
	
	// ie conditional stylesheet
	wp_register_style( 'eclipse_ie', $core_path.'/ie.css' );
	$wp_styles->add_data( 'eclipse_ie', 'conditional', 'IE' );
	
	// child theme support
	wp_register_style( 'child_theme', get_stylesheet_directory_uri().'/style.css', array( 'eclipse_style' ) );
	if( is_child_theme() ) {
		wp_enqueue_style( 'child_theme' );
	}
	
	// get fonts
	if ($options->get($ec_themeslug.'_font') == "" AND $options->get($ec_themeslug.'_custom_font') == "") {
		$font = apply_filters( 'synapse_default_font', 'Arial' );
	}		
	elseif ($options->get($ec_themeslug.'_custom_font') != "" && $options->get($ec_themeslug.'_font') == 'custom') {
		$font = $options->get($ec_themeslug.'_custom_font');	
	}	
	else {
		$font = $options->get($ec_themeslug.'_font'); 
	} 
	
	// register font stylesheet
	if( $font == 'Actor' ||
		$font == 'Coda' ||
		$font == 'Maven Pro' ||
		$font == 'Metrophobic' ||
		$font == 'News Cycle' ||
		$font == 'Nobile' ||
		$font == 'Tenor Sans' ||
		$font == 'Quicksand' ||
		$font == 'Ubuntu') {
		
		// Check if SSL is present, if so then use https othereise use http
		$protocol = is_ssl() ? 'https' : 'http';
		wp_register_style( 'fonts', $protocol . '://fonts.googleapis.com/css?family='.$font, array( 'eclipse_style' ) ); 		
	}
	
	// enqueue stylesheets
	wp_enqueue_style( 'foundation' );
	wp_enqueue_style( 'foundation_apps' );
	wp_enqueue_style( 'shortcode' );
	wp_enqueue_style( 'eclipse_style' );
	wp_enqueue_style( 'elements' );
	wp_enqueue_style( 'fonts' );
	wp_enqueue_style( 'eclipse_ie' );
}

add_action( 'wp_enqueue_scripts', 'eclipse_styles' );

/**
* Load jQuery and register additional scripts.
*/ 
function response_scripts() {
	global $options, $ec_themeslug;
	if ( !is_admin() ) {
	wp_enqueue_script('jquery');
	wp_enqueue_script('jquery-ui-tabs');
	}
	
	$path =  get_template_directory_uri() ."/core/library";
	
	wp_register_script( 'orbit' ,$path.'/js/foundation/jquery.orbit.js');
	wp_register_script( 'apps' ,$path.'/js/foundation/app.js');
	wp_register_script( 'placeholder' ,$path.'/js/foundation/jquery.placeholder.min.js');
	wp_register_script( 'reveal' ,$path.'/js/foundation/jquery.reveal.js');
	wp_register_script( 'tooltips' ,$path.'/js/foundation/jquery.tooltips.js');
	wp_register_script( 'modernizr' ,$path.'/js/foundation/modernizr.foundation.js');
	wp_register_script( 'menu' ,$path.'/js/menu.js');
	wp_register_script( 'slimbox' ,$path.'/js/jquery.slimbox.js');
	wp_register_script( 'plusone' ,$path.'/js/plusone.js');
	wp_register_script( 'mobilemenu' ,$path.'/js/mobilemenu.js');
	wp_register_script( 'oembed' ,$path.'/js/oembed-twitter.js');
	
	wp_enqueue_script ('orbit');
	wp_enqueue_script ('apps');
	wp_enqueue_script ('placeholder');
	wp_enqueue_script ('reveal');
	wp_enqueue_script ('tooltips');
	wp_enqueue_script ('modernizr');
	wp_enqueue_script ('menu');
	wp_enqueue_script ('slimbox');
	wp_enqueue_script ('plusone');
	wp_enqueue_script ('mobilemenu');
	wp_enqueue_script ('oembed');
	if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
	
	if ($options->get($ec_themeslug.'_responsive_video') == '1' ) {
	
		wp_register_script( 'video' ,$path.'/js/video.js');
		wp_enqueue_script ('video');	
	}

}
add_action('wp_enqueue_scripts', 'response_scripts');	

/**
* Custom pagination.
*
* @since 1.0
*/
function response_custom_pagination($pages = '', $range = 4)
{
     $showitems = ($range * 2)+1;  
 
     global $paged;
     if(empty($paged)) $paged = 1;
 
     if($pages == '')
     {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if(!$pages)
         {
             $pages = 1;
         }
     }   
 
     if(1 != $pages)
     {
         echo '<div class="pagination"><span>'.__( 'Page', 'core' ).' '.$paged.' of '.$pages.'</span>';
         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<a href="'.get_pagenum_link(1).'">'.__( '&laquo; First', 'response' ).'</a>';
         if($paged > 1 && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged - 1).'">'.__( '&lsaquo; Previous', 'response' ).'</a>';
 
         for ($i=1; $i <= $pages; $i++)
         {
             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
             {
                 echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
             }
         }
 
         if ($paged < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged + 1).'"">'.__( 'Next &rsaquo;', 'response').'</a>';
         if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($pages).'">'.__( 'Last &raquo;', 'response' ).'</a>';
         echo "</div>\n";
     }
}


/**
* Truncate next/previous post link text for post pagination.
*
* @since 1.0
*/
function response_shorten_linktext($linkstring,$link) {
	$characters = 33;
	preg_match('/<a.*?>(.*?)<\/a>/is',$linkstring,$matches);
	$displayedTitle = $matches[1];
	$newTitle = shorten_with_ellipsis($displayedTitle,$characters);
	return str_replace('>'.$displayedTitle.'<','>'.$newTitle.'<',$linkstring);
}

function shorten_with_ellipsis($inputstring,$characters) {
  return (strlen($inputstring) >= $characters) ? substr($inputstring,0,($characters-3)) . '...' : $inputstring;
}

add_filter('previous_post_link','response_shorten_linktext',10,2);
add_filter('next_post_link','response_shorten_linktext',10,2);

/**
* Comment function
*
* @since 1.0
*/
function response_comment($comment, $args, $depth) {
	global $ec_root;
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php echo get_avatar( $comment, 66 ); ?>
      </div>
      <img class="triangle" style="margin-bottom: -30px; margin-left: 7px;" src="<?php echo "$ec_root/images/comment-triangle.png";?>">
     <div style="background-color: #1a1a1a; margin-left: 100px; padding: 15px 15px 10px 10px; margin-top: -18px; border-radius: 4px; ;">
     <div class="comment-meta commentmetadata">     <span class="comment_author" style="float:left"><?php printf(__('<cite class="fn">%s</cite> <span class="says"></span>'), get_comment_author_link()) ?></span><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s', 'core' ), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)', 'core' ),'  ','') ?> | <span class="reply"> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></span>
     </div>
      
      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.', 'core' ) ?></em>
         <br />
      <?php endif; ?>
		
		<div class="comment_wrap">	
      <?php comment_text() ?>
      </div>

     </div></div>
<?php
}

/**
* Breadcrumbs function
*
* @since 1.0
*/
function response_breadcrumbs() {
  global $ec_root;
  
  $delimiter = "<img src='$ec_root/images/breadcrumb-arrow.png'>";
  $home = 'Home'; // text for the 'Home' link
  $before = '<span class="current">'; // tag before the current crumb
  $after = '</span>'; // tag after the current crumb
 
  if ( !is_home() && !is_front_page() || is_paged() ) {
 
    echo '<div class="row"><div id="crumbs" class="twelve columns"><div class="crumbs_text">';
 
    global $post;
    $homeLink = home_url();
    echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
 
    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, ' ' . $delimiter . ' '));
      echo $before . 'Archive for category "' . single_cat_title('', false) . '"' . $after;
 
    } elseif ( is_day() ) {
      echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
      echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
      echo $before . get_the_time('d') . $after;
 
    } elseif ( is_month() ) {
      echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
      echo $before . get_the_time('F') . $after;
 
    } elseif ( is_year() ) {
      echo $before . get_the_time('Y') . $after;
 
    } elseif ( is_single() && !is_attachment() ) {
      if ( get_post_type() != 'post' ) {
        $post_type = get_post_type_object(get_post_type());
        $slug = $post_type->rewrite;
        echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
        echo $before . get_the_title() . $after;
      } else {
        $cat = get_the_category(); $cat = $cat[0];
        echo is_wp_error( $cat_parents = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ') ) ? '' : $cat_parents;
        echo $before . get_the_title() . $after;
      }
 
    } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
      $post_type = get_post_type_object(get_post_type());
      echo $before . $post_type->labels->singular_name . $after;
 
    } elseif ( is_attachment() ) {
      $parent = get_post($post->post_parent);
      $cat = get_the_category($parent->ID); $cat = $cat[0];
      echo is_wp_error( $cat_parents = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ') ) ? '' : $cat_parents;
      echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
      echo $before . get_the_title() . $after;
 
    } elseif ( is_page() && !$post->post_parent ) {
      echo $before . get_the_title() . $after;
 
    } elseif ( is_page() && $post->post_parent ) {
      $parent_id  = $post->post_parent;
      $breadcrumbs = array();
      while ($parent_id) {
        $page = get_page($parent_id);
        $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
        $parent_id  = $page->post_parent;
      }
      $breadcrumbs = array_reverse($breadcrumbs);
      foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
      echo $before . get_the_title() . $after;
 
    } elseif ( is_search() ) {
      echo $before . 'Search results for "' . get_search_query() . '"' . $after;
 
    } elseif ( is_tag() ) {
      echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
 
    } elseif ( is_author() ) {
       global $author;
      $userdata = get_userdata($author);
      echo $before . 'Articles posted by ' . $userdata->display_name . $after;
 
    } elseif ( is_404() ) {
      echo $before . 'Error 404' . $after;
    }
 
    if ( get_query_var('paged') ) {
      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
      echo __('Page', 'response') . ' ' . get_query_var('paged');
      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
    }
 
    echo '</div></div></div>';
 
  }
} 

function response_title_tag_filter( $old_title ) {
	global $options, $themeslug, $query, $post; 
	
	$blogtitle = ($options->get($themeslug.'_home_title'));
	if (!is_404()) {
		$title = get_post_meta($post->ID, 'seo_title' , true);
	}
	else {
		$title = '';
	}
	
	if (function_exists('is_tag') && is_tag()) { /*Title for tags */
		$title_tag = get_bloginfo('name').' - Tag Archive for &quot;'.single_tag_title("", FALSE).'&quot;  ';
	}
	elseif( is_feed() ) {
		$title_tag = '';
	}
	elseif (is_archive()) { /*Title for archives */ 
		$title_tag = get_bloginfo('name').$old_title.' Archive '; 
	}    
	elseif (is_search()) { /*Title for search */ 
		$title_tag = get_bloginfo('name').' - Search for &quot;'.get_search_query().'&quot;  '; 
	}    
	elseif (is_404()) { /*Title for 404 */
		$title_tag = get_bloginfo('name').' - Not Found '; 
	}
	elseif (is_front_page() AND !is_page() AND $blogtitle == '') { /*Title if front page is latest posts and no custom title */
		$title_tag = get_bloginfo('name').' - '.get_bloginfo('description'); 
	}
	elseif (is_front_page() AND !is_page() AND $blogtitle != '') { /*Title if front page is latest posts with custom title */
		$title_tag = get_bloginfo('name').' - '.$blogtitle ; 
	}
	elseif (is_front_page() AND is_page() AND $title == '') { /*Title if front page is static page and no custom title */
		$title_tag = get_bloginfo('name').' - '.get_bloginfo('description'); 
	}
	elseif (is_front_page() AND is_page() AND $title != '') { /*Title if front page is static page with custom title */
		$title_tag = get_bloginfo('name').' - '.$title ; 
	}
	elseif (is_page() AND $title == '') { /*Title if static page is static page with no custom title */
		$title_tag = get_bloginfo('name').$old_title; 
	}
	elseif (is_page() AND $title != '') { /*Title if static page is static page with custom title */
		$title_tag = get_bloginfo('name').' - '.$title ; 
	}
	elseif (is_page() AND is_front_page() AND $blogtitle == '') { /*Title if blog page with no custom title */
		$title_tag = get_bloginfo('name').$old_title; 
	}
	elseif ($blogtitle != '') { /*Title if blog page with custom title */ 
		$title_tag = get_bloginfo('name').' - '.$blogtitle ; 
	}
	else { /*Title if blog page without custom title */
		$title_tag = get_bloginfo('name').$old_title; 
	}
	
	return $title_tag;
}

add_filter( 'wp_title', 'response_title_tag_filter', 10, 3 )

/**
* End
*/
		    
?>
Back to Top