close

Plugin Directory

Changeset 3451876


Ignore:
Timestamp:
02/02/2026 09:02:18 AM (3 months ago)
Author:
Takahashi_Fumiki
Message:

Update to version 2.1.0 from GitHub

Location:
hamelp
Files:
2 deleted
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hamelp/tags/2.1.0/app/Hametuha/Hamelp/Services/FaqSearchService.php

    r3447047 r3451876  
    1515 */
    1616class FaqSearchService {
     17
    1718
    1819    /**
     
    145146        }
    146147
     148        $user_context = $this->get_user_context();
     149        if ( ! empty( $user_context ) ) {
     150            $base .= "\n\n" . $user_context;
     151        }
     152
    147153        $base .= "\n\n" . 'Answer user questions based on the provided FAQ content.
    148154
     
    156162- Keep your response concise and helpful.
    157163- 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.
    158165
    159166OUTPUT FORMAT:
     
    172179        return $base . "\n\n" . $context;
    173180    }
     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    }
    174271}
  • hamelp/tags/2.1.0/hamelp.php

    r3447972 r3451876  
    44 * Plugin URI:      https://wordpress.org/plugins/hamelp
    55 * Description:     FAQ generator by Hametuha.
    6  * Version: 2.0.2
     6 * Version: 2.1.0
    77 * Author:          Hametuha INC.
    88 * Author URI:      https://hametuha.co.jp
     
    2323 */
    2424function 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' );
    2727    if ( version_compare( phpversion(), '7.4.0', '>=' ) ) {
    2828        require __DIR__ . '/vendor/autoload.php';
    2929        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        }
    3034    } else {
    3135        add_action( 'admin_notices', 'hamelp_version_error' );
  • hamelp/tags/2.1.0/readme.txt

    r3447972 r3451876  
    44Tags: faq,help 
    55Tested up to: 6.9 
    6 Stable Tag: 2.0.2
     6Stable Tag: 2.1.0
    77License: GPL 3.0 or later 
    88License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    1919This plugin will provide...
    2020
    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)
    2525
    2626= AI Overview =
     
    3535Add the **AI FAQ Overview** block in the block editor. The block has the following options:
    3636
    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.
    4040
    4141 Using the Template Function
     
    4343You can also use `hamelp_render_ai_overview()` in your theme templates:
    4444
    45 <pre><?php echo hamelp_render_ai_overview(); ?></pre>
     45<pre>
     46&lt;?php echo hamelp_render_ai_overview(); ?&gt;
     47</pre>
    4648
    4749The function accepts an optional array of arguments:
    4850
    49 <pre><?php
     51<pre>
     52&lt;php
    5053echo hamelp_render_ai_overview( [
    5154    'placeholder'  => 'Ask a question...',
     
    5356    'show_sources' => true,
    5457] );
    55 ?></pre>
     58?&gt;
     59</pre>
    5660
    5761The function automatically enqueues the required JavaScript and CSS assets.
     
    6165You can use shortcode `hamelp-search` in page content.
    6266
    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>
    6470
    6571And you can call in your theme altenatively.
     
    7884== Frequently Asked Questions ==
    7985
    80 > How can I contribute?
     86= How can I contribute? =
    8187
    8288You can contribute to our github repo. Any [issues](https://github.com/hametuha/hamelp/issues) or [PRs](https://github.com/hametuha/hamelp/pulls) are welcomed.
     
    8490== Changelog ==
    8591
     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
    86100= 2.0.0 =
    87101
    88 * Add AI Overview Feature.
    89 * Bump minimum requirements: PHP >=7.4, WordPress >= 6.6
     102 Add AI Overview Feature.
     103 Bump minimum requirements: PHP >=7.4, WordPress >= 6.6
    90104
    91105= 1.0.4 =
    92106
    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.
    94108
    95109= 1.0.3 =
    96110
    97 * Bugfix and change glocal functions.
     111 Bugfix and change glocal functions.
    98112
    99113= 1.0.2 =
    100114
    101 * Fix taxonomy to be shown in Gutenberg.
     115 Fix taxonomy to be shown in Gutenberg.
    102116
    103117= 1.0.1 =
    104118
    105 * Fix no vendor directory bug.
     119 Fix no vendor directory bug.
    106120
    107121= 1.0.0 =
    108122
    109 * Initial release.
     123 Initial release.
  • hamelp/tags/2.1.0/vendor/composer/installed.php

    r3447972 r3451876  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • hamelp/trunk/app/Hametuha/Hamelp/Services/FaqSearchService.php

    r3447047 r3451876  
    1515 */
    1616class FaqSearchService {
     17
    1718
    1819    /**
     
    145146        }
    146147
     148        $user_context = $this->get_user_context();
     149        if ( ! empty( $user_context ) ) {
     150            $base .= "\n\n" . $user_context;
     151        }
     152
    147153        $base .= "\n\n" . 'Answer user questions based on the provided FAQ content.
    148154
     
    156162- Keep your response concise and helpful.
    157163- 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.
    158165
    159166OUTPUT FORMAT:
     
    172179        return $base . "\n\n" . $context;
    173180    }
     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    }
    174271}
  • hamelp/trunk/hamelp.php

    r3447972 r3451876  
    44 * Plugin URI:      https://wordpress.org/plugins/hamelp
    55 * Description:     FAQ generator by Hametuha.
    6  * Version: 2.0.2
     6 * Version: 2.1.0
    77 * Author:          Hametuha INC.
    88 * Author URI:      https://hametuha.co.jp
     
    2323 */
    2424function 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' );
    2727    if ( version_compare( phpversion(), '7.4.0', '>=' ) ) {
    2828        require __DIR__ . '/vendor/autoload.php';
    2929        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        }
    3034    } else {
    3135        add_action( 'admin_notices', 'hamelp_version_error' );
  • hamelp/trunk/readme.txt

    r3447972 r3451876  
    44Tags: faq,help 
    55Tested up to: 6.9 
    6 Stable Tag: 2.0.2
     6Stable Tag: 2.1.0
    77License: GPL 3.0 or later 
    88License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    1919This plugin will provide...
    2020
    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)
    2525
    2626= AI Overview =
     
    3535Add the **AI FAQ Overview** block in the block editor. The block has the following options:
    3636
    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.
    4040
    4141 Using the Template Function
     
    4343You can also use `hamelp_render_ai_overview()` in your theme templates:
    4444
    45 <pre><?php echo hamelp_render_ai_overview(); ?></pre>
     45<pre>
     46&lt;?php echo hamelp_render_ai_overview(); ?&gt;
     47</pre>
    4648
    4749The function accepts an optional array of arguments:
    4850
    49 <pre><?php
     51<pre>
     52&lt;php
    5053echo hamelp_render_ai_overview( [
    5154    'placeholder'  => 'Ask a question...',
     
    5356    'show_sources' => true,
    5457] );
    55 ?></pre>
     58?&gt;
     59</pre>
    5660
    5761The function automatically enqueues the required JavaScript and CSS assets.
     
    6165You can use shortcode `hamelp-search` in page content.
    6266
    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>
    6470
    6571And you can call in your theme altenatively.
     
    7884== Frequently Asked Questions ==
    7985
    80 > How can I contribute?
     86= How can I contribute? =
    8187
    8288You can contribute to our github repo. Any [issues](https://github.com/hametuha/hamelp/issues) or [PRs](https://github.com/hametuha/hamelp/pulls) are welcomed.
     
    8490== Changelog ==
    8591
     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
    86100= 2.0.0 =
    87101
    88 * Add AI Overview Feature.
    89 * Bump minimum requirements: PHP >=7.4, WordPress >= 6.6
     102 Add AI Overview Feature.
     103 Bump minimum requirements: PHP >=7.4, WordPress >= 6.6
    90104
    91105= 1.0.4 =
    92106
    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.
    94108
    95109= 1.0.3 =
    96110
    97 * Bugfix and change glocal functions.
     111 Bugfix and change glocal functions.
    98112
    99113= 1.0.2 =
    100114
    101 * Fix taxonomy to be shown in Gutenberg.
     115 Fix taxonomy to be shown in Gutenberg.
    102116
    103117= 1.0.1 =
    104118
    105 * Fix no vendor directory bug.
     119 Fix no vendor directory bug.
    106120
    107121= 1.0.0 =
    108122
    109 * Initial release.
     123 Initial release.
  • hamelp/trunk/vendor/composer/installed.php

    r3447972 r3451876  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.