Make WordPress Core

Ticket #7773: TakeTwo.diff

File TakeTwo.diff, 1.8 KB (added by redsweater, 14 years ago)

Revision of the initial patch.

  • xmlrpc.php

     
    22312231                }
    22322232
    22332233                // Handle enclosures
    2234                 $enclosure = $content_struct['enclosure'];
    2235                 if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
    2236                         add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
    2237                 }
     2234                $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']);
    22382235
    22392236                $this->attach_uploads( $post_ID, $post_content );
    22402237
     
    22432240                return strval($post_ID);
    22442241        }
    22452242
     2243        function add_enclosure_if_new($post_ID, $enclosure) {
     2244                if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
     2245               
     2246                        $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
     2247                        $found = false;
     2248                        foreach ( (array) get_post_custom($post_ID) as $key => $val) {
     2249                                if ($key == 'enclosure') {
     2250                                        foreach ( (array) $val as $enc ) {
     2251                                                if ($enc == $encstring) {
     2252                                                        $found = true;
     2253                                                        break 2;
     2254                                                }
     2255                                        }
     2256                                }
     2257                        }
     2258                        if (!$found) {
     2259                                add_post_meta( $post_ID, 'enclosure', $encstring );
     2260                        }
     2261                }
     2262        }
     2263       
    22462264        /**
    22472265         * Attach upload to a post.
    22482266         *
     
    25212539                }
    25222540
    25232541                // Handle enclosures
    2524                 $enclosure = $content_struct['enclosure'];
    2525                 if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
    2526                         add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
    2527                 }
     2542                $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']);
    25282543
    25292544                $this->attach_uploads( $ID, $post_content );
    25302545