WordPress.org

Make WordPress Core

Changeset 28743


Ignore:
Timestamp:
06/11/14 19:30:26 (4 years ago)
Author:
wonderboymusic
Message:

OPML:

  • Learn how OPML works, cry.
  • Remove unused globals in startElement()
  • Stop using variable variables in startElement()

Tested with the OPML importer plugin

See #27881.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/link-parse-opml.php

    r27262 r28743  
    1414// columns we wish to find are: link_url, link_name, link_target, link_description 
    1515// we need to map XML attribute names to our columns 
    16 $opml_map = array('URL'         => 'link_url', 
     16$opml_map = array( 
     17    'URL'         => 'link_url', 
    1718    'HTMLURL'     => 'link_url', 
    1819    'TEXT'        => 'link_name', 
     
    4546 */ 
    4647function startElement($parser, $tagName, $attrs) { 
    47     global $updated_timestamp, $all_links, $map; 
    4848    global $names, $urls, $targets, $descriptions, $feeds; 
    4949 
    50     if ($tagName == 'OUTLINE') { 
    51         foreach (array_keys($map) as $key) { 
    52             if (isset($attrs[$key])) { 
    53                 $$map[$key] = $attrs[$key]; 
    54             } 
     50    if ( 'OUTLINE' === $tagName ) { 
     51        $name = ''; 
     52        if ( isset( $attrs['TEXT'] ) ) { 
     53            $name = $attrs['TEXT']; 
    5554        } 
    56  
    57         //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n"); 
    58  
     55        if ( isset( $attrs['TITLE'] ) ) { 
     56            $name = $attrs['TITLE']; 
     57        } 
     58        $url = ''; 
     59        if ( isset( $attrs['URL'] ) ) { 
     60            $url = $attrs['URL']; 
     61        } 
     62        if ( isset( $attrs['HTMLURL'] ) ) { 
     63            $url = $attrs['HTMLURL']; 
     64        } 
    5965        // save the data away. 
    60         $names[] = $link_name; 
    61         $urls[] = $link_url; 
    62         $targets[] = $link_target; 
    63         $feeds[] = $link_rss; 
    64         $descriptions[] = $link_description; 
     66        $names[] = $name; 
     67        $urls[] = $url; 
     68        $targets[] = isset( $attrs['TARGET'] ) ? $attrs['TARGET'] :  ''; 
     69        $feeds[] = isset( $attrs['XMLURL'] ) ? $attrs['XMLURL'] :  ''; 
     70        $descriptions[] = isset( $attrs['DESCRIPTION'] ) ? $attrs['DESCRIPTION'] :  ''; 
    6571    } // end if outline 
    6672} 
Note: See TracChangeset for help on using the changeset viewer.