-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
103 lines (90 loc) · 2.62 KB
/
Copy pathfunctions.php
File metadata and controls
103 lines (90 loc) · 2.62 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
<?php
/*
* Scripts and styles
*/
add_action( 'wp_enqueue_scripts', 'liane_theme_enqueue_styles' );
function liane_theme_enqueue_styles() {
$parenthandle = 'flatbase-style';
$theme = wp_get_theme();
wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css',
array(), // if the parent theme code has a dependency, copy it to here
$theme->parent()->get('Version')
);
wp_enqueue_style( 'liane-style', get_stylesheet_uri(),
array( $parenthandle ),
$theme->get('Version') // this only works if you have Version in the style header
);
}
/*
* Text domain
*/
add_action( 'after_setup_theme', 'liane_setup_theme' );
function liane_setup_theme() {
load_child_theme_textdomain('liane-support', get_stylesheet_directory() . '/languages');
}
/*
* Polylang post types
*/
add_filter( 'pll_get_post_types', 'liane_cpt_to_pll', 10, 2 );
function liane_cpt_to_pll( $post_types, $is_settings ) {
if ( $is_settings ) {
// hides from the list of custom post types in Polylang settings
unset( $post_types['infobox'] );
unset( $post_types['article'] );
unset( $post_types['faq'] );
} else {
// enables language and translation management
$post_types['infobox'] = 'infobox';
$post_types['article'] = 'article';
$post_types['faq'] = 'faq';
}
return $post_types;
}
/*
* Flatbase livesearch filters
*/
add_filter( 'nice_livesearch_label', 'liane_livesearch_label', 100 );
function liane_livesearch_label() {
return __( 'Have a question? Ask or enter a search term.', 'liane-support' );
}
/*
* Flatbase custom livesearch
*/
function nice_livesearch_js() {
// being here we can set admin-ajax.php for WP multisite
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {
jQuery('#live-search #s').liveSearch({url: '/?ajax=true&livesearch=true&lang=<?php echo pll_current_language(); ?>&s='});
});
//]]>
</script>
<?php
}
/*
* Add lang to ajax requests
*/
add_action( 'pre_get_posts', 'liane_ajax_pll', 20 );
function liane_ajax_pll($query) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( $query->is_search ) {
if ( get_query_var('ajax') == true ) {
$query->set( 'lang', htmlspecialchars($_GET['lang']) );
}
}
}
}
/*
* Nice post meta
*/
add_filter( 'nice_post_meta', 'liane_nice_post_meta', 20 );
function liane_nice_post_meta() {
ob_start();
?>
<p class="post-meta">
<?php edit_post_link( __( 'Edit', 'nicethemes' ), '<span class="small"><i class="fa fa-pencil"></i>', '</span>' ); ?>
</p>
<?php
return ob_get_clean();
}