Changeset 3127599
- Timestamp:
- 07/29/2024 04:42:02 PM (20 months ago)
- Location:
- skyword-publishing-api/trunk
- Files:
-
- 4 edited
-
php/options.php (modified) (3 diffs)
-
php/routes/class-skyword-posts.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
skyword.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
skyword-publishing-api/trunk/php/options.php
r3097544 r3127599 68 68 add_settings_field( 'skyword_api_generate_new_users_automatically', ' ', 'skyword_api_generate_new_users_automatically_input', __FILE__, 'skyword_generate_new_users_section' ); 69 69 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' ); 70 72 } 71 73 … … 142 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 ) . '/> (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>'; 143 145 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 149 function 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>'; 145 153 } 146 154 … … 160 168 $options['skyword_api_generate_new_users_automatically'] = empty( $input['skyword_api_generate_new_users_automatically'] ) ? false : true; 161 169 $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; 162 171 163 172 return $options; -
skyword-publishing-api/trunk/php/routes/class-skyword-posts.php
r3097544 r3127599 376 376 $trackingTagShortcode = '[skyword_anonymous_tracking /]'; 377 377 } 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); 379 406 } 380 407 … … 391 418 $newPost['ID'] = (int) $data['id']; 392 419 } 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 ) { 396 421 $data['author'] = str_replace( 'guest-', '', $data['author'] ); 397 422 $author = $coauthors_plus->guest_authors->get_guest_author_by( 'ID', $data['author'] ); 398 423 $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'] ) ) ) { 399 426 $newPost['post_author'] = (int)$data['author']; 400 427 } -
skyword-publishing-api/trunk/readme.txt
r3098029 r3127599 4 4 Requires at least: 3.3 5 5 Tested up to: 6.5.2 6 Stable tag: 1.1. 26 Stable tag: 1.1.3 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 22 22 == Changelog == 23 24 = 1.1.3 = 25 * Feature flag to convert paragraph attributes to WP "align" classes 26 * Fix bug with author checking 23 27 24 28 = 1.1.2 = -
skyword-publishing-api/trunk/skyword.php
r3097544 r3127599 3 3 Plugin Name: Skyword Publishing API 4 4 Description: Integration with the Skyword360 content publication platform. 5 Version: 1.1. 25 Version: 1.1.3 6 6 Author: Skyword, Inc. 7 7 Author URI: http://www.skyword.com … … 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 2" ); //This CANNOT have two decimal places.19 define( 'SKYWORD_VN', "1.13" ); //This CANNOT have two decimal places. 20 20 //.1.4 is NOT valid. 21 21
Note: See TracChangeset
for help on using the changeset viewer.