/** * Edit album option * * @global RTMediaQuery $rtmedia_query * * @param array $options * * @return array|void */ function rtmedia_album_edit($options) { if (!is_rtmedia_album() || !is_user_logged_in()) { return; } if (!is_rtmedia_album_enable()) { return; } global $rtmedia_query; if (isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && !in_array(intval($rtmedia_query->media_query['album_id']), array_map('intval', rtmedia_get_site_option('rtmedia-global-albums')), true)) { if (rtmedia_is_album_editable() || is_rt_admin()) { $options[] = "<a href='edit/' class='rtmedia-edit' title='" . esc_attr__('Edit Album', 'buddypress-media') . "' ><i class='rtmicon dashicons dashicons-edit'></i>" . esc_html__('Edit Album', 'buddypress-media') . '</a>'; $options[] = '<form method="post" class="album-delete-form rtmedia-inline" action="delete/">' . wp_nonce_field('rtmedia_delete_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_delete_album_nonce') . '<button type="submit" name="album-delete" class="rtmedia-delete-album" title="' . esc_attr__('Delete Album', 'buddypress-media') . '"><i class="dashicons dashicons-trash rtmicon"></i>' . esc_html__('Delete Album', 'buddypress-media') . '</button></form>'; if (is_rtmedia_group_album()) { $album_list = rtmedia_group_album_list(); } else { $album_list = rtmedia_user_album_list(); } if ($album_list) { $options[] = '<a href="#rtmedia-merge" class="rtmedia-reveal-modal rtmedia-modal-link" title="' . esc_attr__('Merge Album', 'buddypress-media') . '"><i class="dashicons dashicons-randomize"></i>' . esc_html__('Merge Album', 'buddypress-media') . '</a>'; } } } return $options; }
/** * Render the uploader shortcode and attach the uploader panel * * @param type $template_name */ public function render($template_name) { global $rtmedia_query; $album = ''; if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album()) { $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />'; } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) { if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') { $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>'; } if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') { $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>'; } } $up_privacy = $privacy = ""; //uploader privacy dropdown for uploader under rtMedia Media tab. if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false)) { if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') { // if the context is group, then set the media privacy to public $privacy = "<input type='hidden' name='privacy' value='0'/>"; } else { $up_privacy = new RTMediaPrivacy(); $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy'); if ($up_privacy) { $privacy = "<span><i class='rtmicon-eye'></i> <label for='privacy'> " . __('Privacy: ', 'rtmedia') . "</label>" . $up_privacy . "</span>"; } } } $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop row">' . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", "rtmedia") . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'rtmedia') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'rtmedia') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'rtmedia') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="row">' . wp_nonce_field('rtmedia_' . get_current_user_id(), 'rtmedia_media_delete_nonce') . '<table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div class="rtmedia-container"><div id="rtmedia-action-update"><button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update"><i class="rtmicon-plus-circle"></i>' . apply_filters('rtmedia_attach_file_message', __('Attach Files', 'rtmedia')) . '</button>' . $up_privacy . '</div><div id="rtmedia-whts-new-upload-container"><div id="rtm-upload-start-notice"><span>' . __('Upload will start only after you enter content and click Post Update.', 'rtmedia') . '</span></div><table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div></div>')), 'link_input' => array('title' => __('Insert from URL', 'rtmedia'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />')); $tabs = apply_filters('rtmedia_upload_tabs', $tabs); $attr = $this->attributes; $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload'; if ($attr && is_array($attr)) { foreach ($attr as $key => $val) { ?> <input type='hidden' id="rt_upload_hf_<?php echo sanitize_key($key); ?> " value='<?php echo $val; ?> ' name ='<?php echo $key; ?> ' /> <?php } } $upload_type = 'default'; if (isset($attr['activity']) && $attr['activity']) { $upload_type = 'activity'; } $uploadHelper = new RTMediaUploadHelper(); include $this->locate_template($template_name); }
/** * Template Locator * * @param type $template * * @return string */ static function locate_template($template = false, $context = false, $url = false) { $located = ''; if (!$template) { global $rtmedia_query; if (is_rtmedia_album_gallery()) { $template = 'album-gallery'; } elseif (is_rtmedia_album() || is_rtmedia_gallery()) { $template = 'media-gallery'; if (is_rtmedia_album() && isset($rtmedia_query->media_query) && $rtmedia_query->action_query->action == 'edit') { if (rtmedia_is_album_editable() || is_rt_admin()) { $template = 'album-single-edit'; } } } else { if (is_rtmedia_single()) { $template = 'media-single'; if ($rtmedia_query->action_query->action == 'edit') { $template = 'media-single-edit'; } } else { return; } } $template = apply_filters('rtmedia_template_filter', $template); } $context = apply_filters('rtmedia_context_filter', $context); // check and exit if $template contains relative path if (false !== strpos($template, '.')) { die('No Cheating'); } $template_name = $template . '.php'; if ($context === false) { $context = 'media/'; } if (!$context === '') { $context .= '/'; } $path = 'rtmedia/' . $context; $ogpath = 'templates/' . $context; if (file_exists(trailingslashit(STYLESHEETPATH) . $path . $template_name)) { if ($url) { $located = trailingslashit(get_stylesheet_directory_uri()) . $path . $template_name; } else { $located = trailingslashit(STYLESHEETPATH) . $path . $template_name; } } else { if (file_exists(trailingslashit(TEMPLATEPATH) . $path . $template_name)) { if ($url) { $located = trailingslashit(get_template_directory_uri()) . $path . $template_name; } else { $located = trailingslashit(TEMPLATEPATH) . $path . $template_name; } } else { if ($url) { $located = trailingslashit(RTMEDIA_URL) . $ogpath . $template_name; } else { $located = trailingslashit(RTMEDIA_PATH) . $ogpath . $template_name; } $located = apply_filters('rtmedia_located_template', $located, $url, $ogpath, $template_name); // filter for rtmedia pro } } return $located; }
function rtmedia_item_select() { global $rtmedia_query, $rtmedia_backbone; if ($rtmedia_backbone['backbone']) { if (isset($rtmedia_backbone['is_album']) && $rtmedia_backbone['is_album'] && isset($rtmedia_backbone['is_edit_allowed']) && $rtmedia_backbone['is_edit_allowed']) { echo '<span class="rtm-checkbox-wrap"><input type="checkbox" name="move[]" class="rtmedia-item-selector" value="<%= id %>" /></span>'; } } else { if (is_rtmedia_album() && isset($rtmedia_query->media_query) && $rtmedia_query->action_query->action == 'edit') { if (isset($rtmedia_query->media_query['media_author']) && get_current_user_id() == $rtmedia_query->media_query['media_author']) { echo '<span class="rtm-checkbox-wrap"><input type="checkbox" class="rtmedia-item-selector" name="selected[]" value="' . rtmedia_id() . '" /></span>'; } } } }
function bp_after_activity_post_form() { $url = trailingslashit($_SERVER["REQUEST_URI"]); $slug_split = explode('/', $url); // check position of media slug for end of the URL if ($slug_split[sizeof($slug_split) - 1] == RTMEDIA_MEDIA_SLUG) { // replace media slug with the blank space $slug_split[sizeof($slug_split) - 1] = ''; $url_upload = implode('/', $slug_split); $url = trailingslashit($url_upload) . "upload/"; } else { $url = trailingslashit($url) . "upload/"; } if (rtmedia_is_uploader_view_allowed(true, 'activity')) { $params = array('url' => $url, 'runtimes' => 'html5,flash,html4', 'browse_button' => 'rtmedia-add-media-button-post-update', 'container' => 'rtmedia-whts-new-upload-container', 'drop_element' => 'whats-new-textarea', 'filters' => apply_filters('rtmedia_plupload_files_filter', array(array('title' => __('Media Files', 'buddypress-media'), 'extensions' => get_rtmedia_allowed_upload_type()))), 'max_file_size' => wp_max_upload_size() / (1024 * 1024) . 'M', 'multipart' => true, 'urlstream_upload' => true, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'file_data_name' => 'rtmedia_file', 'multi_selection' => true, 'multipart_params' => apply_filters('rtmedia-multi-params', array('redirect' => 'no', 'rtmedia_update' => 'true', 'action' => 'wp_handle_upload', '_wp_http_referer' => $_SERVER['REQUEST_URI'], 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator(false, true))), 'max_file_size_msg' => apply_filters('rtmedia_plupload_file_size_msg', min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))))); if (wp_is_mobile()) { $params['multi_selection'] = false; } $params = apply_filters('rtmedia_modify_upload_params', $params); wp_enqueue_script('rtmedia-backbone', false, '', false, true); $is_album = is_rtmedia_album() ? true : false; $is_edit_allowed = is_rtmedia_edit_allowed() ? true : false; wp_localize_script('rtmedia-backbone', 'is_album', $is_album); wp_localize_script('rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed); wp_localize_script('rtmedia-backbone', 'rtMedia_update_plupload_config', $params); $uploadView = new RTMediaUploadView(array('activity' => true)); $uploadView->render('uploader'); } else { echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters('rtmedia_upload_not_allowed_message', __('You are not allowed to upload/attach media.', 'buddypress-media'), 'activity') . '</div>'; } }
/** * Render the uploader shortcode and attach the uploader panel * * @param type $template_name */ public function render($template_name) { global $rtmedia_query; $album = ''; if (apply_filters('rtmedia_render_select_album_upload', true)) { if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album($rtmedia_query->media_query['album_id'])) { $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />'; } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) { if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') { $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>'; } if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') { $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>'; } } } $up_privacy = $privacy = ""; //uploader privacy dropdown for uploader under rtMedia Media tab. if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false) || isset($rtmedia_query->is_upload_shortcode) && !isset($this->attributes['privacy'])) { if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group' || function_exists('bp_is_groups_component') && bp_is_groups_component()) { // if the context is group, then set the media privacy to public $privacy = "<input type='hidden' name='privacy' value='0'/>"; } else { $up_privacy = new RTMediaPrivacy(); $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy'); if ($up_privacy) { $privacy = "<span> <label for='privacy'> <i class='dashicons dashicons-visibility rtmicon'></i> " . __('Privacy: ', 'buddypress-media') . "</label>" . $up_privacy . "</span>"; } } } $upload_tabs = array('file_upload' => array('title' => __('File Upload', 'buddypress-media'), 'class' => array('rtm-upload-tab', 'active'), 'content' => '<div class="rtm-upload-tab-content" data-id="rtm-upload-tab">' . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", 'buddypress-media') . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'buddypress-media') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'buddypress-media') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle rtmicon-fw"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . '</div>')); $upload_tabs = apply_filters('rtmedia_uploader_tabs', $upload_tabs); if (is_array($upload_tabs) && !empty($upload_tabs)) { if (sizeof($upload_tabs) == 1 && isset($upload_tabs['file_upload'])) { $upload_tab_html = $upload_tabs['file_upload']['content']; } else { $upload_tab_html = '<div class="rtm-uploader-main-wrapper"><div class="rtm-uploader-tabs"><ul>'; foreach ($upload_tabs as $single_tab) { $upload_tab_html .= '<li class="' . implode(' ', $single_tab['class']) . '">' . $single_tab['title'] . '</li>'; } $upload_tab_html .= '</ul></div>'; foreach ($upload_tabs as $single_tab) { $upload_tab_html .= $single_tab['content']; } $upload_tab_html .= '</div>'; } } else { $upload_tab_html = ''; } $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop clearfix">' . apply_filters('rtmedia_uploader_before_album_privacy', "") . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . $upload_tab_html . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'buddypress-media') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="clearfix">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist"></ul></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div class="rtmedia-plupload-container rtmedia-container clearfix">' . '<div id="rtmedia-action-update" class="clearfix">' . '<div class="rtm-upload-button-wrapper">' . '<div id="rtmedia-whts-new-upload-container">' . '</div>' . '<button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update" title="' . apply_filters('rtmedia_attach_media_button_title', __('Attach Media', 'buddypress-media')) . '">' . '<span class="dashicons dashicons-admin-media"></span>' . apply_filters('rtmedia_attach_file_message', '') . '</button>' . '</div>' . $up_privacy . '</div>' . '</div>' . '<div class="rtmedia-plupload-notice">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist">' . '</ul>' . '</div>')), 'link_input' => array('title' => __('Insert from URL', 'buddypress-media'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />')); $tabs = apply_filters('rtmedia_upload_tabs', $tabs); $attr = $this->attributes; $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload'; if ($attr && is_array($attr)) { foreach ($attr as $key => $val) { ?> <input type='hidden' id="rt_upload_hf_<?php echo sanitize_key($key); ?> " value='<?php echo $val; ?> ' name ='<?php echo $key; ?> ' /> <?php } } $upload_type = 'default'; if (isset($attr['activity']) && $attr['activity']) { $upload_type = 'activity'; } $uploadHelper = new RTMediaUploadHelper(); include $this->locate_template($template_name); }
<?php global $rtmedia_query; if (is_rtmedia_album_gallery()) { $template = 'album-gallery'; } elseif (is_rtmedia_album() || is_rtmedia_gallery()) { $template = 'media-gallery'; if (is_rtmedia_album() && isset($rtmedia_query->media_query) && $rtmedia_query->action_query->action == 'edit') { if (isset($rtmedia_query->media_query['media_author']) && get_current_user_id() == $rtmedia_query->media_query['media_author']) { $template = 'album-single-edit'; } } } else { if (is_rtmedia_single()) { $template = 'media-single'; if ($rtmedia_query->action_query->action == 'edit') { $template = 'media-single-edit'; } } } $ajax = false; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $ajax = true; } if (!$ajax) { ?> <?php if (class_exists('BuddyPress') && !bp_is_blog_page()) { $template_type = 'buddypress'; } else {
function bp_after_activity_post_form() { $url = $_SERVER["REQUEST_URI"]; $url = trailingslashit($url); $params = array('url' => isset($url) && strpos($url, "/media/") !== false ? str_replace("/media/", "/upload/", $url) : 'upload/', 'runtimes' => 'html5,flash,html4', 'browse_button' => 'rtmedia-add-media-button-post-update', 'container' => 'rtmedia-whts-new-upload-container', 'drop_element' => 'whats-new-textarea', 'filters' => apply_filters('rtmedia_plupload_files_filter', array(array('title' => __('Media Files', 'rtmedia'), 'extensions' => get_rtmedia_allowed_upload_type()))), 'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))), 'multipart' => true, 'urlstream_upload' => true, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'file_data_name' => 'rtmedia_file', 'multi_selection' => true, 'multipart_params' => apply_filters('rtmedia-multi-params', array('redirect' => 'no', 'rtmedia_update' => 'true', 'action' => 'wp_handle_upload', '_wp_http_referer' => $_SERVER['REQUEST_URI'], 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator(false, true))), 'max_file_size_msg' => apply_filters("rtmedia_plupload_file_size_msg", min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))))); if (wp_is_mobile()) { $params['multi_selection'] = false; } $params = apply_filters("rtmedia_modify_upload_params", $params); wp_enqueue_script('rtmedia-backbone', false, '', false, true); $is_album = is_rtmedia_album() ? true : false; $is_edit_allowed = is_rtmedia_edit_allowed() ? true : false; wp_localize_script('rtmedia-backbone', 'is_album', $is_album); wp_localize_script('rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed); wp_localize_script('rtmedia-backbone', 'rtMedia_update_plupload_config', $params); $allow_upload = apply_filters('rtmedia_allow_uploader_view', true, 'activity'); if ($allow_upload) { $uploadView = new RTMediaUploadView(array('activity' => true)); $uploadView->render('uploader'); } else { echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters('rtmedia_upload_not_allowed_message', __('You are not allowed to upload/attach media.', 'rtmedia'), 'activity') . "</div>"; } }