/** * Enqueue needed scripts. * * @since 2.3.0 * * @param int $screen_id Screen ID being displayed. */ public function enqueue_scripts($screen_id) { if (false === strpos($screen_id, 'users_page_bp-profile-edit') && false === strpos($screen_id, 'profile_page_bp-profile-edit') || bp_core_get_root_option('bp-disable-avatar-uploads') || !buddypress()->avatar->show_avatars || !bp_attachments_is_wp_version_supported()) { return; } /** * Get Thickbox. * * We cannot simply use add_thickbox() here as WordPress is not playing * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249 * Using media-upload might be interesting in the future for the send to editor stuff * and we make sure the tb_window is wide enougth */ wp_enqueue_style('thickbox'); wp_enqueue_script('media-upload'); // Get Avatar Uploader. bp_attachments_enqueue_scripts('BP_Attachment_Avatar'); }
/** * Enqueues the css and js required by the Cover Image UI. * * @since 2.4.0 */ function bp_core_cover_image_scripts() { if (!bp_attachments_cover_image_is_edit()) { return false; } // Enqueue the Attachments scripts for the Cover Image UI. bp_attachments_enqueue_scripts('BP_Attachment_Cover_Image'); }
/** * Enqueues the css and js required by the Avatar UI * * @since BuddyPress (2.3.0) */ function bp_core_avatar_scripts() { if (!bp_avatar_is_front_edit()) { return false; } // Enqueue the Attachments scripts for the Avatar UI bp_attachments_enqueue_scripts('BP_Attachment_Avatar'); // Add Some actions for Theme backcompat add_action('bp_after_profile_avatar_upload_content', 'bp_avatar_template_check'); add_action('bp_after_group_admin_content', 'bp_avatar_template_check'); add_action('bp_after_group_avatar_creation_step', 'bp_avatar_template_check'); }
/** * An Editor other plugins can use for their need. * * @since 1.3.0 * * @param string $editor_id the Editor's id to insert the BuddyDrive oembed link into. */ function buddydrive_editor($editor_id = '') { $buddydrive = buddydrive(); $current_user_can = (bool) apply_filters('buddydrive_editor_can', is_user_logged_in()); // Bail if current user can't use it and if not in front end if (!$current_user_can || is_admin()) { return; } // Enqueue Thickbox wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); if (!empty($editor_id)) { $buddydrive->editor_id = $editor_id; } // Temporary filters to add custom strings and settings add_filter('bp_attachments_get_plupload_l10n', 'buddydrive_editor_strings', 10, 1); add_filter('bp_attachments_get_plupload_default_settings', 'buddydrive_editor_settings', 10, 1); // Enqueue BuddyPress attachments scripts bp_attachments_enqueue_scripts('BuddyDrive_Attachment'); // Remove the temporary filters remove_filter('bp_attachments_get_plupload_l10n', 'buddydrive_editor_strings', 10, 1); remove_filter('bp_attachments_get_plupload_default_settings', 'buddydrive_editor_settings', 10, 1); $url = remove_query_arg(array_keys($_REQUEST)); ?> <a href="<?php echo esc_url($url); ?> #TB_inline?inlineId=buddydrive-public-uploader" title="<?php esc_attr_e('Add file', 'buddydrive'); ?> " id="buddydrive-btn" class="thickbox button"> <?php echo esc_html_e('Add File', 'buddydrive'); ?> </a> <div id="buddydrive-public-uploader" style="display:none;"> <?php /* Markup for the uploader */ ?> <div class="buddydrive-uploader"></div> <div class="buddydrive-uploader-status"></div> <?php bp_attachments_get_template_part('uploader'); /* Markup for the uploader */ ?> </div> <?php }
/** * BP Attachment Editor */ function front_end_attachments_editor() { // Bail if current user can't use it and if not in front end if (!current_user_can('upload_files') || !buddypress()->core->front_end_attachments->use_bp_attachment) { return; } // Enqueue Thickbox wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); // Temporary filters to add custom strings and settings add_filter('bp_attachments_get_plupload_l10n', 'front_end_attachments_editor_strings', 10, 1); add_filter('bp_attachments_get_plupload_default_settings', 'front_end_attachments_editor_settings', 10, 1); // Enqueue BuddyPress attachments scripts bp_attachments_enqueue_scripts('Front_End_Attachment'); // Remove the temporary filters remove_filter('bp_attachments_get_plupload_l10n', 'front_end_attachments_editor_strings', 10, 1); remove_filter('bp_attachments_get_plupload_default_settings', 'front_end_attachments_editor_settings', 10, 1); $url = remove_query_arg(array_keys($_REQUEST)); ?> <a href="<?php echo esc_url($url); ?> #TB_inline?inlineId=front-end-attachments-modal" title="<?php esc_attr_e('Add file', 'front-end-attachments'); ?> " id="front-end-attachments-btn" class="thickbox button"> <?php echo esc_html_e('Add File', 'front-end-attachments'); ?> </a> <div id="front-end-attachments-modal" style="display:none;"> <?php /* Markup for the uploader */ ?> <div class="fe-attachments-uploader"></div> <div class="fe-attachments-uploader-status"></div> <?php bp_attachments_get_template_part('uploader'); /* Markup for the uploader */ ?> </div> <?php }