diff --git a/field-tags.php b/field-tags.php
new file mode 100644
index 0000000..146f0b4
--- /dev/null
+++ b/field-tags.php
@@ -0,0 +1,127 @@
+ $author_first ) {
+ array_push($authors,
+ array(
+ 'first' => $author_first,
+ 'last' => $data['_coins-author-last'][$index],
+ )
+ );
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+
+ >
+
+
+ post_author );
+ $default_author_first = $default_author_data->first_name;
+ $default_author_last = $default_author_data->last_name;
+
+ if ( ! ($default_author_last && $default_author_first ) ) {
+ $default_author_first = $default_author_data->display_name;
+ $default_author_last = '';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+
+
+ >
+
+
+
\ No newline at end of file
diff --git a/functions.php b/functions.php
index d732280..deea322 100755
--- a/functions.php
+++ b/functions.php
@@ -1,5 +1,10 @@
ID );
$locked_fields = scholarpress_coins_get_locked_fields();
if ( empty( $metabox_display_data ) || ! is_array( $metabox_display_data ) ) {
@@ -50,123 +51,145 @@ function scholarpress_coins_show_meta_box( $post ) {
return;
}
- // Post Title field
- echo '';
- echo '';
- echo '';
- echo '
';
- echo '';
+ // Title Field
+ ?>
+
+
+
+
+ ' . __( 'Author/Creator\'s first or given name:', 'scholarpress-coins' ) . ' ';
- echo '';
- echo '';
- echo '
';
- $authordata = get_userdata( $post->post_author );
- $authorFirst = $authordata->first_name;
- $authorLast = $authordata->last_name;
- if ( empty( $authorLast ) || empty( $authorFirst ) ) {
- $authorFirst = $authordata->display_name;
- }
- echo '';
- echo '';
-
+ ?>
+
+
+
+ ' . __( 'Comma-separated list of subjects:', 'scholarpress-coins' ) . ' ';
- echo '';
- echo '';
- echo '
';
+ ?>
+
+ ID );
$subjects = array();
foreach( $cats as $cat ) {
- $subjects[] = $cat->cat_name;
+ $subjects[] = $cat->cat_name;
}
$subjects_string = implode( ', ', $subjects);
}
- echo '';
+ ?>
+
+
+ ' . __( 'Source (Website/Publication Title):', 'scholarpress-coins' ) . ' ';
- echo '
';
-
- echo '';
- echo '
';
-
+ ?>
+
+
+
+
+
+
+
+
+ ' . __( 'Identifier: (URL)', 'scholarpress-coins' ) . ' ';
- echo '';
- echo '';
- echo '
';
+ ?>
+
+ ID );
- echo '';
+ ?>
+
+
+last_name;
+ $authorFirst = $author->first_name;
+ if ( ! empty( $authorLast ) && ! empty( $authorFirst ) ) {
+ update_post_meta( $post_id, '_coins-author-first', $authorFirst );
+ update_post_meta( $post_id, '_coins-author-last', $authorLast );
+ } else {
+ update_post_meta( $post_id, '_coins-author-first', $author->display_name );
+ update_post_meta( $post_id, '_coins-author-last', 'scholarpress_coins_empty' );
+ unset( $_POST['_coins-author-last'] );
+ }
+ update_post_meta( $post_id, '_coins-author-first-lock', true );
+ } elseif ( array_key_exists( $key . '-lock', $_POST ) && 'on' === $_POST[$key . '-lock'] ) {
update_post_meta( $post_id, $key . '-lock', true );
if ( $key == '_coins-title' ) {
update_post_meta( $post_id, '_coins-title', $_POST['post_title'] );
- }
- elseif ( $key == '_coins-author-first' ) {
- $author = get_userdata( $_POST['post_author'] );
- $authorLast = $author->last_name;
- $authorFirst = $author->first_name;
- if ( ! empty( $authorLast ) && ! empty( $authorFirst ) ) {
- update_post_meta( $post_id, '_coins-author-first', $authorFirst );
- update_post_meta( $post_id, '_coins-author-last', $authorLast );
- } else {
- update_post_meta( $post_id, '_coins-author-first', $author->display_name );
- update_post_meta( $post_id, '_coins-author-last', 'scholarpress_coins_empty' );
- unset( $_POST['_coins-author-last'] );
- }
} elseif ( $key == '_coins-subjects' ) {
$cats = $_POST['post_category'];
$cat_names = array();
@@ -215,6 +238,7 @@ function scholarpress_coins_add_coins_to_content( $content ) {
return $content;
}
$coinsTitle = apply_filters('scholarpress_coins_span_title', scholarpress_coins_get_span_title( $display_data ) );
+ // var_dump($coinsTitle);
$content = '' . $content;
return $content;
}
@@ -242,9 +266,17 @@ function scholarpress_coins_get_span_title( $data ) {
$coinsTitle .= '&rft.subject=' . urlencode( $subject );
}
}
- if ( ! empty( $data['_coins-author-last'] ) && ! empty( $data['_coins-author-first'] ) ) {
- $coinsTitle .= '&rft.aulast=' . urlencode( $data['_coins-author-last'] )
- . '&rft.aufirst=' . urlencode( $data['_coins-author-first'] );
+ if ( ! empty( $data['_coins-author-last'] ) ) {
+ if ( ! is_array($data['_coins-author-first'] ) ) {
+ $data['_coins-author-first'] = str_split( $data['_coins-author-first'], strlen( $data['_coins-author-first'] ) + 1 );
+ $data['_coins-author-last'] = str_split( $data['_coins-author-last'], strlen( $data['_coins-author-last'] ) + 1 );
+ }
+ foreach( $data['_coins-author-first'] as $index => $author_first ) {
+ $coinsTitle .= '&rft.au=' . urlencode( $author_first );
+ if ( ! empty($data['_coins-author-last'][$index] ) ) {
+ $coinsTitle .= urlencode( ' ' . $data['_coins-author-last'][$index] );
+ }
+ }
} else {
$coinsTitle .= '&rft.au=' . urlencode( $data['_coins-author-first'] );
}