Changeset 3776243
- Timestamp:
- 10/31/2026 01:17:29 AM (4 weeks ago)
- Location:
- aim-blog-engine
- Files:
-
- 2 added
- 6 edited
- 1 copied
-
tags/0.1.8 (copied) (copied from aim-blog-engine/trunk )
-
tags/0.1.8/aim-blog-engine.php (modified) (3 diffs)
-
tags/0.1.8/includes/class-aim-be-publisher.php (modified) (4 diffs)
-
tags/0.1.8/includes/class-aim-be-seo.php (added)
-
tags/0.1.8/readme.txt (modified) (2 diffs)
-
trunk/aim-blog-engine.php (modified) (3 diffs)
-
trunk/includes/class-aim-be-publisher.php (modified) (4 diffs)
-
trunk/includes/class-aim-be-seo.php (added)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
aim-blog-engine/tags/0.1.8/aim-blog-engine.php
r3708051 r3776243 4 4 * Plugin URI: https://apps.aimarketingacademy.com 5 5 * Description: Publishes blog posts created in your AiM Blog Engine account to this site as drafts you review. The plugin connects OUTBOUND to your AiM account, so it works even when your site blocks inbound REST access (e.g. behind Cloudflare). 6 * Version: 0.1. 66 * Version: 0.1.8 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 22 22 } 23 23 24 define( 'AIM_BE_VERSION', '0.1. 6' );24 define( 'AIM_BE_VERSION', '0.1.8' ); 25 25 define( 'AIM_BE_FILE', __FILE__ ); 26 26 define( 'AIM_BE_DIR', plugin_dir_path( __FILE__ ) ); … … 46 46 require_once AIM_BE_DIR . 'includes/class-aim-be-api.php'; 47 47 require_once AIM_BE_DIR . 'includes/class-aim-be-publisher.php'; 48 require_once AIM_BE_DIR . 'includes/class-aim-be-seo.php'; 48 49 require_once AIM_BE_DIR . 'includes/class-aim-be-settings.php'; 49 50 -
aim-blog-engine/tags/0.1.8/includes/class-aim-be-publisher.php
r3687444 r3776243 31 31 * @type string $image_url Optional featured image URL. 32 32 * @type string $status Desired status: 'draft' (default) or 'publish'. 33 * @type string $blog_category Optional. The member's blog category name (0.1.7+). 34 * @type array $categories Optional. Suggested category names; only existing ones are used. 35 * @type array $tags Optional. Tag names. 36 * @type string $seo_title Optional. SEO title (0.1.8+). 37 * @type string $seo_description Optional. Meta description (0.1.8+). 38 * @type string $focus_keyword Optional. Focus keyphrase (0.1.8+). 39 * @type array $schema Optional. JSON-LD objects for the post (0.1.8+). 40 * @type array $schema_local_business Optional. LocalBusiness JSON-LD (0.1.8+). 33 41 * } 34 42 * @return array { blog_id, post_id, post_url, status } for the ack call. … … 64 72 } 65 73 if ( $existing_id ) { 74 // An update leaves categories and tags alone (WordPress keeps them when 75 // they aren't passed), so a category the member added by hand stays. 66 76 $postarr['ID'] = $existing_id; 77 } else { 78 // New post: the blog category plus any suggested category the site 79 // already has (never created), and the tags. 80 $category_ids = $this->category_ids( $item ); 81 if ( ! empty( $category_ids ) ) { 82 $postarr['post_category'] = $category_ids; 83 } 84 if ( ! empty( $item['tags'] ) && is_array( $item['tags'] ) ) { 85 $postarr['tags_input'] = array_values( array_filter( array_map( 'sanitize_text_field', $item['tags'] ) ) ); 86 } 67 87 } 68 88 … … 81 101 82 102 update_post_meta( $post_id, '_aim_blog_id', $blog_id ); 103 Aim_Be_Seo::store( $post_id, $item ); 83 104 84 105 if ( ! empty( $item['image_url'] ) ) { … … 92 113 'status' => get_post_status( $post_id ), 93 114 ); 115 } 116 117 /** 118 * Names a site's blog category usually goes by, most specific first. Must 119 * match BLOG_CATEGORY_NAMES in the app (lib/blog-engine/cms/wp-categories.ts). 120 * 121 * @var string[] 122 */ 123 const BLOG_CATEGORY_NAMES = array( 'Blog', 'Blogs', 'News', 'Articles', 'Article', 'Insights', 'Posts' ); 124 125 /** 126 * Category ids for a new post: the member's blog category (or, when it is 127 * empty or no longer exists here, this site's blog-like category) plus any 128 * suggested category that already exists. Nothing is ever created, and 129 * Uncategorized is never chosen. With none, WordPress applies its default. 130 * 131 * @param array $item Post payload from /pending. 132 * @return int[] Category term ids. 133 */ 134 private function category_ids( $item ) { 135 $ids = array(); 136 $blog = $this->find_category( isset( $item['blog_category'] ) ? $item['blog_category'] : '' ); 137 if ( ! $blog ) { 138 foreach ( self::BLOG_CATEGORY_NAMES as $name ) { 139 $blog = $this->find_category( $name ); 140 if ( $blog ) { 141 break; 142 } 143 } 144 } 145 if ( $blog ) { 146 $ids[] = $blog; 147 } 148 if ( ! empty( $item['categories'] ) && is_array( $item['categories'] ) ) { 149 foreach ( $item['categories'] as $name ) { 150 $id = $this->find_category( $name ); 151 if ( $id && ! in_array( $id, $ids, true ) ) { 152 $ids[] = $id; 153 } 154 } 155 } 156 return $ids; 157 } 158 159 /** 160 * An existing category by name, ignoring case and HTML escaping. 161 * 162 * @param string $name Category name. 163 * @return int Term id, or 0 when the site has no such category (or it is Uncategorized). 164 */ 165 private function find_category( $name ) { 166 $name = is_string( $name ) ? trim( wp_specialchars_decode( $name, ENT_QUOTES ) ) : ''; 167 if ( '' === $name ) { 168 return 0; 169 } 170 $term = get_term_by( 'name', $name, 'category' ); 171 if ( ! $term ) { 172 // get_term_by() matches the stored name, which WordPress keeps escaped. 173 $term = get_term_by( 'name', esc_html( $name ), 'category' ); 174 } 175 if ( ! $term || 'uncategorized' === $term->slug ) { 176 return 0; 177 } 178 return (int) $term->term_id; 94 179 } 95 180 -
aim-blog-engine/tags/0.1.8/readme.txt
r3708051 r3776243 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 0.1. 67 Stable tag: 0.1.8 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 54 54 == Changelog == 55 55 56 = 0.1.8 = 57 * New: each post arrives with its SEO title, meta description and schema markup (structured data), the details that help it show up in Google and AI answers. The schema is added to the post's page automatically. 58 * With Yoast SEO or Rank Math, the SEO title, meta description and focus keyphrase fill that plugin's fields when they're empty, so anything you've written there yourself stays. 59 * Without an SEO plugin, the post's page gets its meta description and SEO title directly. 60 61 = 0.1.7 = 62 * New posts go in your blog category, so they appear on your blog page. It's the category you choose in AiM, or your site's own "Blog" (or "News", "Articles") category when you haven't chosen one. 63 * Suggested categories are added only when your site already has them; the plugin never creates categories. 64 * Posts arrive with their tags. 65 * Updating a post never changes its categories, so categories you add yourself stay put. 66 56 67 = 0.1.6 = 57 68 * New: posts now arrive within seconds instead of waiting for the next scheduled check. AiM tells your site when something is ready, so delivery no longer depends on your site getting a visitor to trigger WordPress's scheduler. -
aim-blog-engine/trunk/aim-blog-engine.php
r3708051 r3776243 4 4 * Plugin URI: https://apps.aimarketingacademy.com 5 5 * Description: Publishes blog posts created in your AiM Blog Engine account to this site as drafts you review. The plugin connects OUTBOUND to your AiM account, so it works even when your site blocks inbound REST access (e.g. behind Cloudflare). 6 * Version: 0.1. 66 * Version: 0.1.8 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 22 22 } 23 23 24 define( 'AIM_BE_VERSION', '0.1. 6' );24 define( 'AIM_BE_VERSION', '0.1.8' ); 25 25 define( 'AIM_BE_FILE', __FILE__ ); 26 26 define( 'AIM_BE_DIR', plugin_dir_path( __FILE__ ) ); … … 46 46 require_once AIM_BE_DIR . 'includes/class-aim-be-api.php'; 47 47 require_once AIM_BE_DIR . 'includes/class-aim-be-publisher.php'; 48 require_once AIM_BE_DIR . 'includes/class-aim-be-seo.php'; 48 49 require_once AIM_BE_DIR . 'includes/class-aim-be-settings.php'; 49 50 -
aim-blog-engine/trunk/includes/class-aim-be-publisher.php
r3687444 r3776243 31 31 * @type string $image_url Optional featured image URL. 32 32 * @type string $status Desired status: 'draft' (default) or 'publish'. 33 * @type string $blog_category Optional. The member's blog category name (0.1.7+). 34 * @type array $categories Optional. Suggested category names; only existing ones are used. 35 * @type array $tags Optional. Tag names. 36 * @type string $seo_title Optional. SEO title (0.1.8+). 37 * @type string $seo_description Optional. Meta description (0.1.8+). 38 * @type string $focus_keyword Optional. Focus keyphrase (0.1.8+). 39 * @type array $schema Optional. JSON-LD objects for the post (0.1.8+). 40 * @type array $schema_local_business Optional. LocalBusiness JSON-LD (0.1.8+). 33 41 * } 34 42 * @return array { blog_id, post_id, post_url, status } for the ack call. … … 64 72 } 65 73 if ( $existing_id ) { 74 // An update leaves categories and tags alone (WordPress keeps them when 75 // they aren't passed), so a category the member added by hand stays. 66 76 $postarr['ID'] = $existing_id; 77 } else { 78 // New post: the blog category plus any suggested category the site 79 // already has (never created), and the tags. 80 $category_ids = $this->category_ids( $item ); 81 if ( ! empty( $category_ids ) ) { 82 $postarr['post_category'] = $category_ids; 83 } 84 if ( ! empty( $item['tags'] ) && is_array( $item['tags'] ) ) { 85 $postarr['tags_input'] = array_values( array_filter( array_map( 'sanitize_text_field', $item['tags'] ) ) ); 86 } 67 87 } 68 88 … … 81 101 82 102 update_post_meta( $post_id, '_aim_blog_id', $blog_id ); 103 Aim_Be_Seo::store( $post_id, $item ); 83 104 84 105 if ( ! empty( $item['image_url'] ) ) { … … 92 113 'status' => get_post_status( $post_id ), 93 114 ); 115 } 116 117 /** 118 * Names a site's blog category usually goes by, most specific first. Must 119 * match BLOG_CATEGORY_NAMES in the app (lib/blog-engine/cms/wp-categories.ts). 120 * 121 * @var string[] 122 */ 123 const BLOG_CATEGORY_NAMES = array( 'Blog', 'Blogs', 'News', 'Articles', 'Article', 'Insights', 'Posts' ); 124 125 /** 126 * Category ids for a new post: the member's blog category (or, when it is 127 * empty or no longer exists here, this site's blog-like category) plus any 128 * suggested category that already exists. Nothing is ever created, and 129 * Uncategorized is never chosen. With none, WordPress applies its default. 130 * 131 * @param array $item Post payload from /pending. 132 * @return int[] Category term ids. 133 */ 134 private function category_ids( $item ) { 135 $ids = array(); 136 $blog = $this->find_category( isset( $item['blog_category'] ) ? $item['blog_category'] : '' ); 137 if ( ! $blog ) { 138 foreach ( self::BLOG_CATEGORY_NAMES as $name ) { 139 $blog = $this->find_category( $name ); 140 if ( $blog ) { 141 break; 142 } 143 } 144 } 145 if ( $blog ) { 146 $ids[] = $blog; 147 } 148 if ( ! empty( $item['categories'] ) && is_array( $item['categories'] ) ) { 149 foreach ( $item['categories'] as $name ) { 150 $id = $this->find_category( $name ); 151 if ( $id && ! in_array( $id, $ids, true ) ) { 152 $ids[] = $id; 153 } 154 } 155 } 156 return $ids; 157 } 158 159 /** 160 * An existing category by name, ignoring case and HTML escaping. 161 * 162 * @param string $name Category name. 163 * @return int Term id, or 0 when the site has no such category (or it is Uncategorized). 164 */ 165 private function find_category( $name ) { 166 $name = is_string( $name ) ? trim( wp_specialchars_decode( $name, ENT_QUOTES ) ) : ''; 167 if ( '' === $name ) { 168 return 0; 169 } 170 $term = get_term_by( 'name', $name, 'category' ); 171 if ( ! $term ) { 172 // get_term_by() matches the stored name, which WordPress keeps escaped. 173 $term = get_term_by( 'name', esc_html( $name ), 'category' ); 174 } 175 if ( ! $term || 'uncategorized' === $term->slug ) { 176 return 0; 177 } 178 return (int) $term->term_id; 94 179 } 95 180 -
aim-blog-engine/trunk/readme.txt
r3708051 r3776243 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 0.1. 67 Stable tag: 0.1.8 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 54 54 == Changelog == 55 55 56 = 0.1.8 = 57 * New: each post arrives with its SEO title, meta description and schema markup (structured data), the details that help it show up in Google and AI answers. The schema is added to the post's page automatically. 58 * With Yoast SEO or Rank Math, the SEO title, meta description and focus keyphrase fill that plugin's fields when they're empty, so anything you've written there yourself stays. 59 * Without an SEO plugin, the post's page gets its meta description and SEO title directly. 60 61 = 0.1.7 = 62 * New posts go in your blog category, so they appear on your blog page. It's the category you choose in AiM, or your site's own "Blog" (or "News", "Articles") category when you haven't chosen one. 63 * Suggested categories are added only when your site already has them; the plugin never creates categories. 64 * Posts arrive with their tags. 65 * Updating a post never changes its categories, so categories you add yourself stay put. 66 56 67 = 0.1.6 = 57 68 * New: posts now arrive within seconds instead of waiting for the next scheduled check. AiM tells your site when something is ready, so delivery no longer depends on your site getting a visitor to trigger WordPress's scheduler.
Note:
See TracChangeset
for help on using the changeset viewer.