Changeset 12558
- Timestamp:
- 02/29/2020 04:02:35 PM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 5 edited
-
bp-core/bp-core-attachments.php (modified) (22 diffs)
-
bp-core/bp-core-cssjs.php (modified) (2 diffs)
-
bp-core/bp-core-theme-compatibility.php (modified) (1 diff)
-
bp-core/deprecated/6.0.php (added)
-
bp-groups/bp-groups-template.php (modified) (1 diff)
-
bp-members/screens/change-cover-image.php (added)
-
bp-templates/bp-nouveau/buddypress-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-attachments.php
r12507 r12558 10 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 13 /**14 * Check if the current WordPress version is using Plupload 2.1.115 *16 * Plupload 2.1.1 was introduced in WordPress 3.9. Our bp-plupload.js17 * script requires it. So we need to make sure the current WordPress18 * match with our needs.19 *20 * @since 2.3.021 * @since 3.0.0 This is always true.22 *23 * @return bool Always true.24 */25 function bp_attachments_is_wp_version_supported() {26 return true;27 }28 12 29 13 /** … … 93 77 */ 94 78 function bp_attachments_cover_image_upload_dir( $args = array() ) { 95 // Default values are for profiles.79 // Default values are for members. 96 80 $object_id = bp_displayed_user_id(); 97 81 … … 289 273 * @type int $item_id The ID of the object (Required). Default: 0. 290 274 * @type string $object The object type (eg: group, user, blog) (Required). Default: 'user'. 291 * @type string $component The component for the object (eg: groups, xprofile, blogs). Default: ''.275 * @type string $component The component for the object (eg: groups, members, blogs). Default: ''. 292 276 * @type string $image The absolute path to the image (Required). Default: ''. 293 277 * @type int $crop_w Crop width. Default: 0. … … 326 310 if ( empty( $r['component'] ) ) { 327 311 if ( 'user' === $r['object'] ) { 328 $r['component'] = ' xprofile';312 $r['component'] = 'members'; 329 313 } else { 330 314 $r['component'] = $r['object'] . 's'; … … 358 342 $dir_args = array( $r['item_id'] ); 359 343 360 // In case of xprofile, we need an extra argument.361 if ( ' xprofile' === $r['component'] ) {344 // In case of members, we need an extra argument. 345 if ( 'members' === $r['component'] ) { 362 346 $dir_args = array( false, $r['item_id'] ); 363 347 } … … 376 360 $object_subdir = 'members'; 377 361 378 if ( ' xprofile' !== $r['component'] ) {362 if ( 'members' !== $r['component'] ) { 379 363 $object_subdir = sanitize_key( $r['component'] ); 380 364 } … … 646 630 */ 647 631 function bp_attachments_get_plupload_l10n() { 648 // Localization strings. 649 return apply_filters( 'bp_attachments_get_plupload_l10n', array( 632 /** 633 * Use this filter to edit localization strings. 634 * 635 * @since 2.3.0 636 * 637 * @param array $value An associative array of the localization strings. 638 */ 639 return apply_filters( 640 'bp_attachments_get_plupload_l10n', 641 array( 650 642 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.', 'buddypress' ), 651 643 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.', 'buddypress' ), … … 671 663 'error_uploading' => __( '“%s” has failed to upload.', 'buddypress' ), 672 664 'has_avatar_warning' => __( 'If you'd like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' ) 673 ) ); 665 ) 666 ); 674 667 } 675 668 … … 820 813 $defaults['multi_selection'] = false; 821 814 822 // Default cover component is xprofile.823 $cover_component = ' xprofile';815 // Default cover component is members. 816 $cover_component = 'members'; 824 817 825 818 // Get the object we're editing the cover image of. … … 915 908 } 916 909 // User profile photo. 917 } elseif ( bp_is_active( ' xprofile' ) && 'user' === $args['object'] ) {910 } elseif ( bp_is_active( 'members' ) && 'user' === $args['object'] ) { 918 911 $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' ); 919 912 } … … 1004 997 * @since 2.4.0 1005 998 * 1006 * @param string $component The component to get the settings for (" xprofile" for user or "groups").999 * @param string $component The component to get the settings for ("members" for user or "groups"). 1007 1000 * @return false|array The cover image settings in array, false on failure. 1008 1001 */ 1009 function bp_attachments_get_cover_image_settings( $component = ' xprofile' ) {1002 function bp_attachments_get_cover_image_settings( $component = 'members' ) { 1010 1003 // Default parameters. 1011 1004 $args = array(); … … 1018 1011 } 1019 1012 1013 // Set default args. 1014 $default_args = wp_parse_args( 1015 $args, 1016 array( 1017 'components' => array(), 1018 'width' => 1300, 1019 'height' => 225, 1020 'callback' => '', 1021 'theme_handle' => '', 1022 'default_cover' => '', 1023 ) 1024 ); 1025 1026 // Handle deprecated xProfile fitler. 1027 if ( 'members' === $component ) { 1028 /** This filter is documented in wp-includes/deprecated.php */ 1029 $args = apply_filters_deprecated( 'bp_before_xprofile_cover_image_settings_parse_args', array( $default_args ), '6.0.0', 'bp_before_members_cover_image_settings_parse_args' ); 1030 } 1031 1020 1032 /** 1021 1033 * Then let people override/set the feature using this dynamic filter 1022 1034 * 1023 1035 * Eg: for the user's profile cover image use: 1024 * add_filter( 'bp_before_ xprofile_cover_image_settings_parse_args', 'your_filter', 10, 1 );1036 * add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_filter', 10, 1 ); 1025 1037 * 1026 1038 * @since 2.4.0 … … 1028 1040 * @param array $settings The cover image settings 1029 1041 */ 1030 $settings = bp_parse_args( $args, array( 1031 'components' => array(), 1032 'width' => 1300, 1033 'height' => 225, 1034 'callback' => '', 1035 'theme_handle' => '', 1036 'default_cover' => '', 1037 ), $component . '_cover_image_settings' ); 1042 $settings = bp_parse_args( $args, $default_args, $component . '_cover_image_settings' ); 1043 1044 // Handle deprecated xProfile fitler. 1045 if ( 'members' === $component ) { 1046 /** This filter is documented in wp-includes/deprecated.php */ 1047 $settings = apply_filters_deprecated( 'bp_after_xprofile_cover_image_settings_parse_args', array( $settings ), '6.0.0', 'bp_after_members_cover_image_settings_parse_args' ); 1048 } 1038 1049 1039 1050 if ( empty( $settings['components'] ) || empty( $settings['callback'] ) || empty( $settings['theme_handle'] ) ) { … … 1055 1066 * @since 2.4.0 1056 1067 * 1057 * @param string $component The BuddyPress component concerned (" xprofile" for user or "groups").1068 * @param string $component The BuddyPress component concerned ("members" for user or "groups"). 1058 1069 * @return array|bool An associative array containing the advised width and height for the cover image. False if settings are empty. 1059 1070 */ 1060 function bp_attachments_get_cover_image_dimensions( $component = ' xprofile' ) {1071 function bp_attachments_get_cover_image_dimensions( $component = 'members' ) { 1061 1072 // Let's prevent notices when setting the warning strings. 1062 1073 $default = array( 'width' => 0, 'height' => 0 ); … … 1094 1105 1095 1106 $current_component = bp_current_component(); 1096 if ( bp_is_ active( 'xprofile' ) && bp_is_current_component( 'xprofile') ) {1097 $current_component = ' xprofile';1107 if ( bp_is_user() ) { 1108 $current_component = 'members'; 1098 1109 } 1099 1110 … … 1162 1173 * @param array $args { 1163 1174 * @type string $file The absolute path to the image. Required. 1164 * @type string $component The component for the object (eg: groups, xprofile). Required.1175 * @type string $component The component for the object (eg: groups, members). Required. 1165 1176 * @type string $cover_image_dir The Cover image dir to write the image into. Required. 1166 1177 * } … … 1283 1294 // Member's cover image. 1284 1295 if ( 'user' === $bp_params['object'] ) { 1285 $object_data = array( 'dir' => 'members', 'component' => ' xprofile' );1296 $object_data = array( 'dir' => 'members', 'component' => 'members' ); 1286 1297 1287 1298 if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) { … … 1400 1411 1401 1412 // Set the name of the file. 1402 $name = $_FILES['file']['name'];1413 $name = $_FILES['file']['name']; 1403 1414 $name_parts = pathinfo( $name ); 1404 $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) ); 1415 $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) ); 1416 1417 // Set some arguments for filters. 1418 $item_id = (int) $bp_params['item_id']; 1419 $component = $object_data['component']; 1405 1420 1406 1421 /** 1407 1422 * Fires if the new cover image was successfully uploaded. 1408 1423 * 1409 * The dynamic portion of the hook will be xprofilein case of a user's1424 * The dynamic portion of the hook will be members in case of a user's 1410 1425 * cover image, groups in case of a group's cover image. For instance: 1411 * Use add_action( ' xprofile_cover_image_uploaded' ) to run your specific1426 * Use add_action( 'members_cover_image_uploaded' ) to run your specific 1412 1427 * code once the user has set his cover image. 1413 1428 * … … 1421 1436 */ 1422 1437 do_action( 1423 $ object_data['component']. '_cover_image_uploaded',1424 (int) $bp_params['item_id'],1438 $component . '_cover_image_uploaded', 1439 $item_id, 1425 1440 $name, 1426 1441 $cover_url, 1427 1442 $feedback_code 1428 1443 ); 1444 1445 // Handle deprecated xProfile action. 1446 if ( 'members' === $component ) { 1447 /** This filter is documented in wp-includes/deprecated.php */ 1448 do_action_deprecated( 1449 'xprofile_cover_image_uploaded', 1450 array( 1451 $item_id, 1452 $name, 1453 $cover_url, 1454 $feedback_code, 1455 ), 1456 '6.0.0', 1457 'members_cover_image_deleted' 1458 ); 1459 } 1429 1460 1430 1461 // Finally return the cover image url to the UI. … … 1467 1498 // Set object for the user's case. 1468 1499 if ( 'user' === $args['object'] ) { 1469 $component = ' xprofile';1500 $component = 'members'; 1470 1501 $dir = 'members'; 1471 1502 … … 1478 1509 // Handle delete. 1479 1510 if ( bp_attachments_delete_file( array( 'item_id' => $args['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) { 1511 $item_id = (int) $args['item_id']; 1512 1480 1513 /** 1481 1514 * Fires if the cover image was successfully deleted. 1482 1515 * 1483 * The dynamic portion of the hook will be xprofilein case of a user's1516 * The dynamic portion of the hook will be members in case of a user's 1484 1517 * cover image, groups in case of a group's cover image. For instance: 1485 * Use add_action( ' xprofile_cover_image_deleted' ) to run your specific1518 * Use add_action( 'members_cover_image_deleted' ) to run your specific 1486 1519 * code once the user has deleted his cover image. 1487 1520 * … … 1490 1523 * @param int $item_id Inform about the item id the cover image was deleted for. 1491 1524 */ 1492 do_action( "{$component}_cover_image_deleted", (int) $args['item_id'] ); 1525 do_action( "{$component}_cover_image_deleted", $item_id ); 1526 1527 // Handle deprecated xProfile action. 1528 if ( 'members' === $component ) { 1529 /** This filter is documented in wp-includes/deprecated.php */ 1530 do_action_deprecated( 'xprofile_cover_image_deleted', array( $item_id ), '6.0.0', 'members_cover_image_deleted' ); 1531 } 1493 1532 1494 1533 $response = array( -
trunk/src/bp-core/bp-core-cssjs.php
r12401 r12558 443 443 444 444 $cover_image_object = array( 445 'component' => ' xprofile',445 'component' => 'members', 446 446 'object' => $bp->displayed_user 447 447 ); … … 480 480 $object_dir = $cover_image_object['component']; 481 481 482 if ( ' xprofile' === $object_dir ) {482 if ( 'members' === $object_dir ) { 483 483 $object_dir = 'members'; 484 484 } -
trunk/src/bp-core/bp-core-theme-compatibility.php
r12546 r12558 465 465 'name' => 'cover_image', 466 466 'settings' => array( 467 'components' => array( ' xprofile', 'groups' ),467 'components' => array( 'members', 'groups' ), 468 468 'width' => $bp_content_width, 469 469 'height' => $top_offset + round( $avatar_height / 2 ), -
trunk/src/bp-groups/bp-groups-template.php
r12429 r12558 913 913 */ 914 914 function bp_group_use_cover_image_header() { 915 return (bool) bp_is_active( 'groups', 'cover_image' ) && ! bp_disable_group_cover_image_uploads() && bp_attachments_is_wp_version_supported();915 return (bool) bp_is_active( 'groups', 'cover_image' ) && ! bp_disable_group_cover_image_uploads(); 916 916 } 917 917 -
trunk/src/bp-templates/bp-nouveau/buddypress-functions.php
r12524 r12558 147 147 'name' => 'cover_image', 148 148 'settings' => array( 149 'components' => array( ' xprofile', 'groups' ),149 'components' => array( 'members', 'groups' ), 150 150 'width' => $width, 151 151 'height' => $top_offset + round( $avatar_height / 2 ),
Note: See TracChangeset
for help on using the changeset viewer.