Changeset 3091546
- Timestamp:
- 05/23/2024 01:54:07 PM (23 months ago)
- Location:
- skyword-publishing-api/tags/1.1.2/php/routes
- Files:
-
- 3 edited
-
class-skyword-authors.php (modified) (1 diff)
-
class-skyword-images.php (modified) (3 diffs)
-
class-skyword-posts.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
skyword-publishing-api/tags/1.1.2/php/routes/class-skyword-authors.php
r3090934 r3091546 166 166 $retval = $coauthors_plus->guest_authors->create( $guest_author ); 167 167 if ( is_wp_error( $retval ) ) { 168 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'user_login', $data['email'] ); 168 if ($options['skyword_coauthors_friendly_slugs']) { 169 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'user_login', $this->generate_author_slug($data)); 170 } else { 171 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'user_login', $newUsername ); 172 } 169 173 if ( null !== $author ) { 170 174 $userId = $author->ID; -
skyword-publishing-api/tags/1.1.2/php/routes/class-skyword-images.php
r3090934 r3091546 155 155 156 156 function create_image($request) { 157 global $coauthors_plus; 157 158 $login = $this->authenticate($request); 158 159 if ( 'success' !== $login['status'] ) { … … 165 166 $type = 'image/' . substr($data['filename'], strpos($data['filename'], '.') + 1); 166 167 // Yoast SEO plugin requires 'image/jpeg' and will not accept 'image/jpg' 168 if (is_multisite()) { 169 $activePlugins = (array) get_site_option('active_sitewide_plugins', array()); 170 $activePlugins = array_keys($activePlugins); 171 } else { 172 $activePlugins = (array) get_option('active_plugins', array()); 173 } 167 174 if ( in_array( 'wordpress-seo/wp-seo.php', $activePlugins, true ) ) { 168 175 if ($type === 'image/jpg') { … … 192 199 if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) { 193 200 $attachment['post_author'] = (int)$data['author']; 194 } 195 201 } else if ( null !== $data['author'] && null !== $coauthors_plus ) { 202 $data['author'] = str_replace( 'guest-', '', $data['author'] ); 203 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] ); 204 $authorTerm = $coauthors_plus->update_author_term( $author ); 205 $attachment['post_author'] = (int)$data['author']; 206 } 196 207 197 208 $id = wp_insert_attachment( $attachment, $upload['file'], $postId ); 209 if ( null !== $data['author'] && null !== $coauthors_plus ) { 210 wp_set_object_terms( $id, $authorTerm->slug, $coauthors_plus->coauthor_taxonomy, true ); 211 } 198 212 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 199 213 -
skyword-publishing-api/tags/1.1.2/php/routes/class-skyword-posts.php
r3079629 r3091546 393 393 if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) { 394 394 $newPost['post_author'] = (int)$data['author']; 395 } else if ( null !== $data['author'] && null !== $coauthors_plus ) { 396 $data['author'] = str_replace( 'guest-', '', $data['author'] ); 397 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] ); 398 $authorTerm = $coauthors_plus->update_author_term( $author ); 399 $newPost['post_author'] = (int)$data['author']; 400 if ( 'post' === $postType ) { 401 wp_set_post_terms( $postId, $authorTerm->slug, $coauthors_plus->coauthor_taxonomy, true ); 402 } else { 403 wp_set_object_terms( $postId, $authorTerm->slug, $coauthors_plus->coauthor_taxonomy, true ); 404 } 395 405 } 396 406 … … 417 427 418 428 $this->attachAttachments($postId, $imageIds); 419 420 if ( null !== $coauthors_plus ) {421 if ( ! is_numeric( $data['author'] ) ) {422 $data['author'] = str_replace( 'guest-', '', $data['author'] );423 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] );424 $authorTerm = $coauthors_plus->update_author_term( $author );425 if ( 'post' === $postType ) {426 wp_set_post_terms( $postId, $authorTerm->slug, $coauthors_plus->coauthor_taxonomy, true );427 } else {428 wp_set_object_terms( $postId, $authorTerm->slug, $coauthors_plus->coauthor_taxonomy, true );429 }430 }431 }432 429 433 430 // Provide a hook for customers to do any additional work with the post once it has been handled by us
Note: See TracChangeset
for help on using the changeset viewer.