PluginProbe
FeedWordPress / 2022.0123
FeedWordPress v2022.0123
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
← All changes | feedwordpress.pings.functions.php +36 -62 trunk2022.0123 View file →
@@ -3,68 +3,51 @@
3 3 ## fwp_hold_pings() and fwp_release_pings(): Outbound XML-RPC ping reform ####
4 4 ## ... 'coz it's rude to send 500 pings the first time your aggregator runs ####
5 5 ################################################################################
6 6
7 -global $fwp_held_ping; // Why declare it as global if it's not used anywhere else? (gwyneth 20230920)
7 +global $fwp_held_ping;
8 8
9 -/** @var int|null Hold pings (or not yet, if NULL). */
10 -$fwp_held_ping = NULL;
9 +$fwp_held_ping = NULL; // NULL: not holding pings yet
11 10
12 -function fwp_hold_pings() {
11 +function fwp_hold_pings () {
13 12 global $fwp_held_ping;
14 - if ( is_null ( $fwp_held_ping ) ) :
13 + if (is_null($fwp_held_ping)):
15 14 $fwp_held_ping = 0; // 0: ready to hold pings; none yet received
16 15 FeedWordPress::diagnostic(
17 16 'syndicated_posts:do_pings',
18 - 'FeedWordPress is set up to hold pings, fwp_held_ping=' . json_encode( $fwp_held_ping )
17 + 'FeedWordPress is set up to hold pings, fwp_held_ping='.json_encode($fwp_held_ping)
19 18 );
20 19 endif;
21 -} /* function fwp_hold_pings() */
20 +}
22 21
23 -/**
24 - * Attempts to schedule an immediate ping via the event scheduler,
25 - * falling back to direct ping if scheduler isn't available.
26 - *
27 - * @uses wp_schedule_single_event()
28 - * @uses generic_ping()
29 - * @uses FeedWordPress::diagnostic()
30 - *
31 - * @global $fwp_held_ping
32 - */
33 -function fwp_release_pings() {
22 +function fwp_release_pings () {
34 23 global $fwp_held_ping;
35 24
36 25 $diag_message = null;
37 - if ( $fwp_held_ping ) :
38 - if ( function_exists( 'wp_schedule_single_event') ) :
39 - if ( wp_schedule_single_event( time(), 'do_pings' ) ) :
40 - $diag_message = 'scheduled release of pings';
41 - else :
42 - $diag_message = 'scheduling release of pings failed';
43 - endif;
26 + if ($fwp_held_ping):
27 + if (function_exists('wp_schedule_single_event')) :
28 + wp_schedule_single_event(time(), 'do_pings');
29 + $diag_message = 'scheduled release of pings';
44 30 else :
45 - generic_ping( $fwp_held_ping );
31 + generic_ping($fwp_held_ping);
46 32 $diag_message = 'released pings';
47 33 endif;
48 34 endif;
49 -
35 +
50 36 $fwp_held_ping = NULL; // NULL: not holding pings anymore
51 -
52 - if ( ! is_null( $diag_message ) ) :
37 +
38 + if (!is_null($diag_message)) :
53 39 FeedWordPress::diagnostic(
54 40 'syndicated_posts:do_pings',
55 - "FeedWordPress {$diag_message}, fwp_held_ping=" . json_encode( $fwp_held_ping ) // isn't this _always_ null? (gwyneth 20230919)
41 + "FeedWordPress ${diag_message}, fwp_held_ping=".json_encode($fwp_held_ping)
56 42 );
57 43 endif;
58 -} /* function fwp_release_pings() */
44 +}
59 45
60 -/**
61 - * Pings, unless held.
62 - */
63 -function fwp_do_pings() {
64 - global $fwp_held_ping, $post_id;
46 +function fwp_do_pings () {
47 + global $fwp_held_ping;
65 48
66 - if ( ! is_null( $fwp_held_ping ) and $post_id ) : // Defer until we're done updating
49 + if (!is_null($fwp_held_ping) and $post_id) : // Defer until we're done updating
67 50 $fwp_held_ping = $post_id;
68 51
69 52 FeedWordPress::diagnostic(
70 53 'syndicated_posts:do_pings',
@@ -70,45 +53,36 @@
70 53 'syndicated_posts:do_pings',
71 54 "FeedWordPress intercepted a ping event, fwp_held_ping=".json_encode($fwp_held_ping)
72 55 );
73 56
74 - elseif ( function_exists( 'do_all_pings' ) ) :
57 + elseif (function_exists('do_all_pings')) :
75 58 do_all_pings();
76 59 else :
77 - generic_ping( $fwp_held_ping );
60 + generic_ping($fwp_held_ping);
78 61 endif;
79 -} /* function fwp_do_pings() */
62 +}
80 63
81 -/**
82 - * Pings post, using one or several of the possible methods,
83 - * e.g. XMLRPC_REQUEST, APP_REQUEST.
84 - *
85 - * @param int $post_id Post being considered for pinging.
86 - *
87 - */
88 -function fwp_publish_post_hook( $post_id ) {
64 +function fwp_publish_post_hook ($post_id) {
89 65 global $fwp_held_ping;
90 66
91 - if ( ! is_null( $fwp_held_ping ) ) : // Syndicated post. Don't mark with _pingme
92 - if ( defined( 'XMLRPC_REQUEST' ) ) :
93 - do_action( 'xmlrpc_publish_post', $post_id );
94 - endif;
95 - if ( defined( 'APP_REQUEST' ) ) :
96 - do_action( 'app_publish_post', $post_id );
97 - endif;
98 - if ( defined( 'WP_IMPORTING' ) ) :
67 + if (!is_null($fwp_held_ping)) : // Syndicated post. Don't mark with _pingme
68 + if ( defined('XMLRPC_REQUEST') )
69 + do_action('xmlrpc_publish_post', $post_id);
70 + if ( defined('APP_REQUEST') )
71 + do_action('app_publish_post', $post_id);
72 +
73 + if ( defined('WP_IMPORTING') )
99 74 return;
100 - endif;
101 75
102 76 // Defer sending out pings until we finish updating
103 77 $fwp_held_ping = $post_id;
104 -
78 +
105 79 FeedWordPress::diagnostic(
106 80 'syndicated_posts:do_pings',
107 - "FeedWordPress intercepted a post event, fwp_held_ping=" . json_encode( $fwp_held_ping )
81 + "FeedWordPress intercepted a post event, fwp_held_ping=".json_encode($fwp_held_ping)
108 82 );
109 83 else :
110 - if ( function_exists( '_publish_post_hook' ) ) : // WordPress 2.3
111 - _publish_post_hook( $post_id );
84 + if (function_exists('_publish_post_hook')) : // WordPress 2.3
85 + _publish_post_hook($post_id);
112 86 endif;
113 87 endif;
114 -} /* function fwp_publish_post_hook() */
88 +}