git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@195 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
869 lines
30 KiB
PHP
869 lines
30 KiB
PHP
<?php
|
|
|
|
/* * ************************* Localisation ************************** */
|
|
|
|
load_theme_textdomain('gp_lang', TEMPLATEPATH . '/languages');
|
|
$locale = get_locale();
|
|
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
|
|
if (is_readable($locale_file))
|
|
require_once($locale_file);
|
|
|
|
|
|
/* * ************************* Theme Information ************************** */
|
|
|
|
$themename = __('Score', 'gp_lang'); // Theme Name
|
|
$dirname = "score"; // Directory Name
|
|
|
|
/* * ************************* Dedication Information ********************* */
|
|
|
|
if ( !defined( 'DEDICATION_CATEGORY_SLUG' ) )
|
|
define( 'DEDICATION_CATEGORY_SLUG', 'dedication' );
|
|
|
|
/* * ************************* Concerts Information ********************* */
|
|
|
|
if ( !defined( 'MUSICNEWS_CATEGORY_SLUG' ) )
|
|
define( 'MUSICNEWS_CATEGORY_SLUG', 'music-news' );
|
|
|
|
/* * ************************* Concerts Information ********************* */
|
|
|
|
if ( !defined( 'CONCERTS_CATEGORY_SLUG' ) )
|
|
define( 'CONCERTS_CATEGORY_SLUG', 'concerts' );
|
|
|
|
/* * ************************* File Directories ************************** */
|
|
|
|
define("ghostpool", TEMPLATEPATH . '/');
|
|
define("ghostpool_inc", TEMPLATEPATH . '/lib/inc/');
|
|
define("ghostpool_scripts", TEMPLATEPATH . '/lib/scripts/');
|
|
define("ghostpool_admin", TEMPLATEPATH . '/lib/admin/inc/');
|
|
define("ghostpool_bp", TEMPLATEPATH . '/lib/buddypress/');
|
|
define("BP_THEME_URL", get_template_directory_uri());
|
|
|
|
/* * ************************* Additional Functions ************************** */
|
|
|
|
// Main Theme Options
|
|
require_once(ghostpool_admin . 'theme-options.php');
|
|
require(ghostpool_inc . 'options.php');
|
|
require(ghostpool_inc . 'fetch-video-data.php');
|
|
|
|
// Meta Options
|
|
require_once(ghostpool_admin . 'theme-meta-options.php');
|
|
|
|
// Widgets
|
|
require_once(ghostpool_admin . 'theme-widgets.php');
|
|
|
|
// Sidebars
|
|
require_once(ghostpool_admin . 'theme-sidebars.php');
|
|
|
|
// Shortcodes
|
|
require_once(ghostpool_admin . 'theme-shortcodes.php');
|
|
|
|
// Custom Post Types
|
|
require_once(ghostpool_admin . 'theme-post-types.php');
|
|
|
|
// TinyMCE
|
|
require_once (ghostpool_admin . 'tinymce/tinymce.php');
|
|
|
|
// Update Notification
|
|
// require_once(ghostpool_admin . 'theme-update-notification.php');
|
|
|
|
// WP Show IDs
|
|
require_once(ghostpool_admin . 'wp-show-ids/wp-show-ids.php');
|
|
|
|
// Import/Export Widgets
|
|
require_once(ghostpool_admin . 'widget-settings-importexport/widget_data.php');
|
|
|
|
// Image Resizer
|
|
require_once(ghostpool_scripts . 'image-resizer.php');
|
|
|
|
// Follow Item
|
|
if ($theme_reviews_follow == "0") {
|
|
require_once(ghostpool_scripts . 'wp-favorite-posts/wp-favorite-posts.php');
|
|
}
|
|
|
|
// BuddyPress Functions
|
|
if (function_exists('bp_is_active') && file_exists(ghostpool_bp . 'functions-buddypress.php')) {
|
|
require_once(ghostpool_bp . 'functions-buddypress.php');
|
|
require_once(ghostpool_bp . 'search-buddypress.php');
|
|
}
|
|
|
|
|
|
/* * ************************* Flags img function *********************** */
|
|
function gp_get_flag_img($country_code = '', $flagsize=32) {
|
|
$src = get_template_directory_uri() . '/lib/images/flags/'.$flagsize.'/';
|
|
if ($country_code) {
|
|
$src .= strtolower($country_code) . '.png';
|
|
} else {
|
|
$src .= 'none.png';
|
|
}
|
|
return '<img class="dedicationFlag" src="' . $src . '" alt="' . $country_code . '"/>';
|
|
}
|
|
|
|
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 '<img class="dedicationFlag" src="' . $src . '" alt="' . $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(), '<img>');
|
|
$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.min.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 . '.min.css');
|
|
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() OR is_home() OR is_front_page())
|
|
wp_enqueue_script('comment-reply');
|
|
|
|
wp_enqueue_script('swfobject', get_template_directory_uri() . '/lib/scripts/swfobjects.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'));
|
|
|
|
// Para Vimeo;
|
|
wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.min.js', array('jquery'));
|
|
//wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.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.min.js', array('jquery'));
|
|
//wp_enqueue_script('jtypewriter', get_template_directory_uri(). '/lib/scripts/jquery.jtypewriter.js', array('jquery'));
|
|
|
|
wp_enqueue_script('asong2u', get_template_directory_uri(). '/lib/scripts/asong2u.min.js', array('jquery'));
|
|
//wp_enqueue_script('asong2u', get_template_directory_uri(). '/lib/scripts/asong2u.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];
|
|
|
|
if ($theme_font_dedication === 'Give+You+Glory') {
|
|
wp_enqueue_style('googleFonts', get_template_directory_uri() . '/lib/css/giveyouglory.css');
|
|
} else {
|
|
wp_enqueue_style('googleFonts', 'http://fonts.googleapis.com/css?family=' . $theme_font_dedication);
|
|
}
|
|
echo '<style>';
|
|
echo '#dedicationTitle { ' . $body_font . ' } ';
|
|
echo '</style>';
|
|
}
|
|
}
|
|
|
|
function gp_wp_header() {
|
|
|
|
require(ghostpool_inc . 'options.php');
|
|
|
|
if ($theme_favicon_ico)
|
|
echo '<link rel="shortcut icon" href="' . $theme_favicon_ico . '" /><link rel="icon" href="' . $theme_favicon_ico . '" type="image/vnd.microsoft.icon" />';
|
|
|
|
if ($theme_favicon_png)
|
|
echo '<link rel="icon" type="image/png" href="' . $theme_favicon_png . '" />';
|
|
|
|
if ($theme_apple_icon)
|
|
echo '<link rel="apple-touch-icon" href="' . $theme_apple_icon . '" />';
|
|
|
|
|
|
if ($theme_custom_css)
|
|
echo '<style>' . stripslashes($theme_custom_css) . '</style>';
|
|
|
|
echo stripslashes($theme_scripts);
|
|
|
|
echo '
|
|
<!--[if lte IE 8]>
|
|
<style>
|
|
#page-shadow, #nav, .post-thumbnail, #footer-bottom, #footer-bottom .columns.separate > div {
|
|
behavior: url("' . get_template_directory_uri() . '/lib/scripts/pie/PIE.php");
|
|
}
|
|
</style>
|
|
<![endif]-->';
|
|
|
|
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 <head>.
|
|
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 "<div class='wp-pagenavi'>";
|
|
echo '<span class="pages">' . __('Page', 'gp_lang') . ' ' . $paged . ' ' . __('of', 'gp_lang') . ' ' . $pages . '</span>';
|
|
if ($paged > 2 && $paged > $range + 1 && $showitems < $pages)
|
|
echo "<a href='" . get_pagenum_link(1) . "'>«</a>";
|
|
if ($paged > 1 && $showitems < $pages)
|
|
echo "<a href='" . get_pagenum_link($paged - 1) . "'>‹</a>";
|
|
|
|
for ($i = 1; $i <= $pages; $i++) {
|
|
if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
|
|
echo ($paged == $i) ? "<span class='current'>" . $i . "</span>" : "<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>";
|
|
}
|
|
}
|
|
|
|
if ($paged < $pages && $showitems < $pages)
|
|
echo "<a href='" . get_pagenum_link($paged + 1) . "'>›</a>";
|
|
if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages)
|
|
echo "<a href='" . get_pagenum_link($pages) . "'>»</a>";
|
|
echo "</div>\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 "<div class='wp-pagenavi'>";
|
|
|
|
if ($paged + 1 <= $pages) {
|
|
echo "<a href='" . get_pagenum_link($paged + 1) . "' class='read-more' title='". __('See More', 'gp_lang') . "'>" . __('See More', 'gp_lang') . "</a>";
|
|
echo "<img class='read-more-loader' src='" . get_template_directory_uri() . "/lib/images/loader.gif' style='display:none;'/>";
|
|
}
|
|
echo "</div>\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(
|
|
'<p>[' => '[',
|
|
']</p>' => ']',
|
|
']<br />' => ']'
|
|
);
|
|
|
|
$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 '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/lib/css/login.css" />';
|
|
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='<br />'){
|
|
$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 && ($fs != '0'));
|
|
}
|
|
|
|
function play_video_for_registeres_user() {
|
|
$fs = get_query_var('fs');
|
|
return ($fs == '2');
|
|
}
|
|
|
|
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) {
|
|
$args = array();
|
|
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']);
|
|
if (key_exists('y', $args)) {
|
|
$decoded_url = add_query_arg('fs', 2, $decoded_url); // Para usuarios que están registrados
|
|
} else {
|
|
$decoded_url = add_query_arg('fs', 1, $decoded_url); // Para usuarios no registrados
|
|
}
|
|
return $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() {
|
|
$args = array();
|
|
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']);
|
|
if (key_exists('y', $args)) {
|
|
$decoded_url = add_query_arg('fs', 2, $decoded_url); // Para usuarios que están registrados
|
|
} else {
|
|
$decoded_url = add_query_arg('fs', 1, $decoded_url); // Para usuarios no registrados
|
|
}
|
|
|
|
wp_redirect($decoded_url);
|
|
}
|
|
}
|
|
}
|
|
add_action('wp', 'gp_encoded_dedication_redirect_for_users', 2);
|
|
|
|
function gp_encoded_private_dedication_specials($posts = array()) {
|
|
global $wp_query;
|
|
|
|
if ($wp_query->is_single && $wp_query->is_singular && $wp_query->query_vars && $posts) {
|
|
/* TODO: do we need to ensure wp_query->query_vars['post_type'] == $_first_post->post_type ? */
|
|
$_first_post = reset($posts);
|
|
|
|
/* the hack: only do this if it is of type special and the status is draft */
|
|
if ($_first_post->post_status == 'private') {
|
|
$wp_query->post = $_first_post; /* quick and dirty hack so that you don't get a 404 */
|
|
$wp_query->post->post_status = 'publish';
|
|
|
|
$wp_query->post_count = sizeof($posts); /* these 3 lines probably aren't necessary */
|
|
$wp_query->found_posts = sizeof($posts);
|
|
$wp_query->is_404 = false;
|
|
}
|
|
}
|
|
return $posts;
|
|
}
|
|
|
|
if (!is_admin() && isset($_COOKIE['refid'])) {
|
|
add_filter('posts_results', 'gp_encoded_private_dedication_specials');
|
|
}
|
|
|
|
|
|
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');
|
|
|
|
|
|
function gp_last_login($login) {
|
|
global $user_ID;
|
|
$user = get_userdatabylogin($login);
|
|
update_usermeta($user->ID, 'last_login', current_time('mysql'));
|
|
}
|
|
add_action('wp_login','gp_last_login');
|
|
|
|
function gp_get_last_login($user_id) {
|
|
$last_login = get_user_meta($user_id, 'last_login', true);
|
|
$date_format = get_option('date_format') . ' ' . get_option('time_format');
|
|
$the_last_login = mysql2date($date_format, $last_login, false);
|
|
return $the_last_login;
|
|
}
|
|
|
|
|
|
function gp_get_total_unread_dedications() {
|
|
if(is_user_logged_in()) {
|
|
$user_id = mar_get_user_id();
|
|
$read_ids = mar_get_user_read_posts( $user_id );
|
|
|
|
$args = array(
|
|
'exclude' => $read_ids,
|
|
'numberposts' => -1,
|
|
'cat' => DEDICATION_CATEGORY_SLUG,
|
|
'meta_key' => 'ghostpool_destination_user_id',
|
|
'meta_value' => $user_id
|
|
);
|
|
$unread_posts = get_posts( $args );
|
|
return count($unread_posts);
|
|
}
|
|
else return 0;
|
|
}
|
|
|
|
function gp_get_unread_dedications() {
|
|
$result = array();
|
|
if(is_user_logged_in()) {
|
|
$user_id = mar_get_user_id();
|
|
$read_ids = mar_get_user_read_posts( $user_id );
|
|
|
|
$args = array(
|
|
'exclude' => $read_ids,
|
|
'numberposts' => -1,
|
|
'cat' => DEDICATION_CATEGORY_SLUG,
|
|
'meta_key' => 'ghostpool_destination_user_id',
|
|
'meta_value' => $user_id
|
|
);
|
|
$unread_posts = get_posts( $args );
|
|
foreach ($unread_posts as $unread) {
|
|
$result[] = $unread->ID;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function set_from_email($email) {
|
|
return 'asong2u@asong2u.com';
|
|
}
|
|
add_filter('wp_mail_from', 'set_from_email');
|
|
|
|
function set_mail_content_type() {
|
|
return "text/html";
|
|
}
|
|
add_filter ("wp_mail_content_type", "set_mail_content_type");
|
|
|
|
remove_action( 'login_head', 'wp_no_robots', 10 );
|
|
remove_action('wp_head', 'wp_generator');
|
|
|
|
?>
|