-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
267 lines (215 loc) · 9.52 KB
/
Copy pathfunctions.php
File metadata and controls
267 lines (215 loc) · 9.52 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
/*-----------------------------*/
/* Theme Initial Setup */
/*-----------------------------*/
if ( !function_exists('editorial_theme_setup') ) :
function editorial_theme_setup() {
/* Register Text Domain for Translation */
load_theme_textdomain('editorial');
/* Getting RSS Feed Links */
add_theme_support( 'automatic-feed-links' );
/* Getting Title Tag */
add_theme_support('title-tag');
/* Getting Post Thumbnail */
add_theme_support('post-thumbnails');
// add_theme_support('custom-header');
/* Getting Background Options */
add_theme_support('custom-background');
/* Create custom image size */
add_image_size( 'editorial_gallery', 520, 290, true );
/* Getting Header Options */
add_theme_support('custom-header');
/* Getting Post Formats */
add_theme_support( 'post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'] );
/* */
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
// Content width
if ( ! isset( $content_width ) ) $content_width = 900;
add_editor_style('assets/css/editor-style.css');
/* Register Editorial Menu */
register_nav_menu( 'mainmenu', __( 'Main Menu', 'editorial' ) );
/* Default menu for editorial */
function editorial_default_menu() {
if ( is_user_logged_in() && current_user_can('administrator') ) {
echo '<div id="menu"><ul><li><a href="'. site_url() .'/wp-admin/nav-menus.php">'. __( 'Create a New Menu', 'editorial' ) .'</a></li></ul></div>';
} else {
echo '<div id="menu"><ul><li><a href="'. site_url() .'">'. __( 'Home', 'editorial' ) .'</a></li></ul></div>';
}
}
}
endif;
add_action( 'after_setup_theme', 'editorial_theme_setup' );
/*-----------------------------*/
/* Register Left Sidebar */
/*-----------------------------*/
function editorial_sidebar_register() {
$args = array(
'name' => __( 'Left Sidebar', 'editorial' ),
'description' => __( 'You may add your widget from widgets area.', 'editorial' ),
'id' => 'editorial_left_sidebar',
'before_widget' => '<section>',
'after_widget' => '</section>',
'before_title' => '<header class="major"><h2>',
'after_title' => '</h2></header>',
);
register_sidebar( $args );
}
add_action( 'widgets_init', 'editorial_sidebar_register' );
/*---------------------------------------------------------*/
/* Remove default active widgets */
/*---------------------------------------------------------*/
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
add_action('admin_footer','removed_widgets');
}
function removed_widgets(){
//get all registered sidebars
global $wp_registered_sidebars;
//get saved widgets
$widgets = get_option('sidebars_widgets');
//loop over the sidebars and remove all widgets
foreach ($wp_registered_sidebars as $sidebar => $value) {
unset($widgets[$sidebar]);
}
//update with widgets removed
update_option('sidebars_widgets',$widgets);
}
/* ----------------------------------------------------- */
/* Register Custom Post Type for Services */
/* ----------------------------------------------------- */
function editorial_services_custom_post() {
$labels = array(
'name' => __( 'Services', 'editorial' ),
'singular_name' => __( 'Service', 'editorial' ),
'add_new' => __( 'Add service', 'editorial' ),
'add_new_item' => __( 'Add New service', 'editorial' ),
'not_found' => __( 'No services Found', 'editorial' ),
'new_item' => __( 'New service', 'editorial' ),
'view_item' => __( 'View service', 'editorial' ),
'edit_item' => __( 'Edit service', 'editorial' ),
'search_items' => __( 'Search Banners', 'editorial' ),
'not_found_in_trash' => __( 'No services found in Trash', 'editorial' ),
'all_item' => __( 'All Services', 'editorial' )
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_position' => 22,
'menu_icon' => 'dashicons-admin-generic',
'supports' => [ 'title', 'editor' ]
);
register_post_type( 'services', $args );
}
add_action( 'init', 'editorial_services_custom_post' );
/* ----------------------------------------------------- */
/* Register Custom Post */
/* ----------------------------------------------------- */
function editorial_banner_custom_post() {
$labels = array(
'name' => __( 'Banners', 'editorial' ),
'singular_name' => __( 'Banner', 'editorial' ),
'add_new' => __( 'Add banner', 'editorial' ),
'add_new_item' => __( 'Add New banner', 'editorial' ),
'new_item' => __( 'New Item', 'editorial' ),
'view_item' => __( 'View banner', 'editorial' ),
'edit_item' => __( 'Edit banner', 'editorial' ),
'search_items' => __( 'Search banners', 'editorial' ),
'not_found' => __( 'No banners Found', 'editorial' ),
'all_item' => __( 'All banners', 'editorial' ),
'not_found_in_trash' => __( 'No banners found in Trash', 'editorial' ),
'featured_image' => __( 'Banner image', 'editorial' ),
'set_featured_image' => __( 'Set banner image', 'editorial' ),
'remove_featured_image' => __( 'Remove banner image', 'editorial' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-align-right',
'supports' => ['title', 'editor', 'thumbnail'],
// 'taxonomies' => array( 'post_tag', 'category'),
);
register_post_type( 'banners', $args );
}
add_action( 'init', 'editorial_banner_custom_post' );
function editorial_internal_custom_css() {
?>
<style>
<?php echo !display_header_text() ? '#header a.logo { display: none; }' : ''; ?>
<?php echo !empty( get_header_textcolor() ) ? '#header a.logo strong { color: #'. get_header_textcolor() . '; }' : ''; ?>
</style>
<?php
}
add_action( 'wp_head', 'editorial_internal_custom_css' );
/*-----------------------------*/
/* Enqueue Theme assets */
/*-----------------------------*/
function editorial_theme_assets() {
$opt = wp_get_theme();
$ver = $opt->get( 'Version' );
/* Fonts */
wp_enqueue_style( 'font-awesome-font', get_theme_file_uri('/assets/css/font-awesome.min.css'), null, $ver );
wp_enqueue_style( 'roboto-font', '//fonts.googleapis.com/css?family=Open+Sans:400,600,400italic,600italic|Roboto+Slab:400,700', null, $ver );
/* CSS */
wp_enqueue_style( 'tns-css', '//cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.8.5/tiny-slider.css', null, $ver );
wp_enqueue_style( 'main-css', get_theme_file_uri('/assets/css/main.css'), null, $ver );
wp_enqueue_style( 'theme-css', get_stylesheet_uri(), null, $ver );
/* JavaScripts */
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'browser-min-js', get_theme_file_uri( '/assets/js/browser.min.js' ), array(), $ver, true );
wp_enqueue_script( 'tns-js', '//cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.8.5/min/tiny-slider.js', array(), $ver, true );
wp_enqueue_script( 'breakpoints-min-js', get_theme_file_uri( '/assets/js/breakpoints.min.js' ), array(), $ver, true );
wp_enqueue_script( 'util-js', get_theme_file_uri( '/assets/js/util.js' ), array(), $ver, true );
wp_enqueue_script( 'main-js', get_theme_file_uri( '/assets/js/main.js' ), array(), $ver, true );
if( is_singular() && comments_open() && ( get_option( 'thread_comments' ) == 1) ) {
// Load comment-reply.js (into footer)
wp_enqueue_script( 'comment-reply', 'wp-includes/js/comment-reply', array(), false, true );
}
}
add_action( 'wp_enqueue_scripts', 'editorial_theme_assets' );
// function editorial_body_class( $amarClass ) {
// // unset( $amarClass[array_search('home', $amarClass)] );
// $amarClass[] = 'hello';
// return $amarClass;
// }
// add_filter( 'body_class', 'editorial_body_class' );
/*-----------------------------*/
/* Menu Icon Name Option Add */
/*-----------------------------*/
if ( class_exists( 'ACF' ) && function_exists( 'the_field' ) ) {
function editorial_wp_nav_menu_objects( $items, $args ) {
foreach ($items as $item) {
$editorial_menu_icon = get_field( 'icon_name', $item );
if ( $editorial_menu_icon ) {
$item->title = '<i class="'. esc_attr( $editorial_menu_icon ) .'"></i> ' . $item->title;
}
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'editorial_wp_nav_menu_objects', 10, 2 );
}
/*-----------------------------*/
/* Search Result Highlight */
/*-----------------------------*/
function editorial_highlight_search_result( $text ) {
if ( is_search() ) {
$pattern = '/('. join( '|', explode(' ', get_search_query() ) ) .')/i';
$text = preg_replace( $pattern, '<spen class="search-highlight">\0</spen>', $text);
}
return $text;
}
add_filter( 'the_content', 'editorial_highlight_search_result' );
add_filter( 'the_excerpt', 'editorial_highlight_search_result' );
add_filter( 'the_title', 'editorial_highlight_search_result' );
/* REQUIRED FILES */
if ( class_exists( 'Attachments' ) ) {
require_once( 'inc/attachments/functions.php' );
}
require_once( 'inc/wp-widgets.php' );
require_once( 'inc/wp-customizer.php' );
require_once( 'inc/tgm.php' );
/* Add Meta box plugin options */
if ( class_exists( 'ACF' ) && function_exists( 'the_field' ) ) {
require_once( 'inc/acf-metabox.php' );
}
// Hide ACF Menu
add_filter( 'acf/settings/show_admin', '__return_false' );