-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
217 lines (142 loc) · 5.47 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
215
216
217
<?php
/**
* @package WordPress
* @subpackage Kleo
* @author SeventhQueen <[email protected]>
* @since Kleo 1.0
*/
/* Initialize (CSS, Scripts, Widgets)
******************************/
require_once('functions/init.php');
/* Add body class, depending of site */
//* Add custom body class to the head
add_filter( 'body_class', 'kino_body_class' );
function kino_body_class( $classes ) {
$host = $_SERVER['HTTP_HOST'];
if ( $host == 'kinogeneva.ch' ) {
$classes[] = 'live-site';
} else {
$classes[] = 'test-site';
}
return $classes;
}
/* admin interface
******************************/
require_once('functions/admin.php');
/* Code fore page header
******************************/
require_once('functions/header-output.php');
/* BuddyPress Functionality
******************************/
require_once('functions/bp-user-fields.php');
require_once('functions/bp-group-tabs.php');
require_once('functions/bp-messages.php');
require_once('functions/bp-field-validation.php');
//d'abord tester que le plugin ACF est actif
/**
* Detect plugin. For use on Front End only.
*/
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// check for plugin using plugin name
if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) {
//plugin is activated
require_once('functions/bp-group-add.php');
}
/* Portfolio aka Film Pages
******************************/
require_once('functions/portfolio-films.php');
/* Admin Pages
******************************/
require_once('functions/js-tablesort.php');
/* Forcer éditeur texte par défaut
***************************************/
// Set the editor to HTML ("Text")
add_filter( 'wp_default_editor', create_function(null,'return "html";') );
/* Custom Login Screen
***************************************/
function kino_login_screen() {
echo '<link rel="stylesheet" type="text/css" href="' . get_stylesheet_directory_uri() . '/login/login.css" />';
}
add_action( 'login_head', 'kino_login_screen' );
/* Login redirection
* Voir discussion: https://bitbucket.org/ms-studio/kinogeneva/issues/26/
* UPDATE: il est finalement plus efficace de rediriger vers /inscription-kino/ via la fonctionalité incluse dans les options KLEO, sous Miscellaneous
***************************************/
/* Login redirection for modal window
* Voir discussion: https://bitbucket.org/ms-studio/kinogeneva/issues/112/
***************************************/
// Filter for kleo_title_section
// $args = apply_filters('kleo_title_args', $args);
add_filter('kleo_title_args', 'kino_title_filter',10,1);
function kino_title_filter( $args ) {
if ( function_exists( 'bp_is_user' ) ) {
if ( bp_is_user() ) {
$title_content = $args['title'];
$member_avatar = '<div class="item-avatar rounded kino-title-avatar">'. bp_core_fetch_avatar( array("class" => "avatar kleo-rounded", "alt" => "") ) .'</div>';
$args['title'] = $member_avatar . $title_content ;
// ajouter le @username... ou pas.
$title_username = ' <span class="user-nicename">@'. bp_get_displayed_user_mentionname() .'</span>';
// $args['title'] .= $title_username;
// ajouter les boutons:
// do_action( 'bp_member_header_actions' );
// bp_send_public_message_button
// bp_send_private_message_button = OK
// $title_buttons = do_action( 'bp_member_header_actions' );
$title_buttons = '';
// Test if function exists: bp_get_send_message_button()
if ( function_exists( 'bp_get_send_message_button' ) ) {
$title_buttons .= bp_get_send_message_button();
}
if ( function_exists( 'bp_get_send_public_message_button' ) ) {
$title_buttons .= bp_get_send_public_message_button();
}
if ( function_exists( 'bp_follow_get_add_follow_button' ) ) {
$title_buttons .= bp_follow_get_add_follow_button();
}
$args['title'] .= $title_buttons;
// class="user-nicename">@<?php bp_displayed_user_mentionname();
}
} // if function_exists
return $args;
} // end kino_title_filter
#https://bitbucket.org/ms-studio/kinogeneva/issues/118/a-la-fin-de-l-dition-du-profil-redirection
#https://buddypress.org/support/topic/how-to-redirect-users-to-their-profile-after-they-edit-their-profile/
add_action( 'xprofile_updated_profile', 'SaveEditsRedirect', 12 );
function SaveEditsRedirect() {
global $bp;
if ( is_user_logged_in() && bp_get_current_profile_group_id()==22 ) {
wp_redirect( $bp->displayed_user->domain );
exit;
}
}
//redir sur l'onglet profil à l'édition
//https://bitbucket.org/ms-studio/kinogeneva/issues/265/
add_action( 'xprofile_screen_edit_profile', 'conditionsEditsRedirect', 12 );
function conditionsEditsRedirect() {
global $bp;
if ( is_user_logged_in() && bp_get_current_profile_group_id()==1 ) {
wp_redirect( $bp->displayed_user->domain .'/profile/edit/group/19/');
exit;
}
}
#https://premium.wpmudev.org/blog/hide-wordpress-media-uploader-button/
/**
* Allow access to own content only
*/
function my_authored_content($query) {
//get current user info to see if they are allowed to access ANY posts and pages
$current_user = wp_get_current_user();
// set current user to $is_user
$is_user = $current_user->user_login;
//if is contributor or 'is_user' does not equal #username
if( !current_user_can('edit_posts') ){
//if in the admin panel
if($query->is_admin) {
global $user_ID;
$query->set('author', $user_ID);
}
return $query;
}
return $query;
}
add_filter('pre_get_posts', 'my_authored_content');