'; } function gp_get_flag_img_country($country_name = '', $flagsize=32) { global $countries_array; $src = get_template_directory_uri() . '/lib/images/flags/'.$flagsize.'/'; if ($country_name) { $country_code = array_search($country_name, $countries_array); $src .= strtolower($country_code) . '.png'; } else { $src .= 'none.png'; } return '' . $country_name . ''; } function gp_get_the_flag($userid, $flagsize=32) { if ($userid) { if (bp_has_profile('user_id=' . $userid)) { while (bp_profile_groups()) { bp_the_profile_group(); while (bp_profile_fields()) { bp_the_profile_field(); if (bp_field_has_data()) { $fieldname = strip_tags(bp_get_the_profile_field_name()); if ($fieldname == 'Country') { $value = strip_tags(bp_get_the_profile_field_value(), ''); $value = str_replace('/flags/32/', '/flags/'.$flagsize.'/', $value); if ($value == '') { return gp_get_flag_img('', $flagsize); // Bandera desconocida } else { return $value; } } } } } } } else { return gp_get_flag_img('', $flagsize); // Bandera desconocida } } function gp_the_flag($userid, $flagsize=32) { echo gp_get_the_flag($userid, $flagsize); } /* * ************************* Enqueue Styles ************************** */ function gp_enqueue_styles() { if (!is_admin()) { global $post; require(ghostpool_inc . 'options.php'); wp_enqueue_style('reset', get_template_directory_uri() . '/lib/css/reset.css'); wp_enqueue_style('style', get_template_directory_uri() . '/style.css'); wp_enqueue_style('prettyphoto', get_template_directory_uri() . '/lib/scripts/prettyPhoto/css/prettyPhoto.css'); wp_enqueue_style('videoslider', get_template_directory_uri() . '/lib/scripts/videoslider/css/videoGallery.css'); if (isset($_COOKIE['SkinCookie'])) { $skin = $_COOKIE['SkinCookie']; } if (isset($_GET['skin'])) { $skin = $_GET['skin']; setcookie('SkinCookie', $skin); } if ($_GET['skin'] == "default") { $skin = $theme_skin; setcookie('SkinCookie', $skin, time() - 3600); } if (isset($_GET['skin']) OR (isset($_COOKIE['SkinCookie']) && $_COOKIE['SkinCookie'] != "default")) { wp_enqueue_style('style-skin', get_template_directory_uri() . '/style-' . $skin . '.css'); } else { if ((is_singular() && !is_attachment() && !is_404()) && (get_post_meta($post->ID, 'ghostpool_skin', true) && get_post_meta($post->ID, 'ghostpool_skin', true) != "Default")) { wp_enqueue_style('style-skin', get_template_directory_uri() . '/style-' . get_post_meta($post->ID, 'ghostpool_skin', true) . '.css'); } else { wp_enqueue_style('style-skin', get_template_directory_uri() . '/style-' . $theme_skin . '.css'); } } if ($theme_custom_stylesheet) { wp_enqueue_style('style-theme-custom', get_template_directory_uri() . '/' . $theme_custom_stylesheet); } if ((is_single() OR is_page()) && get_post_meta($post->ID, 'ghostpool_custom_stylesheet', true)) { wp_enqueue_style('style-custom', get_template_directory_uri() . '/' . get_post_meta($post->ID, 'ghostpool_custom_stylesheet', true)); } } } add_action('wp_print_styles', 'gp_enqueue_styles'); /* * ************************* Enqueue Scripts ************************** */ function gp_enqueue_scripts() { if (!is_admin()) { wp_enqueue_script('jquery'); wp_enqueue_script('jqueryui'); //wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery')); if (is_singular()) wp_enqueue_script('comment-reply'); wp_enqueue_script('swfobject', 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'); //wp_enqueue_script('jwplayer', get_template_directory_uri() . '/lib/scripts/mediaplayer/jwplayer.js', array('jquery')); //wp_enqueue_script('carousel', get_template_directory_uri().'/lib/scripts/jquery.carouFredSel.js', array('jquery')); wp_enqueue_script('prettyphoto', get_template_directory_uri() . '/lib/scripts/prettyPhoto/js/jquery.prettyPhoto.js', array('jquery')); wp_enqueue_script('jqtransform', get_template_directory_uri() . '/lib/scripts/jquery.jqtransform.js', array('jquery')); wp_enqueue_script('jqueryeasing', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.easing.1.3.js', array('jquery')); wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.min.js', array('jquery')); wp_enqueue_script('apPlaylistManager', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apPlaylistManager.min.js', array('jquery')); //wp_enqueue_script('apPlaylistManager', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apPlaylistManager.js', array('jquery')); wp_enqueue_script('apYoutubePlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apYoutubePlayer.min.js', array('jquery')); //wp_enqueue_script('apYoutubePlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apYoutubePlayer.js', array('jquery')); wp_enqueue_script('apVimeoPlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apVimeoPlayer.min.js', array('jquery')); //wp_enqueue_script('apVimeoPlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apVimeoPlayer.js', array('jquery')); wp_enqueue_script('videoGallery', get_template_directory_uri().'/lib/scripts/videoslider/js/jquery.videoGallery.min.js', array('jquery')); //wp_enqueue_script('videoGallery', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.videoGallery.js', array('jquery')); wp_enqueue_script('mousewheel', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.mousewheel.js', array('jquery')); //wp_enqueue_script('sharrre', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.sharrre-1.3.0.min.js', array('jquery')); wp_enqueue_script('fullscreen', get_template_directory_uri() . '/lib/scripts/jquery.fullscreen-min.js', array('jquery')); wp_enqueue_script('jtypewriter', get_template_directory_uri(). '/lib/scripts/jquery.jtypewriter.js', array('jquery')); } } add_action('wp_print_scripts', 'gp_enqueue_scripts'); /* * ************************* WP Header Hooks ************************** */ function gp_font_head() { require(ghostpool_inc . 'options.php'); $fonts = array( 'Bad+Script' => "font-family: 'Bad Script', sans-serif;", 'Give+You+Glory' => "font-family: 'Give You Glory', sans-serif;", 'Handlee' => "font-family: 'Handlee', sans-serif;", 'Indie+Flower' => "font-family: 'Indie Flower', sans-serif;", 'Patrick+Hand' => "font-family: 'Patrick Hand', sans-serif;", 'Shadows+Into+Light' => "font-family: 'Shadows Into Light', sans-serif;", 'Shadows+Into+Light+Two' => "font-family: 'Shadows Into Light Two', sans-serif;", ); $body_key = 'Bad+Script'; if (isset($theme_font_dedication)) $body_key = $theme_font_dedication; if (isset($fonts[$body_key])) { $body_font = $fonts[$body_key]; wp_enqueue_style('googleFonts', 'http://fonts.googleapis.com/css?family=' . $theme_font_dedication); echo ''; } } function gp_wp_header() { require(ghostpool_inc . 'options.php'); if ($theme_favicon_ico) echo ''; if ($theme_favicon_png) echo ''; if ($theme_apple_icon) echo ''; if ($theme_custom_css) echo ''; echo stripslashes($theme_scripts); echo ' '; gp_font_head(); } add_action('wp_head', 'gp_wp_header'); /* * ************************* Featured Image Sizes ************************** */ add_theme_support('post-thumbnails'); set_post_thumbnail_size(150, 150, true); /* * ************************* bbPress Support ************************** */ if (is_admin()) { add_theme_support('bbpress'); } /* * ************************* Navigation Menus ************************** */ add_action('init', 'register_my_menus'); function register_my_menus() { register_nav_menus(array( 'header-nav' => __('Header Navigation', 'gp_lang') )); } /* * ************************* Dedication category ********************* */ //add_action('init', 'register_dedication_category'); function register_dedication_category() { global $wpdb; if (!get_category_by_slug(DEDICATION_CATEGORY_SLUG)) { $cat = array( 'cat_name' => 'Dedication', 'category_nicename' => DEDICATION_CATEGORY_SLUG); wp_insert_category($cat); } } /* * ************************* Concerts category ********************* */ //add_action('init', 'register_concerts_category'); function register_concerts_category() { global $wpdb; if (!get_category_by_slug(CONCERTS_CATEGORY_SLUG)) { $cat = array( 'cat_name' => 'Concerts', 'category_nicename' => CONCERTS_CATEGORY_SLUG); wp_insert_category($cat); } } /* * ************************* Other Features ************************** */ // Add support for custom backgrounds add_custom_background(); // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // Set the content width based on the theme's design and stylesheet. if (!isset($content_width)) $content_width = 590; // Add default posts and comments RSS feed links to . add_theme_support('automatic-feed-links'); function remove_private_prefix($title) { $title = str_replace( 'Private:', '', $title); return $title; } add_filter('the_title', 'remove_private_prefix'); /* * ************************* Excerpts ************************** */ // Excerpt Length function new_excerpt_length($length) { return 500; } add_filter('excerpt_length', 'new_excerpt_length'); function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt) >= $limit) { array_pop($excerpt); $excerpt = implode(" ", $excerpt) . '...'; } else { $excerpt = implode(" ", $excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt); return $excerpt; } // Replace excerpt ellipsis function new_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more'); remove_filter('the_excerpt', 'wpautop'); /* * ************************* Add Excerpt Support To Pages ************************** */ add_action('init', 'my_add_excerpts_to_pages'); function my_add_excerpts_to_pages() { add_post_type_support('page', 'excerpt'); } /* * ************************* Shortcode Support For Text Widget ************************** */ add_filter('widget_text', 'do_shortcode'); /* * ************************* Page Navigation ************************** */ function gp_pagination($pages = '', $range = 2) { $showitems = ($range * 2) + 1; global $paged; if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } if ($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } if (1 != $pages) { echo "
"; echo '' . __('Page', 'gp_lang') . ' ' . $paged . ' ' . __('of', 'gp_lang') . ' ' . $pages . ''; if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) echo "«"; if ($paged > 1 && $showitems < $pages) echo ""; for ($i = 1; $i <= $pages; $i++) { if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) { echo ($paged == $i) ? "" . $i . "" : "" . $i . ""; } } if ($paged < $pages && $showitems < $pages) echo ""; if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) echo "»"; echo "
\n"; } } function gp_ajax_pagination($pages = '', $range = 2) { $showitems = ($range * 2) + 1; global $paged; if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } if ($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } if (1 != $pages) { echo "
"; if ($paged + 1 <= $pages) { echo "" . __('See More', 'gp_lang') . ""; } echo "
\n"; } } /* * ************************* Posts Per Page Fix ************************** */ function gp_posts_per_page($query_string) { require(ghostpool_inc . 'options.php'); if (!is_admin()) { if ($page_var == "homepage") { $query_string['posts_per_page'] = $theme_homepage_posts_per_page; } elseif (is_page_template('blog.php')) { $query_string['posts_per_page'] = $theme_blog_posts_per_page; } else { $query_string['posts_per_page'] = $theme_cat_posts_per_page; } } return $query_string; } add_filter('request', 'gp_posts_per_page'); /* * ************************* Shortcode Empty Paragraph Fix ************************** */ // Plugin URI: http://www.johannheyne.de/wordpress/shortcode-empty-paragraph-fix/ add_filter('the_content', 'shortcode_empty_paragraph_fix'); function shortcode_empty_paragraph_fix($content) { $array = array( '

