/** * * @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>"; } }
/** * redirects to the template according to the page request * Pass on the shortcode attributes to the template so that the shortcode can berendered accordingly. * * Also handles the json request coming from the AJAX calls for the media * * @global type $rtmedia_query * @global type $rtmedia_interaction * * @param type $template * @param type $shortcode_attr * * @return type */ function set_template($template = false, $shortcode_attr = false) { global $rtmedia_query, $rtmedia_interaction, $rtmedia_media; do_action('rtmedia_pre_template'); if (isset($rtmedia_query->action_query->action)) { do_action('rtmedia_pre_action_' . $rtmedia_query->action_query->action); } else { do_action('rtmedia_pre_action_default'); } $this->check_return_json(); $this->check_return_upload(); if ($rtmedia_interaction && isset($rtmedia_interaction->context) && in_array($rtmedia_interaction->context->type, array("profile", "group"))) { $this->check_return_edit(); $this->check_return_delete(); $this->check_return_merge(); $this->check_return_comments(); $this->check_delete_comments(); if (isset($rtmedia_query->is_gallery_shortcode) && $rtmedia_query->is_gallery_shortcode == true && isset($shortcode_attr['name']) && $shortcode_attr['name'] == 'gallery') { $valid = $this->sanitize_gallery_attributes($shortcode_attr['attr']); if ($valid) { if (is_array($shortcode_attr['attr'])) { $this->update_global_query($shortcode_attr['attr']); } echo "<div class='rtmedia_gallery_wrapper'>"; $this->add_hidden_fields_in_gallery(); $gallery_template = apply_filters("rtmedia-before-template", $template, $shortcode_attr); include $this->locate_template($gallery_template); echo "</div>"; } else { echo __('Invalid attribute passed for rtmedia_gallery shortcode.', 'buddypress-media'); return false; } } else { return $this->get_default_template(); } } else { if (!$shortcode_attr) { return $this->get_default_template(); } else { if ($shortcode_attr['name'] == 'gallery') { $valid = $this->sanitize_gallery_attributes($shortcode_attr['attr']); if ($valid) { if (is_array($shortcode_attr['attr'])) { $this->update_global_query($shortcode_attr['attr']); } global $rtaccount; if (!isset($rtaccount)) { $rtaccount = 0; } //add_action("rtmedia_before_media_gallery",array(&$this,"")) ; $include_uploader = false; if (isset($shortcode_attr['attr']) && isset($shortcode_attr['attr']['uploader'])) { $include_uploader = $shortcode_attr['attr']['uploader']; unset($shortcode_attr['attr']['uploader']); } if ($include_uploader == "before") { echo RTMediaUploadShortcode::pre_render($shortcode_attr['attr']); } echo "<div class='rtmedia_gallery_wrapper'>"; $this->add_hidden_fields_in_gallery(); $gallery_template = apply_filters("rtmedia-before-template", $template, $shortcode_attr); include $this->locate_template($gallery_template); echo "</div>"; if ($include_uploader == "after" || $include_uploader == "true") { echo RTMediaUploadShortcode::pre_render($shortcode_attr['attr']); } } else { echo __('Invalid attribute passed for rtmedia_gallery shortcode.', 'buddypress-media'); return false; } } } } }
/** * 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>'; } }