From 1c7c7a642dbb3587878ef5fbab7a333dd683413c Mon Sep 17 00:00:00 2001 From: david Date: Thu, 18 Oct 2012 15:17:20 +0000 Subject: [PATCH] =?UTF-8?q?-=20Cambios=20para=20optimizar=20el=20uso=20de?= =?UTF-8?q?=20memoria=20-=20Quitar=20meta=20del=20generador=20en=20la=20ca?= =?UTF-8?q?becera=20-=20Tarea=20#1135=20->=20Mejorar=20la=20inserci=C3=B3n?= =?UTF-8?q?=20en=20Facebook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@189 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6 --- .../plugins/bp-dedication/functions.php | 24 ++++++++++++++++ wp-content/themes/score/functions.php | 3 +- .../themes/score/lib/inc/fetch-video-data.php | 14 +++++++--- .../themes/score/lib/scripts/asong2u.js | 10 +++++-- .../themes/score/lib/scripts/asong2u.min.js | 8 +++--- .../themes/score/loop-dedication-data.php | 5 ++++ wp-content/themes/score/video-slider.php | 28 +++++++++++++------ 7 files changed, 72 insertions(+), 20 deletions(-) diff --git a/wp-content/plugins/bp-dedication/functions.php b/wp-content/plugins/bp-dedication/functions.php index fa97e69..1dc4adb 100644 --- a/wp-content/plugins/bp-dedication/functions.php +++ b/wp-content/plugins/bp-dedication/functions.php @@ -12,6 +12,30 @@ function bp_get_dedication_slug() { return apply_filters( 'bp_get_dedication_slug', $dedication_slug ); } +function bp_dedication_exist_dedications_from_user( $user_id ) { + if ( !$user_id ) + return false; + + return (count_user_posts( $user_id ) > 0); +} + +function bp_dedication_exist_dedications_to_user( $user_id ) { + if ( !$user_id ) + return false; + + $args = array( + 'post_status' => array('publish', 'private'), + 'numberposts' => 1, + 'category' => 'dedication', + 'meta_key' => 'ghostpool_destination_user_id', + 'meta_value' => $user_id + ); + $posts_array = get_posts( $args ); + + return (!empty($posts_array)); +} + + function bp_dedication_get_dedications_from_user( $user_id ) { if ( !$user_id ) return false; diff --git a/wp-content/themes/score/functions.php b/wp-content/themes/score/functions.php index 4e9238c..b607f9c 100644 --- a/wp-content/themes/score/functions.php +++ b/wp-content/themes/score/functions.php @@ -86,6 +86,7 @@ if (function_exists('bp_is_active') && file_exists(ghostpool_bp . 'functions-bud 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.'/'; @@ -834,6 +835,6 @@ function set_mail_content_type() { add_filter ("wp_mail_content_type", "set_mail_content_type"); remove_action( 'login_head', 'wp_no_robots', 10 ); - +remove_action('wp_head', 'wp_generator'); ?> \ No newline at end of file diff --git a/wp-content/themes/score/lib/inc/fetch-video-data.php b/wp-content/themes/score/lib/inc/fetch-video-data.php index 075de1f..6e0a908 100644 --- a/wp-content/themes/score/lib/inc/fetch-video-data.php +++ b/wp-content/themes/score/lib/inc/fetch-video-data.php @@ -44,10 +44,10 @@ function gp_ajax_video_data() { $args = array( 'post_type' => array('post'), 'orderby' => $dedication_orderby, - 'numberposts' => 10, + 'numberposts' => -1, + 'posts_per_page' => -1, 'post_status' => $post_status, 'category_name' => $category_name, - 'offset' => 1, ); } $array = array(); @@ -59,9 +59,13 @@ function gp_ajax_video_data() { $listavideos->the_post(); require(dirname(__FILE__).'/../../loop-dedication-data.php'); - // Perfil del usuario: sólo mostrar las dedicadas por él y para él. El resto se descartan. + // Perfil del usuario: Si tiene ninguna dedicatoria (por él / para él) + // mejor mostrar estas dedicadas. El resto se descartan. if ( $bp->current_component == BP_DEDICATION_SLUG ) { - if (($displayed_id != $gp_settings['from_user_id']) && ($displayed_id != $gp_settings['to_user_id'])) { + $usuario_tiene_dedicatorias = (bp_dedication_exist_dedications_to_user($displayed_id)) || + (bp_dedication_exist_dedications_from_user($displayed_id)); + + if ($usuario_tiene_dedicatorias && ($displayed_id != $gp_settings['from_user_id']) && ($displayed_id != $gp_settings['to_user_id'])) { continue; // me salto esta dedicatoria } } @@ -84,6 +88,7 @@ function gp_ajax_video_data() { $array[$i]['extlink'] = $gp_settings['enc_link']; $array[$i]['artist'] = $gp_settings['artist_short']; $array[$i]['song'] = $gp_settings['song_short']; + $array[$i]['img_src'] = $gp_settings['img_src']; $array[$i]['unreaded'] = $gp_settings['unreaded']; $array[$i]['from_to_text'] = $gp_settings['from_flag']; @@ -108,6 +113,7 @@ function gp_ajax_video_data() { $salida .= '' . $video['permalink']. ''; $salida .= '' . $video['extlink']. ''; $salida .= ''; + $salida .= ''; if ($video['unreaded']) { $salida .= ''; diff --git a/wp-content/themes/score/lib/scripts/asong2u.js b/wp-content/themes/score/lib/scripts/asong2u.js index 4a3a681..c1084b5 100644 --- a/wp-content/themes/score/lib/scripts/asong2u.js +++ b/wp-content/themes/score/lib/scripts/asong2u.js @@ -127,15 +127,19 @@ function updateInfo() { var song = jQuery('#postdata-song-' + id).html(); var link = jQuery('#postdata-link-' + id).html(); var enc_link = jQuery('#postdata-extlink-' + id).html(); + var src_img = jQuery('#postdata-imgsrc-' + id + ' img').attr("src"); var nUrl = oUrl + 'id/' + the_id; jQuery('#dedicate_this_song_button').attr("href", nUrl); - // Social networks - nUrl = 'https://www.facebook.com/sharer.php?u=' + enc_link; + nUrl = 'http://www.facebook.com/sharer.php?s=100'; + nUrl = nUrl + '&p[url]=' + enc_link; + nUrl = nUrl + '&p[title]=' + jQuery('#postdata-title-' + id).text(); + nUrl = nUrl + '&p[summary]=' + artist + ' ' + song; + nUrl = nUrl + '&p[images][0]=' + src_img; jQuery('#fsbbtn a').attr("href", nUrl); - nUrl = 'http://twitter.com/intent/tweet?source=sharethiscom&url=' + enc_link; + nUrl = 'http://twitter.com/intent/tweet?source=asong2u&url=' + enc_link; jQuery('#twtbtn a').attr("href", nUrl); nUrl = 'https://plusone.google.com/_/+1/confirm?url=' + enc_link; jQuery('#gpsbtn a').attr("href", nUrl); diff --git a/wp-content/themes/score/lib/scripts/asong2u.min.js b/wp-content/themes/score/lib/scripts/asong2u.min.js index ca9cc39..239e39e 100644 --- a/wp-content/themes/score/lib/scripts/asong2u.min.js +++ b/wp-content/themes/score/lib/scripts/asong2u.min.js @@ -7,10 +7,10 @@ jQuery(".dedication-profile .home_column_my_dedications img.read-more-loader").r function(a){a=jQuery(a).find("#content").children();jQuery.each(a,function(){jQuery(this).hasClass("post-loop")&&(jQuery(this).removeClass("post type-post status-publish format-standard hentry category-dedication"),jQuery(this).addClass("home-my-dedications"),jQuery(this).addClass("home-dedicated-2-me"));jQuery(".dedication-profile .home_column_dedicated_2_me img.read-more-loader").remove();jQuery(".dedication-profile .home_column_dedicated_2_me a.read-more").remove();jQuery(".dedication-profile .home_column_dedicated_2_me").append(jQuery(this))})})})}); var aIndex=-1,oUrl=""; function updateInfo(){var a=jQuery.fn.videoGallery.getMediaID(),a=jQuery(jQuery("#playlist li").get(a)).attr("id").replace("playlist-element-","");if(aIndex!=a&&0<=a){aIndex=a;""==oUrl&&(oUrl=jQuery("#dedicate_this_song_button").attr("href"));var b=jQuery("#postdata-id-"+a).text(),e=jQuery("#postdata-title-"+a).html(),c=jQuery("#postdata-from-to-"+a).html(),f=jQuery("#postdata-artist-"+a).html(),g=jQuery("#postdata-song-"+a).html(),h=jQuery("#postdata-link-"+a).html(),d=jQuery("#postdata-extlink-"+a).html(), -b=oUrl+"id/"+b;jQuery("#dedicate_this_song_button").attr("href",b);jQuery("#fsbbtn a").attr("href","https://www.facebook.com/sharer.php?u="+d);jQuery("#twtbtn a").attr("href","http://twitter.com/intent/tweet?source=sharethiscom&url="+d);jQuery("#gpsbtn a").attr("href","https://plusone.google.com/_/+1/confirm?url="+d);jQuery("#mysbtn a").attr("href",'javascript:void(window.open("http://www.myspace.com/Modules/PostTo/Pages/?u='+d+'"+encodeURIComponent(document.location.toString()),"ptm","height=450,width=550").focus())'); -jQuery("#dedication-data-panel").hide("fast");jQuery("#dedication-data-panel").slideUp("fast",function(){jQuery("#dedication-data-panel").html(c);jQuery("#dedicationTitle-data-panel").html(c)});jQuery("#dedication-data-panel").slideDown();jQuery("#dedicationFooter_container").slideUp("fast",function(){jQuery("#dedicationArtits").html(f);jQuery("#dedicationSong").html(g)});jQuery("#dedicationFooter_container").slideDown("fast",function(){});jQuery("#dedicationTitle").html(e);shrinkTitle();jQuery("#dedicationTitle a").jTypeWriter(); -jQuery("#dedicationComments_container").slideUp("fast",function(){jQuery("#dedicationComments_container").load(h+" #comments","",function(){init_comments();jQuery("#dedicationComments_container").on("submit","#commentform",function(){prepare_new_comment_home();return!1})})});jQuery("#dedicationComments_container").slideDown();0b.offsetWidth;)size=parseInt(a.style.fontSize.replace("px","")),size-=1,a.style.fontSize=size+"px";a.style.fontSize-=NaN} jQuery(window).ready(function(){0ID, 'ghostpool_thumbnail_height', true) && get_post_meta $gp_settings['image_height'] = $gp_settings['thumbnail_height']; } +$post_thumbnail_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID)); +if ($post_thumbnail_img) + $gp_settings['img_src'] = $post_thumbnail_img[0]; + + $gp_settings['enc_link'] = add_query_arg('refid', bp_dedication_encode(get_permalink()), get_option('siteurl') . '/index.php'); // Song data diff --git a/wp-content/themes/score/video-slider.php b/wp-content/themes/score/video-slider.php index 1b1fb33..f1011b7 100644 --- a/wp-content/themes/score/video-slider.php +++ b/wp-content/themes/score/video-slider.php @@ -15,16 +15,26 @@ get_currentuserinfo(); if ($_ishome || ( $bp->current_component == BP_DEDICATION_SLUG )) { $dedication_orderby = "rand"; $category_name = 'dedication'; - $post_status = array('publish'); + + if (( $bp->current_component == BP_DEDICATION_SLUG )) { + $post_status = array('publish', 'private'); + } else { + $post_status = array('publish'); + } + $args = array( 'post_type' => array('post'), 'orderby' => $dedication_orderby, - //'posts_per_page' => -1, - 'numberposts' => 5, - 'post_status' => $post_status, + 'numberposts' => -1, + 'posts_per_page' => -1, 'category_name' => $category_name, + 'post_status' => $post_status, ); + + $usuario_tiene_dedicatorias = (bp_dedication_exist_dedications_to_user($displayed_id)) || + (bp_dedication_exist_dedications_from_user($displayed_id)); + query_posts($args); } @@ -60,11 +70,11 @@ if (have_posts()) {
    current_component == BP_DEDICATION_SLUG ) { + // Perfil del usuario: Si tiene ninguna dedicatoria (por él / para él) + // mejor mostrar estas dedicadas. El resto se descartan. + if ( $bp->current_component == BP_DEDICATION_SLUG && $usuario_tiene_dedicatorias) { if (($displayed_id != $gp_settings['from_user_id']) && ($displayed_id != $gp_settings['to_user_id'])) { continue; // me salto esta dedicatoria } @@ -78,14 +88,16 @@ if (have_posts()) { + - + FROM:   TO: +