This repository was archived by the owner on Apr 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
211 lines (192 loc) · 7.05 KB
/
functions.php
File metadata and controls
211 lines (192 loc) · 7.05 KB
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
<?php
/**
* function (function.php)
* @package WordPress
* @subpackage MBN
*/
## Full Removal of the WP version
## Also, you need to delete the readme.html file in the root of the site
remove_action('wp_head', 'wp_generator'); // From the title
add_filter('the_generator', '__return_empty_string'); // From feeds and URLs
## Close the ability to publish via xmlrpc.php
add_filter('xmlrpc_enabled', '__return_false');
/**
* custom-logo
*/
add_theme_support('custom-logo');
/**
* title-tag
*/
add_theme_support('title-tag');
if (!isset($content_width))
$content_width = 900;
add_theme_support('screen-reader-text');
add_theme_support('automatic-feed-links');
add_theme_support('custom-header');
add_theme_support('custom-background');
register_nav_menus(array(
'main_menu' => 'Main menu',
'bottom_menu' => 'Bottom menu'
));
add_theme_support('post-thumbnails');
set_post_thumbnail_size(250, 150);
add_image_size('big-thumb', 400, 400, true);
if (!defined('WP_POST_REVISIONS'))
define('WP_POST_REVISIONS', 5);
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function theme_widgets_init() {
register_sidebar(array(
'name' => 'Sidebar',
'id' => "sidebar",
'description' => 'A regular column in the sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>\n",
'before_title' => '<span class="widgettitle">',
'after_title' => "</span>\n",
));
}
add_action('widgets_init', 'theme_widgets_init');
/**
* JavaScript Detection.
*
* Adds a 'js' class to the root '<html>' element when JavaScript is detected.
*
*/
function javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
add_action('wp_head', 'javascript_detection', 0);
if (!class_exists('clean_comments_constructor')) {
class clean_comments_constructor extends Walker_Comment {
public function start_lvl( &$output, $depth = 0, $args = array()) {
$output .= '<ul class="children">' . "\n";
}
public function end_lvl( &$output, $depth = 0, $args = array()) {
$output .= "</ul><!-- .children -->\n";
}
protected function comment( $comment, $depth, $args ) {
$classes = implode(' ', get_comment_class()).($comment->comment_author_email == get_the_author_meta('email') ? ' author-comment' : '');
echo '<li id="comment-'.get_comment_ID().'" class="'.$classes.' media">'."\n";
echo '<div class="media-left">'.get_avatar($comment, 64, '', get_comment_author(), array('class' => 'media-object'))."</div>\n";
echo '<div class="media-body">';
echo '<span class="meta media-heading">Author: '.get_comment_author()."\n";
//echo ' '.get_comment_author_email();
echo ' '.get_comment_author_url();
echo ' Added '.get_comment_date('F j, Y в H:i')."\n";
if ( '0' == $comment->comment_approved ) echo '<br><em class="comment-awaiting-moderation">Your comment will be published after verification by the moderator.</em>'."\n";
echo "</span>";
comment_text()."\n";
$reply_link_args = array(
'depth' => $depth,
'reply_text' => 'Reply',
'login_text' => 'You must be logged in'
);
echo get_comment_reply_link(array_merge($args, $reply_link_args));
echo '</div>'."\n";
}
public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
$output .= "</li><!-- #comment-## -->\n";
}
}
}
if (!function_exists('pagination')) {
function pagination() {
global $wp_query;
$big = 999999999;
$links = paginate_links(array(
'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'type' => 'array',
'prev_text' => 'Prev',
'next_text' => 'Next',
'total' => $wp_query->max_num_pages,
'show_all' => false,
'end_size' => 15,
'mid_size' => 15,
'add_args' => false,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
));
if( is_array( $links ) ) {
echo '<ul class="pagination">';
foreach ( $links as $link ) {
if ( strpos( $link, 'current' ) !== false ) echo "<li class='active'>$link</li>";
else echo "<li>$link</li>";
}
echo '</ul>';
}
}
}
add_action('wp_footer', 'add_scripts');
if (!function_exists('add_scripts')) {
function add_scripts() {
if(is_admin()) return false;
wp_deregister_script('jquery');
wp_enqueue_script('jquery','//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js','','',true);
wp_enqueue_script('bootstrap', get_template_directory_uri().'/js/bootstrap.min.js','','',true);
wp_enqueue_script('main', get_template_directory_uri().'/js/main.js','','',true);
}
}
add_action('wp_print_styles', 'add_styles');
if (!function_exists('add_styles')) {
function add_styles() {
if(is_admin()) return false;
if ( is_rtl() ) {
wp_enqueue_style( 'rtl-bs', get_template_directory_uri().'/css/bootstrap-rtl.min.css' );
wp_enqueue_style( 'rtl-style', get_template_directory_uri() . '/rtl.css');
} else {
wp_enqueue_style( 'bs', get_template_directory_uri().'/css/bootstrap.min.css' );
}
wp_enqueue_style( 'main-theme-css', get_template_directory_uri().'/css/style.css' );
wp_enqueue_style( 'main', get_template_directory_uri().'/style.css' );
}
}
if (!class_exists('bootstrap_menu')) {
class bootstrap_menu extends Walker_Nav_Menu {
private $open_submenu_on_hover;
function __construct($open_submenu_on_hover = true) {
$this->open_submenu_on_hover = $open_submenu_on_hover;
}
function start_lvl(&$output, $depth = 0, $args = array()) {
$output .= "\n<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
$item_html = '';
parent::start_el($item_html, $item, $depth, $args);
if ( $item->is_dropdown && $depth === 0 ) {
if (!$this->open_submenu_on_hover) $item_html = str_replace('<a', '<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"', $item_html);
$item_html = str_replace('</a>', ' <b class="caret"></b></a>', $item_html);
}
$output .= $item_html;
}
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
if ( $element->current ) $element->classes[] = 'active';
$element->is_dropdown = !empty( $children_elements[$element->ID] );
if ( $element->is_dropdown ) {
if ( $depth === 0 ) {
$element->classes[] = 'dropdown';
if ($this->open_submenu_on_hover) $element->classes[] = 'show-on-hover';
} elseif ( $depth === 1 ) {
$element->classes[] = 'dropdown-submenu';
}
}
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
}
}
}
if (!function_exists('content_class_by_sidebar')) {
function content_class_by_sidebar() {
if (is_active_sidebar( 'sidebar' )) {
echo 'col-sm-9';
} else {
echo 'col-sm-12';
}
}
}
?>