Plugin Directory

Changeset 3333767


Ignore:
Timestamp:
07/24/2025 03:45:04 PM (8 months ago)
Author:
skyword
Message:

Updated trunk to 1.1.5 changes

Location:
skyword-publishing-api/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • skyword-publishing-api/trunk/php/class-skyword-publish.php

    r3078729 r3333767  
    151151        }
    152152    }
     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    }
    153194}
  • skyword-publishing-api/trunk/php/routes/class-skyword-authors.php

    r3268962 r3333767  
    144144            $newUsername = uniqid("sw-",false);
    145145            $options = get_option( 'skyword_api_plugin_options' );
    146             if ( null !== $coauthors_plus ) {
     146            if ( null !== $coauthors_plus && $this->coauthorsIsEnabledAndGuestAuthorsIsEnabled()) {
    147147                $guest_author                   = array();
    148148                $guest_author['ID']             = '';
     
    229229                    'description' => array_key_exists('bio', $data) ? $data['bio'] : 'None'
    230230                ));
     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);
    231234            } else {
    232235                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  
    199199        if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) {
    200200            $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() ) {
    202202            $data['author'] = str_replace( 'guest-', '', $data['author'] );
    203203            $author          = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] );
  • skyword-publishing-api/trunk/php/routes/class-skyword-posts.php

    r3268962 r3333767  
    433433            $newPost['ID'] = (int) $data['id'];
    434434        }
    435         if ( null !== $data['author'] && null !== $coauthors_plus ) {
     435        if ( null !== $data['author'] && null !== $coauthors_plus && $this->coauthorsIsEnabledAndGuestAuthorsIsEnabled() ) {
    436436            $data['author'] = str_replace( 'guest-', '', $data['author'] );
    437437            $author          = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] );
  • skyword-publishing-api/trunk/readme.txt

    r3268962 r3333767  
    2121
    2222== Changelog ==
     23
     24= 1.1.5 =
     25* Handle Coauthors Plus option "guest_authors_enabled" being set to false
    2326
    2427= 1.1.4 =
  • skyword-publishing-api/trunk/skyword.php

    r3268962 r3333767  
    1717define( 'SKYWORD_REST_API_VERSION', "Skyword REST API plugin " . $plugin_version );
    1818if ( !defined('SKYWORD_VN') )
    19     define( 'SKYWORD_VN', "1.14" ); //This CANNOT have two decimal points.
     19    define( 'SKYWORD_VN', "1.15" ); //This CANNOT have two decimal points.
    2020//1.1.4 is NOT valid.
    2121
Note: See TracChangeset for help on using the changeset viewer.