Skip to content

Commit

Permalink
Remove JSON handling of AJAX. Comments in JS.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatek committed Feb 1, 2014
1 parent 543567b commit b7254cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
14 changes: 0 additions & 14 deletions co-authors-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,20 +922,6 @@ function ajax_suggest() {

$authors = $this->search_authors( $search, $ignore );

if ( ! empty( $_REQUEST['json'] ) ) {
$author_data = array();
foreach ( $authors as $author ) {
$author_data[] = array(
'numerical_id' => $author->ID,
'user_login' => $author->user_login,
'display_name' => $author->display_name,
'user_email' => $author->user_email,
'id' => $author->user_nicename, // using slugs as ids
);
}
wp_send_json_success( $author_data );
}

foreach( $authors as $author ) {
echo $author->ID ." | ". $author->user_login ." | ". $author->display_name ." | ". $author->user_email ." | ". $author->user_nicename . "\n";
}
Expand Down
13 changes: 11 additions & 2 deletions js/co-authors-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ jQuery(document).ready(function () {

var $coauthors_div = null;

/**
* Initialize the Coauthors UI.
*
* @param array List of coauthors objects.
* Each coauthor object should have the (string) properties:
* login
* email
* name
* nicename
*/
function coauthors_initialize(post_coauthors) {

// Add the controls to add co-authors
Expand Down Expand Up @@ -457,7 +467,6 @@ jQuery(document).ready(function () {
hide_loading();
});

// fire it up!
if ( 'post' == pagenow ) {
var $post_coauthor_logins = jQuery('input[name="coauthors[]"]');
var $post_coauthor_names = jQuery('input[name="coauthorsinput[]"]');
Expand Down Expand Up @@ -506,7 +515,7 @@ jQuery(document).ready(function () {
}
})
coauthors_initialize(post_coauthors);

}
}
}
Expand Down

0 comments on commit b7254cd

Please sign in to comment.