Making WordPress.org

Changeset 707


Ignore:
Timestamp:
06/17/2014 12:38:46 AM (12 years ago)
Author:
coffee2code
Message:

Handbook plugin: prevent pre-existing PHP warnings

  • Explicitly declare array values before use (and check value before use in str_replace())
  • Explicitly declare statically referenced methods as static
  • Add instance arg to widgets()
Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/email-post-changes.php

    r705 r707  
    77class WPorg_Handbook_Email_Post_Changes {
    88
    9         function init() {
     9        public static function init() {
    1010                add_action( 'widgets_init', array( __CLASS__, 'handbook_sidebar' ), 11 ); // After P2
    1111                add_filter( 'email_post_changes_emails', array( __CLASS__, 'email_post_changes_emails' ), 10, 3 );
     
    1414        }
    1515
    16         function handbook_sidebar() {
    17 
     16        public static function handbook_sidebar() {
    1817                require_once dirname( __FILE__ ) . '/widgets.php';
    1918                register_widget( 'WPorg_Handbook_Widget' );
    2019        }
    2120
    22         function option_email_post_changes( $values ) {
     21        public static function option_email_post_changes( $values ) {
    2322                $values['post_types'] = apply_filters( 'wporg_email_changes_for_post_types', $values['post_types'] );
    2423                return $values;
    2524        }
    2625
    27         function email_post_changes_emails( $emails, $post_before, $post_after ) {
     26        public static function email_post_changes_emails( $emails, $post_before, $post_after ) {
    2827                $post = get_post( $post_after );
    2928                $users = get_post_meta( $post->ID, '_wporg_watchlist', true );
     
    3837        }
    3938
    40         function update_watchlist() {
     39        public static function update_watchlist() {
    4140                $post_id = absint( $_GET['post_id'] );
    4241                if ( ! $post_id || ! $post = get_post( $post_id ) ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

    r706 r707  
    7373                $items = $this->get_tags( $tag, $content );
    7474                $first = true;
     75                $matches = array();
     76                $replacements = array();
    7577
    76                 foreach ($items as $item) {
     78                foreach ( $items as $item ) {
    7779                        $replacement = '';
    7880                        $matches[] = $item[0];
     
    8991                }
    9092
    91                 $content = str_replace( $matches, $replacements, $content );
     93                if ( $replacements ) {
     94                        $content = str_replace( $matches, $replacements, $content );
     95                }
    9296
    9397                return $content;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/widgets.php

    r706 r707  
    1111        }
    1212
    13         function widget( $args ) {
     13        function widget( $args, $instance ) {
    1414                if ( ! is_user_logged_in() )
    1515                        return;
Note: See TracChangeset for help on using the changeset viewer.