-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
214 lines (180 loc) · 7.66 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
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
<?php
function roohani_after_setup() {
function roohani_logo_setup() {
$defaults = array(
'height' => 150,
'width' => 200,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
);
add_theme_support( 'custom-logo', $defaults );
}
add_action( 'after_setup_theme', 'roohani_logo_setup' );
// Roohani supports
add_theme_support( 'title-tag' ); // Enable support for title tags.
add_theme_support( 'post-thumbnails' ); // Enable support for post thumbnails and featured images.
add_theme_support( 'post-formats', array(
'status', 'quote', 'gallery', // Enable support for the following post formats:
'image' , 'video', 'audio', // aside, gallery, quote, image, and video
'link' , 'aside', 'chat'
) );
add_theme_support( 'html5', array(
'comment-list',
'comment-form',
'search-form',
'gallery', 'caption'));
add_theme_support( 'automatic-feed-links' );
$defaults = array(
'default-color' => '',
'default-image' => '',
'default-repeat' => 'no-repeat',
'default-size' => 'auto',
'default-attachment' => 'fixed',
'wp-head-callback' => '_custom_background_cb',
);
add_theme_support( 'custom-background', $defaults );
add_theme_support( 'customize-selective-refresh-widgets' );
if( !isset($content_width) ) {
$content_width = 800;
}
// Load Roohani TextDomain
load_theme_textdomain( 'roohani', get_template_directory() . '/languages' );
}
add_action('after_setup_theme', 'roohani_after_setup');
function roohani_shorten_text($string, $max_length, $append = '') {
if (strlen($string) > $max_length) {
$string = substr($string, 0, $max_length);
$pos = strrpos($string, ' ');
if ($pos === false) {
return substr($string, 0, $max_length) . $append;
}
return substr($string, 0, $pos) . $append;
} else {
return $string;
}
}
function roohani_enqueue_sripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('roohani-js', get_template_directory_uri() . '/assets/js/roohani-js.js', array( 'jquery' ), '1.1.4', true );
wp_enqueue_script('lazy-load', get_template_directory_uri() . '/assets/js/lazyload.js', null, '1.0.9', false );
}
add_action('wp_enqueue_scripts', 'roohani_enqueue_sripts');
function roohani_enqueue_style() {
wp_enqueue_style('bootstrap4', get_template_directory_uri() . '/assets/thirdparty/bootstrap.min.css', array( 'roohani-style','customize-preview' ), '4.1.1', 'all');
wp_enqueue_style('roohani-style', get_template_directory_uri() . '/style.css', array( ), '1.1.4', 'all');
wp_enqueue_style('transtion-style', get_template_directory_uri() . '/assets/css/roohani-transtion.css', array( ), '1.1.4', 'all');
wp_enqueue_style( 'font-awesome-free', get_template_directory_uri() . '/assets/thirdparty/fontawesome-free-5.6.1-web/css/all.min.css', '5.6.1' );
}
add_action('wp_enqueue_scripts', 'roohani_enqueue_style');
//Enqueue the Dashicons script
function roohani_load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'roohani_load_dashicons_front_end' );
/**
* Roohani All menus
*/
function roohani_register_menus () {
register_nav_menus( array(
'main-menu' => __( 'Main Menu', 'roohani'),
'footer-menu' => __( 'Footer Menu', 'roohani')
));
};
add_action('init', 'roohani_register_menus');
/**
* Roohani All Widgets
*/
function roohani_widget() {
register_sidebar( array (
'name' => __( 'Main Sidebar', 'roohani' ),
'id' => 'main-sidebar',
'description' => __( 'Add widgets for main sidebar here', 'roohani' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s shadow-sm mb-3 bg-light rounded">',
'after_widget' => '</aside>',
'before_title' => '<span class="widget-title bgani-red">',
'after_title' => '</span>',
));
register_sidebar( array (
'id' => 'footer-1',
'name' => __( 'Footer Widget 1', 'roohani' ),
'description' => __( 'Add widget for Widget Footer 1', 'roohani' ),
'before_widget' => '<aside id="%1$s" class="foo-widget %2$s mb-3">',
'after_widget' => '</aside>',
'before_title' => '<span class="widget foo-widget-title bgani">',
'after_title' => '</span>',
));
register_sidebar( array (
'id' => 'footer-2',
'name' => __( 'Footer Widget 2', 'roohani' ),
'description' => __( 'Add widget for Widget Footer 2', 'roohani' ),
'before_widget' => '<aside id="%1$s" class="foo-widget %2$s mb-3">',
'after_widget' => '</aside>',
'before_title' => '<span class="widget foo-widget-title bgani">',
'after_title' => '</span>',
));
register_sidebar( array (
'id' => 'footer-3',
'name' => __( 'Footer Widget 3', 'roohani' ),
'description' => __( 'Add widget for Widget Footer 3', 'roohani' ),
'before_widget' => '<aside id="%1$s" class="widget foo-widget %2$s mb-3">',
'after_widget' => '</aside>',
'before_title' => '<span class="foo-widget-title bgani">',
'after_title' => '</span>',
));
register_sidebar( array (
'id' => 'footer-4',
'name' => __( 'Footer Widget 4', 'roohani' ),
'description' => __( 'Add widget for Widget Footer 4', 'roohani' ),
'before_widget' => '<aside id="%1$s" class="widget foo-widget %2$s mb-3">',
'after_widget' => '</aside>',
'before_title' => '<span class="foo-widget-title bgani">',
'after_title' => '</span>',
));
}
add_action('widgets_init', 'roohani_widget');
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* @since Roohani 1.0
*
* @param string $link Link to single post/page.
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function roohani_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf(
'<p class="post-more">
Continue reading...
<a href="%1$s" class="link-more">
%2$s <i class="fas fa-arrow-right"></i>
</a>
</p>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( ' <span class="screen-reader-text"> "%1$s" </span>', 'roohani' )
, get_the_title( get_the_ID() ) )
);
return str_replace('<b>',' ', $link);
}
add_filter( 'excerpt_more', 'roohani_excerpt_more' );
require_once( get_template_directory() . '/inc/post-conditions.php' );
// require_once( get_template_directory() . '/inc/related_posts.php' );
// Customizer start
require_once( get_template_directory() . '/inc/custo/theme_options.php' );
require_once( get_template_directory() . '/inc/custo/roohani-copyright.php' );
require_once( get_template_directory() . '/inc/custo/roohani-widget-options.php' );
require_once( get_template_directory() . '/inc/custo/roohani-call-action.php' );
require_once( get_template_directory() . '/inc/custo/roohani-top-bar.php' );
require_once( get_template_directory() . '/inc/custo/roohani-main-menu.php' );
require_once( get_template_directory() . '/inc/custo/roohani-body.php' );
// added in Roohani v1.0.7
require_once( get_template_directory() . '/inc/custo/roohani-scrol-indic.php' );
function roohani_theme_customize_css_output() {
include( get_template_directory() . '/assets/css/style-customizer.php' );
}
add_action( 'wp_head' , 'roohani_theme_customize_css_output' );
?>