· 10 years ago · Sep 25, 2016, 12:24 PM
1<?php
2
3/*include important files*/
4require_once ('themeOptions/functions.php');
5require_once ('smartmetabox/SmartMetaBox.php');
6require_once ('post_templates.php');
7require_once ('bootstrap-carousel.php');
8require_once ('pricetable/pricetable.php');
9require_once ('widgets/portfoliowidget/portfoliowdg.php');
10require_once ('widgets/latest_twitter/latest_twitter_widget.php');
11require_once ('themeOptions/rating.php');
12require_once ('chat/wp-wall.php');
13require_once ('widgets/rating/popular-widget.php');
14require_once ( 'heart/love/heart-love.php');
15{
16/*add page builder*/
17add_action('after_setup_theme', 'oblivion_page_builder');
18function oblivion_page_builder() {
19 include_once(get_template_directory().'/pagebuilder/page-builder.php');
20}
21
22/*register sidebars*/
23add_action( 'after_setup_theme', 'oblivion_register_sidebars' );
24function oblivion_register_sidebars() {
25if ( function_exists('register_sidebar') )
26register_sidebar(array(
27'name' => __( 'Home sidebar', 'oblivion' ),
28'id' => 'one',
29'description' => __( 'Widgets in this area will be shown in the home page.' , 'oblivion'),
30'before_widget' => '<div class="widget">',
31'after_widget' => '</div>',
32'before_title' => '<h3>',
33'after_title' => '</h3>', ));
34if ( function_exists('register_sidebar') )
35register_sidebar(array(
36'name' => __( 'General sidebar', 'oblivion' ),
37'id' => 'two',
38'description' => __( 'General sidebar for use with page builder.' , 'oblivion'),
39'before_widget' => '<div class="widget">',
40'after_widget' => '</div>',
41'before_title' => '<h3>',
42'after_title' => '</h3>', ));
43if ( function_exists('register_sidebar') )
44register_sidebar(array(
45'name' => __( 'Blog sidebar', 'oblivion' ),
46'id' => 'three',
47'description' => __( 'Widgets in this area will be shown in the blog sidebar.' , 'oblivion'),
48'before_widget' => '<div class="widget">',
49'after_widget' => '</div>',
50'before_title' => '<h3>',
51'after_title' => '</h3>', ));
52if ( function_exists('register_sidebar') )
53register_sidebar(array(
54'name' => __( 'Footer area widgets', 'oblivion' ),
55'id' => 'four',
56'description' => __( 'Widgets in this area will be shown in the footer.' , 'oblivion'),
57'before_widget' => '<div class="footer_widget span3">',
58'after_widget' => '</div>',
59'before_title' => '<h3>',
60'after_title' => '</h3>', ));
61}
62
63
64/*add custom menu support*/
65add_theme_support( 'menus' );
66add_action( 'admin_menu', 'oblivion_create_menu' );
67function oblivion_create_menu(){
68$themeicon1 = get_template_directory_uri()."/img/theme_barracks.png";
69add_menu_page("Theme Options", "Theme Options", 'edit_theme_options', 'options-framework', 'optionsframework_page',$themeicon1,1800 );
70}
71
72require_once get_template_directory() . '/themeOptions/class.php';
73
74add_action( 'after_setup_theme', 'oblivion_theme_tweak' );
75
76function oblivion_theme_tweak(){
77
78
79// When this theme is activated send the user to the theme options
80if (is_admin() && isset($_GET['activated'] ) ) {
81// Call action that sets
82add_action('admin_head','gp_setup');
83// Do redirect
84header( 'Location: '.admin_url().'themes.php?page=options-framework' ) ;
85}
86
87
88/*register theme location menu*/
89add_action( 'init', 'register_my_menus' );
90function register_my_menus() {
91 register_nav_menus(
92 array(
93 'header-menu' => __( 'Header Menu' , 'oblivion'),
94 )
95 );
96}
97}
98
99
100
101/* Breadcrumbs */
102
103function oblivion_breadcrumbs_inner(){
104
105 function oblivion_pg(){
106 $pages = get_pages(array(
107 'meta_key' => '_wp_page_template',
108 'meta_value' => 'tmp-blog.php'
109 ));
110 foreach($pages as $page){
111 return $page->post_name;
112 }}
113 function oblivion_get_page_id($name){
114 global $wpdb;
115 /* get page id using custom query */
116 $page_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ( post_name = '".$name."' or post_title = '".$name."' ) and post_status = 'publish' and post_type='page' ");
117 return $page_id;
118 }
119 function oblivion_get_page_permalink($name){
120 $page_id = oblivion_get_page_id($name);
121 return get_permalink($page_id);
122 }
123
124
125
126 if (!is_home()) {
127 echo '<a href="';
128 echo home_url();
129 echo '">';
130 echo __('Home', 'oblivion');
131 echo "</a> / ";
132 if(get_post_type() == 'project'){
133 echo '<a href="';
134 echo oblivion_get_page_permalink(''. oblivion_pg());
135 echo '">';
136 echo __('Projects', 'oblivion');
137 echo "</a> ";
138 if (is_single()) {
139 echo " / ";
140 the_title();
141 }
142 }elseif (is_single()) {
143 if(get_post_type( get_the_ID() ) == 'portfolio'){
144 echo __('Portfolio', 'oblivion');
145 if (is_single()) {
146 echo " / ";
147 the_title();
148 }
149 }else{
150 echo '<a href="';
151 echo oblivion_get_page_permalink(''. oblivion_pg());
152 echo '">';
153 echo __('Blog', 'oblivion');
154 echo "</a> ";
155 if (is_single()) {
156 echo " / ";
157 the_title();
158 }
159 }
160 }elseif(is_category()){
161 echo __('Category: ', 'oblivion');
162 echo single_cat_title();
163 }elseif(is_404()){
164 echo '404';
165 }elseif(is_search()){
166 echo __('Search: ', 'oblivion');
167 echo get_search_query();
168 }elseif(is_author()){
169 $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); echo $curauth->user_nicename;
170 } elseif (is_page()) {
171 echo the_title();
172 }elseif(is_tag()){
173 echo __('Tag: ', 'oblivion');
174 echo GetTagName(get_query_var('tag_id'));
175 }elseif(is_archive()){
176 echo __('Archive', 'oblivion');
177 }
178 }
179}
180
181function oblivion_breadcrumbs(){
182
183if(function_exists('is_bbpress')){
184 if(is_bbpress()){
185 bbp_breadcrumb();
186 }else{
187 oblivion_breadcrumbs_inner();}
188}else{
189 oblivion_breadcrumbs_inner();
190 }
191}
192
193
194/*custom excerpt lenght*/
195add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
196function custom_excerpt_length( $length ){
197 return 55;
198}
199add_filter( 'excerpt_length', 'custom_excerpt_length_pro', 999 );
200function custom_excerpt_length_pro( $length ) {
201 return 20;
202}
203
204
205/*pagination*/
206function kriesi_pagination($pages = '', $range = 1){
207$showitems = ($range * 1)+1;
208$general_show_page = of_get_option('general_post_show');
209global $paged;
210global $paginate;
211if(empty($paged)) $paged = 1;
212if($pages == '')
213{
214global $wp_query;
215$pages = $wp_query->max_num_pages;
216if(!$pages)
217{
218$pages = 1;
219}
220}
221if(1 != $pages){
222$url= get_template_directory_uri();
223$leftpager= '«';
224$rightpager= '»';
225if($paged > 2 && $paged > $range+1 && $showitems < $pages) $paginate.= "";
226if($paged > 1 ) $paginate.= "<a class='page-selector' href='".get_pagenum_link($paged - 1)."'>". $leftpager. "</a>";
227for ($i=1; $i <= $pages; $i++){
228if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
229$paginate.= ($paged == $i)? "<li class='active'><a href='".get_pagenum_link($i)."'>".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a></li>";
230}
231}
232if ($paged < $pages ) $paginate.= "<li><a class='page-selector' href='".get_pagenum_link($paged + 1)."' >". $rightpager. "</a></li>";
233}
234return $paginate;
235}
236
237
238/*add featured image support*/
239add_theme_support( 'post-thumbnails' );
240if ( function_exists( 'add_image_size' ) ) {
241 set_post_thumbnail_size( 287, 222, true );
242 set_post_thumbnail_size( 305, 305, true );
243}
244
245
246/*
247 * Include the TGM_Plugin_Activation class.
248 */
249require_once dirname( __FILE__ ) . '/pluginactivation.php';
250add_action( 'tgmpa_register', 'oblivion_my_theme_register_required_plugins' );
251/*
252 * Register the required plugins for this theme.
253 *
254 * In this example, we register two plugins - one included with the TGMPA library
255 * and one from the .org repo.
256 *
257 * The variable passed to tgmpa_register_plugins() should be an array of plugin
258 * arrays.
259 *
260 * This function is hooked into tgmpa_init, which is fired within the
261 * TGM_Plugin_Activation class constructor.
262 */
263function oblivion_my_theme_register_required_plugins() {
264 /**
265 * Array of plugin arrays. Required keys are name and slug.
266 * If the source is NOT from the .org repo, then source is also required.
267 */
268 $plugins = array(
269 // This is an example of how to include a plugin pre-packaged with a theme
270 array(
271 'name' => 'Paralax slider', // The plugin name
272 'slug' => 'layerslider', // The plugin slug (typically the folder name)
273 'source' => get_stylesheet_directory() . '/plugins/layerslider.zip', // The plugin source
274 'required' => true, // If false, the plugin is only 'recommended' instead of required
275 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
276 'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
277 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
278 'external_url' => '', // If set, overrides default API URL and points to an external URL
279 ),array(
280 'name' => 'Isotope gallery', // The plugin name
281 'slug' => 'sk_isotope_gallery', // The plugin slug (typically the folder name)
282 'source' => get_stylesheet_directory() . '/plugins/sk_isotope_gallery.zip', // The plugin source
283 'required' => false, // If false, the plugin is only 'recommended' instead of required
284 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
285 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
286 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
287 'external_url' => '', // If set, overrides default API URL and points to an external URL
288 ),array(
289 'name' => 'BBpress', // The plugin name
290 'slug' => 'bbpress', // The plugin slug (typically the folder name)
291 'source' => get_stylesheet_directory() . '/plugins/bbpress.zip', // The plugin source
292 'required' => false, // If false, the plugin is only 'recommended' instead of required
293 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
294 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
295 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
296 'external_url' => '', // If set, overrides default API URL and points to an external URL
297 ),
298
299 );
300 // Change this to your theme text domain, used for internationalising strings
301 $theme_text_domain = 'oblivion';
302 /**
303 * Array of configuration settings. Amend each line as needed.
304 * If you want the default strings to be available under your own theme domain,
305 * leave the strings uncommented.
306 * Some of the strings are added into a sprintf, so see the comments at the
307 * end of each line for what each argument will be.
308 */
309 $config = array(
310 'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
311 'default_path' => '', // Default absolute path to pre-packaged plugins
312 'parent_menu_slug' => 'themes.php', // Default parent menu slug
313 'parent_url_slug' => 'themes.php', // Default parent URL slug
314 'menu' => 'install-required-plugins', // Menu slug
315 'has_notices' => true, // Show admin notices or not
316 'is_automatic' => true, // Automatically activate plugins after installation or not
317 'message' => '', // Message to output right before the plugins table
318 'strings' => array(
319 'page_title' => __( 'Install Required Plugins', 'oblivion' ),
320 'menu_title' => __( 'Install Plugins', 'oblivion' ),
321 'installing' => __( 'Installing Plugin: %s', 'oblivion' ), // %1$s = plugin name
322 'oops' => __( 'Something went wrong with the plugin API.', 'oblivion' ),
323 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
324 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s)
325 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
326 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
327 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
328 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
329 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
330 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
331 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
332 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
333 'return' => __( 'Return to Required Plugins Installer', 'oblivion' ),
334 'plugin_activated' => __( 'Plugin activated successfully.', 'oblivion' ),
335 'complete' => __( 'All plugins installed and activated successfully. %s', 'oblivion' ), // %1$s = dashboard link
336 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
337 )
338 );
339 tgmpa( $plugins, $config );
340}
341
342
343/*theme styles*/
344add_action( 'wp_enqueue_scripts', 'oblivion_mytheme_style' );
345function oblivion_mytheme_style() {
346 wp_enqueue_style( 'oblivion_mytheme_style-style', get_bloginfo( 'stylesheet_url' ), array(), '20130401' );
347}
348add_action('wp_enqueue_scripts', 'oblivion_external_styles');
349function oblivion_external_styles(){
350 wp_register_style( 'custom-style', 'http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800,400italic,600italic,700italic', array(), '20130401');
351 wp_enqueue_style( 'custom-style' );
352 wp_register_style( 'custom-style1', get_template_directory_uri().'/css/jquery.fancybox.css', array(), '20130401');
353 wp_enqueue_style( 'custom-style1' );
354 wp_register_style( 'custom-style2', get_template_directory_uri().'/chat/wp-wall.css', array(), '20130401');
355 wp_enqueue_style( 'custom-style2' );
356 wp_register_style( 'pricetable1', get_template_directory_uri().'/pricetable/css/pricetable.css', array(), '20130401');
357 wp_enqueue_style( 'pricetable1' );
358
359}
360
361
362
363/*theme scripts*/
364add_action('wp_enqueue_scripts', 'oblivion_my_scripts');
365function oblivion_my_scripts(){
366wp_register_script( 'bootstrap1', get_template_directory_uri().'/js/bootstrap-transition.js','','',true);
367wp_enqueue_script('bootstrap1');
368wp_register_script( 'bootstrap2', get_template_directory_uri().'/js/bootstrap-tooltip.js','','',true);
369wp_enqueue_script('bootstrap2');
370wp_register_script( 'bootstrap3', get_template_directory_uri().'/js/bootstrap-button.js','','',true);
371wp_enqueue_script('bootstrap3');
372wp_register_script( 'bootstrap4', get_template_directory_uri().'/js/bootstrap-carousel.js','','',true);
373wp_enqueue_script('bootstrap4');
374wp_register_script( 'bootstrap5', get_template_directory_uri().'/js/bootstrap-collapse.js','','',true);
375wp_enqueue_script('bootstrap5');
376wp_register_script( 'bootstrap6', get_template_directory_uri().'/js/bootstrap-modal.js','','',true);
377wp_enqueue_script('bootstrap6');
378
379if(of_get_option('scrollbar') == 1){
380wp_register_script( 'scrollbar', get_template_directory_uri().'/js/jquery.nicescroll.js','','',true);
381wp_enqueue_script('scrollbar');
382}
383
384wp_register_script( 'easing', get_template_directory_uri().'/js/easing.js','','',true);
385wp_enqueue_script('easing');
386wp_register_script( 'main', get_template_directory_uri().'/js/main.js','','',true);
387wp_enqueue_script('main');
388wp_register_script( 'quicksand', get_template_directory_uri().'/js/quicksand.js','','',true);
389wp_enqueue_script('quicksand');
390wp_register_script( 'fancybox', get_template_directory_uri().'/js/jquery.fancybox.js','','',true);
391wp_enqueue_script('fancybox');
392wp_register_script( 'totop', get_template_directory_uri().'/js/jquery.ui.totop.js','','',true);
393wp_enqueue_script('totop');
394wp_register_script( 'custom_js1', get_template_directory_uri().'/js/jquery.validate.min.js','','',true);
395wp_enqueue_script('custom_js1');
396wp_register_script( 'custom_js2', get_template_directory_uri().'/js/jquery-ui-1.10.3.custom.min.js','','',true);
397wp_enqueue_script('custom_js2');
398wp_register_script( 'custom_js3', get_template_directory_uri().'/js/jquery.carouFredSel-6.2.1-packed.js','','',true);
399wp_enqueue_script('custom_js3');
400wp_register_script( 'custom_js4', get_template_directory_uri().'/js/global.js','','',true);
401wp_enqueue_script('custom_js4');
402wp_register_script( 'imagescale', get_template_directory_uri().'/js/imagescale.js','','',true);
403wp_enqueue_script('imagescale');
404}
405
406
407/*admin sctipts*/
408add_action('admin_enqueue_scripts', 'oblivion_scripts_admin');
409function oblivion_scripts_admin(){
410wp_register_script( 'custom_js55', get_template_directory_uri().'/js/simple-slider.js');
411wp_enqueue_script('custom_js55');
412wp_register_script( 'custom_js66', get_template_directory_uri().'/js/jquery.elastic.source.js');
413wp_enqueue_script('custom_js66');
414wp_register_script( 'custom_js77', get_template_directory_uri().'/ckeditor/ckeditor.js');
415wp_enqueue_script('custom_js77');
416wp_register_script( 'custom99', get_template_directory_uri().'/js/bootstrap-tooltip.js','','',true);
417wp_enqueue_script('custom99');
418wp_register_script( 'custom_js88', get_template_directory_uri().'/js/admin-tooltip.js');
419wp_enqueue_script('custom_js88');
420}
421
422/*admin styles*/
423add_action('admin_init', 'oblivion_styles_admin');
424function oblivion_styles_admin(){
425 wp_register_style( 'custom-style11', get_template_directory_uri().'/css/simple-slider.css', array(), '20130401');
426 wp_enqueue_style( 'custom-style11' );
427 wp_register_style( 'custom-style22', get_template_directory_uri().'/css/simple-slider-volume.css', array(), '20130401');
428 wp_enqueue_style( 'custom-style22' );
429 wp_register_style( 'custom-style44', get_template_directory_uri().'/css/font-awesome.css', array(), '20130401');
430 wp_enqueue_style( 'custom-style44' );
431 wp_register_style( 'custom-style55', get_template_directory_uri().'/css/admin.css', array(), '20130401');
432 wp_enqueue_style( 'custom-style55' );
433}
434
435/*add last item in footer sidebar class*/
436add_filter('dynamic_sidebar_params','oblivion_widget_first_last_classes');
437function oblivion_widget_first_last_classes($params) {
438 global $my_widget_num; // Global a counter array
439 $this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
440 $arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
441 if(!$my_widget_num) {// If the counter array doesn't exist, create it
442 $my_widget_num = array();
443 }
444 if(!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) { // Check if the current sidebar has no widgets
445 return $params; // No widgets in this sidebar... bail early.
446 }
447 if(isset($my_widget_num[$this_id])) { // See if the counter array has an entry for this sidebar
448 $my_widget_num[$this_id] ++;
449 } else { // If not, create it starting with 1
450 $my_widget_num[$this_id] = 1;
451 }
452 $class = 'class="widget-' . $my_widget_num[$this_id] . ' '; // Add a widget number class for additional styling options
453 if($my_widget_num[$this_id] == 1) { // If this is the first widget
454 $class .= 'first ';
455 } elseif($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) { // If this is the last widget
456 $class .= 'last ';
457 }
458 $params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']); // Insert our new classes into "before widget"
459 return $params;
460}
461
462
463/*custom comments*/
464function custom_comments($comment, $args, $depth) {
465 $GLOBALS['comment'] = $comment;
466 $GLOBALS['comment_depth'] = $depth;
467 ?>
468 <li class="comment">
469 <div class="wcontainer"><?php commenter_avatar() ?>
470 <?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'oblivion') ?>
471 <div class="comment-body">
472 <div class="comment-author"><?php commenter_link() ?></div>
473 <i><small><?php comment_time('M j, Y @ G:i a'); ?></small> </i><br />
474 <?php comment_text() ?>
475 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
476 </div>
477 <div class="clear"></div>
478 </div>
479 </li>
480<?php }
481
482
483/*custom pings*/
484function custom_pings($comment, $args, $depth) {
485 $GLOBALS['comment'] = $comment;
486 ?>
487 <div class="project-comment row">
488 <div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'oblivion'),
489 get_comment_author_link(),
490 get_comment_date(),
491 get_comment_time() );
492 edit_comment_link(__('Edit', 'oblivion'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
493 <?php if ($comment->comment_approved == '0') _e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'oblivion') ?>
494 <div class="comment-content span6">
495 <?php comment_text() ?>
496 </div>
497 </div>
498<?php
499}
500
501/*Produces an avatar image with the hCard-compliant photo class*/
502function commenter_link() {
503 $commenter = get_comment_author_link();
504 if ( preg_match( '/<a[^>]* class=[^>]+>/', $commenter ) ) {
505 $commenter = preg_replace( '/(<a[^>]* class=[\'"]?)/', '\\1url ' , $commenter );
506 } else {
507 $commenter = preg_replace( '/(<a )/', '\\1class="url "/' , $commenter );
508 }
509 echo ' <span class="comment-info">' . $commenter . '</span>';
510}
511
512/*Commenter avatar*/
513function commenter_avatar() {
514 $avatar_email = get_comment_author_email();
515 $avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 80 ) );
516 echo $avatar;
517}
518
519/*register portfolio post types*/
520add_action('init', 'oblivion_portfolio_register');
521function oblivion_portfolio_register() {
522 $labels = array(
523 'name' => _x('My Portfolio', 'post type general name','oblivion'),
524 'singular_name' => _x('Portfolio Item', 'post type singular name','oblivion'),
525 'add_new' => _x('Add New', 'portfolio item' ,'oblivion'),
526 'add_new_item' => __('Add New Portfolio Item','oblivion'),
527 'edit_item' => __('Edit Portfolio Item','oblivion'),
528 'new_item' => __('New Portfolio Item','oblivion'),
529 'view_item' => __('View Portfolio Item','oblivion'),
530 'search_items' => __('Search Portfolio','oblivion'),
531 'not_found' => __('Nothing found','oblivion'),
532 'not_found_in_trash' => __('Nothing found in Trash','oblivion'),
533 'parent_item_colon' => ''
534 );
535 $args = array(
536 'labels' => $labels,
537 'public' => true,
538 'publicly_queryable' => true,
539 'show_ui' => true,
540 'query_var' => true,
541 'menu_icon' => get_template_directory_uri() . '/img/portfolio.png',
542 'rewrite' => true,
543 'capability_type' => 'post',
544 'hierarchical' => false,
545 'menu_position' => null,
546 'supports' => array('title','editor','thumbnail'),
547 'taxonomies' => array('post_tag')
548 );
549 register_post_type( 'portfolio' , $args );
550}
551
552/*register portfolio categories*/
553add_action( 'init', 'oblivion_custom_taxonomies', 0 );
554function oblivion_custom_taxonomies() {
555 // Add new "Locations" taxonomy to Posts
556 register_taxonomy('portfolio-category', 'portfolio', array(
557 // Hierarchical taxonomy (like categories)
558 'hierarchical' => true,
559 // This array of options controls the labels displayed in the WordPress Admin UI
560 'labels' => array(
561 'name' => _x( 'Categories', 'taxonomy general name','oblivion' ),
562 'singular_name' => _x( 'Category', 'taxonomy singular name','oblivion' ),
563 'search_items' => __( 'Search Category','oblivion' ),
564 'all_items' => __( 'All Categories','oblivion' ),
565 'parent_item' => __( 'Parent Category','oblivion' ),
566 'parent_item_colon' => __( 'Parent Category:','oblivion' ),
567 'edit_item' => __( 'Edit Category','oblivion' ),
568 'update_item' => __( 'Update Category','oblivion' ),
569 'add_new_item' => __( 'Add New Category' ,'oblivion'),
570 'new_item_name' => __( 'New Category Name','oblivion' ),
571 'menu_name' => __( 'Categories','oblivion' ),
572 ),
573 // Control the slugs used for this taxonomy
574 'rewrite' => array(
575 'slug' => 'categories', // This controls the base slug that will display before each term
576 'with_front' => false, // Don't display the category base before "/locations/"
577 'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
578 ),
579 ));
580}
581
582/*custom admin columns for custom post type portfolio*/
583add_filter('manage_edit-portfolio_columns', 'oblivion_add_new_portfolio_columns');
584function oblivion_add_new_portfolio_columns($portfolio_columns) {
585 $columns = array(
586 "cb" => "<input type=\"checkbox\" />",
587 "title" => _("Title",'oblivion' ),
588 "author" => _("Author",'oblivion' ),
589 "slug" => _("URL Slug",'oblivion' ),
590 "custtype-type" => _("Categories",'oblivion' ),
591 "date" => _("Date",'oblivion' ),
592 );
593 return $columns;
594}
595
596add_action("manage_posts_custom_column", "oblivion_custtype_custom_columns",10,2);
597function oblivion_custtype_custom_columns($column,$id) {
598 global $wpdb;
599 global $post;
600 switch ($column) {
601 case 'custtype-type':
602 $terms = get_the_terms( $post->ID , 'portfolio-category' );
603 if($terms){
604 foreach ( $terms as $term ) {
605 echo $term->name;echo ', ';
606 }}
607 break;
608 case 'slug':
609 $text = basename(get_post_permalink($id));
610 echo $text;
611 break;
612 default:
613 break;
614 } // end switch
615}
616
617/*custom admin columns for custom post type taxonomies*/
618add_filter('manage_edit-portfolio-category_columns', 'oblivion_portfolio_category_columns', 2);
619add_action('manage_portfolio-category_custom_column', 'oblivion_portfolio_category_custom_columns', 2, 3);
620function oblivion_portfolio_category_columns($defaults) {
621 $defaults['portfolio-category_ids'] = __('Category ID' ,'oblivion');
622 return $defaults;
623}
624function oblivion_portfolio_category_custom_columns($value, $column_name, $id) {
625 if( $column_name == 'portfolio-category_ids' ) {
626 return (int)$id;
627 }
628}
629
630
631/*add smartmetaboxes*/
632add_action( 'add_meta_boxes', 'oblivion_my_custom_box' );
633add_action( 'save_post', 'saving_my_data' );
634function oblivion_my_custom_box() {
635 add_meta_box( 'my_box', 'Sidebar text', 'my_wp_editor', 'portfolio', 'normal', 'high' );
636}
637function my_wp_editor( $post ) {
638 $field_value = get_post_meta( $post->ID, '_smartmeta_my-awesome-field', false );
639 if(!isset($field_value[0])){ wp_editor( $field_value, '_smartmeta_my-awesome-field' );
640 }else{ wp_editor( $field_value[0], '_smartmeta_my-awesome-field' );}
641
642}
643function saving_my_data( $post_id ) {
644 if ( isset ( $_POST['_smartmeta_my-awesome-field'] ) ) {
645 update_post_meta( $post_id, '_smartmeta_my-awesome-field', $_POST['_smartmeta_my-awesome-field'] );
646 }
647}
648add_smart_meta_box('my-meta-box2', array(
649'title' => __('Project link','oblivion' ), // the title of the meta box
650'pages' => array('portfolio'), // post types on which you want the metabox to appear
651'context' => 'normal', // meta box context (see above)
652'priority' => 'high', // meta box priority (see above)
653'fields' => array( // array describing our fields
654array(
655'name' => __('Enable project link','oblivion' ),
656'id' => 'my-awesome-field5',
657'type' => 'checkbox',),
658array(
659'name' => __('Put the project link in here','oblivion' ),
660'id' => 'my-awesome-field2',
661'type' => 'text',
662),array(
663'name' => __('Put the project button name in here','oblivion' ),
664'id' => 'my-awesome-field4',
665'type' => 'text',)
666)));
667add_smart_meta_box('my-meta-box3', array(
668'title' => __('Video link','oblivion' ), // the title of the meta box
669'pages' => array('portfolio'), // post types on which you want the metabox to appear
670'context' => 'normal', // meta box context (see above)
671'priority' => 'high', // meta box priority (see above)
672'fields' => array( // array describing our fields
673array(
674'name' => __('Put your project embed video here','oblivion' ),
675'id' => 'my-awesome-field3',
676'type' => 'textarea',
677),)));
678add_smart_meta_box('my-meta-box6', array(
679'title' => __('Client','oblivion' ), // the title of the meta box
680'pages' => array('portfolio'), // post types on which you want the metabox to appear
681'context' => 'normal', // meta box context (see above)
682'priority' => 'low', // meta box priority (see above)
683'fields' => array( // array describing our fields
684array(
685'name' => __('Put client name here','oblivion' ),
686'id' => 'my-awesome-field6',
687'type' => 'textarea',
688),)));
689
690
691/*prevent headers alread sent*/
692add_action('init', 'do_output_buffer');
693function do_output_buffer() {
694 ob_start();
695}
696
697/**
698 * Returns an array of system fonts
699 * Feel free to edit this, update the font fallbacks, etc.
700 */
701function options_typography_get_os_fonts() {
702 // OS Font Defaults
703 $os_faces = array(
704 'Arial, sans-serif' => 'Arial',
705 '"Avant Garde", sans-serif' => 'Avant Garde',
706 'Cambria, Georgia, serif' => 'Cambria',
707 'Copse, sans-serif' => 'Copse',
708 'Garamond, "Hoefler Text", Times New Roman, Times, serif' => 'Garamond',
709 'Georgia, serif' => 'Georgia',
710 '"Helvetica Neue", Helvetica, sans-serif' => 'Helvetica Neue',
711 'Tahoma, Geneva, sans-serif' => 'Tahoma'
712 );
713 return $os_faces;
714}
715/**
716 * Returns a select list of Google fonts
717 * Feel free to edit this, update the fallbacks, etc.
718 */
719function options_typography_get_google_fonts() {
720 // Google Font Defaults
721 $google_faces = array(
722 'Arvo, serif' => 'Arvo',
723 'Copse, sans-serif' => 'Copse',
724 'Droid Sans, sans-serif' => 'Droid Sans',
725 'Droid Serif, serif' => 'Droid Serif',
726 'Lobster, cursive' => 'Lobster',
727 'Nobile, sans-serif' => 'Nobile',
728 'Open Sans, sans-serif' => 'Open Sans',
729 'Oswald, sans-serif' => 'Oswald',
730 'Pacifico, cursive' => 'Pacifico',
731 'Rokkitt, serif' => 'Rokkit',
732 'PT Sans, sans-serif' => 'PT Sans',
733 'Quattrocento, serif' => 'Quattrocento',
734 'Raleway, cursive' => 'Raleway',
735 'Ubuntu, sans-serif' => 'Ubuntu',
736 'Yanone Kaffeesatz, sans-serif' => 'Yanone Kaffeesatz'
737 );
738 return $google_faces;
739}
740/**
741 * Checks font options to see if a Google font is selected.
742 * If so, options_typography_enqueue_google_font is called to enqueue the font.
743 * Ensures that each Google font is only enqueued once.
744 */
745if ( !function_exists( 'options_typography_google_fonts' ) ) {
746 function options_typography_google_fonts() {
747 $all_google_fonts = array_keys( options_typography_get_google_fonts() );
748 // Define all the options that possibly have a unique Google font
749 $google_font = of_get_option('google_font', 'Rokkitt, serif');
750 $google_mixed = of_get_option('google_mixed', false);
751 $google_mixed_2 = of_get_option('google_mixed_2', 'Arvo, serif');
752 // Get the font face for each option and put it in an array
753 $selected_fonts = array(
754 $google_font['face'],
755 $google_mixed['face'],
756 $google_mixed_2['face'] );
757 // Remove any duplicates in the list
758 $selected_fonts = array_unique($selected_fonts);
759 // Check each of the unique fonts against the defined Google fonts
760 // If it is a Google font, go ahead and call the function to enqueue it
761 foreach ( $selected_fonts as $font ) {
762 if ( in_array( $font, $all_google_fonts ) ) {
763 options_typography_enqueue_google_font($font);
764 }
765 }
766 }
767}
768add_action( 'wp_enqueue_scripts', 'options_typography_google_fonts' );
769/**
770 * Enqueues the Google $font that is passed
771 */
772function options_typography_enqueue_google_font($font) {
773 $font = explode(',', $font);
774 $font = $font[0];
775 // Certain Google fonts need slight tweaks in order to load properly
776 // Like our friend "Raleway"
777 if ( $font == 'Raleway' )
778 $font = 'Raleway:100';
779 $font = str_replace(" ", "+", $font);
780 wp_enqueue_style( "options_typography_$font", "http://fonts.googleapis.com/css?family=$font", false, null, 'all' );
781}
782/*
783 * Outputs the selected option panel styles inline into the <head>
784 */
785function options_typography_styles() {
786 $output = '';
787 $input = '';
788 if ( of_get_option( 'google_font' ) ) {
789 $input = of_get_option( 'google_font' );
790 $output .= options_typography_font_styles( of_get_option( 'google_font' ) , '.google-font');
791 }
792 if ( $output != '' ) {
793 echo $output;
794 }
795}
796function options_typography_styles2() {
797 $output = '';
798 $input = '';
799 if ( of_get_option( 'google_mixed_2' ) ) {
800 $input = of_get_option( 'google_mixed_2' );
801 $output .= options_typography_font_styles( of_get_option( 'google_mixed_2' ) , '.google_mixed_2');
802 }
803 if ( $output != '' ) {
804 echo $output;
805 }
806}
807/*
808 * Returns a typography option in a format that can be outputted as inline CSS
809 */
810function options_typography_font_styles($option) {
811 $output = '';
812 $output .= ' color:' . $option['color'] .'; ';
813 $output .= 'font-family:' . $option['face'] . '; ';
814 $output .= "\n";
815 return $output;
816}
817
818
819
820/*Styling for the custom post type icon*/
821add_action( 'admin_head', 'wpt_portfolio_icons' );
822function wpt_portfolio_icons() {
823 ?>
824 <style type="text/css" media="screen">
825 #icon-edit.icon32-posts-portfolio {background: url(<?php echo get_template_directory_uri(); ?>/img/portfolio_big.jpg) no-repeat;}
826 </style>
827<?php }
828
829
830/*remove gallery from portfolio*/
831add_filter( 'the_content', 'oblivion_remove_gallery_from_portfolio' );
832function oblivion_remove_gallery_from_portfolio( $content = null ){
833 global $post;
834 if( $post->post_type == 'portfolio' ){
835 $pattern = get_shortcode_regex();
836 preg_match('/'.$pattern.'/s', $content, $matches);
837 if ( isset($matches[2]) && is_array($matches) && $matches[2] == 'gallery') {
838 //shortcode is being used
839 $content = str_replace( $matches['0'], '', $content );
840 }
841 }
842 return $content;
843}
844
845
846/*remove slider from home*/
847add_filter( 'the_content', 'oblivion_remove_slider_from_home' );
848function oblivion_remove_slider_from_home( $content = null ){
849 global $post;
850 if( is_page_template('tmp-home.php') ){
851 $pattern = get_shortcode_regex();
852 preg_match('/'.$pattern.'/s', $content, $matches);
853 if ( isset($matches[2]) && is_array($matches) && $matches[2] == 'layerslider') {
854 //shortcode is being used
855 $content = str_replace( $matches['0'], '', $content );
856 }
857 }
858 return $content;
859}
860
861
862
863/*get tag name*/
864function GetTagName($meta){
865 if (is_string($meta) || (is_numeric($meta) && !is_double($meta))
866 || is_int($meta)){
867 if (is_numeric($meta))
868 $meta = (int)$meta;
869 if (is_int($meta))
870 $TagSlug = get_term_by('id', $meta, 'post_tag');
871 else
872 $TagSlug = get_term_by('slug', $meta, 'post_tag');
873 return $TagSlug->name;
874 }
875}
876
877/*image resize*/
878function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
879
880 // Validate inputs.
881 if ( ! $url || ( ! $width && ! $height ) ) return false;
882
883 // Caipt'n, ready to hook.
884 if ( true === $upscale ) add_filter( 'image_resize_dimensions', 'aq_upscale', 10, 6 );
885
886 // Define upload path & dir.
887 $upload_info = wp_upload_dir();
888 $upload_dir = $upload_info['basedir'];
889 $upload_url = $upload_info['baseurl'];
890
891 $http_prefix = "http://";
892 $https_prefix = "https://";
893
894 /* if the $url scheme differs from $upload_url scheme, make them match
895 if the schemes differe, images don't show up. */
896 if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
897 $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
898 }
899 elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
900 $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
901 }
902
903
904 // Check if $img_url is local.
905 if ( false === strpos( $url, $upload_url ) ) return false;
906
907 // Define path of image.
908 $rel_path = str_replace( $upload_url, '', $url );
909 $img_path = $upload_dir . $rel_path;
910
911 // Check if img path exists, and is an image indeed.
912 if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return false;
913
914 // Get image info.
915 $info = pathinfo( $img_path );
916 $ext = $info['extension'];
917 list( $orig_w, $orig_h ) = getimagesize( $img_path );
918
919 // Get image size after cropping.
920 $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
921 $dst_w = $dims[4];
922 $dst_h = $dims[5];
923
924 // Return the original image only if it exactly fits the needed measures.
925 if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
926 $img_url = $url;
927 $dst_w = $orig_w;
928 $dst_h = $orig_h;
929 } else {
930 // Use this to check if cropped image already exists, so we can return that instead.
931 $suffix = "{$dst_w}x{$dst_h}";
932 $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
933 $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
934
935 if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
936 // Can't resize, so return false saying that the action to do could not be processed as planned.
937 return false;
938 }
939 // Else check if cache exists.
940 elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
941 $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
942 }
943 // Else, we resize the image and return the new resized image url.
944 else {
945
946 // Note: This pre-3.5 fallback check will edited out in subsequent version.
947 if ( function_exists( 'wp_get_image_editor' ) ) {
948
949 $editor = wp_get_image_editor( $img_path );
950
951 if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
952 return false;
953
954 $resized_file = $editor->save();
955
956 if ( ! is_wp_error( $resized_file ) ) {
957 $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
958 $img_url = $upload_url . $resized_rel_path;
959 } else {
960 return false;
961 }
962
963 } else {
964
965 $resized_img_path = wp_get_image_editor( $img_path, $width, $height, $crop ); // Fallback foo.
966 if ( ! is_wp_error( $resized_img_path ) ) {
967 $resized_rel_path = str_replace( $upload_dir, '', $resized_img_path );
968 $img_url = $upload_url . $resized_rel_path;
969 } else {
970 return false;
971 }
972
973 }
974
975 }
976 }
977
978 // Okay, leave the ship.
979 if ( true === $upscale ) remove_filter( 'image_resize_dimensions', 'aq_upscale' );
980
981 // Return the output.
982 if ( $single ) {
983 // str return.
984 $image = $img_url;
985 } else {
986 // array return.
987 $image = array (
988 0 => $img_url,
989 1 => $dst_w,
990 2 => $dst_h
991 );
992 }
993
994 return $image;
995}
996
997
998function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
999 if ( ! $crop ) return null; // Let the wordpress default function handle this.
1000
1001 // Here is the point we allow to use larger image size than the original one.
1002 $aspect_ratio = $orig_w / $orig_h;
1003 $new_w = $dest_w;
1004 $new_h = $dest_h;
1005
1006 if ( ! $new_w ) {
1007 $new_w = intval( $new_h * $aspect_ratio );
1008 }
1009
1010 if ( ! $new_h ) {
1011 $new_h = intval( $new_w / $aspect_ratio );
1012 }
1013
1014 $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
1015
1016 $crop_w = round( $new_w / $size_ratio );
1017 $crop_h = round( $new_h / $size_ratio );
1018
1019 $s_x = floor( ( $orig_w - $crop_w ) / 2 );
1020 $s_y = floor( ( $orig_h - $crop_h ) / 2 );
1021
1022 return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
1023}
1024
1025/*translatable theme*/
1026load_theme_textdomain( 'oblivion', get_template_directory().'/langs' );
1027$locale = get_locale();
1028$locale_file = get_template_directory()."/langs/$locale.php";
1029if ( is_readable($locale_file) )
1030 require_once($locale_file);
1031
1032?>