Ticket #6148: 6148_updated_final.patch
File 6148_updated_final.patch, 12.0 KB (added by , 8 years ago) |
---|
-
buddypress/bp-core/admin/bp-core-admin-slugs.php
diff -Naur wp-content/plugins/old/buddypress/bp-core/admin/bp-core-admin-slugs.php wp-content/plugins/buddypress/bp-core/admin/bp-core-admin-slugs.php
old new 113 113 $bp = buddypress(); 114 114 115 115 // Get the existing WP pages 116 $existing_pages = bp_core_get_directory_page_ids( );116 $existing_pages = bp_core_get_directory_page_ids('all'); 117 117 118 118 // Set up an array of components (along with component names) that have directory pages. 119 119 $directory_pages = bp_core_admin_get_directory_pages(); … … 157 157 </tr> 158 158 159 159 160 <?php endforeach ?>160 <?php endforeach; ?> 161 161 162 162 <?php 163 163 … … 219 219 </td> 220 220 </tr> 221 221 222 <?php endforeach ?>222 <?php endforeach; ?> 223 223 224 224 <?php 225 225 … … 235 235 236 236 <?php 237 237 endif; 238 239 $allowed_directories = bp_admin_get_profiles_pages(); 240 241 if (!empty($directory_pages)): ?> 242 243 <h3><?php _e('Profiles', 'buddypress');?></h3> 244 245 <p><?php _e('Select the default component that should be shown on Profile pages.', 'buddypress');?></p> 246 247 <table class="form-table"> 248 <tbody> 249 250 <?php foreach ($directory_pages as $name => $label) : ?> 251 252 <?php if (!array_key_exists('profile_' . $name, $allowed_directories)) { 253 continue; 254 } 255 ?> 256 257 <tr valign="top"> 258 <th scope="row"> 259 <label for="bp_pages[profile_<?php echo esc_attr($name) ?>]"><?php echo esc_html($label) ?></label> 260 </th> 261 262 <td> 263 264 <?php if (!bp_is_root_blog()) { 265 switch_to_blog(bp_get_root_blog_id()); 266 } 267 ?> 268 <?php 269 /* I don't know how this patch has work before I have changed next lines of code 270 But on PHP 7.0.4 it don't work - I have tested */ 271 $global_array_parameter = $allowed_directories['profile_' . $name]; 272 $bp_profiles_tabs = $bp->{$global_array_parameter}; 273 ?> 274 275 <?php if (!empty($bp_profiles_tabs) || $name == 'groups'): ?> 276 277 <select data-value="<?php echo ($name == 'groups') ? $existing_pages['profile_groups'] : ''; ?>" name="bp_pages[profile_<?php echo esc_attr($name) ?>]" id="bp_pages[profile_<?php echo esc_attr($name) ?>]"> 278 <?php if ($name != 'groups') : ?> 279 <?php foreach ($bp_profiles_tabs as $id => $tab_page): ?> 280 <?php if (!is_numeric($id) || $id > 0): ?> 281 282 <?php $selected_tab = ($tab_page['slug'] == $existing_pages['profile_' . $name]) ? "selected" : "";?> 283 284 <option <?=$selected_tab;?> value="<?=$tab_page['slug'];?>"><?=ucfirst($tab_page['name']);?></option> 285 <?php endif; ?> 286 <?php endforeach; ?> 287 <?php endif; ?> 288 </select> 289 290 <?php endif; ?> 291 292 293 <?php if (!empty($existing_pages['profile_' . $name])): ?> 294 <?php $current_tab = bp_get_tab_by_slug($bp_profiles_tabs, $existing_pages['profile_' . $name]);?> 295 <a href="<?php echo $current_tab['link']; ?>" class="button-secondary" target="_bp"><?php _e('View', 'buddypress');?></a> 296 297 <?php endif; ?> 298 299 <?php if (!bp_is_root_blog()) { 300 restore_current_blog(); 301 } 302 ?> 303 304 </td> 305 </tr> 306 307 308 <?php endforeach; ?> 309 </table> 310 311 <?php endif; ?> 312 <?php 313 238 314 } 239 315 240 316 /** … … 251 327 252 328 // Then, update the directory pages. 253 329 if ( isset( $_POST['bp_pages'] ) ) { 254 $valid_pages = array_merge( bp_core_admin_get_directory_pages(), bp_core_admin_get_static_pages());330 $valid_pages = array_merge(bp_core_admin_get_directory_pages(), bp_core_admin_get_static_pages(), bp_admin_get_profiles_pages()); 255 331 256 332 $new_directory_pages = array(); 257 333 foreach ( (array) $_POST['bp_pages'] as $key => $value ) { 258 334 if ( isset( $valid_pages[ $key ] ) ) { 259 $new_directory_pages[ $key ] = (int)$value;335 $new_directory_pages[ $key ] = $value; 260 336 } 261 337 } 262 338 bp_core_update_directory_page_ids( $new_directory_pages ); 263 339 } 264 340 265 $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings', 'updated' => 'true' ), 'admin.php' ));341 $base_url = bp_get_admin_url( add_query_arg(array('page' => 'bp-page-settings', 'updated' => 'true' ), 'admin.php')); 266 342 267 343 wp_redirect( $base_url ); 268 344 } 269 345 } 270 346 add_action( 'bp_admin_init', 'bp_core_admin_slugs_setup_handler' ); 347 348 function bp_get_tab_by_slug($tabs, $slug) 349 { 350 351 if (!empty($tabs) && !empty($slug)) { 352 353 foreach ($tabs as $tab) { 354 if ($tab['slug'] == $slug) { 355 return $tab; 356 } 357 358 } 359 } 360 361 return false; 362 } 363 364 function my_action_javascript() { 365 if (htmlspecialchars($_GET['page']) == 'bp-page-settings') { 366 $existing_pages = bp_core_get_directory_page_ids('all'); 367 $group = BP_Groups_Group::get_random(1, 1); 368 if (isset($existing_pages['groups']) && count($group['groups'])) { 369 $groups_list_page = get_page($existing_pages['groups']); 370 $group_url = '/' . $groups_list_page->post_name . '/' . $group['groups'][0]->slug . '/'; 371 ?> 372 <script type="text/javascript"> 373 jQuery(document).ready(function($) { 374 var data = { bp_group_nav: 1 }; 375 jQuery.getJSON('<?=$group_url?>', data, function(response) { 376 console.log(response); 377 response.pages.forEach(function(item, index, arr) { 378 var opt = $("<option value='" + item.slug + "'>" + item.name + "</option>"); 379 $("#bp_pages\\[profile_groups\\]").append(opt); 380 }); 381 var val = $("#bp_pages\\[profile_groups\\]").attr("data-value"); 382 $("#bp_pages\\[profile_groups\\]").val(val); 383 }); 384 }); 385 </script> <?php 386 } 387 } 388 } 389 390 add_action('admin_footer', 'my_action_javascript'); -
buddypress/bp-core/bp-core-buddybar.php
diff -Naur wp-content/plugins/old/buddypress/bp-core/bp-core-buddybar.php wp-content/plugins/buddypress/bp-core/bp-core-buddybar.php
old new 230 230 // The requested URL has explicitly included the default subnav 231 231 // (eg: http://example.com/members/membername/activity/just-me/) 232 232 // The canonical version will not contain this subnav slug. 233 if ( ! empty( $r['default_subnav_slug'] ) && bp_is_current_action( $r['default_subnav_slug'] ) && ! bp_action_variable( 0 ) ) { 234 unset( $bp->canonical_stack['action'] ); 235 } elseif ( ! bp_current_action() ) { 233 234 //Modified: canonical redirect not used longer.Need for set default profile page 235 /*if (!empty($r['default_subnav_slug']) && bp_is_current_action($r['default_subnav_slug']) && !bp_action_variable(0)) { 236 unset($bp->canonical_stack['action']); 237 } else*/if ( ! bp_current_action() ) { 236 238 237 239 // Add our screen hook if screen function is callable. 238 240 if ( is_callable( $r['screen_function'] ) ) { … … 848 850 849 851 return 'true' === $pref; 850 852 } 853 854 855 function bp_admin_get_profiles_pages() { 856 857 return array('profile_members' => 'bp_nav', 'profile_groups' => 'group_nav'); 858 859 } 860 861 862 863 add_action('parse_request', 'checkRequest'); 864 865 function checkRequest($wp) { 866 global $bp; 867 868 $redirect_to = array(); 869 870 $existing_pages = bp_core_get_directory_page_ids('all'); 871 $allowed_directories = bp_admin_get_profiles_pages(); 872 873 $current_page = explode("/", $wp->query_vars['pagename']); 874 875 /* Here was second BUG: if slug of members page setted not as 'members', but as 'пользователи' (in russian) for example 876 old code haven't work */ 877 $bp_redirect_slug = $existing_pages['profile_' . $current_page[0]]; 878 if (empty($bp_redirect_slug)) { 879 $wp_content_current_page = get_page_by_path($current_page[0]); 880 if (isset($wp_content_current_page->ID)) { 881 $bp_settings_page_type = array_keys($existing_pages, $wp_content_current_page->ID); 882 if (count($bp_settings_page_type)) { 883 $bp_redirect_slug = $existing_pages['profile_' . $bp_settings_page_type[0]]; 884 } 885 } 886 } 887 888 889 if (!empty($bp_redirect_slug) && (count($current_page) > 1 || $wp->query_vars['page'])) { 890 if (empty($current_page[2]) && $bp_redirect_slug) { 891 $redirect_to = array_merge(array(""), $redirect_to, $current_page); 892 if ($wp->query_vars['page']) { 893 $redirect_to[] = $wp->query_vars['page']; 894 } 895 if (!is_numeric($bp_redirect_slug)) { 896 $redirect_to[] = $bp_redirect_slug; 897 } 898 } 899 } 900 901 if (!empty($redirect_to)) { 902 bp_core_redirect(implode("/", $redirect_to)); 903 } 904 905 } -
buddypress/bp-groups/bp-groups-loader.php
diff -Naur wp-content/plugins/old/buddypress/bp-groups/bp-groups-loader.php wp-content/plugins/buddypress/bp-groups/bp-groups-loader.php
old new 25 25 buddypress()->groups = new BP_Groups_Component(); 26 26 } 27 27 add_action( 'bp_setup_components', 'bp_setup_groups', 6 ); 28 29 /* Getting of group nav menu options array */ 30 function bp_get_group_menu() { 31 if (htmlspecialchars($_GET['bp_group_nav'])) { 32 global $bp; 33 if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) { 34 echo json_encode(array("pages" => array_values($bp->bp_options_nav[$bp->groups->current_group->slug]))); 35 } 36 die(); 37 } 38 } 39 add_action('bp_setup_nav', 'bp_get_group_menu', 100000); -
buddypress/bp-groups/classes/class-bp-groups-component.php
diff -Naur wp-content/plugins/old/buddypress/bp-groups/classes/class-bp-groups-component.php wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-component.php
old new 404 404 // When viewing the default extension, the canonical URL should not have 405 405 // that extension's slug, unless more has been tacked onto the URL via 406 406 // action variables. 407 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { 408 unset( $bp->canonical_stack['action'] ); 409 } 407 408 //No used longer.Need for set default profile page 409 /* if (bp_is_current_action($this->default_extension) && empty($bp->action_variables)) { 410 unset($bp->canonical_stack['action']); 411 }*/ 410 412 } 411 413 412 414 /** -
buddypress/bp-members/classes/class-bp-members-component.php
diff -Naur wp-content/plugins/old/buddypress/bp-members/classes/class-bp-members-component.php wp-content/plugins/buddypress/bp-members/classes/class-bp-members-component.php
old new 202 202 $bp->current_component = $bp->default_component; 203 203 204 204 // The canonical URL will not contain the default component. 205 } elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) { 206 unset( $bp->canonical_stack['component'] ); 207 } 205 } 206 //No used longer.Need for set default profile page 207 /*elseif (bp_is_current_component($bp->default_component) && !bp_current_action()) { 208 unset($bp->canonical_stack['component']); 209 }*/ 208 210 209 211 // If we're on a spammer's profile page, only users with the 'bp_moderate' cap 210 212 // can view subpages on the spammer's profile.