Making WordPress.org

Changeset 5015


Ignore:
Timestamp:
02/28/2017 12:35:50 AM (8 years ago)
Author:
iandunn
Message:

WordPress.tv: Add extra stats and define bump_stats_extras() stub

The stub is cleaner than always adding function_exists() checks when calling the function.

Location:
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php

    r4220 r5015  
    682682        }
    683683
    684         // Make it easier to contribute to this theme by not assuming WP.com context.
    685         if ( function_exists( 'bump_stats_extras' ) ) {
    686             bump_stats_extras( 'wptv-activity', 'publish-video' );
    687         }
     684        bump_stats_extras( 'wptv-activity', 'publish-video' );
    688685    }
    689686}
     
    853850    return $username_exists;
    854851}
     852
     853if ( ! function_exists( 'bump_stats_extras' ) ) {
     854    /**
     855     * Define a stub for `bump_stats_extras()`
     856     *
     857     * This function only exists on WordPress.com, so we need a stub to prevent fatal `undefined function` errors
     858     * in the Meta Environment and other local dev environments.
     859     *
     860     * @param string $name
     861     * @param string $value
     862     * @param int    $num
     863     * @param bool   $today
     864     * @param bool   $hour
     865     */
     866    function bump_stats_extras( $name, $value, $num = 1, $today = false, $hour = false ) {
     867        // This is intentionally empty
     868    }
     869}
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.php

    r1725 r5015  
    5656        // Normal users won't see the honeypot field, so if there's a value in it, then we can assume the submission is spam from a bot
    5757        if ( ! isset( $_POST['wptv_honey'] ) || ! empty( $_POST['wptv_honey'] ) ) {
    58             if ( function_exists( 'bump_stats_extras' ) ) {
    59                 bump_stats_extras( 'wptv-spam', 'honeypot_trapped_anon_upload' );
    60             }
     58            bump_stats_extras( 'wptv-spam', 'honeypot_trapped_anon_upload' );
    6159
    6260            return $this->error( 13 );
     
    160158
    161159    function error( $msg ) {
     160        bump_stats_extras( 'wptv-errors', 'video-upload-failed' );
    162161        $this->errors = $msg;
    163162
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-upload-subtitles/wordpresstv-upload-subtitles.php

    r4221 r5015  
    489489     */
    490490    function error( $message ) {
     491        bump_stats_extras( 'wptv-errors', 'subtitle-upload-failed' );
     492
    491493        wp_safe_redirect( add_query_arg( array(
    492494            'video' => $this->video_id,
     
    500502     */
    501503    function success() {
     504        bump_stats_extras( 'wptv-activity', 'subtitle-uploaded' );
     505
    502506        wp_safe_redirect( add_query_arg( array(
    503507            'video'   => $this->video_id,
Note: See TracChangeset for help on using the changeset viewer.