WordPress.org

Make WordPress Core

Ticket #2552: 2552-debug.diff

File 2552-debug.diff, 6.8 KB (added by mdawaffe, 7 years ago)

ghetto debugging

  • wp-admin/list-manipulation.php

     
    6565                die('1'); 
    6666        else    die('0'); 
    6767        break; 
     68case 'dim-comment' : 
     69        if ( !$comment = get_comment( $id ) ) 
     70                die('0'); 
     71        if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 
     72                die('-1'); 
     73        if ( !current_user_can( 'moderate_comments' ) ) 
     74                die('-1'); 
     75 
     76        if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { 
     77                if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 
     78                        die('1'); 
     79        } else { 
     80                if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 
     81                        die('1'); 
     82        } 
     83        die('0'); 
     84        break; 
    6885endswitch; 
    6986?> 
  • wp-admin/wp-admin.css

     
    326326        color: #009ef0; 
    327327} 
    328328 
     329.approve { 
     330        display: none; 
     331} 
     332 
     333.unapproved .approve { 
     334        display: inline; 
     335} 
     336 
     337.unapproved .unapprove { 
     338        display: none; 
     339} 
     340 
    329341.updated { 
    330342        background: #CFEBF7 url(images/notice.gif) no-repeat 1em ; 
    331343        border: 1px solid #2580B2; 
     
    951963#jaxcat { 
    952964        margin: 0; 
    953965        padding: 0; 
    954 } 
    955  No newline at end of file 
     966} 
  • wp-admin/edit.php

     
    114114<br style="clear:both;" /> 
    115115 
    116116<?php 
    117  
    118117// define the columns to display, the syntax is 'internal name' => 'display name' 
    119118$posts_columns = array( 
    120119  'id'         => __('ID'), 
     
    246245        if ($comments) { 
    247246        ?>  
    248247<h3><?php _e('Comments') ?></h3>  
    249 <ol id="comments">  
     248<ol id="the-list">  
    250249<?php 
     250$i = 0; 
    251251foreach ($comments as $comment) { 
    252 $comment_status = wp_get_comment_status($comment->comment_ID); 
     252$class = ( ++$i % 2 ) ? array('alternate') : array(); 
     253if ( 'unapproved' == $comment_status = wp_get_comment_status($comment->comment_ID) ) 
     254        $class[] = 'unapproved'; 
    253255?>  
    254256 
    255 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> > 
     257<li id='comment-<?php echo $comment->comment_ID; ?>'<?php if ( $class ) echo " class='" . join(' ', $class) . "'"; ?>> 
    256258  <?php comment_date('Y-n-j') ?>  
    257259  @ 
    258260  <?php comment_time('g:m:s a') ?>  
    259261  <?php  
    260262                        if ( current_user_can('edit_post', $post->ID) ) { 
    261                                 echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" .  __('Edit') . "</a>"; 
    262                                 echo " - <a href=\"post.php?action=deletecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> "; 
     263                                echo "[ <a href='post.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" .  __('Edit') . '</a>'; 
     264                                echo ' - <a href="post.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete') . '</a> '; 
    263265                                if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 
    264                                         if ('approved' == wp_get_comment_status($comment->comment_ID)) { 
    265                                                 echo " - <a href=\"post.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> "; 
    266                                         } else { 
    267                                                 echo " - <a href=\"post.php?action=approvecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Approve') . "</a> "; 
    268                                         } 
     266                                        echo '<span class="unapprove"> - <a href="comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ' );">' . __('Unapprove') . '</a> </span>'; 
     267                                        echo '<span class="approve"> - <a href="comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ' );">' . __('Approve') . '</a> </span>'; 
    269268                                } 
    270269                                echo "]"; 
    271270                        } // end if any comments to show 
  • wp-admin/list-manipulation.js

     
    1414        } 
    1515} 
    1616 
     17function dimSomething( what, id ) { 
     18        return ajaxDelete( 'dim-' + what, id ); 
     19}        
     20 
    1721function getResponseElement() { 
    1822        var p = document.getElementById('ajax-response-p'); 
    1923        if (!p) { 
     
    3337        ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; }; 
    3438        ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; }; 
    3539        ajaxDel.onCompletion = function() { removeThisItem( what.replace('-as-spam', '') + '-' + id ); }; 
    36         ajaxDel.runAJAX('action=delete-' + what + '&id=' + id); 
     40        ajaxAction = what.match('dim-') ? '' : 'delete-'; 
     41        ajaxDel.runAJAX('action=' +ajaxAction + what + '&id=' + id); 
    3742        return false; 
    3843} 
    3944 
    4045function removeThisItem(id) { 
     46alert('removeThisItem'); 
     47        dimming = false; 
     48        if ( id.match('dim-') ) { dimming = true; id = id.replace('dim-', ''); } 
     49alert('dimming: ' + dimming); 
    4150        var response = ajaxDel.response; 
    4251        if ( isNaN(response) ) { alert(response); } 
    4352        response = parseInt(response, 10); 
     53alert('response: ' + response); 
    4454        if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; } 
    4555        else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened.  Try refreshing the page? Either that or what you tried to delete never existed in the first place."; } 
    4656        else if ( 1 == response ) { 
    4757                theItem = document.getElementById(id); 
    48                 Fat.fade_element(id,null,700,'#FF3333'); 
    49                 setTimeout('theItem.parentNode.removeChild(theItem)', 705); 
    50                 var pos = getListPos(id); 
    51                 listItems.splice(pos,1); 
    52                 recolorList(pos); 
     58alert('theItem'); 
     59                if ( dimming ) { 
     60alert(theItem.className); 
     61                        if ( theItem.className.match('unapproved') ) { 
     62                                Fat.fade_element(id,null,700,null); 
     63alert('fade'); 
     64                                theItem.className = theItem.className.replace('unapproved', ''); 
     65                        } else { 
     66                                Fat.fade_element(id,null,700,'#FF3333'); 
     67alert('fade'); 
     68                                theItem.className = theItem.className + ' unapproved'; 
     69                        } 
     70                } else { 
     71                        Fat.fade_element(id,null,700,'#FF3333'); 
     72                        setTimeout('theItem.parentNode.removeChild(theItem)', 705); 
     73                        var pos = getListPos(id); 
     74                        listItems.splice(pos,1); 
     75                        recolorList(pos); 
     76                } 
     77alert(theItem.className); 
    5378                ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement); 
    54  
     79alert('del0rted'); 
    5580        } 
    5681} 
    5782