-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
95 lines (64 loc) · 2.57 KB
/
functions.php
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
<?php
// start a session
if ( session_id() == '' ) session_start();
// set a custom field prefix
define( "CMB_PREFIX", "_p_" );
// include the login library
include( "library/associo.php" );
include( "library/login.php" );
// include the content type
include( "library/post-type/job.php" );
include( "library/post-type/event.php" );
include( "library/post-type/person.php" );
// include some theme-related things
include( "library/menus.php" );
include( "library/scripts.php" );
include( "library/categories.php" );
include( "library/svgs.php" );
include( "library/forums.php" );
include( "library/post-list.php" );
include( "library/notice.php" );
// an extra image manipulation function
include( "library/images.php" );
// include our metaboxes library
include( "library/metabox.php" );
include( "library/metabox-theme.php" );
// include quote metaboxes/functions
include( "library/title.php" );
include( "library/showcase.php" );
include( "library/accordion.php" );
// [anchor] shortcode
function p_anchor( $atts, $content = null, $code = "" ) {
return '<a name="'.$content.'"></a>';
}
add_shortcode('anchor' , 'p_anchor' );
// enable oembed and shortcodes in text widgets (only if the object exists)
if ( isset( $wp_embed ) ) {
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );
}
// exclude some categories.
function exclude_posts_from_recentPostWidget_by_cat() {
$exclude = array( 'cat' => '-7850, -7851, -7852, -7853' );
return $exclude;
}
add_filter('widget_posts_args','exclude_posts_from_recentPostWidget_by_cat');
// pagination
function pagination( $prev = '«', $next = '»' ) {
global $wp_query, $wp_rewrite;
$posts_per_page = ( isset( $wp_query->query_vars['posts_per_page'] ) ? $wp_query->query_vars['posts_per_page'] : 14 );
$total = ceil( $wp_query->found_posts / $posts_per_page );
$current = ( $wp_query->query_vars['paged'] > 1 ? $wp_query->query_vars['paged'] : 1 );
$pagination = array(
'base' => @add_query_arg('paged','%#%'),
'format' => '',
'total' => $total,
'current' => $current,
'prev_text' => __($prev),
'next_text' => __($next),
'type' => 'plain'
);
if ( $wp_rewrite->using_permalinks() ) $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
if ( !empty($wp_query->query_vars['s']) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
echo paginate_links( $pagination );
}