Plugin Directory

Changeset 3127599


Ignore:
Timestamp:
07/29/2024 04:42:02 PM (20 months ago)
Author:
skyword
Message:

1.1.3 to stable version

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

Legend:

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

    r3097544 r3127599  
    6868    add_settings_field( 'skyword_api_generate_new_users_automatically', ' ', 'skyword_api_generate_new_users_automatically_input', __FILE__, 'skyword_generate_new_users_section' );
    6969    add_settings_field( 'skyword_coauthors_friendly_slugs', ' ', 'skyword_coauthors_friendly_slugs_input', __FILE__, 'skyword_generate_new_users_section' );
     70    add_settings_section( 'skyword_miscellaneous_section', 'Miscellaneous', 'skyword_api_plugin_section_text', __FILE__ );
     71    add_settings_field( 'skyword_align_class_conversion', ' ', 'skyword_align_class_conversion_input', __FILE__, 'skyword_miscellaneous_section' );
    7072}
    7173
     
    142144        echo '<input type="checkbox" id="friendly_slugs" name="skyword_api_plugin_options[skyword_coauthors_friendly_slugs]" value="1" ' . checked( 1, $options['skyword_coauthors_friendly_slugs'], false ) . '/> (BETA) Assign meaningful slugs to Coauthors Plus author pages.<p>New Coauthors Plus pages will receive a slug for their page based on their byline.</p>';
    143145    else
    144         echo '<input type="checkbox" id="friendly_slugs" name="skyword_api_plugin_options[skyword_coauthors_friendly_slugs]" value="1" ' . checked( 1, $options['skyword_coauthors_friendly_slugs'], false ) . ' disabled/><span style="color:lightgrey"> (BETA) Assign meaningful slugs to Coauthors Plus author pages. (Co-Authors Plus plugin disabled, so this option has been disabled)</span><p style="color:lightgrey">New Coauthors Plus pages will receive a slug for their page based on their byline.</p>';
     146        echo '<input type="checkbox" id="friendly_slugs" name="skyword_api_plugin_options[skyword_coauthors_friendly_slugs]" value="1" ' . checked( 1, $options['skyword_coauthors_friendly_slugs'], false ) . ' disabled/><span style="color:lightgrey"> (BETA) Assign meaningful slugs to Coauthors Plus author pages. (Co-Authors Plus plugin disabled, so this option has been disabled)</span><p style="color:lightgrey">New Coauthors Plus pages will receive a slug for their page based on their byline.</span></p>';
     147}
     148
     149function skyword_align_class_conversion_input() {
     150    $options = get_option( 'skyword_api_plugin_options' );
     151
     152    echo '<input type="checkbox" id="align_class_conversion" name="skyword_api_plugin_options[skyword_align_class_conversion]" value="1" ' . checked( 1, $options['skyword_align_class_conversion'], false ) . ' /> (BETA) Convert paragraph tag classes to be prefixed with align</span>Classes left/right/center/wide/full will be replaced with alignleft, etc.</p>';
    145153}
    146154
     
    160168    $options['skyword_api_generate_new_users_automatically'] = empty( $input['skyword_api_generate_new_users_automatically'] ) ? false : true;
    161169    $options['skyword_coauthors_friendly_slugs'] = empty( $input['skyword_coauthors_friendly_slugs'] ) ? false : true;
     170    $options['skyword_align_class_conversion'] = empty( $input['skyword_align_class_conversion'] ) ? false : true;
    162171
    163172    return $options;
  • skyword-publishing-api/trunk/php/routes/class-skyword-posts.php

    r3097544 r3127599  
    376376                $trackingTagShortcode = '[skyword_anonymous_tracking /]';
    377377            }
    378             $newPost['post_content'] = wp_kses_post($fields['body']['value'] . $trackingTagShortcode);
     378
     379            $options = get_option( 'skyword_api_plugin_options' );
     380            if ($options['skyword_align_class_conversion']) {
     381                // Adjust to WP align attributes
     382                $html = wp_kses_post($fields['body']['value']);
     383                // Make sure BR tags are balanced
     384                $html = str_replace("<br>", "<br/>", $html);
     385                $doc = new DomDocument();
     386                $doc->loadHTML($html, LIBXML_NOERROR);
     387                $list = $doc->getElementsByTagName("p");
     388                if ($list->length > 0) {
     389                    foreach ($list as $node) {
     390                        $classAttribute = $node->getAttribute("class");
     391                        forEach(array("left", "center", "right", "full", "wide") as $classValue) {
     392                            if(str_contains($classAttribute, $classValue)) {
     393                                //change node value
     394                                $node->setAttribute("class", str_replace($classAttribute, $classValue, "align" . $classValue));
     395                            }
     396                        }
     397                    }
     398                }
     399                $newBody = $doc->saveHTML();
     400            } else {
     401                // No change needed
     402                $newBody = $fields['body']['value'];
     403            }
     404
     405            $newPost['post_content'] = wp_kses_post($newBody . $trackingTagShortcode);
    379406        }
    380407
     
    391418            $newPost['ID'] = (int) $data['id'];
    392419        }
    393         if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) {
    394             $newPost['post_author'] = (int)$data['author'];
    395         } else if ( null !== $data['author'] && null !== $coauthors_plus ) {
     420        if ( null !== $data['author'] && null !== $coauthors_plus ) {
    396421            $data['author'] = str_replace( 'guest-', '', $data['author'] );
    397422            $author          = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] );
    398423            $authorTerm      = $coauthors_plus->update_author_term( $author );
     424            $newPost['post_author'] = (int)$data['author'];
     425        } else if ( null !== $data['author'] && is_numeric( trim( $data['author'] ) ) ) {
    399426            $newPost['post_author'] = (int)$data['author'];
    400427        }
  • skyword-publishing-api/trunk/readme.txt

    r3098029 r3127599  
    44Requires at least: 3.3
    55Tested up to: 6.5.2
    6 Stable tag: 1.1.2
     6Stable tag: 1.1.3
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2121
    2222== Changelog ==
     23
     24= 1.1.3 =
     25* Feature flag to convert paragraph attributes to WP "align" classes
     26* Fix bug with author checking
    2327
    2428= 1.1.2 =
  • skyword-publishing-api/trunk/skyword.php

    r3097544 r3127599  
    33Plugin Name: Skyword Publishing API
    44Description: Integration with the Skyword360 content publication platform.
    5 Version: 1.1.2
     5Version: 1.1.3
    66Author: Skyword, Inc.
    77Author URI: http://www.skyword.com
     
    1717define( 'SKYWORD_REST_API_VERSION', "Skyword REST API plugin " . $plugin_version );
    1818if ( !defined('SKYWORD_VN') )
    19     define( 'SKYWORD_VN', "1.12" ); //This CANNOT have two decimal places.
     19    define( 'SKYWORD_VN', "1.13" ); //This CANNOT have two decimal places.
    2020//.1.4 is NOT valid.
    2121
Note: See TracChangeset for help on using the changeset viewer.