Making WordPress.org

Changeset 11844


Ignore:
Timestamp:
05/13/2022 04:46:11 PM (4 years ago)
Author:
iandunn
Message:

Profiles: Use API helper to send request.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-profiles-wp-activity-notifier/wporg-profiles-wp-activity-notifier.php

    r11843 r11844  
    77*/
    88
     9use WordPressdotorg\Profiles;
     10
    911class WPOrg_WP_Activity_Notifier {
    10         private $activity_handler_url = 'https://profiles.wordpress.org/wp-admin/admin-ajax.php';
    11 
    1212        /**
    1313         * @var WPOrg_WP_Activity_Notifier The singleton instance.
     
    2929
    3030        private function __construct() {
     31                require_once WPMU_PLUGIN_DIR . '/pub/profile-helpers.php';
     32
    3133                add_action( 'init', array( $this, 'init' ) );
    3234        }
     
    134136
    135137                $args = array(
    136                         'body' => array(
    137                                 'action'   => 'wporg_handle_activity',
    138                                 'source'   => 'wordpress',
    139                                 'user'     => $author->user_login,
    140                                 'post_id'  => $post->ID,
    141                                 'blog'     => get_bloginfo( 'name' ),
    142                                 'blog_url' => site_url(),
    143                                 'title'    => get_the_title( $post ),
    144                                 'content'  => $content,
    145                                 'url'      => get_permalink( $post->ID ),
    146                         ),
     138                        'action'   => 'wporg_handle_activity',
     139                        'source'   => 'wordpress',
     140                        'user'     => $author->user_login,
     141                        'post_id'  => $post->ID,
     142                        'blog'     => get_bloginfo( 'name' ),
     143                        'blog_url' => site_url(),
     144                        'title'    => get_the_title( $post ),
     145                        'content'  => $content,
     146                        'url'      => get_permalink( $post->ID ),
    147147                );
    148148
    149                 wp_remote_post( $this->activity_handler_url, $args );
     149                Profiles\api( $args );
    150150        }
    151151
     
    205205
    206206                $args = array(
    207                         'body' => array(
    208                                 'action'     => 'wporg_handle_activity',
    209                                 'source'     => 'wordpress',
    210                                 'user'       => $user->user_login,
    211                                 'comment_id' => $comment->comment_ID,
    212                                 'content'    => get_comment_excerpt( $comment ),
    213                                 'title'      => get_the_title( $post ),
    214                                 'blog'       => get_bloginfo( 'name' ),
    215                                 'blog_url'   => site_url(),
    216                                 'url'        => get_comment_link( $comment ),
    217                         ),
     207                        'action'     => 'wporg_handle_activity',
     208                        'source'     => 'wordpress',
     209                        'user'       => $user->user_login,
     210                        'comment_id' => $comment->comment_ID,
     211                        'content'    => get_comment_excerpt( $comment ),
     212                        'title'      => get_the_title( $post ),
     213                        'blog'       => get_bloginfo( 'name' ),
     214                        'blog_url'   => site_url(),
     215                        'url'        => get_comment_link( $comment ),
    218216                );
    219217
    220                 wp_remote_post( $this->activity_handler_url, $args );
     218                Profiles\api( $args );
    221219        }
    222220
     
    251249
    252250                $args = array(
    253                         'body' => array(
    254                                 'action'    => 'wporg_handle_activity',
    255                                 'activity'  => $activity,
    256                                 'source'    => 'forum',
    257                                 'user'      => get_user_by( 'id', bbp_get_topic_author_id( $topic_id ) )->user_login,
    258                                 'post_id'   => '',
    259                                 'topic_id'  => $topic_id,
    260                                 'forum_id'  => bbp_get_topic_forum_id( $topic_id ),
    261                                 'title'     => strip_tags( bbp_get_topic_title( $topic_id ) ),
    262                                 'url'       => $url,
    263                                 'message'   => bbp_get_topic_excerpt( $topic_id, 55 ),
    264                                 'site'      => get_bloginfo( 'name' ),
    265                                 'site_url'  => site_url(),
    266                         ),
     251                        'action'    => 'wporg_handle_activity',
     252                        'activity'  => $activity,
     253                        'source'    => 'forum',
     254                        'user'      => get_user_by( 'id', bbp_get_topic_author_id( $topic_id ) )->user_login,
     255                        'post_id'   => '',
     256                        'topic_id'  => $topic_id,
     257                        'forum_id'  => bbp_get_topic_forum_id( $topic_id ),
     258                        'title'     => strip_tags( bbp_get_topic_title( $topic_id ) ),
     259                        'url'       => $url,
     260                        'message'   => bbp_get_topic_excerpt( $topic_id, 55 ),
     261                        'site'      => get_bloginfo( 'name' ),
     262                        'site_url'  => site_url(),
    267263                );
    268264
    269                 wp_remote_post( $this->activity_handler_url, $args );
     265                Profiles\api( $args );
    270266        }
    271267
     
    318314
    319315                $args = array(
    320                         'body' => array(
    321                                 'action'    => 'wporg_handle_activity',
    322                                 'activity'  => $activity,
    323                                 'source'    => 'forum',
    324                                 'user'      => get_user_by( 'id', bbp_get_reply_author_id( $reply_id ) )->user_login,
    325                                 'post_id'   => $reply_id,
    326                                 'topic_id'  => bbp_get_reply_topic_id( $reply_id ),
    327                                 'forum_id'  => bbp_get_reply_forum_id( $reply_id ),
    328                                 'title'     => strip_tags( bbp_get_reply_topic_title( $reply_id ) ),
    329                                 'url'       => $url,
    330                                 'message'   => $this->get_reply_excerpt( $reply_id, 15 ),
    331                                 'site'      => get_bloginfo( 'name' ),
    332                                 'site_url'  => site_url(),
    333                         ),
     316                        'action'    => 'wporg_handle_activity',
     317                        'activity'  => $activity,
     318                        'source'    => 'forum',
     319                        'user'      => get_user_by( 'id', bbp_get_reply_author_id( $reply_id ) )->user_login,
     320                        'post_id'   => $reply_id,
     321                        'topic_id'  => bbp_get_reply_topic_id( $reply_id ),
     322                        'forum_id'  => bbp_get_reply_forum_id( $reply_id ),
     323                        'title'     => strip_tags( bbp_get_reply_topic_title( $reply_id ) ),
     324                        'url'       => $url,
     325                        'message'   => $this->get_reply_excerpt( $reply_id, 15 ),
     326                        'site'      => get_bloginfo( 'name' ),
     327                        'site_url'  => site_url(),
    334328                );
    335329
    336                 wp_remote_post( $this->activity_handler_url, $args );
     330                Profiles\api( $args );
    337331        }
    338332
Note: See TracChangeset for help on using the changeset viewer.