Changeset 3333767
- Timestamp:
- 07/24/2025 03:45:04 PM (8 months ago)
- Location:
- skyword-publishing-api/trunk
- Files:
-
- 6 edited
-
php/class-skyword-publish.php (modified) (1 diff)
-
php/routes/class-skyword-authors.php (modified) (2 diffs)
-
php/routes/class-skyword-images.php (modified) (1 diff)
-
php/routes/class-skyword-posts.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
skyword.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
skyword-publishing-api/trunk/php/class-skyword-publish.php
r3078729 r3333767 151 151 } 152 152 } 153 154 155 /** 156 * Checks if Co-Authors Plus is active AND if its Guest Authors feature is ENABLED. 157 * 158 * @return bool True if Co-Authors Plus is active AND Guest Authors is ENABLED, false otherwise. 159 */ 160 protected function coauthorsIsEnabledAndGuestAuthorsIsEnabled() { 161 162 // Ensure 'is_plugin_active' function is available. 163 if ( ! function_exists( 'is_plugin_active' ) ) { 164 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 165 } 166 167 // Define the standard plugin path for Co-Authors Plus. 168 $coauthors_plus_plugin_path = 'co-authors-plus/co-authors-plus.php'; 169 170 // 1. Check if Co-Authors Plus is active. 171 if ( ! is_plugin_active( $coauthors_plus_plugin_path ) ) { 172 // Co-Authors Plus is not active, so return false 173 return false; 174 } 175 176 // Co-Authors Plus IS active. Now, check its Guest Authors setting. 177 $cap_options = get_option( 'coauthors_plus_options' ); 178 179 // Check if the option 'coauthors_plus_options' is an array and contains the 'guest_authors_enabled' key. 180 // Then, check if its value is explicitly '0' or boolean false. 181 // If the option or key doesn't exist, it implies the feature is not enabled, so it's effectively disabled. 182 if ( 183 ! is_array( $cap_options ) || // Option doesn't exist or isn't an array 184 ! isset( $cap_options['guest_authors_enabled'] ) || // Specific key not set 185 ( (bool) $cap_options['guest_authors_enabled'] === false || $cap_options['guest_authors_enabled'] === '0' ) 186 ) { 187 // Co-Authors Plus is active, but Guest Authors is NOT enabled (or option not set). 188 return false; // Guest Authors are disabled. 189 } 190 191 // If we reach here, Co-Authors Plus is active and Guest Authors is enabled. 192 return true; 193 } 153 194 } -
skyword-publishing-api/trunk/php/routes/class-skyword-authors.php
r3268962 r3333767 144 144 $newUsername = uniqid("sw-",false); 145 145 $options = get_option( 'skyword_api_plugin_options' ); 146 if ( null !== $coauthors_plus ) {146 if ( null !== $coauthors_plus && $this->coauthorsIsEnabledAndGuestAuthorsIsEnabled()) { 147 147 $guest_author = array(); 148 148 $guest_author['ID'] = ''; … … 229 229 'description' => array_key_exists('bio', $data) ? $data['bio'] : 'None' 230 230 )); 231 } else if ( null !== $coauthors_plus && !$this->coauthorsIsEnabledAndGuestAuthorsIsEnabled()) { 232 $response = new WP_REST_Response('author ' . $userId . ' listed, but coauthors enabled with no guests', 400); 233 $response->header('Link', 'skyword/authors/' . $userId); 231 234 } else { 232 235 return new WP_REST_Response('could not create new author - install co-authors plus or enable new author creation through Skyword', 500); -
skyword-publishing-api/trunk/php/routes/class-skyword-images.php
r3268962 r3333767 199 199 if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) { 200 200 $attachment['post_author'] = (int)$data['author']; 201 } else if ( null !== $data['author'] && null !== $coauthors_plus ) {201 } else if ( null !== $data['author'] && null !== $coauthors_plus && $this->coauthorsIsEnabledAndGuestAuthorsIsEnabled() ) { 202 202 $data['author'] = str_replace( 'guest-', '', $data['author'] ); 203 203 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] ); -
skyword-publishing-api/trunk/php/routes/class-skyword-posts.php
r3268962 r3333767 433 433 $newPost['ID'] = (int) $data['id']; 434 434 } 435 if ( null !== $data['author'] && null !== $coauthors_plus ) {435 if ( null !== $data['author'] && null !== $coauthors_plus && $this->coauthorsIsEnabledAndGuestAuthorsIsEnabled() ) { 436 436 $data['author'] = str_replace( 'guest-', '', $data['author'] ); 437 437 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] ); -
skyword-publishing-api/trunk/readme.txt
r3268962 r3333767 21 21 22 22 == Changelog == 23 24 = 1.1.5 = 25 * Handle Coauthors Plus option "guest_authors_enabled" being set to false 23 26 24 27 = 1.1.4 = -
skyword-publishing-api/trunk/skyword.php
r3268962 r3333767 17 17 define( 'SKYWORD_REST_API_VERSION', "Skyword REST API plugin " . $plugin_version ); 18 18 if ( !defined('SKYWORD_VN') ) 19 define( 'SKYWORD_VN', "1.1 4" ); //This CANNOT have two decimal points.19 define( 'SKYWORD_VN', "1.15" ); //This CANNOT have two decimal points. 20 20 //1.1.4 is NOT valid. 21 21
Note: See TracChangeset
for help on using the changeset viewer.