WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (3 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-links-opml.php

    r42201 r42343  
    1515require_once( dirname( __FILE__ ) . '/wp-load.php' );
    1616
    17 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
     17header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
    1818$link_cat = '';
    19 if ( !empty($_GET['link_cat']) ) {
     19if ( ! empty( $_GET['link_cat'] ) ) {
    2020    $link_cat = $_GET['link_cat'];
    21     if ( !in_array($link_cat, array('all', '0')) )
    22         $link_cat = absint( (string)urldecode($link_cat) );
     21    if ( ! in_array( $link_cat, array( 'all', '0' ) ) ) {
     22        $link_cat = absint( (string) urldecode( $link_cat ) );
     23    }
    2324}
    2425
    25 echo '<?xml version="1.0"?'.">\n";
     26echo '<?xml version="1.0"?' . ">\n";
    2627?>
    2728<opml version="1.0">
    2829    <head>
    29         <title><?php
     30        <title>
     31        <?php
    3032            /* translators: 1: Site name */
    31             printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) );
    32         ?></title>
    33         <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
     33            printf( __( 'Links for %s' ), esc_attr( get_bloginfo( 'name', 'display' ) ) );
     34        ?>
     35        </title>
     36        <dateCreated><?php echo gmdate( 'D, d M Y H:i:s' ); ?> GMT</dateCreated>
    3437        <?php
    3538        /**
     
    4346    <body>
    4447<?php
    45 if ( empty($link_cat) )
    46     $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0));
    47 else
    48     $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0, 'include' => $link_cat));
     48if ( empty( $link_cat ) ) {
     49    $cats = get_categories(
     50        array(
     51            'taxonomy'     => 'link_category',
     52            'hierarchical' => 0,
     53        )
     54    );
     55} else {
     56    $cats = get_categories(
     57        array(
     58            'taxonomy'     => 'link_category',
     59            'hierarchical' => 0,
     60            'include'      => $link_cat,
     61        )
     62    );
     63}
    4964
    50 foreach ( (array)$cats as $cat ) :
     65foreach ( (array) $cats as $cat ) :
    5166    /**
    5267     * Filters the OPML outline link category name.
     
    5974
    6075?>
    61 <outline type="category" title="<?php echo esc_attr($catname); ?>">
     76<outline type="category" title="<?php echo esc_attr( $catname ); ?>">
    6277<?php
    63     $bookmarks = get_bookmarks(array("category" => $cat->term_id));
    64     foreach ( (array)$bookmarks as $bookmark ) :
    65         /**
    66         * Filters the OPML outline link title text.
    67         *
    68         * @since 2.2.0
    69         *
    70         * @param string $title The OPML outline title text.
    71         */
    72         $title = apply_filters( 'link_title', $bookmark->link_name );
     78    $bookmarks = get_bookmarks( array( 'category' => $cat->term_id ) );
     79foreach ( (array) $bookmarks as $bookmark ) :
     80    /**
     81    * Filters the OPML outline link title text.
     82    *
     83    * @since 2.2.0
     84    *
     85    * @param string $title The OPML outline title text.
     86    */
     87    $title = apply_filters( 'link_title', $bookmark->link_name );
    7388?>
    74     <outline text="<?php echo esc_attr($title); ?>" type="link" xmlUrl="<?php echo esc_attr($bookmark->link_rss); ?>" htmlUrl="<?php echo esc_attr($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
     89<outline text="<?php echo esc_attr( $title ); ?>" type="link" xmlUrl="<?php echo esc_attr( $bookmark->link_rss ); ?>" htmlUrl="<?php echo esc_attr( $bookmark->link_url ); ?>" updated="
     90                            <?php
     91                            if ( '0000-00-00 00:00:00' != $bookmark->link_updated ) {
     92                                echo $bookmark->link_updated;}
     93?>
     94" />
    7595<?php
    7696    endforeach; // $bookmarks
Note: See TracChangeset for help on using the changeset viewer.