| | 469 | |
| | 470 | if ( !class_exists( 'Xprofile_User_Admin' ) ) : |
| | 471 | /** |
| | 472 | * Load xProfile user's profile admin area. |
| | 473 | * |
| | 474 | * @package BuddyPress |
| | 475 | * @subpackage xProfileAdministration |
| | 476 | * |
| | 477 | * @since BuddyPress (?) |
| | 478 | */ |
| | 479 | class Xprofile_User_Admin { |
| | 480 | |
| | 481 | /** |
| | 482 | * screen id for edit user's profile page. |
| | 483 | * |
| | 484 | * @access public |
| | 485 | * @var string |
| | 486 | */ |
| | 487 | public $user_page = ''; |
| | 488 | |
| | 489 | /** |
| | 490 | * Constructor method. |
| | 491 | * |
| | 492 | * @access public |
| | 493 | * @since BuddyPress (?) |
| | 494 | */ |
| | 495 | public function __construct() { |
| | 496 | $this->setup_globals(); |
| | 497 | $this->setup_actions(); |
| | 498 | } |
| | 499 | |
| | 500 | /** |
| | 501 | * Set admin-related globals. |
| | 502 | * |
| | 503 | * @access private |
| | 504 | * @since BuddyPress (?) |
| | 505 | */ |
| | 506 | private function setup_globals() { |
| | 507 | $bp = buddypress(); |
| | 508 | |
| | 509 | // Paths and URLs |
| | 510 | $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-xprofile/admin' ); // Admin path |
| | 511 | $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-xprofile/admin' ); // Admin url |
| | 512 | $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL |
| | 513 | $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL |
| | 514 | |
| | 515 | // Main settings page |
| | 516 | $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; |
| | 517 | |
| | 518 | // The Edit Profile Screen id |
| | 519 | $this->user_page = ''; |
| | 520 | |
| | 521 | // The screen ids to load specific css for |
| | 522 | $this->screen_id = array(); |
| | 523 | |
| | 524 | // The WordPress edit user url |
| | 525 | $this->edit_url = bp_get_admin_url( 'user-edit.php' ); |
| | 526 | |
| | 527 | // BuddyPress edit user's profile url |
| | 528 | $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); |
| | 529 | } |
| | 530 | |
| | 531 | /** |
| | 532 | * Set admin-related actions and filters. |
| | 533 | * |
| | 534 | * @access private |
| | 535 | * @since BuddyPress (?) |
| | 536 | * |
| | 537 | * @uses add_action() To add various actions. |
| | 538 | * @uses add_filter() To add various filters. |
| | 539 | */ |
| | 540 | private function setup_actions() { |
| | 541 | |
| | 542 | /** Actions ***************************************************/ |
| | 543 | |
| | 544 | // Add some page specific output to the <head> |
| | 545 | add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); |
| | 546 | |
| | 547 | // Add menu item to all users menu |
| | 548 | add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); |
| | 549 | |
| | 550 | // Enqueue all admin JS and CSS |
| | 551 | add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| | 552 | |
| | 553 | // Create the Profile Navigation (WordPress/Community) |
| | 554 | add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
| | 555 | |
| | 556 | |
| | 557 | /** Filters ***************************************************/ |
| | 558 | |
| | 559 | // Add a row action to users listing |
| | 560 | add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
| | 561 | |
| | 562 | } |
| | 563 | |
| | 564 | /** |
| | 565 | * Create the All users Edit Profile submenu |
| | 566 | * |
| | 567 | * @access public |
| | 568 | * @since BuddyPress (?) |
| | 569 | * |
| | 570 | * @uses add_users_page() To add the Edit Profile page in Users section. |
| | 571 | */ |
| | 572 | public function admin_menus() { |
| | 573 | |
| | 574 | // Manage user's profile |
| | 575 | $hook = $this->user_page = add_users_page( |
| | 576 | __( 'Edit Profile', 'buddypress' ), |
| | 577 | __( 'Edit Profile', 'buddypress' ), |
| | 578 | 'bp_moderate', |
| | 579 | 'bp-profile-edit', |
| | 580 | array( &$this, 'user_admin' ) |
| | 581 | ); |
| | 582 | |
| | 583 | $edit_page = 'user-edit'; |
| | 584 | |
| | 585 | if ( bp_core_do_network_admin() ) { |
| | 586 | $edit_page .= '-network'; |
| | 587 | $this->user_page .= '-network'; |
| | 588 | } |
| | 589 | |
| | 590 | $this->screen_id = array( $edit_page, $this->user_page ); |
| | 591 | |
| | 592 | add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); |
| | 593 | add_action( "load-$hook", array( $this, 'user_admin_load' ) ); |
| | 594 | |
| | 595 | } |
| | 596 | |
| | 597 | /** |
| | 598 | * Add some specific styling to the Edit user and Edit user's profile page. |
| | 599 | * |
| | 600 | * @access public |
| | 601 | * @since BuddyPress (?) |
| | 602 | */ |
| | 603 | public function enqueue_scripts() { |
| | 604 | if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { |
| | 605 | return; |
| | 606 | } |
| | 607 | |
| | 608 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| | 609 | |
| | 610 | $file = $this->css_url . "admin{$min}.css"; |
| | 611 | $file = apply_filters( 'bp_xprofile_admin_css', $file ); |
| | 612 | wp_enqueue_style( 'bp-xprofile-css', $file, array(), bp_get_version() ); |
| | 613 | |
| | 614 | // Plugins may want to hook here to load some css/js |
| | 615 | do_action( 'bp_xprofile_user_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); |
| | 616 | } |
| | 617 | |
| | 618 | /** |
| | 619 | * Create the Profile navigation in Edit User & Edit Profile pages |
| | 620 | * |
| | 621 | * @access public |
| | 622 | * @since BuddyPress (?) |
| | 623 | */ |
| | 624 | public function profile_nav( $user = null, $active = 'WordPress' ) { |
| | 625 | if ( empty( $user->ID ) ) |
| | 626 | return; |
| | 627 | |
| | 628 | $query_args = array( 'user_id' => $user->ID ); |
| | 629 | |
| | 630 | if ( ! empty( $_REQUEST['wp_http_referer'] ) ) |
| | 631 | $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
| | 632 | |
| | 633 | $community_url = add_query_arg( $query_args, $this->edit_profile_url ); |
| | 634 | $wordpress_url = add_query_arg( $query_args, $this->edit_url ); |
| | 635 | |
| | 636 | $bp_active = false; |
| | 637 | $wp_active = ' nav-tab-active'; |
| | 638 | if ( 'BuddyPress' == $active ) { |
| | 639 | $bp_active = ' nav-tab-active'; |
| | 640 | $wp_active = false; |
| | 641 | } |
| | 642 | |
| | 643 | ?> |
| | 644 | <ul id="profile-nav" class="nav-tab-wrapper"> |
| | 645 | <li class="nav-tab<?php echo $wp_active;?>"><a href="<?php echo $wordpress_url;?>"><?php _e( 'WordPress Profile' ); ?></a></li> |
| | 646 | <li class="nav-tab<?php echo $bp_active;?>"><a href="<?php echo $community_url;?>"><?php _e( 'Community Profile' ); ?></a></li> |
| | 647 | </ul> |
| | 648 | <?php |
| | 649 | } |
| | 650 | |
| | 651 | /** |
| | 652 | * Highlight the All users menu if on Edit Profile pages |
| | 653 | * |
| | 654 | * @access public |
| | 655 | * @since BuddyPress (?) |
| | 656 | * |
| | 657 | * @global $plugin_page |
| | 658 | * @global $submenu_file |
| | 659 | */ |
| | 660 | public function modify_admin_menu_highlight() { |
| | 661 | global $plugin_page, $submenu_file; |
| | 662 | |
| | 663 | // Only Show the All users menu |
| | 664 | if ( 'bp-profile-edit' == $plugin_page ) |
| | 665 | $submenu_file = 'users.php'; |
| | 666 | } |
| | 667 | |
| | 668 | /** |
| | 669 | * Remove the Edit Profile submenu page |
| | 670 | * |
| | 671 | * @access public |
| | 672 | * @since BuddyPress (?) |
| | 673 | */ |
| | 674 | public function admin_head() { |
| | 675 | // Remove submenu to force using Profile Navigation |
| | 676 | remove_submenu_page( 'users.php', 'bp-profile-edit' ); |
| | 677 | } |
| | 678 | |
| | 679 | /** |
| | 680 | * Set up the User's profile admin page. |
| | 681 | * |
| | 682 | * Loaded before the page is rendered, this function does all initial setup, |
| | 683 | * including: processing form requests, registering contextual help, and |
| | 684 | * setting up screen options. |
| | 685 | * |
| | 686 | * @access public |
| | 687 | * @since BuddyPress (?) |
| | 688 | */ |
| | 689 | public function user_admin_load() { |
| | 690 | if ( ! $user_id = intval( $_GET['user_id'] ) ) |
| | 691 | wp_die( __( 'No users were found', 'buddypress' ) ); |
| | 692 | |
| | 693 | $bp = buddypress(); |
| | 694 | |
| | 695 | /** |
| | 696 | * Sets displayed user id if empty on the user's profile admin page. |
| | 697 | * this is probably not the right way to do it. But bp_get_the_profile_field_options() args |
| | 698 | * does not accept a user_id parameter and for instance, bp_displayed_user_id() is used in |
| | 699 | * BP_XProfile_ProfileData::get_value_byid() to retrieve datas. |
| | 700 | */ |
| | 701 | if ( empty( $bp->displayed_user->id ) ) { |
| | 702 | // Let's set the user displayed id |
| | 703 | $bp->displayed_user->id = $user_id; |
| | 704 | |
| | 705 | // The domain for the user currently being displayed |
| | 706 | $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); |
| | 707 | |
| | 708 | // The core userdata of the user who is currently being displayed |
| | 709 | $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); |
| | 710 | |
| | 711 | // Fetch the full name displayed user |
| | 712 | $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() ); |
| | 713 | } |
| | 714 | |
| | 715 | // Build redirection URL |
| | 716 | $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); |
| | 717 | $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; |
| | 718 | |
| | 719 | if ( ! empty( $_REQUEST['user_status'] ) ) { |
| | 720 | $spam = ( 'spam' == $_REQUEST['user_status'] ) ? true : false ; |
| | 721 | |
| | 722 | if ( $spam != bp_is_user_spammer( $user_id ) ) |
| | 723 | $doaction = $_REQUEST['user_status']; |
| | 724 | } |
| | 725 | |
| | 726 | // Call an action for plugins to hook in early |
| | 727 | do_action_ref_array( 'bp_xprofile_user_admin_load', array( $doaction, $_REQUEST ) ); |
| | 728 | |
| | 729 | // Prepare the display of the Community Profile screen |
| | 730 | if ( ! in_array( $doaction, array( 'update', 'delete_avatar', 'spam', 'ham' ) ) ) { |
| | 731 | add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); |
| | 732 | |
| | 733 | get_current_screen()->add_help_tab( array( |
| | 734 | 'id' => 'bp-profile-edit-overview', |
| | 735 | 'title' => __( 'Overview', 'buddypress' ), |
| | 736 | 'content' => |
| | 737 | '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . |
| | 738 | '<p>' . __( 'You can edit the different fields of his extended profile from the main metabox', 'buddypress' ) . '</p>' . |
| | 739 | '<p>' . __( 'You can get some interesting informations about him on right side metaboxes', 'buddypress' ) . '</p>' |
| | 740 | ) ); |
| | 741 | |
| | 742 | // Help panel - sidebar links |
| | 743 | get_current_screen()->set_help_sidebar( |
| | 744 | '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . |
| | 745 | '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . |
| | 746 | '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' |
| | 747 | ); |
| | 748 | |
| | 749 | // Register metaboxes for the edit screen. |
| | 750 | add_meta_box( 'submitdiv', _x( 'Status', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_status_metabox' ), get_current_screen()->id, 'side', 'core' ); |
| | 751 | |
| | 752 | // Each Group of fields will have his own metabox |
| | 753 | if ( false == bp_is_user_spammer( $user_id ) && bp_has_profile( array( 'fetch_fields' => false ) ) ) { |
| | 754 | while ( bp_profile_groups() ) : bp_the_profile_group(); |
| | 755 | add_meta_box( 'bp_xprofile_user_admin_fields_' . bp_get_the_profile_group_slug(), bp_get_the_profile_group_name(), array( &$this, 'user_admin_profile_metaboxes' ), get_current_screen()->id, 'normal', 'core', array( 'profile_group_id' => bp_get_the_profile_group_id() ) ); |
| | 756 | endwhile; |
| | 757 | // if a user has been mark as a spammer, his BuddyPress datas are removed ! |
| | 758 | } else { |
| | 759 | add_meta_box( 'bp_xprofile_user_admin_empty_profile', _x( 'User marked as a spammer', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_spammer_metabox' ), get_current_screen()->id, 'normal', 'core' ); |
| | 760 | } |
| | 761 | |
| | 762 | // Avatar Metabox |
| | 763 | add_meta_box( 'bp_xprofile_user_admin_avatar', _x( 'Avatar', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_avatar_metabox' ), get_current_screen()->id, 'side', 'low' ); |
| | 764 | |
| | 765 | // User Stat metabox |
| | 766 | add_meta_box( 'bp_xprofile_user_admin_stat', _x( 'Stats', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_stats_metabox' ), get_current_screen()->id, 'side', 'low' ); |
| | 767 | |
| | 768 | // Custom metabox ? |
| | 769 | do_action( 'bp_xprofile_user_admin_metaboxes' ); |
| | 770 | |
| | 771 | // Enqueue javascripts |
| | 772 | wp_enqueue_script( 'postbox' ); |
| | 773 | wp_enqueue_script( 'dashboard' ); |
| | 774 | wp_enqueue_script( 'comment' ); |
| | 775 | |
| | 776 | // Spam or Ham user |
| | 777 | } else if ( in_array( $doaction, array( 'spam', 'ham' ) ) ) { |
| | 778 | |
| | 779 | check_admin_referer( 'edit-bp-profile_' . $user_id ); |
| | 780 | |
| | 781 | if ( bp_core_process_spammer_status( $user_id, $doaction ) ) |
| | 782 | $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); |
| | 783 | else |
| | 784 | $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); |
| | 785 | |
| | 786 | bp_core_redirect( $redirect_to ); |
| | 787 | |
| | 788 | // delete avatar |
| | 789 | } else if ( 'delete_avatar' == $doaction ) { |
| | 790 | |
| | 791 | check_admin_referer( 'delete_avatar' ); |
| | 792 | |
| | 793 | $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); |
| | 794 | |
| | 795 | if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) |
| | 796 | $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); |
| | 797 | else |
| | 798 | $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); |
| | 799 | |
| | 800 | bp_core_redirect( $redirect_to ); |
| | 801 | |
| | 802 | // update fields |
| | 803 | } else { |
| | 804 | |
| | 805 | // Check to see if any new information has been submitted |
| | 806 | if ( isset( $_POST['field_ids'] ) ) { |
| | 807 | |
| | 808 | // Check the nonce |
| | 809 | check_admin_referer( 'edit-bp-profile_' . $user_id ); |
| | 810 | |
| | 811 | // Check we have field ID's |
| | 812 | if ( empty( $_POST['field_ids'] ) ) { |
| | 813 | $redirect_to = add_query_arg( 'error', '1', $redirect_to ); |
| | 814 | bp_core_redirect( $redirect_to ); |
| | 815 | } |
| | 816 | |
| | 817 | $merge_ids = ''; |
| | 818 | foreach ( $_POST['field_ids'] as $ids ) { |
| | 819 | $merge_ids .= $ids . ','; |
| | 820 | } |
| | 821 | |
| | 822 | // Explode the posted field IDs into an array so we know which |
| | 823 | // fields have been submitted |
| | 824 | $posted_field_ids = array_filter( wp_parse_id_list( $merge_ids ) ); |
| | 825 | $is_required = array(); |
| | 826 | |
| | 827 | // Loop through the posted fields formatting any datebox values |
| | 828 | // then validate the field |
| | 829 | foreach ( (array) $posted_field_ids as $field_id ) { |
| | 830 | if ( !isset( $_POST['field_' . $field_id] ) ) { |
| | 831 | |
| | 832 | if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) { |
| | 833 | // Concatenate the values |
| | 834 | $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; |
| | 835 | |
| | 836 | // Turn the concatenated value into a timestamp |
| | 837 | $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); |
| | 838 | } |
| | 839 | |
| | 840 | } |
| | 841 | |
| | 842 | $is_required[$field_id] = xprofile_check_is_required_field( $field_id ); |
| | 843 | if ( $is_required[$field_id] && empty( $_POST['field_' . $field_id] ) ) { |
| | 844 | $redirect_to = add_query_arg( 'error', '2', $redirect_to ); |
| | 845 | bp_core_redirect( $redirect_to ); |
| | 846 | } |
| | 847 | } |
| | 848 | |
| | 849 | // Set the errors var |
| | 850 | $errors = false; |
| | 851 | |
| | 852 | // Now we've checked for required fields, lets save the values. |
| | 853 | foreach ( (array) $posted_field_ids as $field_id ) { |
| | 854 | |
| | 855 | // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit. |
| | 856 | if ( empty( $_POST['field_' . $field_id] ) ) { |
| | 857 | $value = array(); |
| | 858 | } else { |
| | 859 | $value = $_POST['field_' . $field_id]; |
| | 860 | } |
| | 861 | |
| | 862 | if ( !xprofile_set_field_data( $field_id, $user_id, $value, $is_required[$field_id] ) ) { |
| | 863 | $errors = true; |
| | 864 | } else { |
| | 865 | do_action( 'xprofile_profile_field_data_updated', $field_id, $value ); |
| | 866 | } |
| | 867 | |
| | 868 | } |
| | 869 | |
| | 870 | do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors ); |
| | 871 | |
| | 872 | |
| | 873 | // Set the feedback messages |
| | 874 | if ( !empty( $errors ) ) { |
| | 875 | $redirect_to = add_query_arg( 'error', '3', $redirect_to ); |
| | 876 | } else { |
| | 877 | $redirect_to = add_query_arg( 'updated', '1', $redirect_to ); |
| | 878 | } |
| | 879 | |
| | 880 | bp_core_redirect( $redirect_to ); |
| | 881 | |
| | 882 | } |
| | 883 | |
| | 884 | do_action( 'xprofile_screen_edit_profile' ); |
| | 885 | |
| | 886 | } |
| | 887 | |
| | 888 | } |
| | 889 | |
| | 890 | /** |
| | 891 | * Display the user's profile. |
| | 892 | * |
| | 893 | * @access public |
| | 894 | * @since BuddyPress (?) |
| | 895 | */ |
| | 896 | public function user_admin() { |
| | 897 | if ( ! current_user_can( 'bp_moderate' ) ) |
| | 898 | die( '-1' ); |
| | 899 | |
| | 900 | $user = get_user_to_edit( $_GET['user_id'] ); |
| | 901 | |
| | 902 | // Construct URL for form |
| | 903 | $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); |
| | 904 | $form_url = add_query_arg( 'action', 'update', $form_url ); |
| | 905 | $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); |
| | 906 | |
| | 907 | // Prepare notice for admin |
| | 908 | $notice = array(); |
| | 909 | |
| | 910 | if ( ! empty( $_REQUEST['updated'] ) ) { |
| | 911 | switch ( $_REQUEST['updated'] ) { |
| | 912 | case 'avatar': |
| | 913 | $notice = array( |
| | 914 | 'class' => 'updated', |
| | 915 | 'message' => __( 'Avatar was deleted successfully!', 'buddypress' ) |
| | 916 | ); |
| | 917 | break; |
| | 918 | case 'ham' : |
| | 919 | $notice = array( |
| | 920 | 'class' => 'updated', |
| | 921 | 'message' => __( 'User removed as spammer.', 'buddypress' ) |
| | 922 | ); |
| | 923 | break; |
| | 924 | case 'spam' : |
| | 925 | $notice = array( |
| | 926 | 'class' => 'updated', |
| | 927 | 'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) |
| | 928 | ); |
| | 929 | break; |
| | 930 | case 1 : |
| | 931 | $notice = array( |
| | 932 | 'class' => 'updated', |
| | 933 | 'message' => __( 'Profile updated.', 'buddypress' ) |
| | 934 | ); |
| | 935 | break; |
| | 936 | } |
| | 937 | } |
| | 938 | |
| | 939 | if ( ! empty( $_REQUEST['error'] ) ) { |
| | 940 | switch ( $_REQUEST['error'] ) { |
| | 941 | case 'avatar': |
| | 942 | $notice = array( |
| | 943 | 'class' => 'error', |
| | 944 | 'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ) |
| | 945 | ); |
| | 946 | break; |
| | 947 | case 'ham' : |
| | 948 | $notice = array( |
| | 949 | 'class' => 'error', |
| | 950 | 'message' => __( 'User could not be removed as spammer.', 'buddypress' ) |
| | 951 | ); |
| | 952 | break; |
| | 953 | case 'spam' : |
| | 954 | $notice = array( |
| | 955 | 'class' => 'error', |
| | 956 | 'message' => __( 'User could not be marked as spammer.', 'buddypress' ) |
| | 957 | ); |
| | 958 | break; |
| | 959 | case 1 : |
| | 960 | $notice = array( |
| | 961 | 'class' => 'error', |
| | 962 | 'message' => __( 'An error occured while trying to update the profile.', 'buddypress' ) |
| | 963 | ); |
| | 964 | break; |
| | 965 | case 2: |
| | 966 | $notice = array( |
| | 967 | 'class' => 'error', |
| | 968 | 'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ) |
| | 969 | ); |
| | 970 | break; |
| | 971 | case 3: |
| | 972 | $notice = array( |
| | 973 | 'class' => 'error', |
| | 974 | 'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ) |
| | 975 | ); |
| | 976 | break; |
| | 977 | } |
| | 978 | } |
| | 979 | |
| | 980 | if ( ! empty( $notice ) ) : |
| | 981 | if ( 'updated' == $notice['class'] ) :?> |
| | 982 | <div id="message" class="<?php echo $notice['class']; ?>"> |
| | 983 | <?php else: ?> |
| | 984 | <div class="<?php echo $notice['class']; ?>"> |
| | 985 | <?php endif; ?> |
| | 986 | <p><?php echo $notice['message']; ?></p> |
| | 987 | <?php if ( $wp_http_referer && 'updated' == $notice['class'] ) : ?> |
| | 988 | <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e( '← Back to Users', 'buddypress' ); ?></a></p> |
| | 989 | <?php endif; ?> |
| | 990 | </div> |
| | 991 | <?php endif; ?> |
| | 992 | |
| | 993 | <div class="wrap" id="community-profile-page"> |
| | 994 | <?php screen_icon( 'users' ); ?> |
| | 995 | <h2> |
| | 996 | <?php |
| | 997 | _e( 'Edit User', 'buddypress' ) ; |
| | 998 | if ( current_user_can( 'create_users' ) ) { ?> |
| | 999 | <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> |
| | 1000 | <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
| | 1001 | <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> |
| | 1002 | <?php } |
| | 1003 | ?> |
| | 1004 | </h2> |
| | 1005 | |
| | 1006 | <?php if ( ! empty( $user ) ) : |
| | 1007 | |
| | 1008 | $this->profile_nav( $user, 'BuddyPress' ); ?> |
| | 1009 | |
| | 1010 | <form action="<?php echo esc_attr( $form_url ); ?>" id="your-profile" method="post"> |
| | 1011 | <div id="poststuff"> |
| | 1012 | |
| | 1013 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| | 1014 | <div id="post-body-content"> |
| | 1015 | </div><!-- #post-body-content --> |
| | 1016 | |
| | 1017 | <div id="postbox-container-1" class="postbox-container"> |
| | 1018 | <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?> |
| | 1019 | </div> |
| | 1020 | |
| | 1021 | <div id="postbox-container-2" class="postbox-container"> |
| | 1022 | <?php do_meta_boxes( get_current_screen()->id, 'normal', $user ); ?> |
| | 1023 | <?php do_meta_boxes( get_current_screen()->id, 'advanced', $user ); ?> |
| | 1024 | </div> |
| | 1025 | </div><!-- #post-body --> |
| | 1026 | |
| | 1027 | </div><!-- #poststuff --> |
| | 1028 | <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
| | 1029 | <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
| | 1030 | <?php wp_nonce_field( 'edit-bp-profile_' . $user->ID ); ?> |
| | 1031 | |
| | 1032 | </form> |
| | 1033 | |
| | 1034 | <?php else : ?> |
| | 1035 | <p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p> |
| | 1036 | <?php endif; ?> |
| | 1037 | |
| | 1038 | </div><!-- .wrap --> |
| | 1039 | <?php |
| | 1040 | } |
| | 1041 | |
| | 1042 | /** |
| | 1043 | * Renders the Status metabox for user's profile screen. |
| | 1044 | * |
| | 1045 | * Actions are : |
| | 1046 | * - Update profile fields |
| | 1047 | * - Spam/Unspam user |
| | 1048 | * |
| | 1049 | * @access public |
| | 1050 | * @since BuddyPress (?) |
| | 1051 | * |
| | 1052 | * @param WP_User $user The WP_User object for the user's profile to edit |
| | 1053 | */ |
| | 1054 | public function user_admin_status_metabox( $user = null ) { |
| | 1055 | if ( empty( $user->ID ) ) |
| | 1056 | return; |
| | 1057 | ?> |
| | 1058 | |
| | 1059 | <div class="submitbox" id="submitcomment"> |
| | 1060 | |
| | 1061 | <div id="minor-publishing"> |
| | 1062 | <div id="minor-publishing-actions"> |
| | 1063 | <div id="preview-action"> |
| | 1064 | <a class="button preview" href="<?php echo esc_attr( bp_core_get_user_domain( $user->ID ) ); ?>" target="_blank"><?php _e( 'View Profile', 'buddypress' ); ?></a> |
| | 1065 | </div> |
| | 1066 | |
| | 1067 | <div class="clear"></div> |
| | 1068 | </div><!-- #minor-publishing-actions --> |
| | 1069 | |
| | 1070 | <div id="misc-publishing-actions"> |
| | 1071 | <div class="misc-pub-section" id="comment-status-radio"> |
| | 1072 | <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( bp_is_user_spammer( $user->ID ), false ); ?>><?php _e( 'Approved', 'buddypress' ); ?></label><br /> |
| | 1073 | <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( bp_is_user_spammer( $user->ID ), true ); ?>><?php _e( 'Spam', 'buddypress' ); ?></label> |
| | 1074 | </div> |
| | 1075 | |
| | 1076 | <div class="misc-pub-section curtime misc-pub-section-last"> |
| | 1077 | <?php |
| | 1078 | // translators: Publish box date format, see http://php.net/date |
| | 1079 | $datef = __( 'M j, Y @ G:i', 'buddypress' ); |
| | 1080 | $date = date_i18n( $datef, strtotime( $user->user_registered ) ); |
| | 1081 | ?> |
| | 1082 | <span id="timestamp"><?php printf( __( 'Registered on: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></span> |
| | 1083 | |
| | 1084 | <div id='timestampdiv' class='hide-if-js'> |
| | 1085 | <?php touch_time( 1, 0, 5 ); ?> |
| | 1086 | </div><!-- #timestampdiv --> |
| | 1087 | </div> |
| | 1088 | </div> <!-- #misc-publishing-actions --> |
| | 1089 | |
| | 1090 | <div class="clear"></div> |
| | 1091 | </div><!-- #minor-publishing --> |
| | 1092 | |
| | 1093 | <div id="major-publishing-actions"> |
| | 1094 | <div id="publishing-action"> |
| | 1095 | <?php submit_button( __( 'Update Profile', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?> |
| | 1096 | </div> |
| | 1097 | <div class="clear"></div> |
| | 1098 | </div><!-- #major-publishing-actions --> |
| | 1099 | |
| | 1100 | </div><!-- #submitcomment --> |
| | 1101 | |
| | 1102 | <?php |
| | 1103 | } |
| | 1104 | |
| | 1105 | /** |
| | 1106 | * Renders the xprofile metabox for user's profile screen. |
| | 1107 | * |
| | 1108 | * @access public |
| | 1109 | * @since BuddyPress (?) |
| | 1110 | * |
| | 1111 | * @param WP_User $user The WP_User object for the user's profile to edit |
| | 1112 | */ |
| | 1113 | public function user_admin_profile_metaboxes( $user = null, $args = array() ) { |
| | 1114 | if ( empty( $user->ID ) ) |
| | 1115 | return; |
| | 1116 | |
| | 1117 | $r = bp_parse_args( $args['args'], array( |
| | 1118 | 'profile_group_id' => 0, |
| | 1119 | 'user_id' => $user->ID |
| | 1120 | ), 'bp_xprofile_user_admin_profile_loop_args' ); |
| | 1121 | |
| | 1122 | // We really need these args |
| | 1123 | if ( empty( $r['profile_group_id'] ) || empty( $r['user_id'] ) ) |
| | 1124 | return; |
| | 1125 | |
| | 1126 | if ( bp_has_profile( $r ) ) : |
| | 1127 | |
| | 1128 | while ( bp_profile_groups() ) : bp_the_profile_group(); ?> |
| | 1129 | |
| | 1130 | <p class="description"><?php bp_the_profile_group_description(); ?></p> |
| | 1131 | |
| | 1132 | <table class="form-table"> |
| | 1133 | <tbody> |
| | 1134 | |
| | 1135 | <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> |
| | 1136 | |
| | 1137 | <tr> |
| | 1138 | |
| | 1139 | <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?> |
| | 1140 | |
| | 1141 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| | 1142 | <td> |
| | 1143 | <input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>/> |
| | 1144 | <span class="description"><?php bp_the_profile_field_description(); ?></span> |
| | 1145 | </td> |
| | 1146 | |
| | 1147 | <?php endif; ?> |
| | 1148 | |
| | 1149 | <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?> |
| | 1150 | |
| | 1151 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| | 1152 | <td> |
| | 1153 | <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>><?php bp_the_profile_field_edit_value(); ?></textarea> |
| | 1154 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| | 1155 | </td> |
| | 1156 | |
| | 1157 | <?php endif; ?> |
| | 1158 | |
| | 1159 | <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?> |
| | 1160 | |
| | 1161 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| | 1162 | <td> |
| | 1163 | <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| | 1164 | <?php bp_the_profile_field_options(); ?> |
| | 1165 | </select> |
| | 1166 | <span class="description"><?php bp_the_profile_field_description(); ?></span> |
| | 1167 | </td> |
| | 1168 | |
| | 1169 | <?php endif; ?> |
| | 1170 | |
| | 1171 | <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?> |
| | 1172 | |
| | 1173 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| | 1174 | <td> |
| | 1175 | <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" multiple="multiple" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| | 1176 | |
| | 1177 | <?php bp_the_profile_field_options(); ?> |
| | 1178 | |
| | 1179 | </select> |
| | 1180 | |
| | 1181 | |
| | 1182 | <?php if ( !bp_get_the_profile_field_is_required() ) : ?> |
| | 1183 | |
| | 1184 | <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> |
| | 1185 | |
| | 1186 | <?php endif; ?> |
| | 1187 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| | 1188 | </td> |
| | 1189 | |
| | 1190 | <?php endif; ?> |
| | 1191 | |
| | 1192 | <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?> |
| | 1193 | |
| | 1194 | <th> |
| | 1195 | <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> |
| | 1196 | </th> |
| | 1197 | <td> |
| | 1198 | <fieldset> |
| | 1199 | <legend class="screen-reader-text"><span><?php bp_the_profile_field_name(); ?></span></legend> |
| | 1200 | <?php bp_the_profile_field_options(); ?> |
| | 1201 | </fieldset> |
| | 1202 | |
| | 1203 | <?php if ( !bp_get_the_profile_field_is_required() ) : ?> |
| | 1204 | |
| | 1205 | <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> |
| | 1206 | |
| | 1207 | <?php endif; ?> |
| | 1208 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| | 1209 | </td> |
| | 1210 | |
| | 1211 | <?php endif; ?> |
| | 1212 | |
| | 1213 | <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?> |
| | 1214 | |
| | 1215 | <th> |
| | 1216 | <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> |
| | 1217 | </th> |
| | 1218 | <td> |
| | 1219 | <?php bp_the_profile_field_options(); ?> |
| | 1220 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| | 1221 | </td> |
| | 1222 | |
| | 1223 | <?php endif; ?> |
| | 1224 | |
| | 1225 | <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?> |
| | 1226 | |
| | 1227 | <th> |
| | 1228 | <label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label> |
| | 1229 | </th> |
| | 1230 | <td> |
| | 1231 | <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| | 1232 | |
| | 1233 | <?php bp_the_profile_field_options( 'type=day' ); ?> |
| | 1234 | |
| | 1235 | </select> |
| | 1236 | |
| | 1237 | <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| | 1238 | |
| | 1239 | <?php bp_the_profile_field_options( 'type=month' ); ?> |
| | 1240 | |
| | 1241 | </select> |
| | 1242 | |
| | 1243 | <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| | 1244 | |
| | 1245 | <?php bp_the_profile_field_options( 'type=year' ); ?> |
| | 1246 | |
| | 1247 | </select> |
| | 1248 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| | 1249 | </td> |
| | 1250 | |
| | 1251 | <?php endif; ?> |
| | 1252 | |
| | 1253 | </tr> |
| | 1254 | |
| | 1255 | <?php endwhile; ?> |
| | 1256 | </tbody> |
| | 1257 | |
| | 1258 | </table> |
| | 1259 | <input type="hidden" name="field_ids[]" id="field_ids_<?php bp_the_profile_group_slug(); ?>" value="<?php bp_the_profile_group_field_ids(); ?>" /> |
| | 1260 | <?php endwhile; |
| | 1261 | endif; |
| | 1262 | } |
| | 1263 | |
| | 1264 | /** |
| | 1265 | * Renders the fallback metabox in case a user has been marked as a spammer. |
| | 1266 | * |
| | 1267 | * @access public |
| | 1268 | * @since BuddyPress (?) |
| | 1269 | * |
| | 1270 | * @param WP_User $user The WP_User object for the user's profile to edit |
| | 1271 | */ |
| | 1272 | public function user_admin_spammer_metabox( $user = null ) { |
| | 1273 | ?> |
| | 1274 | <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> |
| | 1275 | <?php |
| | 1276 | } |
| | 1277 | |
| | 1278 | /** |
| | 1279 | * Renders the Avatar metabox to moderate inappropriate images. |
| | 1280 | * |
| | 1281 | * @access public |
| | 1282 | * @since BuddyPress (?) |
| | 1283 | * |
| | 1284 | * @param WP_User $user The WP_User object for the user's profile to edit |
| | 1285 | */ |
| | 1286 | public function user_admin_avatar_metabox( $user = null ) { |
| | 1287 | if ( empty( $user->ID ) ) |
| | 1288 | return; |
| | 1289 | |
| | 1290 | $args = array( |
| | 1291 | 'item_id' => $user->ID, |
| | 1292 | 'object' => 'user', |
| | 1293 | 'type' => 'full', |
| | 1294 | 'title' => $user->display_name |
| | 1295 | ); |
| | 1296 | |
| | 1297 | ?> |
| | 1298 | |
| | 1299 | <div class="avatar"> |
| | 1300 | |
| | 1301 | <?php echo bp_core_fetch_avatar( $args ); ?> |
| | 1302 | |
| | 1303 | <?php if ( bp_get_user_has_avatar( $user->ID ) ) : |
| | 1304 | |
| | 1305 | $query_args = array( |
| | 1306 | 'user_id' => $user->ID, |
| | 1307 | 'action' => 'delete_avatar' |
| | 1308 | ); |
| | 1309 | |
| | 1310 | if ( ! empty( $_REQUEST['wp_http_referer'] ) ) |
| | 1311 | $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
| | 1312 | |
| | 1313 | $community_url = add_query_arg( $query_args, $this->edit_profile_url ); |
| | 1314 | $delete_link = wp_nonce_url( $community_url, 'delete_avatar' );?> |
| | 1315 | |
| | 1316 | <a href="<?php echo $delete_link ;?>" title="<?php _e( 'Delete Avatar', 'buddypress' ); ?>"><span class="dashicons dashicons dashicons-trash"></span> <?php _e( 'Delete Avatar', 'buddypress' ); ?></a></li> |
| | 1317 | |
| | 1318 | <?php endif; ?> |
| | 1319 | |
| | 1320 | </div> |
| | 1321 | <?php |
| | 1322 | } |
| | 1323 | |
| | 1324 | /** |
| | 1325 | * Renders the Avatar metabox to moderate inappropriate images. |
| | 1326 | * |
| | 1327 | * @access public |
| | 1328 | * @since BuddyPress (?) |
| | 1329 | * |
| | 1330 | * @param WP_User $user The WP_User object for the user's profile to edit |
| | 1331 | */ |
| | 1332 | public function user_admin_stats_metabox( $user = null ) { |
| | 1333 | if ( empty( $user->ID ) ) |
| | 1334 | return; |
| | 1335 | $last_active = bp_get_user_last_activity( $user->ID ); |
| | 1336 | |
| | 1337 | $datef = __( 'M j, Y @ G:i', 'buddypress' ); |
| | 1338 | $date = date_i18n( $datef, strtotime( $last_active ) ); |
| | 1339 | ?> |
| | 1340 | <ul> |
| | 1341 | <li><div class="dashicons dashicons-last-active"></div> <?php printf( __( 'Last active: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></li> |
| | 1342 | <?php |
| | 1343 | if ( bp_is_active( 'friends' ) && $friends_amount = friends_get_total_friend_count( $user->ID ) ) { |
| | 1344 | ?> |
| | 1345 | <li><div class="dashicons dashicons-friends"></div> <?php printf( _n( '1 friend', '<strong>%s</strong> friends', $friends_amount, 'buddypress' ), $friends_amount );?></li> |
| | 1346 | <?php |
| | 1347 | } |
| | 1348 | if ( bp_is_active( 'groups' ) && $groups_amount = bp_get_total_group_count_for_user( $user->ID ) ) { |
| | 1349 | ?> |
| | 1350 | <li><div class="dashicons dashicons-groups"></div> <?php printf( _n( '1 group', '<strong>%s</strong> groups', $groups_amount, 'buddypress' ), $groups_amount );?></li> |
| | 1351 | <?php |
| | 1352 | } |
| | 1353 | if ( bp_is_active( 'blogs' ) && is_multisite() && $blogs_amount = bp_blogs_total_blogs_for_user( $user->ID ) ) { |
| | 1354 | ?> |
| | 1355 | <li><div class="dashicons dashicons-blogs"></div> <?php printf( _n( '1 site', '<strong>%s</strong> sites', $blogs_amount, 'buddypress' ), $blogs_amount );?></li> |
| | 1356 | <?php |
| | 1357 | } |
| | 1358 | |
| | 1359 | // Plugins may add their custom stats here... |
| | 1360 | do_action( 'bp_xprofile_user_admin_stats', $user->ID, $user ); |
| | 1361 | ?> |
| | 1362 | </ul> |
| | 1363 | <?php |
| | 1364 | } |
| | 1365 | |
| | 1366 | /** |
| | 1367 | * Adds a link to user's profile in users listing row actions. |
| | 1368 | * |
| | 1369 | * @access public |
| | 1370 | * @since BuddyPress (?) |
| | 1371 | * |
| | 1372 | * @param array $actions the WordPress row actions (edit, delete) |
| | 1373 | * @param object $user The object for the user's row |
| | 1374 | */ |
| | 1375 | public function row_actions( $actions = '', $user = null ) { |
| | 1376 | if ( get_current_user_id() == $user->ID ) |
| | 1377 | return $actions; |
| | 1378 | |
| | 1379 | $edit_xprofile = esc_url( add_query_arg( array( |
| | 1380 | 'user_id' => $user->ID, |
| | 1381 | 'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) |
| | 1382 | ), $this->edit_profile_url ) ); |
| | 1383 | |
| | 1384 | $edit_action = $actions['edit']; |
| | 1385 | unset( $actions['edit'] ); |
| | 1386 | |
| | 1387 | $new_edit_actions = array( |
| | 1388 | 'edit' => $edit_action, |
| | 1389 | 'edit-xprofile' => '<a href="' . $edit_xprofile . '">' . __( 'Profile', 'buddypress' ) . '</a>' |
| | 1390 | ); |
| | 1391 | |
| | 1392 | return array_merge( $new_edit_actions, $actions ); |
| | 1393 | } |
| | 1394 | |
| | 1395 | } |
| | 1396 | |
| | 1397 | endif; // class_exists check |
| | 1398 | |
| | 1399 | /** |
| | 1400 | * Setup xProfile User Admin. |
| | 1401 | * |
| | 1402 | * @since BuddyPress (?) |
| | 1403 | * |
| | 1404 | * @uses buddypress() to get BuddyPress main instance |
| | 1405 | */ |
| | 1406 | function xprofile_user_admin() { |
| | 1407 | buddypress()->admin->xprofile = new Xprofile_User_Admin(); |
| | 1408 | } |
| | 1409 | |
| | 1410 | // Load the xprofile user admin |
| | 1411 | if ( is_admin() ) { |
| | 1412 | add_action( 'bp_loaded', 'xprofile_user_admin', 11 ); |
| | 1413 | } |