/**
  * Render the uploader shortcode and attach the uploader panel
  *
  * @param mixed $attr
  */
 static function pre_render($attr)
 {
     if (rtmedia_is_uploader_view_allowed(true, 'uploader_shortcode')) {
         global $post;
         global $rtmedia_query;
         if (!$rtmedia_query) {
             $rtmedia_query = new RTMediaQuery();
         }
         if (!isset($attr['is_up_shortcode']) || $attr['is_up_shortcode'] !== false) {
             $rtmedia_query->is_upload_shortcode = true;
             // set is_upload_shortcode in rtmedia query as true
         } else {
             $rtmedia_query->is_upload_shortcode = false;
             // set is_upload_shortcode in rtmedia query as true
         }
         if (isset($attr['media_type'])) {
             global $rtmedia;
             $allowed_media_type = $rtmedia->allowed_types;
             if (isset($allowed_media_type[$attr['media_type']])) {
                 wp_localize_script('rtmedia-backbone', "rtmedia_upload_type_filter", $allowed_media_type[$attr['media_type']]['extn']);
             }
         }
         if (isset($attr) && !empty($attr)) {
             if (!is_array($attr)) {
                 $attr = array();
             }
             //		if ( ! isset ( $attr[ "context_id" ] ) && isset ( $post->ID ) ) {
             //		    $attr[ "context_id" ] = $post->ID;
             //		}
             if (!isset($attr["context"]) && isset($post->post_type)) {
                 $attr["context"] = $post->post_type;
             }
         }
         $attr = apply_filters('rtmedia_media_uploader_attributes', $attr);
         if (self::display_allowed() || isset($attr['allow_anonymous']) && $attr['allow_anonymous'] === true) {
             if (!_device_can_upload()) {
                 echo '<p>' . esc_html__('The web browser on your device cannot be used to upload files.', 'buddypress-media') . '</p>';
                 return;
             }
             ob_start();
             self::$add_sc_script = true;
             RTMediaUploadTemplate::render($attr);
             self::$uploader_displayed = true;
             return ob_get_clean();
         }
     } else {
         echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters('rtmedia_upload_not_allowed_message', esc_html__('You are not allowed to upload/attach media.', 'buddypress-media'), 'uploader_shortcode') . "</div>";
     }
 }
/**
 *
 * @param type $attr
 */
function rtmedia_uploader($attr = '')
{
    if (rtmedia_is_uploader_view_allowed(true, 'media_gallery')) {
        if (function_exists('bp_is_blog_page') && !bp_is_blog_page()) {
            if (function_exists('bp_is_user') && bp_is_user() && function_exists('bp_displayed_user_id') && bp_displayed_user_id() == get_current_user_id()) {
                echo RTMediaUploadShortcode::pre_render($attr);
            } else {
                if (function_exists('bp_is_group') && bp_is_group()) {
                    if (can_user_upload_in_group()) {
                        echo RTMediaUploadShortcode::pre_render($attr);
                    }
                }
            }
        }
    } else {
        echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters('rtmedia_upload_not_allowed_message', __('You are not allowed to upload/attach media.', 'rtmedia'), 'media_gallery') . "</div>";
    }
}
Esempio n. 3
0
/**
 * Rendering RTMedia Uploader
 *
 * @param       array|string    $attr
 */
function rtmedia_uploader($attr = '')
{
    if (rtmedia_is_uploader_view_allowed(true, 'media_gallery')) {
        if (function_exists('bp_is_blog_page') && !bp_is_blog_page()) {
            if (function_exists('bp_is_user') && bp_is_user() && function_exists('bp_displayed_user_id') && bp_displayed_user_id() === get_current_user_id()) {
                echo RTMediaUploadShortcode::pre_render($attr);
                // @codingStandardsIgnoreLine
            } else {
                if (function_exists('bp_is_group') && bp_is_group()) {
                    if (can_user_upload_in_group()) {
                        echo RTMediaUploadShortcode::pre_render($attr);
                        // @codingStandardsIgnoreLine
                    }
                }
            }
        }
    } else {
        echo "<div class='rtmedia-upload-not-allowed'>" . wp_kses(apply_filters('rtmedia_upload_not_allowed_message', esc_html__('You are not allowed to upload/attach media.', 'buddypress-media'), 'media_gallery'), RTMediaUpload::$wp_kses_allowed_tags) . '</div>';
    }
}
 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>';
     }
 }
 function bp_after_activity_post_form()
 {
     $url = $_SERVER['REQUEST_URI'];
     $url = trailingslashit($url);
     if (rtmedia_is_uploader_view_allowed(true, 'activity')) {
         $params = array('url' => isset($url) && false !== strpos($url, '/media/') ? 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);
         $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>';
     }
 }