<!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>[3607] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer: developer.wordpress.org: Add explanation editor role.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/3607">3607</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/3607","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coffee2code</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-06-30 21:06:52 +0000 (Thu, 30 Jun 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>developer.wordpress.org: Add explanation editor role.
Props DrewAPicture.
See <a href="http://meta.trac.wordpress.org/ticket/1781">#1781</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincexplanationsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsexplanationsjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/explanations.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincexplanationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php 2016-06-30 19:54:07 UTC (rev 3606)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php 2016-06-30 21:06:52 UTC (rev 3607)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,18 +36,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->post_types = DevHub\get_parsed_post_types();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Setup.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'init', array( $this, 'register_post_type' ), 0 );
- add_action( 'init', array( $this, 'remove_editor_support' ), 100 );
- add_action( 'edit_form_after_title', array( $this, 'post_to_expl_controls' ) );
- add_action( 'edit_form_top', array( $this, 'expl_to_post_controls' ) );
- add_action( 'admin_bar_menu', array( $this, 'toolbar_edit_link' ), 100 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'init', array( $this, 'register_post_type' ), 0 );
+ add_action( 'init', array( $this, 'remove_editor_support' ), 100 );
+ add_action( 'edit_form_after_title', array( $this, 'post_to_expl_controls' ) );
+ add_action( 'edit_form_top', array( $this, 'expl_to_post_controls' ) );
+ add_action( 'admin_bar_menu', array( $this, 'toolbar_edit_link' ), 100 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Permissions.
+ add_action( 'after_switch_theme', array( $this, 'add_roles' ) );
+ add_filter( 'user_has_cap', array( $this, 'grant_caps' ) );
+ add_filter( 'post_row_actions', array( $this, 'expl_row_action' ), 10, 2 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Script and styles.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // AJAX.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'wp_ajax_new_explanation', array( $this, 'new_explanation' ) );
- add_action( 'wp_ajax_un_publish', array( $this, 'un_publish_explanation' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'wp_ajax_new_explanation', array( $this, 'new_explanation' ) );
+ add_action( 'wp_ajax_un_publish', array( $this, 'un_publish_explanation' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Content tweaks.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'syntaxhighlighter_precode', 'html_entity_decode' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,6 +80,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_ui' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_in_menu' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_in_nav_menus' => false,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'capability_type' => 'explanation',
+ 'map_meta_cap' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => array( 'editor', 'revisions' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'rewrite' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'query_var' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -153,21 +160,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->exp_post_type !== $post->post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $parent = is_a( $post, 'WP_Post' ) ? $post->post_parent : get_post( $post )->post_parent;
-
- if ( 0 !== $parent ) :
- $prefix = '<strong>' . __( 'Associated with: ', 'wporg' ) . '</strong>';
- ?>
- <div class="postbox-container" style="margin-top:20px;width:100%;">
- <div class="postbox">
- <div class="inside" style="padding-bottom:0;">
- <?php edit_post_link( get_the_title( $parent ), $prefix, '', $parent ); ?>
- </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ?>
+ <div class="postbox-container" style="margin-top:20px;width:100%;">
+ <div class="postbox">
+ <div class="inside" style="padding-bottom:0;">
+ <strong><?php _e( 'Associated with: ', 'wporg' ); ?></strong>
+ <?php
+ // Edit link if the current user can edit, otherwise view link.
+ if ( current_user_can( 'edit_post', $post->post_parent ) ) :
+ edit_post_link( get_the_title( $post->post_parent ), '', '', $post->post_parent );
+ else :
+ printf( '<a href="%1$s">%2$s</a>',
+ esc_url( get_permalink( $post->post_parent ) ),
+ str_replace( 'Explanation: ', '', get_the_title( $post->post_parent ) )
+ );
+ endif;
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- endif;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -201,6 +213,110 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Adds the 'Explanation Editor' role.
+ *
+ * @access public
+ */
+ public function add_roles() {
+ add_role(
+ 'expl_editor',
+ __( 'Explanation Editor', 'wporg' ),
+ array(
+ 'unfiltered_html' => true,
+ 'read' => true,
+ 'edit_explanations' => true,
+ 'edit_others_explanations' => true,
+ 'edit_published_explanations' => true,
+ 'edit_private_explanations' => true,
+ 'read_private_explanations' => true,
+ )
+ );
+ }
+
+ /**
+ * Grants explanation capabilities to users.
+ *
+ * @access public
+ *
+ * @param array $caps Capabilities.
+ * @return array Modified capabilities array.
+ */
+ public function grant_caps( $caps ) {
+
+ if ( ! is_user_member_of_blog() ) {
+ return $caps;
+ }
+
+ $role = wp_get_current_user()->roles[0];
+
+ // Only grant explanation post type caps for admins, editors, and explanation editors.
+ if ( in_array( $role, array( 'administrator', 'editor', 'expl_editor' ) ) ) {
+ $base_caps = array(
+ 'edit_explanations', 'edit_others_explanations',
+ 'edit_published_explanations', 'edit_posts'
+ );
+
+ foreach ( $base_caps as $cap ) {
+ $caps[ $cap ] = true;
+ }
+
+ $editor_caps = array(
+ 'publish_explanations',
+ 'delete_explanations', 'delete_others_explanations',
+ 'delete_published_explanations', 'delete_private_explanations',
+ 'edit_private_explanations', 'read_private_explanations'
+ );
+
+ if ( ! empty( $caps['edit_pages'] ) ) {
+ foreach ( $editor_caps as $cap ) {
+ $caps[ $cap ] = true;
+ }
+ }
+ }
+
+ return $caps;
+ }
+
+ /**
+ * Adds the 'Add/Edit Explanation' row actions to the parsed post type list tables.
+ *
+ * @access public
+ *
+ * @param array $actions Row actions.
+ * @param \WP_Post $post Parsed post object.
+ * @return array (Maybe) filtered row actions.
+ */
+ public function expl_row_action( $actions, $post ) {
+ if ( ! in_array( $post->post_type, \DevHub\get_parsed_post_types() ) ) {
+ return $actions;
+ }
+
+ $expl = \DevHub\get_explanation( $post );
+
+ $expl_action = array();
+
+ if ( $expl ) {
+ if ( ! current_user_can( 'edit_posts', $expl->ID ) ) {
+ return $actions;
+ }
+
+ $expl_action['edit-expl'] = sprintf( '<a href="%1$s" alt="%2$s">%3$s</a>',
+ esc_url( get_edit_post_link( $expl->ID ) ),
+ esc_attr__( 'Edit Explanation', 'wporg' ),
+ __( 'Edit Explanation', 'wporg' )
+ );
+ } else {
+ $expl_action['add-expl'] = sprintf( '<a href="" class="create-expl" data-nonce="%1$s" data-id="%2$s">%3$s</a>',
+ esc_attr( wp_create_nonce( 'create-expl' ) ),
+ esc_attr( $post->ID ),
+ __( 'Add Explanation', 'wporg' )
+ );
+ }
+
+ return array_merge( $expl_action, $actions );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Output the Explanation status controls.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,11 +331,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <span id="expl-row-actions" class="expl-row-actions">
</span><span class="cx" style="display: block; padding: 0 10px"> <a id="edit-expl" href="<?php echo get_edit_post_link( $explanation->ID ); ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'Edit Content', 'wporg' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'Edit Explanation', 'wporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </a>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php if ( 'publish' == get_post_status( $explanation ) ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <a href="#unpublish" id="unpublish-expl" data-nonce="<?php echo wp_create_nonce( 'unpublish-expl' ); ?>" data-id="<?php the_ID(); ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'Un-publish', 'wporg' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'Unpublish', 'wporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </a>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </span><!-- .expl-row-actions -->
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,7 +365,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch( $status = $post->post_status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'draft' :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $label = __( 'Drafted', 'wporg' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $label = __( 'Draft', 'wporg' );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'pending' :
</span><span class="cx" style="display: block; padding: 0 10px"> $label = __( 'Pending Review', 'wporg' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,17 +389,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function admin_enqueue_scripts() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed_post_types = array();
+
+ foreach ( \DevHub\get_parsed_post_types() as $post_type ) {
+ $parsed_post_types[] = $post_type;
+ $parsed_post_types[] = "edit-{$post_type}";
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( get_current_screen()->id, array_merge(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- DevHub\get_parsed_post_types(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed_post_types,
</ins><span class="cx" style="display: block; padding: 0 10px"> array( 'wporg_explanations', 'edit-wporg_explanations' )
</span><span class="cx" style="display: block; padding: 0 10px"> ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( 'wporg-admin', get_template_directory_uri() . '/stylesheets/admin.css', array(), '20141218' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'wporg-explanations', get_template_directory_uri() . '/js/explanations.js', array( 'jquery', 'wp-util' ), '20141218', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_localize_script( 'wporg-explanations', 'wporg', array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'editContentLabel' => __( 'Edit Content', 'wporg' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'editContentLabel' => __( 'Edit Explanation', 'wporg' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'statusLabel' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'draft' => __( 'Drafted', 'wporg' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'draft' => __( 'Draft', 'wporg' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'pending' => __( 'Pending Review', 'wporg' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'publish' => __( 'Published', 'wporg' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,6 +423,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'create-expl', 'nonce' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = empty( $_REQUEST['post_id'] ) ? 0 : absint( $_REQUEST['post_id'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $context = empty( $_REQUEST['context'] ) ? '' : sanitize_text_field( $_REQUEST['context'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( DevHub\get_explanation( $post_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( new WP_Error( 'post_exists', __( 'Explanation already exists.', 'wporg' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,7 +439,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_wp_error( $explanation ) && 0 !== $explanation ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_success( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_id' => $explanation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_id' => $explanation,
+ 'parent_id' => $post_id,
+ 'context' => $context
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsexplanationsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/explanations.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/explanations.js 2016-06-30 19:54:07 UTC (rev 3606)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/explanations.js 2016-06-30 21:06:52 UTC (rev 3607)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,6 +13,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unPublishLink = $( '#unpublish-expl' ),
</span><span class="cx" style="display: block; padding: 0 10px"> rowActions = $( '#expl-row-actions' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var rowCreateLink = $( '.create-expl' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * AJAX handler for creating and associating a new explanation post.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,7 +28,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> error: createExplError,
</span><span class="cx" style="display: block; padding: 0 10px"> data: {
</span><span class="cx" style="display: block; padding: 0 10px"> nonce: $( this ).data( 'nonce' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- post_id: $( this ).data( 'id' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ post_id: $( this ).data( 'id' ),
+ context: event.data.context
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -37,9 +40,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {object} data Data response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function createExplSuccess( data ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- createLink.hide();
- rowActions.html( '<a href="post.php?post=' + data.post_id + '&action=edit">' + wporg.editContentLabel + '</a>' );
- statusLabel.text( wporg.statusLabel.draft );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var editLink = '<a href="post.php?post=' + data.post_id + '&action=edit">' + wporg.editContentLabel + '</a>';
+
+ if ( 'edit' == data.context ) {
+ // Action in the parsed post type edit screen.
+ createLink.hide();
+ rowActions.html( editLink );
+ statusLabel.text( wporg.statusLabel.draft );
+ } else {
+ // Row link in the list table.
+ $( '#post-' + data.parent_id + ' .add-expl' ).html( editLink + ' | ' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,7 +98,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function unPublishError( data ) {}
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Events.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( '#create-expl' ).on( 'click', createExplanation );
- $( '#unpublish-expl' ).on( 'click', unPublishExplantaion );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ createLink.on( 'click', { context: 'edit' }, createExplanation );
+ rowCreateLink.on( 'click', { context: 'list' }, createExplanation );
+ unPublishLink.on( 'click', unPublishExplantaion );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } )( jQuery );
</span></span></pre>
</div>
</div>
</body>
</html>