PluginProbe
FeedWordPress / 2020.0818
FeedWordPress v2020.0818
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / feedwordpressdiagnostic.class.php

feedwordpressdiagnostic.class.php in FeedWordPress 2020.0818, at feedwordpressdiagnostic.class.php

85 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * class FeedWordPressDiagnostic: help to organize some diagnostics output functions.
4 */
5 class FeedWordPressDiagnostic {
6 public static function feed_error ($error, $old, $link) {
7 $wpError = $error['object'];
8 $url = $link->uri();
9
10 // check for effects of an effective-url filter
11 $effectiveUrl = $link->uri(array('fetch' => true));
12 if ($url != $effectiveUrl) : $url .= ' | ' . $effectiveUrl; endif;
13
14 $mesgs = $wpError->get_error_messages();
15 foreach ($mesgs as $mesg) :
16 $mesg = esc_html($mesg);
17 FeedWordPress::diagnostic(
18 'updated_feeds:errors',
19 "Feed Error: [${url}] update returned error: $mesg"
20 );
21
22 $hours = get_option('feedwordpress_diagnostics_persistent_errors_hours', 2);
23 $span = ($error['ts'] - $error['since']);
24
25 if ($span >= ($hours * 60 * 60)) :
26 $since = date('r', $error['since']);
27 $mostRecent = date('r', $error['ts']);
28 FeedWordPress::diagnostic(
29 'updated_feeds:errors:persistent',
30 "Feed Update Error: [${url}] returning errors"
31 ." since ${since}:<br/><code>$mesg</code>",
32 $url, $error['since'], $error['ts']
33 );
34 endif;
35 endforeach;
36 }
37
38 public static function admin_emails ($id = '') {
39 $users = get_users_of_blog($id);
40 $recipients = array();
41 foreach ($users as $user) :
42 $user_id = (isset($user->user_id) ? $user->user_id : $user->ID);
43 $dude = new WP_User($user_id);
44 if ($dude->has_cap('administrator')) :
45 if ($dude->user_email) :
46 $recipients[] = $dude->user_email;
47 endif;
48 endif;
49 endforeach;
50 return $recipients;
51 }
52
53 public static function noncritical_bug ($varname, $var, $line, $file = NULL) {
54 if (FEEDWORDPRESS_DEBUG) : // halt only when we are doing debugging
55 self::critical_bug($varname, $var, $line, $file);
56 endif;
57 } /* FeedWordPressDiagnostic::noncritical_bug () */
58
59 public static function critical_bug ($varname, $var, $line, $file = NULL) {
60 global $wp_version;
61
62 if (!is_null($file)) :
63 $location = "line # ${line} of ".basename($file);
64 else :
65 $location = "line # ${line}";
66 endif;
67
68 print '<p><strong>Critical error:</strong> There may be a bug in FeedWordPress. Please <a href="'.FEEDWORDPRESS_AUTHOR_CONTACT.'">contact the author</a> and paste the following information into your e-mail:</p>';
69 print "\n<plaintext>";
70 print "Triggered at ${location}\n";
71 print "FeedWordPress: ".FEEDWORDPRESS_VERSION."\n";
72 print "WordPress: {$wp_version}\n";
73 print "PHP: ".phpversion()."\n";
74 print "Error data: ";
75 print $varname.": "; var_dump($var); echo "\n";
76 die;
77 } /* FeedWordPressDiagnostic::critical_bug () */
78
79 public static function is_on ($level) {
80 $show = get_option('feedwordpress_diagnostics_show', array());
81 return (in_array($level, $show));
82 } /* FeedWordPressDiagnostic::is_on () */
83
84 } /* class FeedWordPressDiagnostic */
85