Making WordPress.org


Ignore:
Timestamp:
06/17/2014 12:38:46 AM (11 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()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.