<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2328] 2013/ahoereth/trunk: Huge clean up.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2328">2328</a></dd>
<dt>Author</dt> <dd>a.hoereth</dd>
<dt>Date</dt> <dd>2013-09-16 16:41:47 +0000 (Mon, 16 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Huge clean up. 1.0 upcoming. See <a href="http://gsoc.trac.wordpress.org/ticket/325">#325</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013ahoerethtrunkcoderevisionsphp">2013/ahoereth/trunk/code-revisions.php</a></li>
<li><a href="#2013ahoerethtrunkincclasscoderevisionseditorsphp">2013/ahoereth/trunk/inc/class-code-revisions-editors.php</a></li>
<li><a href="#2013ahoerethtrunkincclasscoderevisionsphp">2013/ahoereth/trunk/inc/class-code-revisions.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#2013ahoerethtrunkcsseditorsmincss">2013/ahoereth/trunk/css/editors.min.css</a></li>
<li><a href="#2013ahoerethtrunkcssviewermincss">2013/ahoereth/trunk/css/viewer.min.css</a></li>
<li><a href="#2013ahoerethtrunkjseditorsminjs">2013/ahoereth/trunk/js/editors.min.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013ahoerethtrunkcoderevisionsphp"></a>
<div class="modfile"><h4>Modified: 2013/ahoereth/trunk/code-revisions.php (2327 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/code-revisions.php   2013-09-16 16:30:44 UTC (rev 2327)
+++ 2013/ahoereth/trunk/code-revisions.php      2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -35,12 +35,11 @@
</span><span class="cx"> if ( !defined( 'CODE_REVISIONS_POST_TYPE' ) )
</span><span class="cx">  define( 'CODE_REVISIONS_POST_TYPE', 'code' );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> /*
</span><del>- * Initialize the main class - required on all pages. It registers the custom
- * post type etc.
</del><ins>+ * Initialize the main class and register the uninstall hook.
</ins><span class="cx">  */
</span><span class="cx"> include_once( CODE_REVISIONS_DIR . 'inc/class-code-revisions.php' );
</span><ins>+register_uninstall_hook( __FILE__, array( 'Code_Revisions', 'uninstall' ) );
</ins><span class="cx"> new Code_Revisions;
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -57,24 +56,6 @@
</span><span class="cx"> add_action( 'load-theme-editor.php',  'code_revisions_editors' );
</span><span class="cx"> 
</span><span class="cx"> /*
</span><del>- * Include file containing function for overwriting pluggable WP core function
- * wp_text_diff().
</del><ins>+ * Including file which overwrites pluggable WP Core functions like wp_text_diff().
</ins><span class="cx">  */
</span><span class="cx"> include_once( 'inc/plugged.php' );
</span><del>-
-/**
- * Delete code revision posts and post meta fields on plugin uninstall.
- *
- * @since 0.8
- */
-function code_revisions_uninstall() {
-       if ( ! current_user_can( 'delete_plugins' ) )
-               return;
-
-       $metakey = '_' . str_replace( '-', '_', CODE_REVISIONS_NAME );
-
-       $posts = get_posts( 'numberposts=-1&post_type=' . CODE_REVISIONS_POST_TYPE . '&post_status=any' );
-       foreach( $posts as $post )
-               wp_delete_post( $post->ID );
-}
-register_uninstall_hook( __FILE__, 'code_revisions_uninstall' );
</del></span></pre></div>
<a id="2013ahoerethtrunkcsseditorsmincss"></a>
<div class="addfile"><h4>Added: 2013/ahoereth/trunk/css/editors.min.css (0 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/css/editors.min.css                          (rev 0)
+++ 2013/ahoereth/trunk/css/editors.min.css     2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+.metabox-holder .postbox{width:97%}#revisionsdiv .hndle{cursor:default}#revisionsdiv .handlediv{width:auto;margin-right:10px;background:0;line-height:27px}#revisionsdiv .handlediv input{margin-left:5px;margin-top:2px}#revisionsdiv .inside{margin-right:0}.revisions_link{margin-left:5px}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="2013ahoerethtrunkcssviewermincss"></a>
<div class="addfile"><h4>Added: 2013/ahoereth/trunk/css/viewer.min.css (0 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/css/viewer.min.css                           (rev 0)
+++ 2013/ahoereth/trunk/css/viewer.min.css      2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+table.diff td{padding:0}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="2013ahoerethtrunkincclasscoderevisionseditorsphp"></a>
<div class="modfile"><h4>Modified: 2013/ahoereth/trunk/inc/class-code-revisions-editors.php (2327 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/inc/class-code-revisions-editors.php 2013-09-16 16:30:44 UTC (rev 2327)
+++ 2013/ahoereth/trunk/inc/class-code-revisions-editors.php    2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -82,8 +82,7 @@
</span><span class="cx">   * @param string $pagenow current admin page
</span><span class="cx">   */
</span><span class="cx">  function scripts( $pagenow ) {
</span><del>-               //$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
-               $suffix = '';
</del><ins>+                $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
</ins><span class="cx"> 
</span><span class="cx">          wp_register_style( 'code_revisions_editors', CODE_REVISIONS_URL . "css/editors$suffix.css", array(), CODE_REVISIONS_VER );
</span><span class="cx">          wp_enqueue_style(  'code_revisions_editors' );
</span><span class="lines">@@ -418,4 +417,5 @@
</span><span class="cx">          include_once( CODE_REVISIONS_DIR . 'inc/metabox.php' );
</span><span class="cx">          return ob_get_clean();
</span><span class="cx">  }
</span><ins>+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="2013ahoerethtrunkincclasscoderevisionsphp"></a>
<div class="modfile"><h4>Modified: 2013/ahoereth/trunk/inc/class-code-revisions.php (2327 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/inc/class-code-revisions.php 2013-09-16 16:30:44 UTC (rev 2327)
+++ 2013/ahoereth/trunk/inc/class-code-revisions.php    2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -28,18 +28,44 @@
</span><span class="cx">   * @since 0.1
</span><span class="cx">   */
</span><span class="cx">  public function __construct() {
</span><del>-               add_action( 'init',                     array( $this, 'post_type' )        );
-               add_action( 'load-post.php',            array( $this, 'redirect'  )        );
-               add_action( 'wp_restore_post_revision', array( $this, 'restore'   ), 10, 2 );
-               add_action( 'admin_enqueue_scripts',    array( $this, 'styles'    )        );
-               add_filter( 'parent_file',              array( $this, 'parentage' )        );
</del><ins>+                add_action( 'init',                     array( $this, 'post_type'        ) );
+               add_filter( 'parent_file',              array( $this, 'parentage'        ) );
+               add_action( 'admin_enqueue_scripts',    array( $this, 'styles'           ) );
+               add_action( 'load-post.php',            array( $this, 'redirect'         ) );
+               add_action( 'load-themes.php',          array( $this, 'uninstall_theme'  ) );
</ins><span class="cx">           add_action( 'load-plugins.php',         array( $this, 'uninstall_plugin' ) );
</span><del>-               add_action( 'load-themes.php',          array( $this, 'uninstall_theme'  ) );
</del><ins>+                add_action( 'wp_restore_post_revision', array( $this, 'restore' ), 10, 2   );
</ins><span class="cx"> 
</span><span class="cx">          $this->metakey = '_' . str_replace( '-', '_', CODE_REVISIONS_NAME );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><ins>+        * Register the custom post type for saving file contents
+        * as posts for revision capabilities.
+        *
+        * @since 0.1
+        * @uses register_post_type
+        */
+       public function post_type() {
+               register_post_type( CODE_REVISIONS_POST_TYPE,   array(
+                       'labels' => array(
+                               'name'          => __( 'Editor Files', 'code-revisions' ),
+                               'singular_name' => __( 'Editor File',  'code-revisions' ),
+                       ),
+                       'public'       => false,
+                       'rewrite'      => false,
+                       'query_var'    => false,
+                       'can_export'   => false,
+                       'supports'     => array(
+                               'title',
+                               'editor',
+                               'author',
+                               'revisions'
+                       ),
+               ) );
+       }
+
+       /**
</ins><span class="cx">    * Filter $parent_file and change $submenu_file to expand and highlight the
</span><span class="cx">   * correct submenu when viewing code revisions in the revision viewer.
</span><span class="cx">   *
</span><span class="lines">@@ -70,7 +96,9 @@
</span><span class="cx">          if ( ! $this->id = $this->viewing_code_revision() )
</span><span class="cx">                  return;
</span><span class="cx"> 
</span><del>-               wp_register_style( 'code_revisions_viewer', CODE_REVISIONS_URL . "css/viewer.css", array(), CODE_REVISIONS_VER );
</del><ins>+                $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
+
+               wp_register_style( 'code_revisions_viewer', CODE_REVISIONS_URL . "css/viewer$suffix.css", array(), CODE_REVISIONS_VER );
</ins><span class="cx">           wp_enqueue_style(  'code_revisions_viewer' );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -103,30 +131,26 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Register the custom post type for saving file contents
-        * as posts for revision capabilities.
</del><ins>+         * Redirect from post editor to file editor.
</ins><span class="cx">    *
</span><del>-        * @since 0.1
-        * @uses register_post_type
</del><ins>+         * @since 0.2
+        * @uses wp_redirect
</ins><span class="cx">    */
</span><del>-       public function post_type() {
-               register_post_type( CODE_REVISIONS_POST_TYPE,   array(
-                       'labels' => array(
-                               'name'          => __( 'Editor Files', 'code-revisions' ),
-                               'singular_name' => __( 'Editor File',  'code-revisions' ),
-                       ),
-                       'public'       => false,
-                       'rewrite'      => false,
-                       'query_var'    => false,
-                       'can_export'   => false, // true?
-                       // 'capabilities' => ?,  // specification required?
-                       'supports'     => array(
-                               'title',
-                               'editor',
-                               'author',
-                               'revisions'
-                       ),
-               ));
</del><ins>+        public function redirect() {
+               if ( ! isset( $_REQUEST['post'] ) || ! is_numeric( $_REQUEST['post'] ) )
+                       return;
+
+               // get post data
+               $post = get_post( $_REQUEST['post'] );
+
+               // check post type
+               if ( $post->post_type != CODE_REVISIONS_POST_TYPE )
+                       return;
+
+               // It's a file, not a post! Redirect to corresponding code editor.
+               extract( get_post_meta( $post->ID, $this->metakey, true ) );
+               wp_redirect( admin_url( "$type-editor.php?$type=".urlencode($package)."&file=".urlencode($file) ) );
+               exit;
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="lines">@@ -194,29 +218,6 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Redirect from post editor to file editor.
-        *
-        * @since 0.2
-        * @uses wp_redirect
-        */
-       public function redirect() {
-               if ( ! isset( $_REQUEST['post'] ) || ! is_numeric( $_REQUEST['post'] ) )
-                       return;
-
-               // get post data
-               $post = get_post( $_REQUEST['post'] );
-
-               // check post type
-               if ( $post->post_type != CODE_REVISIONS_POST_TYPE )
-                       return;
-
-               // It's a file, not a post! Redirect to corresponding code editor.
-               extract( get_post_meta( $post->ID, $this->metakey, true ) );
-               wp_redirect( admin_url( "$type-editor.php?$type=".urlencode($package)."&file=".urlencode($file) ) );
-               exit;
-       }
-
-       /**
</del><span class="cx">    * Hooks into the theme uninstall process and removes related code revision posts.
</span><span class="cx">   *
</span><span class="cx">   * @since 1.0
</span><span class="lines">@@ -259,20 +260,39 @@
</span><span class="cx">   * @param array $packages package name strings (either theme stylesheet or 'plugin/plugin.php')
</span><span class="cx">   */
</span><span class="cx">  private function uninstall_packages( $packages ) {
</span><del>-               $query = new WP_Query( array(
-                       "meta_key"    => $this->metakey,
-                       "post_type"   => CODE_REVISIONS_POST_TYPE,
-                       "numberposts" => -1
</del><ins>+                $posts = get_posts( array(
+                       'numberposts' => -1,
+                       'post_type'   => CODE_REVISIONS_POST_TYPE,
+                       'post_status' => 'any',
+                       'meta_key'    => $this->metakey,
</ins><span class="cx">           ) );
</span><span class="cx"> 
</span><del>-               while ( $query->have_posts() ) {
-                       $query->the_post();
-
-                       $meta = get_post_meta( get_the_ID(), $this->metakey, true );
</del><ins>+                foreach ( $posts as $post ) {
+                       $meta = get_post_meta( $post->ID, $this->metakey, true );
</ins><span class="cx">                   if ( ! empty( $meta ) && in_array( $meta['package'], $packages ) )
</span><del>-                               wp_delete_post( get_the_ID() );
</del><ins>+                                wp_delete_post( $post->ID );
</ins><span class="cx">           }
</span><ins>+       }
</ins><span class="cx"> 
</span><del>-               wp_reset_postdata();
</del><ins>+        /**
+        * Delete code revision posts and post meta fields on plugin uninstall.
+        *
+        * @since 0.8
+        */
+       public static function uninstall() {
+               if ( ! current_user_can( 'activate_plugins' ) )
+                       return;
+
+               check_admin_referer( 'bulk-plugins' );
+
+               $posts = get_posts( array(
+                       'numberposts' => -1,
+                       'post_type'   => CODE_REVISIONS_POST_TYPE,
+                       'post_status' => 'any',
+               ) );
+
+               foreach ( $posts as $post )
+                       wp_delete_post( $post->ID );
</ins><span class="cx">   }
</span><ins>+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="2013ahoerethtrunkjseditorsminjs"></a>
<div class="addfile"><h4>Added: 2013/ahoereth/trunk/js/editors.min.js (0 => 2328)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/ahoereth/trunk/js/editors.min.js                            (rev 0)
+++ 2013/ahoereth/trunk/js/editors.min.js       2013-09-16 16:41:47 UTC (rev 2328)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+jQuery(document).ready(function(a){data=_code_revisions;a("#template #submit").after('<span class="revisions_link">'+data.text+"</span>");if(0<data.post_id){a("#template").append(data.revisions_list)}function b(e){e--;var h=a("#newcontent");var d=h.val().split("\n"),j=0;for(var g=0;g<d.length;g++){if(g==e){break}j+=(d[g].length+1)}var c=d[e].length+j;if(typeof h[0].selectionStart!="undefined"){h.focus();h[0].selectionStart=j;h[0].selectionEnd=c;return true}if(document.selection&&document.selection.createRange){h.focus();h.select();var f=document.selection.createRange();f.collapse(true);f.moveEnd("character",c);f.moveStart("character",j);f.select();return true}return false}if(data.newcontent.length>0){a("#newcontent").val(data.newcontent)}if(data.line.length>0){b(data.line);a("#highlight_line").click(function(){b(data.line)})}});
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>