Changeset 3833293
- Timestamp:
- 11/29/2026 03:54:45 PM (7 hours ago)
- Location:
- blurbwing/trunk
- Files:
-
- 1 added
- 15 edited
-
assets/js/editor-sidebar.js (modified) (1 diff)
-
assets/js/settings.js (modified) (1 diff)
-
blurbwing.php (modified) (2 diffs)
-
includes/class-admin.php (modified) (2 diffs)
-
includes/class-ai.php (modified) (1 diff)
-
includes/class-data.php (modified) (2 diffs)
-
includes/class-export.php (modified) (2 diffs)
-
includes/class-feeds.php (modified) (4 diffs)
-
includes/class-pipeline.php (modified) (3 diffs)
-
includes/class-post-type.php (modified) (2 diffs)
-
includes/class-rest-drafts-controller.php (added)
-
includes/class-rest.php (modified) (5 diffs)
-
includes/class-settings.php (modified) (2 diffs)
-
languages/blurbwing.pot (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blurbwing/trunk/assets/js/editor-sidebar.js
r3707991 r3833293 24 24 .replace( /<!--[\s\S]*?-->/g, '' ) 25 25 .replace( /<[^>]+>/g, '' ) 26 .replace( /& [a-z]+;/gi, '' )26 .replace( /&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/gi, '_' ) 27 27 .replace( /\s+/g, ' ' ) 28 28 .trim(); -
blurbwing/trunk/assets/js/settings.js
r3707991 r3833293 22 22 var s = response.summary || {}; 23 23 status.textContent = ( s.drafts_created || 0 ) + ' drafts created, ' + ( s.items_seen || 0 ) + ' items seen.'; 24 25 window.setTimeout( function () { 26 window.location.reload(); 27 }, 1200 ); 24 28 } else { 25 29 status.textContent = ( response && response.message ) || config.failed || 'Run failed.'; 30 button.disabled = false; 26 31 } 27 28 window.setTimeout( function () {29 window.location.reload();30 }, 1200 );31 32 } ).catch( function () { 32 33 status.textContent = config.failed || 'Run failed.'; -
blurbwing/trunk/blurbwing.php
r3707991 r3833293 3 3 * Plugin Name: Blurbwing 4 4 * Description: Pulls news on topics you pick and drafts platform-tailored social posts with WordPress AI on a daily schedule, ready to review and copy from wp-admin. 5 * Version: 0.1. 05 * Version: 0.1.1 6 6 * Requires at least: 7.0 7 7 * Requires PHP: 8.1 … … 18 18 defined( 'ABSPATH' ) || exit; 19 19 20 define( 'BLURBWING_VERSION', '0.1. 0' );20 define( 'BLURBWING_VERSION', '0.1.1' ); 21 21 define( 'BLURBWING_FILE', __FILE__ ); 22 22 define( 'BLURBWING_DIR', plugin_dir_path( __FILE__ ) ); -
blurbwing/trunk/includes/class-admin.php
r3707991 r3833293 229 229 'blurbwingAdmin', 230 230 array( 231 'base' => '/' . Rest:: NAMESPACE . '/draft/',231 'base' => '/' . Rest::ROUTE_NAMESPACE . '/draft/', 232 232 'nonce' => wp_create_nonce( 'wp_rest' ), 233 233 'copied' => __( 'Copied to clipboard', 'blurbwing' ), … … 251 251 } 252 252 253 $text = trim( wp_strip_all_tags( $post->post_content) );253 $text = trim( html_entity_decode( wp_strip_all_tags( $post->post_content ), ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); 254 254 $source = (string) get_post_meta( $post_id, Post_Type::META_SOURCE_URL, true ); 255 255 -
blurbwing/trunk/includes/class-ai.php
r3707991 r3833293 204 204 } 205 205 206 $data = json_decode( $result->toText(), true ); 206 try { 207 $data = json_decode( $result->toText(), true ); 208 } catch ( \Throwable $e ) { 209 return new WP_Error( 'blurbwing_ai_exception', $e->getMessage() ); 210 } 207 211 208 212 if ( ! is_array( $data ) ) { -
blurbwing/trunk/includes/class-data.php
r3707991 r3833293 12 12 13 13 /** 14 * Removes every draft, term, option and scheduled event the plugin created. 14 * Removes every draft, term, option, user meta and scheduled event the plugin 15 * created. 15 16 */ 16 17 final class Data { … … 51 52 } 52 53 54 delete_metadata( 'user', 0, Provider_Notice::DISMISSED_META, '', true ); 53 55 delete_option( Settings::OPTION ); 54 56 delete_option( Pipeline::LOG_OPTION ); -
blurbwing/trunk/includes/class-export.php
r3707991 r3833293 87 87 return array( 88 88 'id' => $post->ID, 89 'title' => get_the_title( $post),89 'title' => html_entity_decode( $post->post_title, ENT_QUOTES | ENT_HTML5, 'UTF-8' ), 90 90 'platform' => is_array( $platform ) && $platform ? $platform[0] : '', 91 91 'topic' => is_array( $topic ) && $topic ? $topic[0] : '', … … 93 93 'source_url' => (string) get_post_meta( $post->ID, Post_Type::META_SOURCE_URL, true ), 94 94 'source_publisher' => (string) get_post_meta( $post->ID, Post_Type::META_SOURCE_PUBLISHER, true ), 95 'content' => trim( wp_strip_all_tags( $post->post_content) ),95 'content' => trim( html_entity_decode( wp_strip_all_tags( $post->post_content ), ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ), 96 96 'card_text' => (string) get_post_meta( $post->ID, Post_Type::META_CARD_TEXT, true ), 97 97 'first_comment' => (string) get_post_meta( $post->ID, Post_Type::META_FIRST_COMMENT, true ), -
blurbwing/trunk/includes/class-feeds.php
r3707991 r3833293 109 109 */ 110 110 public static function normalise( string $title, string $url, string $publisher, string $summary, ?int $timestamp ): ?array { 111 $url = esc_url_raw( trim( $url), array( 'http', 'https' ) );112 $title = s anitize_text_field( $title );111 $url = esc_url_raw( trim( self::decode( $url ) ), array( 'http', 'https' ) ); 112 $title = self::plain_text( $title ); 113 113 114 114 if ( '' === $url || '' === $title ) { … … 119 119 'title' => $title, 120 120 'url' => $url, 121 'publisher' => s anitize_text_field( $publisher ),121 'publisher' => self::plain_text( $publisher ), 122 122 'summary' => self::summary_excerpt( $summary ), 123 123 'timestamp' => $timestamp, … … 127 127 128 128 /** 129 * SimplePie returns titles and links HTML-escaped; this is the plain value. 130 * 131 * @param string $value Escaped feed field. 132 */ 133 private static function decode( string $value ): string { 134 return html_entity_decode( $value, ENT_QUOTES | ENT_HTML5, 'UTF-8' ); 135 } 136 137 /** 138 * Feed text with real markup removed and entities decoded. Angle brackets 139 * that were text in the feed stay escaped, so a headline such as 140 * "The <dialog> element" is not stripped as a tag later. 141 * 142 * @param string $value Escaped feed field. 143 */ 144 private static function plain_text( string $value ): string { 145 $value = self::decode( sanitize_text_field( $value ) ); 146 147 return sanitize_text_field( str_replace( array( '<', '>' ), array( '<', '>' ), $value ) ); 148 } 149 150 /** 129 151 * A plain-text, length-capped excerpt of an item's description. Never the 130 152 * full content: the AI writes original commentary from a short summary. … … 209 231 array( 210 232 'post_type' => Post_Type::POST_TYPE, 211 'post_status' => 'any',212 'posts_per_page' => count( $hashes ),233 'post_status' => array( 'any', 'trash' ), 234 'posts_per_page' => -1, 213 235 'fields' => 'ids', 214 236 'no_found_rows' => true, -
blurbwing/trunk/includes/class-pipeline.php
r3707991 r3833293 92 92 } 93 93 94 $generated = Ai::generate( $item, (array) $settings['platforms'] ); 95 96 if ( is_wp_error( $generated ) ) { 97 $summary['errors'][] = $generated->get_error_message(); 98 continue; 94 try { 95 $generated = Ai::generate( $item, (array) $settings['platforms'] ); 96 97 if ( is_wp_error( $generated ) ) { 98 $summary['errors'][] = $generated->get_error_message(); 99 continue; 100 } 101 102 $meta = $generated['meta']; 103 $spent += (int) $meta['tokens_in'] + (int) $meta['tokens_out']; 104 $summary['tokens_in'] += (int) $meta['tokens_in']; 105 $summary['tokens_out'] += (int) $meta['tokens_out']; 106 $summary['model'] = '' !== $meta['model'] ? $meta['model'] : $summary['model']; 107 $summary['provider'] = '' !== $meta['provider'] ? $meta['provider'] : $summary['provider']; 108 109 $created = self::store_item_drafts( $item, (array) $generated['data'], $meta ); 110 $summary['drafts_created'] += count( $created ); 111 } catch ( \Throwable $e ) { 112 $summary['errors'][] = $e->getMessage(); 99 113 } 100 101 $meta = $generated['meta'];102 $spent += (int) $meta['tokens_in'] + (int) $meta['tokens_out'];103 $summary['tokens_in'] += (int) $meta['tokens_in'];104 $summary['tokens_out'] += (int) $meta['tokens_out'];105 $summary['model'] = '' !== $meta['model'] ? $meta['model'] : $summary['model'];106 $summary['provider'] = '' !== $meta['provider'] ? $meta['provider'] : $summary['provider'];107 108 $created = self::store_item_drafts( $item, (array) $generated['data'], $meta );109 $summary['drafts_created'] += count( $created );110 114 } 111 115 … … 299 303 * 300 304 * No outbound request is made until an administrator has saved the 301 * settings and WordPress has an AI provider to write with. 305 * settings, WordPress has an AI provider to write with and at least one 306 * platform is selected. 302 307 */ 303 308 public static function outbound_block(): ?WP_Error { … … 308 313 if ( ! Ai::is_available() ) { 309 314 return new WP_Error( 'blurbwing_no_provider', __( 'Connect an AI provider under Settings → Connectors first.', 'blurbwing' ) ); 315 } 316 317 if ( ! Settings::platforms() ) { 318 return new WP_Error( 'blurbwing_no_platforms', __( 'No platforms selected.', 'blurbwing' ) ); 310 319 } 311 320 -
blurbwing/trunk/includes/class-post-type.php
r3707991 r3833293 75 75 self::POST_TYPE, 76 76 array( 77 'labels' => array(77 'labels' => array( 78 78 'name' => __( 'Drafts', 'blurbwing' ), 79 79 'singular_name' => __( 'Draft', 'blurbwing' ), … … 88 88 'all_items' => __( 'Drafts', 'blurbwing' ), 89 89 ), 90 'public' => false, 91 'show_ui' => true, 92 'show_in_menu' => true, 93 'show_in_rest' => true, 94 'menu_icon' => 'dashicons-megaphone', 95 'menu_position' => 26, 96 'supports' => array( 'title', 'editor', 'author', 'revisions', 'custom-fields' ), 97 'capability_type' => 'post', 98 'map_meta_cap' => true, 99 'has_archive' => false, 100 'rewrite' => false, 101 'query_var' => false, 90 'public' => false, 91 'show_ui' => true, 92 'show_in_menu' => true, 93 'show_in_rest' => true, 94 'rest_controller_class' => Rest_Drafts_Controller::class, 95 'menu_icon' => 'dashicons-megaphone', 96 'menu_position' => 26, 97 'supports' => array( 'title', 'editor', 'author', 'revisions', 'custom-fields' ), 98 'capability_type' => 'post', 99 'map_meta_cap' => true, 100 'has_archive' => false, 101 'rewrite' => false, 102 'query_var' => false, 102 103 ) 103 104 ); -
blurbwing/trunk/includes/class-rest.php
r3707991 r3833293 17 17 final class Rest { 18 18 19 public const NAMESPACE = 'blurbwing/v1';19 public const ROUTE_NAMESPACE = 'blurbwing/v1'; 20 20 21 21 /** … … 24 24 public static function register_routes(): void { 25 25 register_rest_route( 26 self:: NAMESPACE,26 self::ROUTE_NAMESPACE, 27 27 '/run', 28 28 array( … … 34 34 35 35 register_rest_route( 36 self:: NAMESPACE,36 self::ROUTE_NAMESPACE, 37 37 '/draft/(?P<id>\d+)/state', 38 38 array( … … 55 55 56 56 register_rest_route( 57 self:: NAMESPACE,57 self::ROUTE_NAMESPACE, 58 58 '/erase', 59 59 array( … … 65 65 66 66 register_rest_route( 67 self:: NAMESPACE,67 self::ROUTE_NAMESPACE, 68 68 '/draft/(?P<id>\d+)/copy', 69 69 array( -
blurbwing/trunk/includes/class-settings.php
r3707991 r3833293 208 208 'blurbwingRun', 209 209 array( 210 'path' => '/' . Rest:: NAMESPACE . '/run',211 'erasePath' => '/' . Rest:: NAMESPACE . '/erase',210 'path' => '/' . Rest::ROUTE_NAMESPACE . '/run', 211 'erasePath' => '/' . Rest::ROUTE_NAMESPACE . '/erase', 212 212 'nonce' => wp_create_nonce( 'wp_rest' ), 213 213 'running' => __( 'Running…', 'blurbwing' ), … … 256 256 $per_run = max( 1, min( self::MAX_PER_RUN, (int) ( $input['drafts_per_run'] ?? $defaults['drafts_per_run'] ) ) ); 257 257 258 $budget = max( 0, min( 10000000, (int) ( $input['budget_tokens'] ?? $defaults['budget_tokens'] ) ) ); 258 $budget = $input['budget_tokens'] ?? ''; 259 $budget = is_scalar( $budget ) && '' !== trim( (string) $budget ) ? (int) $budget : $defaults['budget_tokens']; 260 $budget = max( 0, min( 10000000, $budget ) ); 259 261 260 262 return array( -
blurbwing/trunk/languages/blurbwing.pot
r3707991 r3833293 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Blurbwing 0.1. 0\n"5 "Project-Id-Version: Blurbwing 0.1.1\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/blurbwing\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026- 09-21T17:21:21+00:00\n"12 "POT-Creation-Date: 2026-11-29T15:32:22+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 82 82 83 83 #: includes/class-ai.php:146 84 #: includes/class-pipeline.php:318 84 85 msgid "No platforms selected." 85 86 msgstr "" … … 93 94 msgstr "" 94 95 95 #: includes/class-ai.php:2 0996 #: includes/class-ai.php:213 96 97 msgid "The AI response was not valid JSON." 97 98 msgstr "" … … 113 114 msgstr "" 114 115 115 #: includes/class-pipeline.php:3 05116 #: includes/class-pipeline.php:310 116 117 msgid "Choose your topics and save the settings before the first run." 117 118 msgstr "" 118 119 119 #: includes/class-pipeline.php:3 09120 #: includes/class-pipeline.php:314 120 121 msgid "Connect an AI provider under Settings → Connectors first." 121 122 msgstr "" … … 166 167 msgstr "" 167 168 168 #: includes/class-post-type.php:11 5169 #: includes/class-settings.php:32 6169 #: includes/class-post-type.php:116 170 #: includes/class-settings.php:328 170 171 msgid "Platforms" 171 172 msgstr "" 172 173 173 #: includes/class-post-type.php:11 6174 #: includes/class-post-type.php:117 174 175 msgid "Platform" 175 176 msgstr "" 176 177 177 #: includes/class-post-type.php:13 1178 #: includes/class-settings.php:31 2178 #: includes/class-post-type.php:132 179 #: includes/class-settings.php:314 179 180 msgid "Topics" 180 181 msgstr "" 181 182 182 #: includes/class-post-type.php:13 2183 #: includes/class-post-type.php:133 183 184 msgid "Topic" 184 185 msgstr "" … … 235 236 236 237 #: includes/class-settings.php:180 237 #: includes/class-settings.php:30 7238 #: includes/class-settings.php:309 238 239 msgid "Blurbwing Settings" 239 240 msgstr "" … … 263 264 msgstr "" 264 265 265 #: includes/class-settings.php:32 1266 #: includes/class-settings.php:323 266 267 msgid "Each topic bundles a set of curated feeds." 267 268 msgstr "" 268 269 269 #: includes/class-settings.php:33 5270 #: includes/class-settings.php:337 270 271 msgid "A draft is generated for each selected platform." 271 272 msgstr "" 272 273 273 #: includes/class-settings.php:34 0274 #: includes/class-settings.php:342 274 275 msgid "Custom feeds" 275 276 msgstr "" 276 277 277 #: includes/class-settings.php:34 3278 #: includes/class-settings.php:345 278 279 msgid "One RSS or Atom feed URL per line. These are polled in addition to your topics." 279 280 msgstr "" 280 281 281 #: includes/class-settings.php:34 7282 #: includes/class-settings.php:349 282 283 msgid "Run time" 283 284 msgstr "" 284 285 285 286 #. translators: %s: site timezone 286 #: includes/class-settings.php:35 5287 #: includes/class-settings.php:357 287 288 #, php-format 288 289 msgid "Daily, in the site timezone (%s)." 289 290 msgstr "" 290 291 291 #: includes/class-settings.php:36 4292 #: includes/class-settings.php:366 292 293 msgid "Drafts per run" 293 294 msgstr "" 294 295 295 #: includes/class-settings.php:36 7296 #: includes/class-settings.php:369 296 297 msgid "How many source items become drafts each run." 297 298 msgstr "" 298 299 299 #: includes/class-settings.php:37 1300 #: includes/class-settings.php:373 300 301 msgid "Daily token budget" 301 302 msgstr "" 302 303 303 #: includes/class-settings.php:37 4304 #: includes/class-settings.php:376 304 305 msgid "A run stops once this many tokens have been spent today. 0 removes the cap, which is not recommended." 305 306 msgstr "" 306 307 307 #: includes/class-settings.php:38 2308 #: includes/class-settings.php:384 308 309 msgid "Schedule" 309 310 msgstr "" 310 311 311 #: includes/class-settings.php:385 312 #: includes/class-settings.php:387 313 #: includes/class-settings.php:390 314 msgid "Run now" 315 msgstr "" 316 312 317 #: includes/class-settings.php:388 313 msgid "Run now"314 msgstr ""315 316 #: includes/class-settings.php:386317 318 msgid "Generate drafts immediately instead of waiting for the daily run." 318 319 msgstr "" 319 320 320 #: includes/class-settings.php:39 5321 #: includes/class-settings.php:397 321 322 msgid "Export" 322 323 msgstr "" 323 324 324 #: includes/class-settings.php:39 6325 #: includes/class-settings.php:398 325 326 msgid "Download every draft as a file." 326 327 msgstr "" 327 328 328 #: includes/class-settings.php: 398329 #: includes/class-settings.php:400 329 330 msgid "Export CSV" 330 331 msgstr "" 331 332 332 #: includes/class-settings.php: 399333 #: includes/class-settings.php:401 333 334 msgid "Export JSON" 334 335 msgstr "" 335 336 336 #: includes/class-settings.php:403 337 #: includes/class-settings.php:405 338 #: includes/class-settings.php:408 339 msgid "Delete all data" 340 msgstr "" 341 337 342 #: includes/class-settings.php:406 338 msgid "Delete all data"339 msgstr ""340 341 #: includes/class-settings.php:404342 343 msgid "Permanently deletes every draft, its terms, the run log and all settings. This cannot be undone. The plugin stays active." 343 344 msgstr "" 344 345 345 346 #. translators: %s: date and time of the next run 346 #: includes/class-settings.php:42 3347 #: includes/class-settings.php:425 347 348 #, php-format 348 349 msgid "Next run: %s (site timezone)." 349 350 msgstr "" 350 351 351 #: includes/class-settings.php:4 28352 #: includes/class-settings.php:430 352 353 msgid "No run is scheduled yet. Save the settings to schedule one." 353 354 msgstr "" 354 355 355 #: includes/class-settings.php:43 3356 #: includes/class-settings.php:435 356 357 msgid "WP-Cron is disabled on this site (DISABLE_WP_CRON). Scheduled runs will not fire on their own. Add a system cron entry like this:" 357 358 msgstr "" 358 359 359 #: includes/class-settings.php:43 6360 #: includes/class-settings.php:438 360 361 msgid "WP-Cron fires on site traffic, so a very quiet site may run late. A system cron entry makes it reliable." 361 362 msgstr "" 362 363 363 #: includes/class-settings.php:45 0364 #: includes/class-settings.php:452 364 365 msgid "Recent runs" 365 366 msgstr "" 366 367 367 #: includes/class-settings.php:45 2368 #: includes/class-settings.php:454 368 369 msgid "When" 369 370 msgstr "" 370 371 371 #: includes/class-settings.php:45 2372 #: includes/class-settings.php:454 372 373 msgid "Seen" 373 374 msgstr "" 374 375 375 #: includes/class-settings.php:45 2376 #: includes/class-settings.php:454 376 377 msgid "Created" 377 378 msgstr "" 378 379 379 #: includes/class-settings.php:45 2380 #: includes/class-settings.php:454 380 381 msgid "Tokens" 381 382 msgstr "" 382 383 383 #: includes/class-settings.php:45 2384 #: includes/class-settings.php:454 384 385 msgid "Model" 385 386 msgstr "" 386 387 387 #: includes/class-settings.php:45 2388 #: includes/class-settings.php:454 388 389 msgid "Notes" 389 390 msgstr "" -
blurbwing/trunk/readme.txt
r3707991 r3833293 3 3 Tags: social media, drafts, ai, rss, content 4 4 Requires at least: 7.0 5 Tested up to: 7. 15 Tested up to: 7.2 6 6 Requires PHP: 8.1 7 Stable tag: 0.1. 07 Stable tag: 0.1.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 116 116 == Changelog == 117 117 118 = 0.1.1 = 119 * Tested with WordPress 7.2 and PHP 8.6; removes a PHP 8.6 deprecation notice. 120 * Security: a draft that had been published was readable through the REST API by anyone. Reading a draft now takes the same permission as editing it. 121 * Fixed: Copy and Export returned HTML entities (`'`, `&`) instead of the characters themselves; the editor's character count is accurate again. 122 * Fixed: stories that were already drafted, or whose draft was trashed, could be drafted again on a later run. 123 * Fixed: one unusable AI response stopped the whole run without a log entry. The run now records the error and carries on. 124 * Fixed: feed links and titles containing `&` were stored HTML-encoded, which broke links with more than one query parameter. 125 * Fixed: a run no longer fetches feeds when no platform is selected, an empty token budget falls back to the default instead of unlimited, and "Run now" keeps its message on screen when a run is blocked. 126 * Fixed: uninstall and "Delete all data" now also remove platform and topic terms and notice dismissals. 127 118 128 = 0.1.0 = 119 129 * First release: scheduled AI drafting from RSS topics, per-platform drafts, ranking pass, token budget, run log, editor sidebar, copy button, and developer hooks. -
blurbwing/trunk/uninstall.php
r3707991 r3833293 9 9 10 10 require_once __DIR__ . '/includes/class-post-type.php'; 11 require_once __DIR__ . '/includes/class-provider-notice.php'; 11 12 require_once __DIR__ . '/includes/class-settings.php'; 12 13 require_once __DIR__ . '/includes/class-pipeline.php'; … … 14 15 require_once __DIR__ . '/includes/class-data.php'; 15 16 17 // The plugin is not loaded here: core cannot find or detach terms of an unregistered taxonomy. 18 Blurbwing\Post_Type::register_post_type(); 19 Blurbwing\Post_Type::register_taxonomies(); 20 16 21 Blurbwing\Data::erase();
Note:
See TracChangeset
for help on using the changeset viewer.