WordPress.org

Make WordPress Core

Ticket #1870: pingless.diff

File pingless.diff, 8.9 KB (added by skeltoac, 13 years ago)

Finally, a diff I can upload ;)

  • wp-includes/comment-functions.php

     
    622622        // We don't wanna ping first and second types, even if they have a valid <link/>
    623623
    624624        foreach($post_links_temp[0] as $link_test) :
    625                 if ( !in_array($link_test, $pung) && url_to_postid($link_test) != $post_ID) : // If we haven't pung it already and it isn't a link to itself
     625                if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
     626                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    626627                        $test = parse_url($link_test);
    627628                        if (isset($test['query']))
    628629                                $post_links[] = $link_test;
     
    753754        return false;
    754755}
    755756
     757function is_local_attachment($url) {
     758        if ( !strstr($url, get_bloginfo('home') ) )
     759                return false;
     760        if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') )
     761                return true;
     762        if ( $id = url_to_postid($url) ) {
     763                $post = & get_post($id);
     764                if ( 'attachment' == $post->post_status )
     765                        return true;
     766        }               
     767        return false;
     768}
    756769
    757770function wp_set_comment_status($comment_id, $comment_status) {
    758771    global $wpdb;
     
    788801    }
    789802}
    790803
    791 
    792804function wp_get_comment_status($comment_id) {
    793805        global $wpdb;
    794806       
  • wp-admin/inline-uploading.php

     
    7777$imagedata['file'] = $file;
    7878$imagedata['thumb'] = "thumb-$filename";
    7979
    80 add_post_meta($id, 'imagedata', $imagedata);
     80add_post_meta($id, '_wp_attachment_metadata', $imagedata);
    8181
    8282if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    8383        if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
     
    135135        $back = false;
    136136}
    137137
    138 $i = 0;
    139138$uwidth_sum = 0;
    140139$images_html = '';
    141140$images_style = '';
     
    154153        $images_script .= "attachmenton = '$__attachment_on';\nattachmentoff = '$__attachment_off';\n";
    155154        $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n";
    156155        foreach ( $images as $key => $image ) {
    157                 $meta = get_post_meta($image['ID'], 'imagedata', true);
     156                $attachment_ID = $image['ID'];
     157                $meta = get_post_meta($attachment_ID, '_wp_attachment_metadata', true);
    158158                if (!is_array($meta)) {
    159                         wp_delete_attachment($image['ID']);
    160                         continue;
     159                        $meta = get_post_meta($attachment_ID, 'imagedata', true); // Try 1.6 Alpha meta key
     160                        if (!is_array($meta)) {
     161                                continue;
     162                        } else {
     163                                add_post_meta($attachment_ID, '_wp_attachment_metadata', $meta);
     164                        }
    161165                }
    162166                $image = array_merge($image, $meta);
    163167                if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
    164168                        $src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb'];
    165                         $images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n";
     169                        $images_script .= "src".$attachment_ID."a = '$src';\nsrc".$attachment_ID."b = '".$image['guid']."';\n";
    166170                        $thumb = 'true';
    167171                        $thumbtext = $__thumbnail_on;
    168172                } else {
     
    175179                $uwidth_sum += 128;
    176180                $xpadding = (128 - $image['uwidth']) / 2;
    177181                $ypadding = (96 - $image['uheight']) / 2;
    178                 $attachment = $image['ID'];
    179                 $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
    180                 $href = get_attachment_link($attachment);
    181                 $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n";
     182                $images_style .= "#target{$attachment_ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
     183                $href = get_attachment_link($attachment_ID);
     184                $images_script .= "href{$attachment_ID}a = '$href';\nhref{$attachment_ID}b = '{$image['guid']}';\n";
    182185                $images_html .= "
    183 <div id='target$i' class='imagewrap left'>
    184         <div id='popup$i' class='popup'>
    185                 <a id=\"L$i\" onclick=\"toggleLink($i);return false;\" href=\"javascript:void();\">$__attachment_on</a>
    186                 <a id=\"I$i\" onclick=\"if($thumb)toggleImage($i);else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
    187                 <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment=$attachment&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
     186<div id='target{$attachment_ID}' class='imagewrap left'>
     187        <div id='popup{$attachment_ID}' class='popup'>
     188                <a id=\"L{$attachment_ID}\" onclick=\"toggleLink({$attachment_ID});return false;\" href=\"javascript:void();\">$__attachment_on</a>
     189                <a id=\"I{$attachment_ID}\" onclick=\"if($thumb)toggleImage({$attachment_ID});else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
     190                <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$attachment_ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
    188191                <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    189192        </div>
    190         <a id=\"link$i\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup($i);return false;\" title=\"{$image['post_title']}\">         
    191                 <img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
     193        <a id=\"{$attachment_ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup({$attachment_ID});return false;\" title=\"{$image['post_title']}\">               
     194                <img id=\"image{$attachment_ID}\" src=\"$src\" alt=\"{$attachment_ID}\" $height_width />
    192195        </a>
    193196</div>
    194197";
    195                 $i++;
    196198        }
    197199}
    198200
     
    242244popup = false;
    243245}
    244246function toggleLink(n) {
    245         o=document.getElementById('link'+n);
     247        o=document.getElementById(n);
    246248        oi=document.getElementById('L'+n);
    247249        if ( oi.innerHTML == attachmenton ) {
    248250                o.href = eval('href'+n+'b');
  • wp-admin/admin-functions.php

     
    6363        if ( $_POST['temp_ID'] )
    6464                relocate_children($_POST['temp_ID'], $post_ID);
    6565
     66        // Now that we have an ID we can fix the attachment anchor hrefs
     67        fix_attachment_links($post_ID);
     68
    6669        return $post_ID;
    6770}
    6871
     
    7477        return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
    7578}
    7679
     80// Replace hrefs of attachment anchors with up-to-date permalinks.
     81function fix_attachment_links($post_ID) {
     82        global $wp_rewrite;
     83
     84        // Relevance check.
     85        if ( false == $wp_rewrite->using_permalinks() )
     86                return;
     87
     88        $post = & get_post($post_ID);
     89
     90        $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
     91
     92        // See if we have any rel="attachment" links
     93        if ( 0 == preg_match_all($search, $post->post_content, $anchor_matches, PREG_PATTERN_ORDER) )
     94                return;
     95
     96        $i = 0;
     97        $search = "# id=(\"|)(\d+)\\1#i";
     98        foreach ( $anchor_matches[0] as $anchor ) {
     99                echo "$search\n$anchor\n";
     100                if ( 0 == preg_match($search, $anchor, $id_matches) )
     101                        continue;
     102
     103                $id = $id_matches[2];
     104                $post_search[$i] = $anchor;
     105                $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
     106                ++$i;
     107        }
     108
     109        $post->post_content = str_replace($post_search, $post_replace, $post->post_content);
     110
     111        return wp_update_post($post);
     112}
     113
    77114// Update an existing post with values provided in $_POST.
    78115function edit_post() {
    79116        global $user_ID;
     
    17951832        return array('file' => $file, 'id' => $id);
    17961833}
    17971834
    1798 ?>
    1799  No newline at end of file
     1835?>
  • wp-admin/admin-header.php

     
    105105        convert_newlines_to_brs : false,
    106106        remove_linebreaks : true,
    107107        save_callback : "wp_save_callback",
    108         valid_elements : "-a[href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],address,-h1[class|align],-h2[class|align],-h3[class|align],-h4[class|align],-h5[class|align],-h6[class|align],hr",
     108        valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],address,-h1[class|align],-h2[class|align],-h3[class|align],-h4[class|align],-h5[class|align],-h6[class|align],hr",
    109109        plugins : "wordpress,autosave"
    110110        <?php do_action('mce_options'); ?>
    111111});