Changeset 3451876
- Timestamp:
- 02/02/2026 09:02:18 AM (3 months ago)
- Location:
- hamelp
- Files:
-
- 2 deleted
- 8 edited
- 1 copied
-
tags/2.1.0 (copied) (copied from hamelp/trunk)
-
tags/2.1.0/app/Hametuha/Hamelp/Services/FaqSearchService.php (modified) (4 diffs)
-
tags/2.1.0/hamelp.php (modified) (2 diffs)
-
tags/2.1.0/languages (deleted)
-
tags/2.1.0/readme.txt (modified) (8 diffs)
-
tags/2.1.0/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/app/Hametuha/Hamelp/Services/FaqSearchService.php (modified) (4 diffs)
-
trunk/hamelp.php (modified) (2 diffs)
-
trunk/languages (deleted)
-
trunk/readme.txt (modified) (8 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hamelp/tags/2.1.0/app/Hametuha/Hamelp/Services/FaqSearchService.php
r3447047 r3451876 15 15 */ 16 16 class FaqSearchService { 17 17 18 18 19 /** … … 145 146 } 146 147 148 $user_context = $this->get_user_context(); 149 if ( ! empty( $user_context ) ) { 150 $base .= "\n\n" . $user_context; 151 } 152 147 153 $base .= "\n\n" . 'Answer user questions based on the provided FAQ content. 148 154 … … 156 162 - Keep your response concise and helpful. 157 163 - Respond in the same language as the user question. 164 - If user information is provided, you may address them by name and tailor your response to their context (e.g., role, membership). Do not repeat their personal information back to them. 158 165 159 166 OUTPUT FORMAT: … … 172 179 return $base . "\n\n" . $context; 173 180 } 181 182 /** 183 * Get user context string for personalization. 184 * 185 * Returns empty string for logged-out users. 186 * 187 * @return string User context for system prompt, empty if not logged in. 188 */ 189 protected function get_user_context(): string { 190 $user = wp_get_current_user(); 191 if ( ! $user->exists() ) { 192 return ''; 193 } 194 195 $lines = [ 'Current user information:' ]; 196 $lines[] = sprintf( 'Display name: %s', $user->display_name ); 197 198 // Filter roles to prevent exposing internal plugin roles. 199 $display_roles = $this->get_display_roles( $user ); 200 if ( ! empty( $display_roles ) ) { 201 $lines[] = sprintf( 'Role: %s', implode( ', ', $display_roles ) ); 202 } 203 204 $lines[] = sprintf( 'Registered: %s', $user->user_registered ); 205 206 $context = implode( "\n", $lines ); 207 208 /** 209 * Filter user context included in the AI system prompt. 210 * 211 * Allows sites to add custom user-specific information 212 * (e.g., subscription status, purchase history, membership tier) 213 * that helps the AI provide personalized answers. 214 * 215 * Return an empty string to disable user personalization entirely. 216 * 217 * @param string $context The user context string. 218 * @param \WP_User $user The current WordPress user object. 219 */ 220 $context = apply_filters( 'hamelp_user_context', $context, $user ); 221 222 return is_string( $context ) ? $context : ''; 223 } 224 225 /** 226 * Get user roles filtered by whitelist for display. 227 * 228 * Filters out internal plugin roles (e.g., backup plugins) 229 * that should not be exposed to the AI. 230 * 231 * @param \WP_User $user The user object. 232 * @return string[] Filtered role names safe for display. 233 */ 234 protected function get_display_roles( \WP_User $user ): array { 235 /** 236 * Filter the list of allowed user roles to display in AI context. 237 * 238 * Only roles in this list will be shown to the AI. 239 * This prevents internal plugin roles from being exposed. 240 * 241 * @param string[] $allowed_roles List of role slugs to allow. 242 */ 243 $allowed_roles = apply_filters( 244 'hamelp_allowed_user_roles', 245 [ 246 // WordPress core roles. 247 'administrator', 248 'editor', 249 'author', 250 'contributor', 251 'subscriber', 252 // WooCommerce roles. 253 'customer', 254 'shop_manager', 255 ] 256 ); 257 258 $display_roles = array_intersect( $user->roles, $allowed_roles ); 259 260 /** 261 * Filter the user roles to be displayed in AI context. 262 * 263 * Called after whitelist filtering. Allows further customization 264 * such as translating role slugs to human-readable names. 265 * 266 * @param string[] $display_roles Roles to display (already filtered). 267 * @param \WP_User $user The user object. 268 */ 269 return apply_filters( 'hamelp_display_user_roles', $display_roles, $user ); 270 } 174 271 } -
hamelp/tags/2.1.0/hamelp.php
r3447972 r3451876 4 4 * Plugin URI: https://wordpress.org/plugins/hamelp 5 5 * Description: FAQ generator by Hametuha. 6 * Version: 2. 0.26 * Version: 2.1.0 7 7 * Author: Hametuha INC. 8 8 * Author URI: https://hametuha.co.jp … … 23 23 */ 24 24 function hamelp_init() { 25 // i18n .26 load_plugin_textdomain( 'hamelp' , false, basename( __DIR__ ) . '/languages');25 // i18n (translations are loaded from WordPress.org via GlotPress). 26 load_plugin_textdomain( 'hamelp' ); 27 27 if ( version_compare( phpversion(), '7.4.0', '>=' ) ) { 28 28 require __DIR__ . '/vendor/autoload.php'; 29 29 call_user_func( [ 'Hametuha\\Hamelp', 'get' ] ); 30 // Load development hooks (environment check is inside the file). 31 if ( file_exists( __DIR__ . '/dev/hooks.php' ) ) { 32 require_once __DIR__ . '/dev/hooks.php'; 33 } 30 34 } else { 31 35 add_action( 'admin_notices', 'hamelp_version_error' ); -
hamelp/tags/2.1.0/readme.txt
r3447972 r3451876 4 4 Tags: faq,help 5 5 Tested up to: 6.9 6 Stable Tag: 2. 0.26 Stable Tag: 2.1.0 7 7 License: GPL 3.0 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 19 19 This plugin will provide... 20 20 21 *Custom post type with single page and archive page.22 *Custom taxonomy associated to CPT.23 *Incremental search box.24 *AI Overview(Since 2.0.0)21 - Custom post type with single page and archive page. 22 - Custom taxonomy associated to CPT. 23 - Incremental search box. 24 - AI Overview(Since 2.0.0) 25 25 26 26 = AI Overview = … … 35 35 Add the **AI FAQ Overview** block in the block editor. The block has the following options: 36 36 37 - **Placeholder** — Input placeholder text.38 - **Button Text** — Submit button label.39 - **Show Sources** — Display related FAQ links below the answer.37 - **Placeholder** — Input placeholder text. 38 - **Button Text** — Submit button label. 39 - **Show Sources** — Display related FAQ links below the answer. 40 40 41 41 Using the Template Function … … 43 43 You can also use `hamelp_render_ai_overview()` in your theme templates: 44 44 45 <pre><?php echo hamelp_render_ai_overview(); ?></pre> 45 <pre> 46 <?php echo hamelp_render_ai_overview(); ?> 47 </pre> 46 48 47 49 The function accepts an optional array of arguments: 48 50 49 <pre><?php 51 <pre> 52 <php 50 53 echo hamelp_render_ai_overview( [ 51 54 'placeholder' => 'Ask a question...', … … 53 56 'show_sources' => true, 54 57 ] ); 55 ?></pre> 58 ?> 59 </pre> 56 60 57 61 The function automatically enqueues the required JavaScript and CSS assets. … … 61 65 You can use shortcode `hamelp-search` in page content. 62 66 63 <pre>[hamelp-search label='Enter your question here.'][/hamelp-search]</pre> 67 <pre> 68 [hamelp-search label='Enter your question here.'][/hamelp-search] 69 </pre> 64 70 65 71 And you can call in your theme altenatively. … … 78 84 == Frequently Asked Questions == 79 85 80 > How can I contribute? 86 = How can I contribute? = 81 87 82 88 You can contribute to our github repo. Any [issues](https://github.com/hametuha/hamelp/issues) or [PRs](https://github.com/hametuha/hamelp/pulls) are welcomed. … … 84 90 == Changelog == 85 91 92 = 2.1.0 = 93 94 - Add user context to AI Overview for personalized responses. 95 - Add whitelist-based user role filtering for security (`hamelp_allowed_user_roles` filter). 96 - Add `hamelp_user_context` and `hamelp_display_user_roles` filters for customization. 97 - Add development hooks support for local environment testing. 98 - Remove bundled translations in favor of GlotPress (WordPress.org). 99 86 100 = 2.0.0 = 87 101 88 *Add AI Overview Feature.89 *Bump minimum requirements: PHP >=7.4, WordPress >= 6.6102 - Add AI Overview Feature. 103 - Bump minimum requirements: PHP >=7.4, WordPress >= 6.6 90 104 91 105 = 1.0.4 = 92 106 93 *Add [structured data](https://developers.google.com/search/docs/data-types/faqpage) for FAQPage.107 - Add [structured data](https://developers.google.com/search/docs/data-types/faqpage) for FAQPage. 94 108 95 109 = 1.0.3 = 96 110 97 *Bugfix and change glocal functions.111 - Bugfix and change glocal functions. 98 112 99 113 = 1.0.2 = 100 114 101 *Fix taxonomy to be shown in Gutenberg.115 - Fix taxonomy to be shown in Gutenberg. 102 116 103 117 = 1.0.1 = 104 118 105 *Fix no vendor directory bug.119 - Fix no vendor directory bug. 106 120 107 121 = 1.0.0 = 108 122 109 *Initial release.123 - Initial release. -
hamelp/tags/2.1.0/vendor/composer/installed.php
r3447972 r3451876 2 2 'root' => array( 3 3 'name' => 'hametuha/hamelp', 4 'pretty_version' => 'v2. 0.2',5 'version' => '2. 0.2.0',6 'reference' => ' cec9f36d5013096c7c46ab983233b3fcb5f7fbe6',4 'pretty_version' => 'v2.1.0', 5 'version' => '2.1.0.0', 6 'reference' => '8ae6ed4622fbc570677bb4e4297432ca13f0de4f', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'hametuha/hamelp' => array( 14 'pretty_version' => 'v2. 0.2',15 'version' => '2. 0.2.0',16 'reference' => ' cec9f36d5013096c7c46ab983233b3fcb5f7fbe6',14 'pretty_version' => 'v2.1.0', 15 'version' => '2.1.0.0', 16 'reference' => '8ae6ed4622fbc570677bb4e4297432ca13f0de4f', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
hamelp/trunk/app/Hametuha/Hamelp/Services/FaqSearchService.php
r3447047 r3451876 15 15 */ 16 16 class FaqSearchService { 17 17 18 18 19 /** … … 145 146 } 146 147 148 $user_context = $this->get_user_context(); 149 if ( ! empty( $user_context ) ) { 150 $base .= "\n\n" . $user_context; 151 } 152 147 153 $base .= "\n\n" . 'Answer user questions based on the provided FAQ content. 148 154 … … 156 162 - Keep your response concise and helpful. 157 163 - Respond in the same language as the user question. 164 - If user information is provided, you may address them by name and tailor your response to their context (e.g., role, membership). Do not repeat their personal information back to them. 158 165 159 166 OUTPUT FORMAT: … … 172 179 return $base . "\n\n" . $context; 173 180 } 181 182 /** 183 * Get user context string for personalization. 184 * 185 * Returns empty string for logged-out users. 186 * 187 * @return string User context for system prompt, empty if not logged in. 188 */ 189 protected function get_user_context(): string { 190 $user = wp_get_current_user(); 191 if ( ! $user->exists() ) { 192 return ''; 193 } 194 195 $lines = [ 'Current user information:' ]; 196 $lines[] = sprintf( 'Display name: %s', $user->display_name ); 197 198 // Filter roles to prevent exposing internal plugin roles. 199 $display_roles = $this->get_display_roles( $user ); 200 if ( ! empty( $display_roles ) ) { 201 $lines[] = sprintf( 'Role: %s', implode( ', ', $display_roles ) ); 202 } 203 204 $lines[] = sprintf( 'Registered: %s', $user->user_registered ); 205 206 $context = implode( "\n", $lines ); 207 208 /** 209 * Filter user context included in the AI system prompt. 210 * 211 * Allows sites to add custom user-specific information 212 * (e.g., subscription status, purchase history, membership tier) 213 * that helps the AI provide personalized answers. 214 * 215 * Return an empty string to disable user personalization entirely. 216 * 217 * @param string $context The user context string. 218 * @param \WP_User $user The current WordPress user object. 219 */ 220 $context = apply_filters( 'hamelp_user_context', $context, $user ); 221 222 return is_string( $context ) ? $context : ''; 223 } 224 225 /** 226 * Get user roles filtered by whitelist for display. 227 * 228 * Filters out internal plugin roles (e.g., backup plugins) 229 * that should not be exposed to the AI. 230 * 231 * @param \WP_User $user The user object. 232 * @return string[] Filtered role names safe for display. 233 */ 234 protected function get_display_roles( \WP_User $user ): array { 235 /** 236 * Filter the list of allowed user roles to display in AI context. 237 * 238 * Only roles in this list will be shown to the AI. 239 * This prevents internal plugin roles from being exposed. 240 * 241 * @param string[] $allowed_roles List of role slugs to allow. 242 */ 243 $allowed_roles = apply_filters( 244 'hamelp_allowed_user_roles', 245 [ 246 // WordPress core roles. 247 'administrator', 248 'editor', 249 'author', 250 'contributor', 251 'subscriber', 252 // WooCommerce roles. 253 'customer', 254 'shop_manager', 255 ] 256 ); 257 258 $display_roles = array_intersect( $user->roles, $allowed_roles ); 259 260 /** 261 * Filter the user roles to be displayed in AI context. 262 * 263 * Called after whitelist filtering. Allows further customization 264 * such as translating role slugs to human-readable names. 265 * 266 * @param string[] $display_roles Roles to display (already filtered). 267 * @param \WP_User $user The user object. 268 */ 269 return apply_filters( 'hamelp_display_user_roles', $display_roles, $user ); 270 } 174 271 } -
hamelp/trunk/hamelp.php
r3447972 r3451876 4 4 * Plugin URI: https://wordpress.org/plugins/hamelp 5 5 * Description: FAQ generator by Hametuha. 6 * Version: 2. 0.26 * Version: 2.1.0 7 7 * Author: Hametuha INC. 8 8 * Author URI: https://hametuha.co.jp … … 23 23 */ 24 24 function hamelp_init() { 25 // i18n .26 load_plugin_textdomain( 'hamelp' , false, basename( __DIR__ ) . '/languages');25 // i18n (translations are loaded from WordPress.org via GlotPress). 26 load_plugin_textdomain( 'hamelp' ); 27 27 if ( version_compare( phpversion(), '7.4.0', '>=' ) ) { 28 28 require __DIR__ . '/vendor/autoload.php'; 29 29 call_user_func( [ 'Hametuha\\Hamelp', 'get' ] ); 30 // Load development hooks (environment check is inside the file). 31 if ( file_exists( __DIR__ . '/dev/hooks.php' ) ) { 32 require_once __DIR__ . '/dev/hooks.php'; 33 } 30 34 } else { 31 35 add_action( 'admin_notices', 'hamelp_version_error' ); -
hamelp/trunk/readme.txt
r3447972 r3451876 4 4 Tags: faq,help 5 5 Tested up to: 6.9 6 Stable Tag: 2. 0.26 Stable Tag: 2.1.0 7 7 License: GPL 3.0 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 19 19 This plugin will provide... 20 20 21 *Custom post type with single page and archive page.22 *Custom taxonomy associated to CPT.23 *Incremental search box.24 *AI Overview(Since 2.0.0)21 - Custom post type with single page and archive page. 22 - Custom taxonomy associated to CPT. 23 - Incremental search box. 24 - AI Overview(Since 2.0.0) 25 25 26 26 = AI Overview = … … 35 35 Add the **AI FAQ Overview** block in the block editor. The block has the following options: 36 36 37 - **Placeholder** — Input placeholder text.38 - **Button Text** — Submit button label.39 - **Show Sources** — Display related FAQ links below the answer.37 - **Placeholder** — Input placeholder text. 38 - **Button Text** — Submit button label. 39 - **Show Sources** — Display related FAQ links below the answer. 40 40 41 41 Using the Template Function … … 43 43 You can also use `hamelp_render_ai_overview()` in your theme templates: 44 44 45 <pre><?php echo hamelp_render_ai_overview(); ?></pre> 45 <pre> 46 <?php echo hamelp_render_ai_overview(); ?> 47 </pre> 46 48 47 49 The function accepts an optional array of arguments: 48 50 49 <pre><?php 51 <pre> 52 <php 50 53 echo hamelp_render_ai_overview( [ 51 54 'placeholder' => 'Ask a question...', … … 53 56 'show_sources' => true, 54 57 ] ); 55 ?></pre> 58 ?> 59 </pre> 56 60 57 61 The function automatically enqueues the required JavaScript and CSS assets. … … 61 65 You can use shortcode `hamelp-search` in page content. 62 66 63 <pre>[hamelp-search label='Enter your question here.'][/hamelp-search]</pre> 67 <pre> 68 [hamelp-search label='Enter your question here.'][/hamelp-search] 69 </pre> 64 70 65 71 And you can call in your theme altenatively. … … 78 84 == Frequently Asked Questions == 79 85 80 > How can I contribute? 86 = How can I contribute? = 81 87 82 88 You can contribute to our github repo. Any [issues](https://github.com/hametuha/hamelp/issues) or [PRs](https://github.com/hametuha/hamelp/pulls) are welcomed. … … 84 90 == Changelog == 85 91 92 = 2.1.0 = 93 94 - Add user context to AI Overview for personalized responses. 95 - Add whitelist-based user role filtering for security (`hamelp_allowed_user_roles` filter). 96 - Add `hamelp_user_context` and `hamelp_display_user_roles` filters for customization. 97 - Add development hooks support for local environment testing. 98 - Remove bundled translations in favor of GlotPress (WordPress.org). 99 86 100 = 2.0.0 = 87 101 88 *Add AI Overview Feature.89 *Bump minimum requirements: PHP >=7.4, WordPress >= 6.6102 - Add AI Overview Feature. 103 - Bump minimum requirements: PHP >=7.4, WordPress >= 6.6 90 104 91 105 = 1.0.4 = 92 106 93 *Add [structured data](https://developers.google.com/search/docs/data-types/faqpage) for FAQPage.107 - Add [structured data](https://developers.google.com/search/docs/data-types/faqpage) for FAQPage. 94 108 95 109 = 1.0.3 = 96 110 97 *Bugfix and change glocal functions.111 - Bugfix and change glocal functions. 98 112 99 113 = 1.0.2 = 100 114 101 *Fix taxonomy to be shown in Gutenberg.115 - Fix taxonomy to be shown in Gutenberg. 102 116 103 117 = 1.0.1 = 104 118 105 *Fix no vendor directory bug.119 - Fix no vendor directory bug. 106 120 107 121 = 1.0.0 = 108 122 109 *Initial release.123 - Initial release. -
hamelp/trunk/vendor/composer/installed.php
r3447972 r3451876 2 2 'root' => array( 3 3 'name' => 'hametuha/hamelp', 4 'pretty_version' => 'v2. 0.2',5 'version' => '2. 0.2.0',6 'reference' => ' cec9f36d5013096c7c46ab983233b3fcb5f7fbe6',4 'pretty_version' => 'v2.1.0', 5 'version' => '2.1.0.0', 6 'reference' => '8ae6ed4622fbc570677bb4e4297432ca13f0de4f', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'hametuha/hamelp' => array( 14 'pretty_version' => 'v2. 0.2',15 'version' => '2. 0.2.0',16 'reference' => ' cec9f36d5013096c7c46ab983233b3fcb5f7fbe6',14 'pretty_version' => 'v2.1.0', 15 'version' => '2.1.0.0', 16 'reference' => '8ae6ed4622fbc570677bb4e4297432ca13f0de4f', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.