[' => '[', ']

' => ']', ']
' => ']' ); $content = strtr($content, $array); return $content; } /* * ************************* Custom Media Gallery Field ************************** */ function ghostpool_attachment_fields_to_edit($form_fields, $post) { $form_fields["ghostpool_video_url"] = array( "label" => __('Audio/Video URL', 'gp_lang'), "input" => "text", "value" => get_post_meta($post->ID, "_ghostpool_video_url", true), "helps" => __('The URL of your video or audio file (YouTube/Vimeo/FLV/MP4/M4V/MP3).', 'gp_lang'), ); return $form_fields; } add_filter("attachment_fields_to_edit", "ghostpool_attachment_fields_to_edit", null, 2); function ghostpool_attachment_fields_to_save($post, $attachment) { if (isset($attachment['ghostpool_video_url'])) { update_post_meta($post['ID'], '_ghostpool_video_url', $attachment['ghostpool_video_url']); } return $post; } add_filter("attachment_fields_to_save", "ghostpool_attachment_fields_to_save", null, 2); /* * ************************* Redirect to Theme Options after Activation ************************** */ if (is_admin() && isset($_GET['activated']) && $pagenow == "themes.php") { add_action('admin_head', 'ct_option_setup'); header('Location: ' . admin_url() . 'themes.php?page=theme-options.php'); } /* * ************************* Custom login ************************** */ function custom_login() { echo ''; remove_action('login_head', 'wp_shake_js', 12); } add_action('login_head', 'custom_login'); function the_url( $url ) { return get_bloginfo( 'siteurl' ); } add_filter( 'login_headerurl', 'the_url' ); /* ************************* Other functions ************************** */ function htmlwrap(&$str, $maxLength, $char='
'){ $count = 0; $newStr = ''; $openTag = false; $lenstr = strlen($str); for($i=0; $i<$lenstr; $i++){ $newStr .= $str{$i}; if($str{$i} == '<'){ $openTag = true; continue; } if(($openTag) && ($str{$i} == '>')){ $openTag = false; continue; } if(!$openTag){ if($str{$i} == ' '){ if ($count == 0) { $newStr = substr($newStr,0, -1); continue; } else { $lastspace = $count + 1; } } $count++; if($count==$maxLength){ if ($str{$i+1} != ' ' && $lastspace && ($lastspace < $count)) { $tmp = ($count - $lastspace)* -1; $newStr = substr($newStr,0, $tmp) . $char . substr($newStr,$tmp); $count = $tmp * -1; } else { $newStr .= $char; $count = 0; } $lastspace = 0; } } } return $newStr; } function cutstr($str, $length, $ellipsis=''){ $cut = (array)explode('\n\n', htmlwrap($str, $length, '\n\n')); return $cut[0] . ((strlen($cut[0]) < strlen($str)) ? $ellipsis : ''); } function add_fs_var($public_query_vars) { $public_query_vars[] = 'fs'; return $public_query_vars; } add_filter('query_vars', 'add_fs_var'); function play_video_on_full_screen() { $fs = get_query_var('fs'); return ($fs == '1'); } if(!function_exists('_log')){ function _log( $message ) { if( WP_DEBUG === true ){ if( is_array( $message ) || is_object( $message ) ){ error_log( print_r( $message, true ) ); } else { error_log( $message ); } } } } function make_encoded_dedications_visible_for_nonusers($visibility) { if(isset($_COOKIE['refid'])) { setcookie('refid','',time()-3600, SITECOOKIEPATH); $_COOKIE['refid'] = null; unset( $_COOKIE['refid'] ); // Puede ser visible return false; } else { return $visibility; } } add_filter('pbp_login_required_check', 'make_encoded_dedications_visible_for_nonusers', 1); function gp_encoded_dedication_redirect_for_nonusers($current_uri, $redirect_to) { wp_parse_str($_SERVER['QUERY_STRING'], $args); if (key_exists('refid', $args)) { setcookie("refid", 1, time()+60, SITECOOKIEPATH); // Cookie con 1 minuto de validez $decoded_url = bp_dedication_decode($args['refid']); return add_query_arg('fs', 1, $decoded_url); } else return $current_uri; } add_filter('pbp_redirect_login_page', 'gp_encoded_dedication_redirect_for_nonusers', 1, 2); function gp_encoded_dedication_redirect_for_users() { if ( true == is_user_logged_in() ) { wp_parse_str($_SERVER['QUERY_STRING'], $args); if (key_exists('refid', $args)) { $decoded_url = bp_dedication_decode($args['refid']); wp_redirect(add_query_arg('fs', 1, $decoded_url)); } } } add_action('wp', 'gp_encoded_dedication_redirect_for_users', 2); function asociate_dedications_to_new_user($user_id) { global $post; $user = get_user_by('id', $user_id); $category_name = 'dedication'; $post_status = array('publish', 'private'); $args = array( 'post_type' => array('post'), 'posts_per_page' => -1, 'post_status' => $post_status, 'category_name' => $category_name, 'meta_key' => 'ghostpool_destination_user_email', 'meta_value' => $user->user_email ); $emailPosts = new WP_Query($args); while ($emailPosts->have_posts()) { $emailPosts->the_post(); if (!update_post_meta(get_the_ID(), 'ghostpool_destination_user_id', $user_id)) add_post_meta(get_the_ID(), 'ghostpool_destination_user_id', $user_id, true); if (!update_post_meta(get_the_ID(), 'ghostpool_destination_user_name', $user->user_login)) add_post_meta(get_the_ID(), 'ghostpool_destination_user_name', $user->user_login, true); delete_post_meta(get_the_ID(), 'ghostpool_destination_user_email'); delete_post_meta(get_the_ID(), 'ghostpool_destination_user_country'); } wp_reset_postdata(); } add_action( 'user_register', 'asociate_dedications_to_new_user'); ?>