function bwg_shortcode($params)
{
    if (isset($params['id'])) {
        global $wpdb;
        $shortcode = $wpdb->get_var($wpdb->prepare("SELECT tagtext FROM " . $wpdb->prefix . "bwg_shortcode WHERE id='%d'", $params['id']));
        if ($shortcode) {
            $shortcode_params = explode('" ', $shortcode);
            foreach ($shortcode_params as $shortcode_param) {
                $shortcode_param = str_replace('"', '', $shortcode_param);
                $shortcode_elem = explode('=', $shortcode_param);
                $params[str_replace(' ', '', $shortcode_elem[0])] = $shortcode_elem[1];
            }
        } else {
            die;
        }
    }
    shortcode_atts(array('gallery_type' => 'thumbnails', 'theme_id' => 1), $params);
    switch ($params['gallery_type']) {
        case 'thumbnails':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'order_by' => 'asc', 'show_search_box' => 0, 'search_box_width' => 180, 'image_column_number' => 3, 'images_per_page' => 15, 'image_title' => 'none', 'image_enable_page' => 1, 'thumb_width' => 120, 'thumb_height' => 90, 'image_width' => 800, 'image_height' => 600, 'image_effect' => 'fade', 'enable_image_filmstrip' => 0, 'image_filmstrip_height' => 50, 'enable_image_ctrl_btn' => 1, 'enable_image_fullscreen' => 1, 'enable_comment_social' => 1, 'enable_image_facebook' => 1, 'enable_image_twitter' => 1, 'enable_image_google' => 1, 'watermark_type' => 'none', 'load_more_image_count' => 15, 'show_tag_box' => 0), $params);
            break;
        case 'slideshow':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'order_by' => 'asc', 'slideshow_effect' => 'fade', 'slideshow_interval' => 5, 'slideshow_width' => 800, 'slideshow_height' => 600, 'enable_slideshow_autoplay' => 0, 'enable_slideshow_shuffle' => 0, 'enable_slideshow_ctrl' => 1, 'enable_slideshow_filmstrip' => 1, 'slideshow_filmstrip_height' => 70, 'slideshow_enable_title' => 0, 'slideshow_title_full_width' => 0, 'slideshow_title_position' => 'top-right', 'slideshow_enable_description' => 0, 'slideshow_description_position' => 'bottom-right', 'enable_slideshow_music' => 0, 'slideshow_music_url' => '', 'slideshow_effect_duration' => 1), $params);
            break;
        case 'image_browser':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'order_by' => 'asc', 'show_search_box' => 0, 'search_box_width' => 180, 'image_browser_width' => 800, 'image_browser_title_enable' => 1, 'image_browser_description_enable' => 1, 'watermark_type' => 'none'), $params);
            break;
        case 'album_compact_preview':
            shortcode_atts(array('album_id' => 1, 'sort_by' => 'order', 'show_search_box' => 0, 'search_box_width' => 180, 'compuct_album_column_number' => 3, 'compuct_albums_per_page' => 15, 'compuct_album_title' => 'hover', 'compuct_album_view_type' => 'thumbnail', 'compuct_album_thumb_width' => 120, 'compuct_album_thumb_height' => 90, 'compuct_album_image_column_number' => 3, 'compuct_album_images_per_page' => 15, 'compuct_album_image_title' => 'none', 'compuct_album_image_thumb_width' => 120, 'compuct_album_image_thumb_height' => 120, 'compuct_album_enable_page' => 1, 'watermark_type' => 'none', 'compuct_album_load_more_image_count' => 15, 'compuct_albums_per_page_load_more' => 15), $params);
            break;
        case 'album_extended_preview':
            shortcode_atts(array('album_id' => 1, 'sort_by' => 'order', 'show_search_box' => 0, 'search_box_width' => 180, 'extended_albums_per_page' => 15, 'extended_album_height' => 150, 'extended_album_description_enable' => 1, 'extended_album_view_type' => 'thumbnail', 'extended_album_thumb_width' => 120, 'extended_album_thumb_height' => 90, 'extended_album_image_column_number' => 3, 'extended_album_images_per_page' => 15, 'extended_album_image_title' => 'none', 'extended_album_image_thumb_width' => 120, 'extended_album_image_thumb_height' => 90, 'extended_album_enable_page' => 1, 'watermark_type' => 'none', 'extended_album_load_more_image_count' => 15, 'extended_albums_per_page_load_more' => 15), $params);
            break;
        default:
            die;
    }
    if ($params['gallery_type'] != 'slideshow') {
        shortcode_atts(array('popup_fullscreen' => 0, 'popup_autoplay' => 0, 'popup_width' => 800, 'popup_height' => 600, 'popup_effect' => 'fade', 'popup_interval' => 5, 'popup_enable_filmstrip' => 0, 'popup_filmstrip_height' => 70, 'popup_enable_ctrl_btn' => 1, 'popup_enable_fullscreen' => 1, 'popup_enable_info' => 1, 'popup_info_full_width' => 0, 'popup_info_always_show' => 0, 'popup_hit_counter' => 0, 'popup_enable_rate' => 0, 'popup_enable_comment' => 1, 'popup_enable_facebook' => 1, 'popup_enable_twitter' => 1, 'popup_enable_google' => 1, 'popup_enable_pinterest' => 0, 'popup_enable_tumblr' => 0, 'watermark_type' => 'none', 'popup_effect_duration' => 1), $params);
    }
    switch ($params['watermark_type']) {
        case 'text':
            shortcode_atts(array('watermark_link' => '', 'watermark_text' => '', 'watermark_font_size' => 12, 'watermark_font' => 'Arial', 'watermark_color' => 'FFFFFF', 'watermark_opacity' => 30, 'watermark_position' => 'bottom-right'), $params);
            break;
        case 'image':
            shortcode_atts(array('watermark_link' => '', 'watermark_url' => '', 'watermark_width' => 120, 'watermark_height' => 90, 'watermark_opacity' => 30, 'watermark_position' => 'bottom-right'), $params);
            break;
        default:
            $params['watermark_type'] = 'none';
            break;
    }
    foreach ($params as $key => $param) {
        if (empty($param[$key]) == FALSE) {
            $param[$key] = esc_html(addslashes($param[$key]));
        }
    }
    ob_start();
    bwg_front_end($params);
    return str_replace(array("\r\n", "\n", "\r"), '', ob_get_clean());
    // return ob_get_clean();
}
Example #2
0
function bwg_shortcode($params)
{
    shortcode_atts(array('gallery_type' => 'thumbnails', 'theme_id' => 1), $params);
    switch ($params['gallery_type']) {
        case 'thumbnails':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'image_column_number' => 3, 'images_per_page' => 15, 'image_title' => 'none', 'image_enable_page' => 1, 'thumb_width' => 120, 'thumb_height' => 90, 'image_width' => 800, 'image_height' => 600, 'image_effect' => 'fade', 'enable_image_filmstrip' => 0, 'image_filmstrip_height' => 50, 'enable_image_ctrl_btn' => 1, 'enable_image_fullscreen' => 1, 'enable_comment_social' => 1, 'enable_image_facebook' => 1, 'enable_image_twitter' => 1, 'enable_image_google' => 1, 'watermark_type' => 'none'), $params);
            break;
        case 'slideshow':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'slideshow_effect' => 'fade', 'slideshow_interval' => 5, 'slideshow_width' => 800, 'slideshow_height' => 600, 'enable_slideshow_autoplay' => 0, 'enable_slideshow_shuffle' => 0, 'enable_slideshow_ctrl' => 1, 'enable_slideshow_filmstrip' => 1, 'slideshow_filmstrip_height' => 90, 'slideshow_enable_title' => 0, 'slideshow_title_position' => 'top-right', 'slideshow_enable_description' => 0, 'slideshow_description_position' => 'bottom-right', 'enable_slideshow_music' => 0, 'slideshow_music_url' => ''), $params);
            break;
        case 'image_browser':
            shortcode_atts(array('gallery_id' => 1, 'sort_by' => 'order', 'image_browser_width' => 800, 'image_browser_title_enable' => 1, 'image_browser_description_enable' => 1, 'watermark_type' => 'none'), $params);
            break;
        case 'album_compact_preview':
            shortcode_atts(array('album_id' => 1, 'sort_by' => 'order', 'compuct_album_column_number' => 3, 'compuct_albums_per_page' => 15, 'compuct_album_title' => 'hover', 'compuct_album_thumb_width' => 120, 'compuct_album_thumb_height' => 90, 'compuct_album_image_column_number' => 3, 'compuct_album_images_per_page' => 15, 'compuct_album_image_title' => 'none', 'compuct_album_image_thumb_width' => 120, 'compuct_album_image_thumb_height' => 120, 'compuct_album_enable_page' => 1, 'watermark_type' => 'none'), $params);
            break;
        case 'album_extended_preview':
            shortcode_atts(array('album_id' => 1, 'sort_by' => 'order', 'extended_albums_per_page' => 15, 'extended_album_height' => 150, 'extended_album_description_enable' => 1, 'extended_album_thumb_width' => 120, 'extended_album_thumb_height' => 90, 'extended_album_image_column_number' => 3, 'extended_album_images_per_page' => 15, 'extended_album_image_title' => 'none', 'extended_album_image_thumb_width' => 120, 'extended_album_image_thumb_height' => 90, 'extended_album_enable_page' => 1, 'watermark_type' => 'none'), $params);
            break;
        default:
            die;
    }
    if ($params['gallery_type'] != 'slideshow') {
        shortcode_atts(array('popup_width' => 800, 'popup_height' => 600, 'popup_effect' => 'fade', 'popup_interval' => 5, 'popup_enable_filmstrip' => 0, 'popup_filmstrip_height' => 70, 'popup_enable_ctrl_btn' => 1, 'popup_enable_fullscreen' => 1, 'popup_enable_comment' => 1, 'popup_enable_facebook' => 1, 'popup_enable_twitter' => 1, 'popup_enable_google' => 1, 'watermark_type' => 'none'), $params);
    }
    switch ($params['watermark_type']) {
        case 'text':
            shortcode_atts(array('watermark_link' => '', 'watermark_text' => '', 'watermark_font_size' => 12, 'watermark_font' => 'Arial', 'watermark_color' => 'FFFFFF', 'watermark_opacity' => 30, 'watermark_position' => 'bottom-right'), $params);
            break;
        case 'image':
            shortcode_atts(array('watermark_link' => '', 'watermark_url' => '', 'watermark_width' => 120, 'watermark_height' => 90, 'watermark_opacity' => 30, 'watermark_position' => 'bottom-right'), $params);
            break;
        default:
            $params['watermark_type'] = 'none';
            break;
    }
    foreach ($params as $key => $param) {
        if (empty($param[$key]) == false) {
            $param[$key] = esc_html(addslashes($param[$key]));
        }
    }
    ob_start();
    bwg_front_end($params);
    return str_replace(array("\r\n", "\n", "\r"), '', ob_get_clean());
}