-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
154 lines (123 loc) · 4.86 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
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
<?php
/* Register Scripts and Style */
function theme_register_scripts() {
wp_enqueue_style( 'olympos-css', get_stylesheet_uri() );
wp_enqueue_script( 'olympos-js', esc_url( trailingslashit( get_template_directory_uri() ) . 'js/olympos.min.js' ), array( 'jquery' ), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_register_scripts', 1 );
function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
/*
wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ) );
wp_enqueue_script( 'bootstrap-css', get_stylesheet_directory_uri() . '/css/bootstrap-grid.min.css' );
wp_enqueue_script( 'bootstrap-css', get_stylesheet_directory_uri() . '/css/bootstrap-reboot.min.css' );
wp_enqueue_script( 'bootstrap-css', get_stylesheet_directory_uri() . '/css/bootstrap.min.css' );
*/
wp_enqueue_script( 'tether-script', 'https://npmcdn.com/[email protected]/dist/js/tether.min.js', array( 'jquery' ) );
wp_enqueue_style( 'bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' );
wp_enqueue_script( 'custom-script', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js' );
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
/* Add menu support */
// if (function_exists('add_theme_support')) {
// add_theme_support('menus');
// }
function theme_setup(){
add_theme_support("menus");
register_nav_menu('primary', 'Primery Header Nav');
}
add_action('init', 'theme_setup');
/* Add post image support */
add_theme_support( 'post-thumbnails' );
/* Add custom thumbnail sizes */
if ( function_exists( 'add_image_size' ) ) {
//add_image_size( 'custom-image-size', 500, 500, true );
}
/* Add widget support */
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'SidebarOne',
'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'SidebarTwo',
'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
/* EXCERPT
Usage:
<?php echo excerpt(100); ?>
*/
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}
// Add page slug to body class, love this - Credit: Starkers Wordpress Theme
function add_slug_to_body_class($classes)
{
global $post;
if (is_home()) {
$key = array_search('blog', $classes);
if ($key > -1) {
unset($classes[$key]);
}
} elseif (is_page()) {
$classes[] = sanitize_html_class($post->post_name);
} elseif (is_singular()) {
$classes[] = sanitize_html_class($post->post_name);
}
return $classes;
}
add_filter('uwpqsf_result_tempt', 'customize_output', '', 4);
function customize_output($results , $arg, $id, $getdata ){
// The Query
$apiclass = new uwpqsfprocess();
$query = new WP_Query( $arg );
ob_start(); $result = '';
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();global $post;
echo '<div class="col-sm-4">';
echo '<a href="'.get_permalink().'">';
echo '<div class="recipes-img-cont">';
echo '<img src="'.types_render_field( "recipe-image", array( 'raw' => true) ). '" width="100%" height="auto"">';
echo '<p>View</p>';
echo '</div>';
echo '</a>';
echo '<p class="allrec-title">'.get_the_title().'</p>';
echo '</div>';
}
echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata);
} else {
echo '';
}
/* Restore original Post Data */
wp_reset_postdata();
$results = ob_get_clean();
return $results;
}
function register_header_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_header_menu' );
// ini_set('display_errors', true);
// error_reporting(E_ALL);
// Register Custom Navigation Walker
// require('/wp-content/themes/olympos/wp_bootstrap_navwalker.php');
// require_once($_SERVER['DOCUMENT_ROOT'].'wp_bootstrap_navwalker.php');
// echo getcwd();