Changeset 3743334
- Timestamp:
- 10/13/2026 09:00:03 AM (5 weeks ago)
- Location:
- getautoseo-ai-content-publisher
- Files:
-
- 8 edited
- 1 copied
-
tags/1.3.116 (copied) (copied from getautoseo-ai-content-publisher/trunk )
-
tags/1.3.116/autoseo.php (modified) (3 diffs)
-
tags/1.3.116/includes/class-autoseo-api.php (modified) (1 diff)
-
tags/1.3.116/includes/class-autoseo-publisher.php (modified) (3 diffs)
-
tags/1.3.116/readme.txt (modified) (2 diffs)
-
trunk/autoseo.php (modified) (3 diffs)
-
trunk/includes/class-autoseo-api.php (modified) (1 diff)
-
trunk/includes/class-autoseo-publisher.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
getautoseo-ai-content-publisher/tags/1.3.116/autoseo.php
r3734214 r3743334 4 4 * Plugin URI: https://getautoseo.com 5 5 * Description: Automate your SEO content creation and publishing with AI-powered tools. Generate high-quality articles, optimize for search engines, and publish directly to your WordPress site. 6 * Version: 1.3.11 56 * Version: 1.3.116 7 7 * Author: GetAutoSEO Team 8 8 * License: GPL v2 or later … … 21 21 22 22 // Define plugin constants 23 define('AUTOSEO_VERSION', '1.3.11 5');23 define('AUTOSEO_VERSION', '1.3.116'); 24 24 define('AUTOSEO_PLUGIN_DIR', plugin_dir_path(__FILE__)); 25 25 define('AUTOSEO_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 3709 3709 } 3710 3710 3711 // The hero path does not bake content, but attachment hooks can still 3712 // change tags. Restore the AutoSEO list after either image type. 3713 AutoSEO_Publisher::reapply_stored_tags($post_id); 3714 3711 3715 return rest_ensure_response(array( 3712 3716 'success' => true, -
getautoseo-ai-content-publisher/tags/1.3.116/includes/class-autoseo-api.php
r3734214 r3743334 866 866 && !$force_content_update 867 867 ) { 868 // Content is unchanged, but a later image save can replace 869 // tags. Apply the AutoSEO tag list without rewriting the post. 870 if (!empty($article['wordpress_tags'])) { 871 AutoSEO_Publisher::sync_tags_if_different($wp_post->ID, $article['wordpress_tags']); 872 } 873 868 874 if ($needs_url_confirmation) { 869 875 $publisher = new AutoSEO_Publisher(); -
getautoseo-ai-content-publisher/tags/1.3.116/includes/class-autoseo-publisher.php
r3734214 r3743334 15 15 private static $batch_mode = false; 16 16 private static $batched_webhooks = array(); 17 private static $pending_tag_sync = array(); 18 private static $tag_shutdown_registered = false; 17 19 18 20 private $seo_owned_titles = array(); … … 728 730 AutoSEO_Plugin::disallow_content_updates(); 729 731 } 732 733 // wp_update_post runs save_post. Another plugin can replace tags there. 734 self::reapply_stored_tags($post_id); 730 735 731 736 $this->log_debug(sprintf('Baked infographic into post_content for post %d', $post_id)); … … 2069 2074 */ 2070 2075 private function set_wordpress_tags($post_id, $article) { 2071 // Skip if no tags available2072 2076 if (empty($article->wordpress_tags)) { 2073 2077 return; 2074 2078 } 2075 2079 2076 // Parse comma-separated tags 2077 $tags_array = array_map('trim', explode(',', $article->wordpress_tags)); 2078 $tags_array = array_filter($tags_array); // Remove empty values 2079 2080 if (empty($tags_array)) { 2081 return; 2082 } 2083 2084 // Set the tags on the post (wp_set_post_tags will create tags if they don't exist) 2085 $result = wp_set_post_tags($post_id, $tags_array, false); // false = replace existing tags 2080 self::sync_tags_if_different($post_id, $article->wordpress_tags); 2081 } 2082 2083 /** 2084 * Replace the post's tags when they are not the AutoSEO list. 2085 * 2086 * A later save in the same request (infographic bake, another plugin's 2087 * save_post or shutdown hook) can replace these tags. The list is applied 2088 * again at the end of the request. 2089 * 2090 * @param int $post_id WordPress post ID 2091 * @param string $tag_string Comma-separated AutoSEO tags 2092 */ 2093 public static function sync_tags_if_different($post_id, $tag_string) { 2094 $post_id = (int) $post_id; 2095 $desired = self::parse_tag_list($tag_string); 2096 if ($post_id <= 0 || empty($desired)) { 2097 return; 2098 } 2099 2100 $current = wp_get_post_tags($post_id, array('fields' => 'names')); 2101 if (!is_array($current)) { 2102 $current = array(); 2103 } 2104 2105 if (self::tag_lists_match($current, $desired)) { 2106 update_post_meta($post_id, '_autoseo_wordpress_tags', $tag_string); 2107 return; 2108 } 2109 2110 $result = wp_set_post_tags($post_id, $desired, false); 2086 2111 2087 2112 if (is_wp_error($result)) { 2088 $this->log_debug(sprintf(2089 ' Failed to set tags for post %d: %s',2113 error_log(sprintf( 2114 '[AutoSEO Publisher] Failed to set tags for post %d: %s', 2090 2115 $post_id, 2091 2116 $result->get_error_message() 2092 2117 )); 2093 } else { 2094 $this->log_debug(sprintf( 2095 'Set %d tags for post %d: %s', 2096 count($tags_array), 2097 $post_id, 2098 implode(', ', $tags_array) 2099 )); 2100 } 2101 2102 // Store the original tags in post meta for reference 2103 update_post_meta($post_id, '_autoseo_wordpress_tags', $article->wordpress_tags); 2118 return; 2119 } 2120 2121 update_post_meta($post_id, '_autoseo_wordpress_tags', $tag_string); 2122 self::$pending_tag_sync[$post_id] = $tag_string; 2123 2124 if (!self::$tag_shutdown_registered) { 2125 self::$tag_shutdown_registered = true; 2126 add_action('shutdown', array(__CLASS__, 'reapply_pending_tags'), PHP_INT_MAX); 2127 } 2128 } 2129 2130 /** 2131 * Put AutoSEO tags back after other plugins run on shutdown. 2132 */ 2133 public static function reapply_pending_tags() { 2134 $pending = self::$pending_tag_sync; 2135 self::$pending_tag_sync = array(); 2136 2137 foreach ($pending as $post_id => $tag_string) { 2138 $desired = self::parse_tag_list($tag_string); 2139 if (empty($desired)) { 2140 continue; 2141 } 2142 $current = wp_get_post_tags((int) $post_id, array('fields' => 'names')); 2143 if (!is_array($current) || self::tag_lists_match($current, $desired)) { 2144 continue; 2145 } 2146 wp_set_post_tags((int) $post_id, $desired, false); 2147 update_post_meta((int) $post_id, '_autoseo_wordpress_tags', $tag_string); 2148 } 2149 } 2150 2151 /** 2152 * Restore tags stored on the post after a later content save. 2153 * 2154 * @param int $post_id WordPress post ID 2155 */ 2156 public static function reapply_stored_tags($post_id) { 2157 $tag_string = get_post_meta((int) $post_id, '_autoseo_wordpress_tags', true); 2158 if (!is_string($tag_string) || trim($tag_string) === '') { 2159 return; 2160 } 2161 self::sync_tags_if_different((int) $post_id, $tag_string); 2162 } 2163 2164 /** 2165 * @param string $tag_string Comma-separated tags 2166 * @return array 2167 */ 2168 private static function parse_tag_list($tag_string) { 2169 $tags = array_map('trim', explode(',', (string) $tag_string)); 2170 $tags = array_filter($tags, function ($tag) { 2171 return $tag !== ''; 2172 }); 2173 return array_values($tags); 2174 } 2175 2176 /** 2177 * @param array $left Tag names 2178 * @param array $right Tag names 2179 * @return bool 2180 */ 2181 private static function tag_lists_match($left, $right) { 2182 $normalize = function ($tags) { 2183 $tags = array_map(function ($tag) { 2184 return strtolower(trim((string) $tag)); 2185 }, $tags); 2186 $tags = array_values(array_filter($tags, function ($tag) { 2187 return $tag !== ''; 2188 })); 2189 sort($tags); 2190 return $tags; 2191 }; 2192 2193 return $normalize($left) === $normalize($right); 2104 2194 } 2105 2195 -
getautoseo-ai-content-publisher/tags/1.3.116/readme.txt
r3734214 r3743334 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.3.11 57 Stable tag: 1.3.116 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 112 112 113 113 == Changelog == 114 115 = 1.3.116 = 116 * FIXED: WordPress post tags from AutoSEO are applied again when a later image save replaces them. The next sync also restores tags on posts that already lost them, without rewriting the article. 114 117 115 118 = 1.3.115 = -
getautoseo-ai-content-publisher/trunk/autoseo.php
r3734214 r3743334 4 4 * Plugin URI: https://getautoseo.com 5 5 * Description: Automate your SEO content creation and publishing with AI-powered tools. Generate high-quality articles, optimize for search engines, and publish directly to your WordPress site. 6 * Version: 1.3.11 56 * Version: 1.3.116 7 7 * Author: GetAutoSEO Team 8 8 * License: GPL v2 or later … … 21 21 22 22 // Define plugin constants 23 define('AUTOSEO_VERSION', '1.3.11 5');23 define('AUTOSEO_VERSION', '1.3.116'); 24 24 define('AUTOSEO_PLUGIN_DIR', plugin_dir_path(__FILE__)); 25 25 define('AUTOSEO_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 3709 3709 } 3710 3710 3711 // The hero path does not bake content, but attachment hooks can still 3712 // change tags. Restore the AutoSEO list after either image type. 3713 AutoSEO_Publisher::reapply_stored_tags($post_id); 3714 3711 3715 return rest_ensure_response(array( 3712 3716 'success' => true, -
getautoseo-ai-content-publisher/trunk/includes/class-autoseo-api.php
r3734214 r3743334 866 866 && !$force_content_update 867 867 ) { 868 // Content is unchanged, but a later image save can replace 869 // tags. Apply the AutoSEO tag list without rewriting the post. 870 if (!empty($article['wordpress_tags'])) { 871 AutoSEO_Publisher::sync_tags_if_different($wp_post->ID, $article['wordpress_tags']); 872 } 873 868 874 if ($needs_url_confirmation) { 869 875 $publisher = new AutoSEO_Publisher(); -
getautoseo-ai-content-publisher/trunk/includes/class-autoseo-publisher.php
r3734214 r3743334 15 15 private static $batch_mode = false; 16 16 private static $batched_webhooks = array(); 17 private static $pending_tag_sync = array(); 18 private static $tag_shutdown_registered = false; 17 19 18 20 private $seo_owned_titles = array(); … … 728 730 AutoSEO_Plugin::disallow_content_updates(); 729 731 } 732 733 // wp_update_post runs save_post. Another plugin can replace tags there. 734 self::reapply_stored_tags($post_id); 730 735 731 736 $this->log_debug(sprintf('Baked infographic into post_content for post %d', $post_id)); … … 2069 2074 */ 2070 2075 private function set_wordpress_tags($post_id, $article) { 2071 // Skip if no tags available2072 2076 if (empty($article->wordpress_tags)) { 2073 2077 return; 2074 2078 } 2075 2079 2076 // Parse comma-separated tags 2077 $tags_array = array_map('trim', explode(',', $article->wordpress_tags)); 2078 $tags_array = array_filter($tags_array); // Remove empty values 2079 2080 if (empty($tags_array)) { 2081 return; 2082 } 2083 2084 // Set the tags on the post (wp_set_post_tags will create tags if they don't exist) 2085 $result = wp_set_post_tags($post_id, $tags_array, false); // false = replace existing tags 2080 self::sync_tags_if_different($post_id, $article->wordpress_tags); 2081 } 2082 2083 /** 2084 * Replace the post's tags when they are not the AutoSEO list. 2085 * 2086 * A later save in the same request (infographic bake, another plugin's 2087 * save_post or shutdown hook) can replace these tags. The list is applied 2088 * again at the end of the request. 2089 * 2090 * @param int $post_id WordPress post ID 2091 * @param string $tag_string Comma-separated AutoSEO tags 2092 */ 2093 public static function sync_tags_if_different($post_id, $tag_string) { 2094 $post_id = (int) $post_id; 2095 $desired = self::parse_tag_list($tag_string); 2096 if ($post_id <= 0 || empty($desired)) { 2097 return; 2098 } 2099 2100 $current = wp_get_post_tags($post_id, array('fields' => 'names')); 2101 if (!is_array($current)) { 2102 $current = array(); 2103 } 2104 2105 if (self::tag_lists_match($current, $desired)) { 2106 update_post_meta($post_id, '_autoseo_wordpress_tags', $tag_string); 2107 return; 2108 } 2109 2110 $result = wp_set_post_tags($post_id, $desired, false); 2086 2111 2087 2112 if (is_wp_error($result)) { 2088 $this->log_debug(sprintf(2089 ' Failed to set tags for post %d: %s',2113 error_log(sprintf( 2114 '[AutoSEO Publisher] Failed to set tags for post %d: %s', 2090 2115 $post_id, 2091 2116 $result->get_error_message() 2092 2117 )); 2093 } else { 2094 $this->log_debug(sprintf( 2095 'Set %d tags for post %d: %s', 2096 count($tags_array), 2097 $post_id, 2098 implode(', ', $tags_array) 2099 )); 2100 } 2101 2102 // Store the original tags in post meta for reference 2103 update_post_meta($post_id, '_autoseo_wordpress_tags', $article->wordpress_tags); 2118 return; 2119 } 2120 2121 update_post_meta($post_id, '_autoseo_wordpress_tags', $tag_string); 2122 self::$pending_tag_sync[$post_id] = $tag_string; 2123 2124 if (!self::$tag_shutdown_registered) { 2125 self::$tag_shutdown_registered = true; 2126 add_action('shutdown', array(__CLASS__, 'reapply_pending_tags'), PHP_INT_MAX); 2127 } 2128 } 2129 2130 /** 2131 * Put AutoSEO tags back after other plugins run on shutdown. 2132 */ 2133 public static function reapply_pending_tags() { 2134 $pending = self::$pending_tag_sync; 2135 self::$pending_tag_sync = array(); 2136 2137 foreach ($pending as $post_id => $tag_string) { 2138 $desired = self::parse_tag_list($tag_string); 2139 if (empty($desired)) { 2140 continue; 2141 } 2142 $current = wp_get_post_tags((int) $post_id, array('fields' => 'names')); 2143 if (!is_array($current) || self::tag_lists_match($current, $desired)) { 2144 continue; 2145 } 2146 wp_set_post_tags((int) $post_id, $desired, false); 2147 update_post_meta((int) $post_id, '_autoseo_wordpress_tags', $tag_string); 2148 } 2149 } 2150 2151 /** 2152 * Restore tags stored on the post after a later content save. 2153 * 2154 * @param int $post_id WordPress post ID 2155 */ 2156 public static function reapply_stored_tags($post_id) { 2157 $tag_string = get_post_meta((int) $post_id, '_autoseo_wordpress_tags', true); 2158 if (!is_string($tag_string) || trim($tag_string) === '') { 2159 return; 2160 } 2161 self::sync_tags_if_different((int) $post_id, $tag_string); 2162 } 2163 2164 /** 2165 * @param string $tag_string Comma-separated tags 2166 * @return array 2167 */ 2168 private static function parse_tag_list($tag_string) { 2169 $tags = array_map('trim', explode(',', (string) $tag_string)); 2170 $tags = array_filter($tags, function ($tag) { 2171 return $tag !== ''; 2172 }); 2173 return array_values($tags); 2174 } 2175 2176 /** 2177 * @param array $left Tag names 2178 * @param array $right Tag names 2179 * @return bool 2180 */ 2181 private static function tag_lists_match($left, $right) { 2182 $normalize = function ($tags) { 2183 $tags = array_map(function ($tag) { 2184 return strtolower(trim((string) $tag)); 2185 }, $tags); 2186 $tags = array_values(array_filter($tags, function ($tag) { 2187 return $tag !== ''; 2188 })); 2189 sort($tags); 2190 return $tags; 2191 }; 2192 2193 return $normalize($left) === $normalize($right); 2104 2194 } 2105 2195 -
getautoseo-ai-content-publisher/trunk/readme.txt
r3734214 r3743334 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.3.11 57 Stable tag: 1.3.116 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 112 112 113 113 == Changelog == 114 115 = 1.3.116 = 116 * FIXED: WordPress post tags from AutoSEO are applied again when a later image save replaces them. The next sync also restores tags on posts that already lost them, without rewriting the article. 114 117 115 118 = 1.3.115 =
Note:
See TracChangeset
for help on using the changeset viewer.