/**
  * 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;
 }
Example #2
0
<?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 {