- Statut : non résolu
- Ce sujet contient 11 réponses, 2 participants et a été mis à jour pour la dernière fois par
bloingo, le il y a 18 années et 7 mois.
-
AuteurMessages
-
3 novembre 2006 à 9 h 40 min #449174
Bonjour, tout le monde 🙂
Problème(s) rencontré(s) :
je suis en train de faire divers tests de themes et je me retrouve avec une erreur affichée que je ne comprends pas
Warning: Invalid argument supplied for foreach() in /home.10.2/monsite/www/wp-content/plugins/brianslatestcomments.php on line 89themes testés :
Traffic Cone Trophy 1.0 par Daniel Lee
3k2redux klee par Michael Heilemann & Chris J Davis
Sirius 1.0 par Olaf A. Schmitzcette erreur disparait lorsque j’utilise le theme :
Blix 0.9.1 par Sebastian Schmieg
ou le
SeaBeast v.1.2 par Mike Cherimmais pour celui la, je reviendrai pour un paquet des qestions, il est peut etre un peu compliqué pour moi
( du php dans tous les coins 😉c’est peut etre une histoire de plugins utilisé par les themes qui crashent (?)
alors, pour » l’invalid argument » , si quelqu’un sait ?? merci 🙂3 novembre 2006 à 9 h 54 min #583505Salut 🙂
Peux-tu poster ici le contenu du fichier « tonsite/www/wp-content/plugins/brianslatestcomments.php » ?
C’est très probablement un appel à ce script défectueux dans l’un de tes thèmes que tu ne fais pas dans l’autre 😉
3 novembre 2006 à 10 h 48 min #583506Salut MS-DOS_91 🙂
bon, j’espere que je vais poster le bon fichier,
si je me suis gourré, c’est normal, je suis une vraie nouille 😉
a + 🙂
<?php
/*
Plugin Name: Brian’s Latest Comments
Plugin URI: http://meidell/latestcomments/
Version: 1.5.10
Description: This shows an overview of the recently active articles and the last people to comment on them. Original idea and code fixes contributed by Michael Heilemann.
If you have Dunstan’s Time Since installed, this plugin uses it for the title= » » attributes on the comments and posts. (For WordPress 1.5)
Author: Brian Meidell
Author URI: http://meidell.dk/blogVersion 1.5: Now works without LOCK TABLE and CREATE TEMPORARY TABLE priviledges.
Version 1.5.1: Can’t remember what I did here
Version 1.5.2: Fixed count select statement to not include spammy comments
Version 1.5.3: Properly excludes track- and pingbacks
Version 1.5.4: Excludes posts that are not published, even if they have comments
Version 1.5.5: Fade old comments, fixed bug that wreaked havoc with Time Since
Version 1.5.6: Bugfix from Jonas Rabbe (http://www.jonas.rabbe.com/) pertaining to timesince
Version 1.5.7: Bugfix so old colors can be darker than new colors (stupid oversight), thanks to http://spiri.dk for spotting it.
Bugfix where single digit hex would cause invalid colors, thanks to http://www.wereldkeuken.be/ for the fix.
Version 1.5.8: Bugfix from Matthias Schutz regarding time_since.
Version 1.5.9: Added function redefiniotion protection if people use the plugin in several places
Version 1.5.10: Added bugfix by http://cavemonkey50.com
Added time_since bugfix from http://getk2.com/forum/showthread.php?t=449*/
function blc_latest_comments($num_posts = 5, $num_comments = 6, $hide_pingbacks_and_trackbacks = true, $prefix = «
- « , $postfix = «
« , $fade_old = true, $range_in_days = 10, $new_col = « #444444 », $old_col = « #cccccc »)
{
global $wpdb, $tablecomments, $tableposts;if(!function_exists(‘blc_clamp’))
{
function blc_clamp($min, $max, $val)
{
return max($min,min($max,$val));
}
}function get_channel($col, $offset)
{
return hexdec(substr($col, $offset, 2));
}function channels($col)
{
$r = get_channel($col, 1);
$g = get_channel($col, 3);
$b = get_channel($col, 5);
return array($r, $g, $b);
}$max_time = $range_in_days * 24 * 60 * 60 ;
function scale_channel($old, $new, $diff, $max_time)
{
$range = $old – $new;
$c = round($diff/$max_time*($range))+$new;
$c = blc_clamp(min($new, $old), max($new, $old), $c);
$c_hex = str_pad(dechex($c), 2, ‘0’, STR_PAD_LEFT);
return $c_hex;
}$usetimesince = function_exists(‘time_since’); // Work nicely with Dunstan’s Time Since plugin (adapted by Michael Heilemann)
// This is compensating for the lack of subqueries in mysql 3.x
// The approach used in previous versions needed the user to
// have database lock and create tmp table priviledges.
// This uses more queries and manual DISTINCT code, but it works with just select privs.
if(!$hide_pingbacks_and_trackbacks)
$ping = « »;
else
$ping = « AND comment_type’pingback’ AND comment_type’trackback' »;
$posts = $wpdb->get_results(« SELECT
comment_post_ID, post_title
FROM ($tablecomments LEFT JOIN $tableposts ON (comment_post_ID = ID))
WHERE comment_approved = ‘1’
AND ($tableposts.post_status=’publish’ OR $tableposts.post_status=’static’)
$ping
ORDER BY comment_date DESC; »);$seen = array();
$num = 0;if($fade_old)
{
list($r_new, $g_new, $b_new) = channels($new_col);
list($r_old, $g_old, $b_old) = channels($old_col);
}foreach($posts as $post)
{
// The following 5 lines is a manual DISTINCT and LIMIT,
// since mysql 3.x doesn’t allow you to control which way a DISTINCT
// select merges multiple entries.
if(array_key_exists($post->comment_post_ID, $seen))
continue;
$seen[$post->comment_post_ID] = true;
if($num++ > $num_posts)
break;$commenters = $wpdb->get_results(« SELECT *, UNIX_TIMESTAMP(comment_date) AS unixdate FROM $tablecomments
WHERE comment_approved = ‘1’
AND comment_post_ID = ‘ ».$post->comment_post_ID. »‘
$ping
ORDER BY comment_date DESC
LIMIT $num_comments; »);$count = $wpdb->get_var(« SELECT COUNT(comment_ID) AS c FROM $tablecomments WHERE comment_post_ID = $post->comment_post_ID AND comment_approved = ‘1’ « .$ping);
$i = 0;
$link = get_permalink($post->comment_post_ID);
if($usetimesince)
//$title = » title= »Last comment was « .time_since($commenters[0]->unixdate). » ago » »;
$title = » title= »Last comment was « .time_since(strtotime($commenters[0]->comment_date_gmt. » GMT »),time()). » ago » »;
else
$title = « »;
echo $prefix. »« .stripslashes($post->post_title). « « .$count. »
n« ;
foreach($commenters as $commenter)
{
if($usetimesince)
// $title = » title= »Posted « .time_since($commenter->unixdate). » ago » »;
$title = » title= »Posted « .time_since(strtotime($commenter->comment_date_gmt. » GMT »), time()). » ago » »;if($fade_old)
{
$diff = time() – $commenter->unixdate;
$r_hex = scale_channel($r_old, $r_new, $diff, $max_time);
$g_hex = scale_channel($g_old, $g_new, $diff, $max_time);
$b_hex = scale_channel($b_old, $b_new, $diff, $max_time);
$colstr = » style= »color: # ».$r_hex.$g_hex.$b_hex. »; » »;
}if($i++ > 0)
echo « , « ;echo « comment_ID. » »$title> ».stripslashes($commenter->comment_author). »« ;
}
if($count > $num_comments)
echo » […]« ;
echo « « .$postfix. »n »;}
}?>
3 novembre 2006 à 11 h 19 min #583507Berk 😡
<?php
/*
Plugin Name: Brian's Latest Comments
Plugin URI: http://meidell/latestcomments/
Version: 1.5.10
Description: This shows an overview of the recently active articles and the last people to comment on them. Original idea and code fixes contributed by <a href="http://binarybonsai.com">Michael Heilemann</a>.<br />If you have <a href="http://binarybonsai.com/archives/2004/08/17/time-since-plugin/">Dunstan’s Time Since</a> installed, this plugin uses it for the title= » » attributes on the comments and posts. (For WordPress 1.5)
Author: Brian Meidell
Author URI: http://meidell.dk/blog
Version 1.5: Now works without LOCK TABLE and CREATE TEMPORARY TABLE priviledges.
Version 1.5.1: Can’t remember what I did here
Version 1.5.2: Fixed count select statement to not include spammy comments
Version 1.5.3: Properly excludes track- and pingbacks
Version 1.5.4: Excludes posts that are not published, even if they have comments
Version 1.5.5: Fade old comments, fixed bug that wreaked havoc with Time Since
Version 1.5.6: Bugfix from Jonas Rabbe (http://www.jonas.rabbe.com/) pertaining to timesince
Version 1.5.7: Bugfix so old colors can be darker than new colors (stupid oversight), thanks to http://spiri.dk for spotting it.
Bugfix where single digit hex would cause invalid colors, thanks to http://www.wereldkeuken.be/ for the fix.
Version 1.5.8: Bugfix from Matthias Schutz regarding time_since.
Version 1.5.9: Added function redefiniotion protection if people use the plugin in several places
Version 1.5.10: Added bugfix by http://cavemonkey50.com
Added time_since bugfix from http://getk2.com/forum/showthread.php?t=449
*/
function blc_latest_comments($num_posts = 5,
$num_comments = 6,
$hide_pingbacks_and_trackbacks = true,
$prefix = ‘<li class="alternate">‘,
$postfix = ‘</li>‘,
$fade_old = true,
$range_in_days = 10,
$new_col = ‘#444444’,
$old_col = ‘#cccccc’)
{
global $wpdb, $tablecomments, $tableposts;
if (!function_exists(‘blc_clamp’))
{
function blc_clamp($min, $max, $val)
{
return max($min, min($max, $val));
}
}
function get_channel($col, $offset)
{
return hexdec(substr($col, $offset, 2));
}
function channels($col)
{
$r = get_channel($col, 1);
$g = get_channel($col, 3);
$b = get_channel($col, 5);
return array($r, $g, $b);
}
$max_time = $range_in_days * 86400; // 86400 = 24 * 60 * 60 ;-)
function scale_channel($old, $new, $diff, $max_time)
{
$range = $old – $new;
$c = round($diff / $max_time * ($range)) + $new;
$c = blc_clamp(min($new, $old), max($new, $old), $c);
$c_hex = str_pad(dechex($c), 2, ‘0’, STR_PAD_LEFT);
return $c_hex;
}
$usetimesince = function_exists(‘time_since’); // Work nicely with Dunstan’s Time Since plugin (adapted by Michael Heilemann)
// This is compensating for the lack of subqueries in mysql 3.x
// The approach used in previous versions needed the user to
// have database lock and create tmp table priviledges.
// This uses more queries and manual DISTINCT code, but it works with just select privs.
$ping = ($hide_pingbacks_and_trackbacks) ? « AND comment_type ‘pingback’ AND comment_type ‘trackback' » : »;
$posts = $wpdb->get_results(« SELECT comment_post_ID, post_title
FROM $tablecomments
LEFT JOIN $tableposts ON comment_post_ID = ID
WHERE comment_approved = ‘1’
AND ($tableposts.post_status = ‘publish’ OR $tableposts.post_status = ‘static’)
$ping
ORDER BY comment_date DESC
« );
$seen = array();
$num = 0;
if ($fade_old)
{
list($r_new, $g_new, $b_new) = channels($new_col);
list($r_old, $g_old, $b_old) = channels($old_col);
}
foreach ($posts AS $post)
{
// The following 5 lines is a manual DISTINCT and LIMIT,
// since mysql 3.x doesn’t allow you to control which way a DISTINCT
// select merges multiple entries.
if (array_key_exists($post->comment_post_ID, $seen))
continue;
$seen[$post->comment_post_ID] = true;
if ($num++ > $num_posts)
break;
$commenters = $wpdb->get_results(« SELECT *, UNIX_TIMESTAMP(comment_date) AS unixdate FROM $tablecomments
WHERE comment_approved = ‘1’
AND comment_post_ID = ‘ ».$post->comment_post_ID. »‘
$ping
ORDER BY comment_date DESC
LIMIT $num_comments
« );
$count = $wpdb->get_var(« SELECT COUNT(comment_ID) AS c FROM $tablecomments WHERE comment_post_ID = $post->comment_post_ID AND comment_approved = ‘1’ « .$ping);
$i = 0;
$link = get_permalink($post->comment_post_ID);
$title = ($usetimesince) ? ‘ title= »Last comment was ‘.time_since(strtotime($commenters[0]->comment_date_gmt.’ GMT’), time()).’ ago »‘ : »;
echo $prefix,’<a class="activityentry">‘,stripslashes($post->post_title),’</a> <a href="',$link,'#comments" title="Go to the comments of this entry">‘,$count,’</a><br />‘, »n »,’<small>‘;
foreach ($commenters AS $commenter)
{
if ($usetimesince)
// $title = » title= »Posted « .time_since($commenter->unixdate). » ago » »;
$title = ‘ title= »Posted ‘.time_since(strtotime($commenter->comment_date_gmt.’ GMT’), time()).’ ago »‘;
if ($fade_old)
{
$diff = time() – $commenter->unixdate;
$r_hex = scale_channel($r_old, $r_new, $diff, $max_time);
$g_hex = scale_channel($g_old, $g_new, $diff, $max_time);
$b_hex = scale_channel($b_old, $b_new, $diff, $max_time);
$colstr = ‘ style= »color: #’.$r_hex.$g_hex.$b_hex.’; »‘;
}
if ($i++ > 0)
echo ‘, ‘;
echo ‘<a>comment_ID,' »‘,$title,’>’,stripslashes($commenter->comment_author),’</a>‘;
}
if ($count > $num_comments)
echo ‘ <a href="',$link,'#comments" title="Go to the comments of this entry">[…]</a>‘;
echo ‘</small>‘,$postfix, »n »;
}
}
?>…Pas testé, mais il y a quelques erreurs en moins et beaucoup d’optimisations en plus 😉
3 novembre 2006 à 11 h 25 min #583508super merci MS-DOS 🙂
mais, euh, parles moi comme à une nouille stp
– donc, je copie ton code, et j’upload pour remplacer le fichier Berk par le tien ??
c’est ça ??? 🙂3 novembre 2006 à 11 h 30 min #583509Excuses-moi 🙂
Oui, essaies de remplacer ton fichier par celui-ci et dis-moi ce que tu obtiens 😉
Si il y a toujours une erreur, ça vient probablement de la requête qui est obsolète et qu’il faudra « remanier » 😕3 novembre 2006 à 11 h 32 min #583510ok, merci 🙂
je vais essayer, j’ai jamais fait ça, une grande premiere3 novembre 2006 à 11 h 37 min #583511…. euh ! là, c’est la m……..
c’est bien pire qu’avant , y a tout plein de nouveaux N°s de lignes d’erreur ,..
et ça mouline un max pour afficher la pagebon, je recommence pour voir
et non, ça marche pas
ce que je constate c’est que ce sont les N°s de lignes d’erreur qui ont changépar exemple, avant, sur le theme Traffic Cone Trophy 1.0 par Daniel Lee
j’avais
Warning: Invalid argument supplied for foreach() in /home.10.2/monsite/www/wp-content/plugins/brianslatestcomments.php on line 89
et maintenant , j’ai :Warning: Invalid argument supplied for foreach() in /home.10.2/monsite/www/wp-content/plugins/brianslatestcomments.php on line 95
3 novembre 2006 à 12 h 16 min #583512Essaies avec ça :
<?php
/*
Plugin Name: Brian's Latest Comments
Plugin URI: http://meidell/latestcomments/
Version: 1.5.10
Description: This shows an overview of the recently active articles and the last people to comment on them. Original idea and code fixes contributed by <a href="http://binarybonsai.com">Michael Heilemann</a>.<br />If you have <a href="http://binarybonsai.com/archives/2004/08/17/time-since-plugin/">Dunstan’s Time Since</a> installed, this plugin uses it for the title= » » attributes on the comments and posts. (For WordPress 1.5)
Author: Brian Meidell
Author URI: http://meidell.dk/blog
Version 1.5: Now works without LOCK TABLE and CREATE TEMPORARY TABLE priviledges.
Version 1.5.1: Can’t remember what I did here
Version 1.5.2: Fixed count select statement to not include spammy comments
Version 1.5.3: Properly excludes track- and pingbacks
Version 1.5.4: Excludes posts that are not published, even if they have comments
Version 1.5.5: Fade old comments, fixed bug that wreaked havoc with Time Since
Version 1.5.6: Bugfix from Jonas Rabbe (http://www.jonas.rabbe.com/) pertaining to timesince
Version 1.5.7: Bugfix so old colors can be darker than new colors (stupid oversight), thanks to http://spiri.dk for spotting it.
Bugfix where single digit hex would cause invalid colors, thanks to http://www.wereldkeuken.be/ for the fix.
Version 1.5.8: Bugfix from Matthias Schutz regarding time_since.
Version 1.5.9: Added function redefiniotion protection if people use the plugin in several places
Version 1.5.10: Added bugfix by http://cavemonkey50.com
Added time_since bugfix from http://getk2.com/forum/showthread.php?t=449
*/
function blc_latest_comments($num_posts = 5,
$num_comments = 6,
$hide_pingbacks_and_trackbacks = true,
$prefix = ‘<li class="alternate">‘,
$postfix = ‘</li>‘,
$fade_old = true,
$range_in_days = 10,
$new_col = ‘#444444’,
$old_col = ‘#cccccc’)
{
global $wpdb;
if (!function_exists(‘blc_clamp’))
{
function blc_clamp($min, $max, $val)
{
return max($min, min($max, $val));
}
}
function get_channel($col, $offset)
{
return hexdec(substr($col, $offset, 2));
}
function channels($col)
{
$r = get_channel($col, 1);
$g = get_channel($col, 3);
$b = get_channel($col, 5);
return array($r, $g, $b);
}
$max_time = $range_in_days * 86400; // 86400 = 24 * 60 * 60 ;-)
function scale_channel($old, $new, $diff, $max_time)
{
$range = $old – $new;
$c = round($diff / $max_time * ($range)) + $new;
$c = blc_clamp(min($new, $old), max($new, $old), $c);
$c_hex = str_pad(dechex($c), 2, ‘0’, STR_PAD_LEFT);
return $c_hex;
}
$usetimesince = function_exists(‘time_since’); // Work nicely with Dunstan’s Time Since plugin (adapted by Michael Heilemann)
// This is compensating for the lack of subqueries in mysql 3.x
// The approach used in previous versions needed the user to
// have database lock and create tmp table priviledges.
// This uses more queries and manual DISTINCT code, but it works with just select privs.
$ping = ($hide_pingbacks_and_trackbacks) ? « AND comment_type ‘pingback’ AND comment_type ‘trackback' » : »;
$posts = $wpdb->get_results(« SELECT comment_post_ID, post_title
FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_ID = ID
WHERE comment_approved = ‘1’
AND ($wpdb->posts.post_status = ‘publish’ OR $wpdb->posts.post_status = ‘static’)
$ping
ORDER BY comment_date DESC
« );
$seen = array();
$num = 0;
if ($fade_old)
{
list($r_new, $g_new, $b_new) = channels($new_col);
list($r_old, $g_old, $b_old) = channels($old_col);
}
if ($posts)
foreach ($posts AS $post)
{
// The following 5 lines is a manual DISTINCT and LIMIT,
// since mysql 3.x doesn’t allow you to control which way a DISTINCT
// select merges multiple entries.
if (array_key_exists($post->comment_post_ID, $seen))
continue;
$seen[$post->comment_post_ID] = true;
if ($num++ > $num_posts)
break;
$commenters = $wpdb->get_results(« SELECT *, UNIX_TIMESTAMP(comment_date) AS unixdate FROM $wpdb->comments
WHERE comment_approved = ‘1’
AND comment_post_ID = ‘ ».$post->comment_post_ID. »‘
$ping
ORDER BY comment_date DESC
LIMIT $num_comments
« );
$count = $wpdb->get_var(« SELECT COUNT(comment_ID) AS c FROM $wpdb->comments WHERE comment_post_ID = $post->comment_post_ID AND comment_approved = ‘1’ « .$ping);
$i = 0;
$link = get_permalink($post->comment_post_ID);
$title = ($usetimesince) ? ‘ title= »Last comment was ‘.time_since(strtotime($commenters[0]->comment_date_gmt.’ GMT’), time()).’ ago »‘ : »;
echo $prefix,’<a class="activityentry">‘,stripslashes($post->post_title),’</a> <a href="',$link,'#comments" title="Go to the comments of this entry">‘,$count,’</a><br />‘, »n »,’<small>‘;
if ($commenters)
foreach ($commenters AS $commenter)
{
if ($usetimesince)
// $title = » title= »Posted « .time_since($commenter->unixdate). » ago » »;
$title = ‘ title= »Posted ‘.time_since(strtotime($commenter->comment_date_gmt.’ GMT’), time()).’ ago »‘;
if ($fade_old)
{
$diff = time() – $commenter->unixdate;
$r_hex = scale_channel($r_old, $r_new, $diff, $max_time);
$g_hex = scale_channel($g_old, $g_new, $diff, $max_time);
$b_hex = scale_channel($b_old, $b_new, $diff, $max_time);
$colstr = ‘ style= »color: #’.$r_hex.$g_hex.$b_hex.’; »‘;
}
if ($i++ > 0)
echo ‘, ‘;
echo ‘<a>comment_ID,' »‘,$title,’>’,stripslashes($commenter->comment_author),’</a>‘;
}
if ($count > $num_comments)
echo ‘ <a href="',$link,'#comments" title="Go to the comments of this entry">[…]</a>‘;
echo ‘</small>‘,$postfix, »n »;
}
}
?>J’ai ajouté des conditions pour que les foreach ne s’exécutent que si il y a des résultats et j’ai remplacé les noms des tables $tableposts et $tablecomments par leurs équivalents actuels : $wpdb->posts et $wpdb->comments 😉
3 novembre 2006 à 13 h 16 min #583513ben là, je dois te dire que ……… hé bé, heu,……………….
ça maaaarche ! 🙂🙂
waw, t’es trop fort
tout est impec pour les 2 themes :
themes testés :
Traffic Cone Trophy 1.0 par Daniel Lee
3k2redux klee par Michael Heilemann & Chris J Davispour le 3eme :
Sirius 1.0 par Olaf A. Schmitz
Warning: Invalid argument supplied for foreach() in
/home.10.2/site/www/site/wp-content/themes/sirius/functions.php on line 364
lui,il est toujours dans les choux, mais c’est pas grave pour l’instant, j’ai les 2 autres 🙂je te remercie énormément 🙂
… et, en fait, je suis d’accord avec toi
il fallait bien des conditions pour que les foreach ne s’exécutent que si il y a des résultats et, effectivement remplacer les noms des tables $tableposts et $tablecomments par leurs équivalents actuels : $wpdb->posts et $wpdb->comments
😎:D:D
merci encore MS-DOS_1991 🙂🍺
et viva wpfr
3 novembre 2006 à 13 h 35 min #583514De rien 😉
:wp::wp:
3 novembre 2006 à 13 h 48 min #583515non, non, j’insiste, merci et bravo 🙂
c’est vraiment super cette communauté,
ça donnerait presque envie de devenir compétent soi meme pour aider les autres
allez, a +++ 🙂
à propos, je vois que je suis affublé du titre de Connaisseur WP, incompétent WP me paraitrait plus adéquat, non ?? 🙂 -
AuteurMessages
- Vous devez être connecté pour répondre à ce sujet.