Пример #1
0
 public function upload_dir_filter()
 {
     $upload_dir_data = parent::upload_dir_filter();
     if (!is_user_logged_in()) {
         return $upload_dir_data;
     }
     return array('path' => $this->upload_path . '/' . bp_loggedin_user_id(), 'url' => $this->url . '/' . bp_loggedin_user_id(), 'subdir' => '/' . bp_loggedin_user_id(), 'basedir' => $this->upload_path . '/' . bp_loggedin_user_id(), 'baseurl' => $this->url . '/' . bp_loggedin_user_id(), 'error' => false);
 }
 /**
  * Build script datas for the Uploader UI
  */
 public function script_data()
 {
     // Get default script data
     $script_data = parent::script_data();
     $script_data['bp_params'] = array('item_id' => bp_loggedin_user_id());
     // Include our specific css
     $script_data['extra_css'] = array('fe-attachments-style');
     // Include our specific js
     $script_data['extra_js'] = array('fe-attachments-script');
     return apply_filters('front_end_attachment_script_data', $script_data);
 }
 /**
  * Build script datas for the Uploader UI.
  *
  * @since 2.3.0
  *
  * @return array The javascript localization data.
  */
 public function script_data()
 {
     // Get default script data.
     $script_data = parent::script_data();
     // Defaults to Avatar Backbone script.
     $js_scripts = array('bp-avatar');
     // Default object.
     $object = '';
     // Get the possible item ids.
     $user_id = $this->get_user_id();
     $group_id = $this->get_group_id();
     if (!empty($user_id)) {
         // Should we load the the Webcam Avatar javascript file.
         if (bp_avatar_use_webcam()) {
             $js_scripts = array('bp-webcam');
         }
         $script_data['bp_params'] = array('object' => 'user', 'item_id' => $user_id, 'has_avatar' => bp_get_user_has_avatar($user_id), 'nonces' => array('set' => wp_create_nonce('bp_avatar_cropstore'), 'remove' => wp_create_nonce('bp_delete_avatar_link')));
         // Set feedback messages.
         $script_data['feedback_messages'] = array(1 => __('There was a problem cropping your profile photo.', 'buddypress'), 2 => __('Your new profile photo was uploaded successfully.', 'buddypress'), 3 => __('There was a problem deleting your profile photo. Please try again.', 'buddypress'), 4 => __('Your profile photo was deleted successfully!', 'buddypress'));
     } elseif (!empty($group_id)) {
         $script_data['bp_params'] = array('object' => 'group', 'item_id' => $group_id, 'has_avatar' => bp_get_group_has_avatar($group_id), 'nonces' => array('set' => wp_create_nonce('bp_avatar_cropstore'), 'remove' => wp_create_nonce('bp_group_avatar_delete')));
         // Set feedback messages.
         $script_data['feedback_messages'] = array(1 => __('There was a problem cropping the group profile photo.', 'buddypress'), 2 => __('The group profile photo was uploaded successfully.', 'buddypress'), 3 => __('There was a problem deleting the group profile photo. Please try again.', 'buddypress'), 4 => __('The group profile photo was deleted successfully!', 'buddypress'));
     } else {
         /**
          * Use this filter to include specific BuddyPress params for your object.
          * e.g. Blavatar.
          *
          * @since 2.3.0
          *
          * @param array $value The avatar specific BuddyPress parameters.
          */
         $script_data['bp_params'] = apply_filters('bp_attachment_avatar_params', array());
     }
     // Include the specific css.
     $script_data['extra_css'] = array('bp-avatar');
     // Include the specific css.
     $script_data['extra_js'] = $js_scripts;
     // Set the object to contextualize the filter.
     if (isset($script_data['bp_params']['object'])) {
         $object = $script_data['bp_params']['object'];
     }
     /**
      * Use this filter to override/extend the avatar script data.
      *
      * @since 2.3.0
      *
      * @param array  $script_data The avatar script data.
      * @param string $object      The object the avatar belongs to (eg: user or group).
      */
     return apply_filters('bp_attachment_avatar_script_data', $script_data, $object);
 }
 public function __construct($args = array())
 {
     return parent::__construct($args);
 }
 /**
  * Build script datas for the Uploader UI
  *
  * @since 2.4.0
  *
  * @return array the javascript localization data
  */
 public function script_data()
 {
     // Get default script data
     $script_data = parent::script_data();
     if (bp_is_user()) {
         $item_id = bp_displayed_user_id();
         $script_data['bp_params'] = array('object' => 'user', 'item_id' => $item_id, 'has_cover_image' => bp_attachments_get_user_has_cover_image($item_id), 'nonces' => array('remove' => wp_create_nonce('bp_delete_cover_image')));
         // Set feedback messages
         $script_data['feedback_messages'] = array(1 => __('Your new cover image was uploaded successfully.', 'buddypress'), 2 => __('There was a problem deleting your cover image. Please try again.', 'buddypress'), 3 => __('Your cover image was deleted successfully!', 'buddypress'));
     } elseif (bp_is_group()) {
         $item_id = bp_get_current_group_id();
         $script_data['bp_params'] = array('object' => 'group', 'item_id' => bp_get_current_group_id(), 'has_cover_image' => bp_attachments_get_group_has_cover_image($item_id), 'nonces' => array('remove' => wp_create_nonce('bp_delete_cover_image')));
         // Set feedback messages
         $script_data['feedback_messages'] = array(1 => __('The group cover image was uploaded successfully.', 'buddypress'), 2 => __('There was a problem deleting the group cover image. Please try again.', 'buddypress'), 3 => __('The group cover image was deleted successfully!', 'buddypress'));
     } else {
         /**
          * Use this filter to include specific BuddyPress params for your object.
          * e.g. Cover image for blogs single item.
          *
          * @since 2.4.0
          *
          * @param array $value The cover image specific BuddyPress parameters.
          */
         $script_data['bp_params'] = apply_filters('bp_attachment_cover_image_params', array());
     }
     // Include our specific js & css
     $script_data['extra_js'] = array('bp-cover-image');
     $script_data['extra_css'] = array('bp-avatar');
     return apply_filters('bp_attachments_cover_image_script_data', $script_data);
 }
 /**
  * @group avatars
  * @group cover_images
  */
 public function test_bp_attachment_get_image_data()
 {
     $image_data = BP_Attachment::get_image_data(BP_TESTS_DIR . 'assets/upside-down.jpg');
     $this->assertTrue(3 === $image_data['meta']['orientation']);
 }
 public function upload_dir_filter($upload_dir = array())
 {
     $this->original_upload_dir = $upload_dir;
     return parent::upload_dir_filter($upload_dir);
 }
 /**
  * Build script datas for the Uploader UI
  *
  * @since 1.3.0
  *
  * @return array the javascript localization data
  */
 public function script_data()
 {
     // Get default script data
     $script_data = parent::script_data();
     $script_data['bp_params'] = array('object' => buddydrive_get_file_post_type(), 'item_id' => bp_loggedin_user_id(), 'privacy' => 'public');
     if (buddydrive_current_group_is_enabled()) {
         $script_data['bp_params']['privacy'] = 'groups';
         $script_data['bp_params']['privacy_item_id'] = bp_get_current_group_id();
     }
     // Include our specific css
     $script_data['extra_css'] = array('buddydrive-public-style');
     // Include our specific js
     $script_data['extra_js'] = array('buddydrive-public-js');
     return apply_filters('buddydrive_attachment_script_data', $script_data);
 }