function sunshine_favorites_content($content)
{
    global $sunshine;
    if (is_page($sunshine->options['page_favorites'])) {
        $content .= SunshineFrontend::get_template('favorites');
    }
    return $content;
}
function sunshine_init()
{
    global $sunshine;
    add_rewrite_endpoint($sunshine->options['endpoint_gallery'], EP_PERMALINK | EP_PAGES);
    add_rewrite_endpoint($sunshine->options['endpoint_image'], EP_PERMALINK | EP_PAGES);
    add_rewrite_endpoint($sunshine->options['endpoint_order'], EP_PERMALINK | EP_PAGES);
    SunshineUser::instance();
    SunshineCountries::instance();
    $functions = SUNSHINE_PATH . 'themes/' . $sunshine->options['theme'] . '/functions.php';
    if (file_exists($functions)) {
        include_once $functions;
    }
    if (is_admin()) {
        include_once 'admin/sunshine-admin.php';
    } else {
        SunshineSession::instance();
        SunshinePaymentMethods::instance();
        SunshineEmail::instance();
        SunshineFrontend::instance();
    }
}
 static function get_template($template, $file = '')
 {
     global $sunshine;
     if (self::$output) {
         return self::$output;
     }
     if (!$file) {
         if (file_exists(get_stylesheet_directory() . '/sunshine/' . $template . '.php')) {
             $file = get_stylesheet_directory() . '/sunshine/' . $template . '.php';
         } else {
             $file = SUNSHINE_PATH . 'themes/' . $sunshine->options['theme'] . '/' . $template . '.php';
         }
     }
     ob_start();
     load_template($file);
     $output = ob_get_contents();
     ob_end_clean();
     self::$output = $output;
     return $output;
 }
function sunshine_gallery_notice_more_images()
{
    if (isset($_GET['post']) && get_post_type($_GET['post']) == 'sunshine-gallery') {
        $post_id = intval($_GET['post']);
        $selected_dir = get_post_meta($post_id, 'sunshine_gallery_images_directory', true);
        // See if there are new images in selected directory
        if ($selected_dir) {
            $upload_dir = wp_upload_dir();
            $attachments = get_posts(array('post_type' => 'attachment', 'post_parent' => $post_id, 'posts_per_page' => -1));
            $file_count = count($attachments);
            $file_count_in_dir = sunshine_image_folder_count($upload_dir['basedir'] . '/sunshine/' . $selected_dir);
            if ($file_count_in_dir > $file_count) {
                $unprocessed = $file_count_in_dir - $file_count;
                echo '<div class="updated">
			       <p>There ' . SunshineFrontend::pluralize($unprocessed, 'is', 'are', 0) . ' <strong>' . $unprocessed . ' unprocessed ' . SunshineFrontend::pluralize($unprocessed, 'photo', 'photos', 0) . '</strong> in your selected folder. Please click the "Update" button to process these images and add them to your gallery.</p>
			    </div>';
            }
        }
    }
}