Plugin Directory

Changeset 3331420


Ignore:
Timestamp:
07/21/2025 11:35:16 AM (9 months ago)
Author:
siteimprove
Message:

Deploy version 2.1.0

Location:
siteimprove
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • siteimprove/tags/2.1.0/admin/class-siteimprove-admin.php

    r3325770 r3331420  
    257257        }
    258258        $public_url = get_option( 'siteimprove_public_url' );
    259 
     259        $ignore_segments = get_option( 'siteimprove_ignore_path_segments' );
     260
     261        // Parse the URL to get its components.
     262        $parsed_url = wp_parse_url( $url );
     263        $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
     264
     265        // Apply path segment filtering if configured.
     266        if ( ! empty( $ignore_segments ) && ! empty( $path ) ) {
     267            // Split the ignore segments by comma and trim whitespace.
     268            $segments_to_ignore = array_map( 'trim', explode( ',', $ignore_segments ) );
     269
     270            // Split the path into segments.
     271            $path_segments = array_filter( explode( '/', $path ) );
     272
     273            // Remove segments that should be ignored.
     274            $filtered_segments = array();
     275            foreach ( $path_segments as $segment ) {
     276                if ( ! in_array( $segment, $segments_to_ignore, true ) ) {
     277                    $filtered_segments[] = $segment;
     278                }
     279            }
     280
     281            // Reconstruct the path.
     282            $path = '/' . implode( '/', $filtered_segments );
     283        }
     284
     285        // Apply public URL transformation if configured.
    260286        if ( ! empty( $public_url ) ) {
    261             $parsed_url = wp_parse_url( $url );
    262             $url = "$public_url$parsed_url[path]" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' );
     287            $url = "$public_url$path" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' );
     288        } else {
     289            // If no public URL is set, reconstruct the URL with the filtered path.
     290            $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
     291            $host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
     292            $port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
     293            $query = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
     294            $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
     295
     296            $url = $scheme . $host . $port . $path . $query . $fragment;
    263297        }
    264298
  • siteimprove/tags/2.1.0/admin/partials/class-siteimprove-admin-settings.php

    r3325770 r3331420  
    4444        register_setting( 'siteimprove', 'siteimprove_disable_new_version', 'Siteimprove_Admin_Settings::validate_siteimprove_disable_new_version' );
    4545        register_setting( 'siteimprove', 'siteimprove_public_url', 'Siteimprove_Admin_Settings::validate_public_url' );
     46        register_setting( 'siteimprove', 'siteimprove_ignore_path_segments', 'Siteimprove_Admin_Settings::validate_ignore_path_segments' );
    4647        register_setting( 'siteimprove', 'siteimprove_api_username', 'Siteimprove_Admin_Settings::validate_api_username' );
    4748        register_setting( 'siteimprove', 'siteimprove_api_key', 'Siteimprove_Admin_Settings::validate_api_key' );
     
    7273            'Siteimprove_Admin_Settings::siteimprove_settings_section_title',
    7374            'siteimprove'
     75        );
     76
     77        // register a new field siteimprove_public_url_field, inside the siteimprove_token section of the settings page.
     78        add_settings_field(
     79            'siteimprove_public_url',
     80            __( 'Public URL', 'siteimprove' ),
     81            'Siteimprove_Admin_Settings::siteimprove_public_url_field',
     82            'siteimprove',
     83            'siteimprove_public_url'
     84        );
     85
     86        // register a new field siteimprove_ignore_path_segments_field, inside the siteimprove_public_url section of the settings page.
     87        add_settings_field(
     88            'siteimprove_ignore_path_segments',
     89            __( 'Ignore Path Segments', 'siteimprove' ),
     90            'Siteimprove_Admin_Settings::siteimprove_ignore_path_segments_field',
     91            'siteimprove',
     92            'siteimprove_public_url'
    7493        );
    7594
     
    240259                                    <p>
    241260                                    <?php
    242                                     esc_html_e( 'Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. Otherwise you can leave this field empty.' );
    243                                     ?>
    244                                     </p>
    245                                     <p>
    246                                     <?php
    247                                     esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' );
     261                                    esc_html_e( 'Configure URL transformation settings. Public URL changes the domain/host of the URL. Ignore Path Segments removes specific path segments from the URL. These settings can be used independently or together.', 'siteimprove' );
    248262                                    ?>
    249263                                    </p>
     
    304318        ?>
    305319                        <input type="text" id="siteimprove_public_url_field" name="siteimprove_public_url" value="<?php echo esc_attr( get_option( 'siteimprove_public_url' ) ); ?>"  size="50" />
     320                        <p>
     321                        <?php
     322                        esc_html_e( '(Optional) Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. This changes the domain/host of the URL and works independently of the Ignore Path Segments setting.', 'siteimprove' );
     323                        ?>
     324                        </p>
     325                        <p>
     326                        <?php
     327                        esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' );
     328                        ?>
     329                        </p>
     330                        <?php
     331    }
     332
     333    /**
     334     * Form fields
     335     *
     336     * @param mixed $args Field Arguments.
     337     * @return void
     338     */
     339    public static function siteimprove_ignore_path_segments_field( $args ) {
     340        ?>
     341                        <input type="text" id="siteimprove_ignore_path_segments_field" name="siteimprove_ignore_path_segments" value="<?php echo esc_attr( get_option( 'siteimprove_ignore_path_segments' ) ); ?>"  size="50" />
     342                        <p>
     343                        <?php
     344                        esc_html_e( '(Optional) Specify path segments to remove from the URL path. Use comma-separated values (e.g. "cms,staging"). This doe not remove anything from the Public URL set. This can be used to clean up path segments from the CMS URLs to better match the end published URLs scanned in the Siteimprove platform in the plugin requests.', 'siteimprove' );
     345                        ?>
     346                        </p>
     347                        <p>
     348                        <?php
     349                        esc_html_e( 'Example: If your URL is https://staging.mysite.com/cms/blog/staging/mypost and you set the Ignore Path Segments to "cms,staging", the result will be https://staging.mysite.com/blog/mypost.', 'siteimprove' );
     350                        ?>
     351                        </p>
    306352                        <?php
    307353    }
     
    514560
    515561    /**
     562     * Field Validation for Ignore Path Segments
     563     *
     564     * @param string $value Original value posted in settings page.
     565     * @return string
     566     */
     567    public static function validate_ignore_path_segments( $value ) {
     568        if ( ! empty( $value ) ) {
     569            $old_value = get_option( 'siteimprove_ignore_path_segments' );
     570            // Validate that the value contains only alphanumeric characters, hyphens, underscores, and commas.
     571            if ( ! preg_match( '/^[a-zA-Z0-9\-\_,\s]+$/', $value ) ) {
     572                add_settings_error( 'siteimprove_messages', 'siteimprove_ignore_path_segments_error', __( 'Invalid format for Ignore Path Segments field. Only alphanumeric characters, hyphens, underscores, and commas are allowed.', 'siteimprove' ) );
     573                return $old_value;
     574            }
     575        }
     576
     577        return sanitize_text_field( $value );
     578    }
     579
     580    /**
    516581     * Abstractor for any API requests made on the admin page
    517582     *
  • siteimprove/tags/2.1.0/includes/class-siteimprove.php

    r3325770 r3331420  
    6161
    6262        $this->plugin_name = 'siteimprove';
    63         $this->version     = '2.0.8';
     63        $this->version     = '2.1.0';
    6464
    6565        $this->load_dependencies();
  • siteimprove/tags/2.1.0/languages/siteimprove.pot

    r3064701 r3331420  
    124124msgid "Unable to check website domain. Please try again later"
    125125msgstr ""
     126
     127#: admin/partials/class-siteimprove-admin-settings.php:78
     128msgid "Ignore Path Segments"
     129msgstr ""
     130
     131#: admin/partials/class-siteimprove-admin-settings.php:260
     132msgid "Configure URL transformation settings. Public URL changes the domain/host of the URL. Ignore Path Segments removes specific path segments from the URL. These settings can be used independently or together."
     133msgstr ""
     134
     135#: admin/partials/class-siteimprove-admin-settings.php:320
     136msgid "(Optional) Please provide the Public URL for the current site if for any reasons it's not the same as the Admin Panel URL. This changes the domain/host of the URL and works independently of the Ignore Path Segments setting."
     137msgstr ""
     138
     139#: admin/partials/class-siteimprove-admin-settings.php:325
     140msgid "Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com"
     141msgstr ""
     142
     143#: admin/partials/class-siteimprove-admin-settings.php:340
     144msgid "(Optional) Specify path segments to remove from the URL path. Use comma-separated values (e.g. "cms,staging"). This doe not remove anything from the Public URL set. This can be used to clean up path segments from the CMS URLs to better match the end published URLs scanned in the Siteimprove platform in the plugin requests."
     145msgstr ""
     146
     147#: admin/partials/class-siteimprove-admin-settings.php:345
     148msgid "Example: If your URL is https://staging.mysite.com/cms/blog/staging/mypost and you set the Ignore Path Segments to "cms,staging", the result will be https://staging.mysite.com/blog/mypost."
     149msgstr ""
     150
     151#: admin/partials/class-siteimprove-admin-settings.php:558
     152msgid "Invalid format for Ignore Path Segments field. Only alphanumeric characters, hyphens, underscores, and commas are allowed."
     153msgstr ""
  • siteimprove/tags/2.1.0/readme.txt

    r3325773 r3331420  
    3535A new Siteimprove menu option will also appear on the left menu bar. Click on this menu option to continue configuring the plugin once you’ve logged in. 
    3636
    37 The token field is automatically filled and should not be changed unless a new token is required. In such cases, please click on “Request new token” to generate a new token.
     37The token field is automatically filled and should not be changed unless a new token is required. In such cases, please click on "Request new token" to generate a new token.
    3838
    3939Public URL is optional to fill in if, for any reason, your published pages are not on the same URL as your configuration panel.
     40
     41Ignore Path Segments is optional and allows you to specify path segments that should be removed when building the public URL. This is useful when your admin panel has additional path segments that shouldn't be included in the public URL (e.g., "wp-admin,staging"). Use comma-separated values.
    4042
    4143When you download the plugin, you automatically will be using the latest experience. If for some reason, you want to use the previous experience of the Siteimprove plugin, uncheck "Use latest experience" in the configuration panel.
     
    8688
    8789== Changelog ==
     90= 2.1.0 =
     91* Added - Ignore Path Segments setting to remove specific path segments when building public URLs
     92* Enhanced - Public URL functionality to handle complex URL transformations
     93
    8894= 2.0.8 =
    8995* Updated - "Tested up to"
  • siteimprove/tags/2.1.0/siteimprove.php

    r3330388 r3331420  
    1010 * Plugin URI:          https://www.siteimprove.com/integrations/cms-plugin/wordpress/
    1111 * Description:         Integration with Siteimprove.
    12  * Version:             2.0.8
     12 * Version:             v2.1.0
    1313 * Author:              Siteimprove
    1414 * Author URI:          http://www.siteimprove.com/
  • siteimprove/trunk/admin/class-siteimprove-admin.php

    r3325770 r3331420  
    257257        }
    258258        $public_url = get_option( 'siteimprove_public_url' );
    259 
     259        $ignore_segments = get_option( 'siteimprove_ignore_path_segments' );
     260
     261        // Parse the URL to get its components.
     262        $parsed_url = wp_parse_url( $url );
     263        $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
     264
     265        // Apply path segment filtering if configured.
     266        if ( ! empty( $ignore_segments ) && ! empty( $path ) ) {
     267            // Split the ignore segments by comma and trim whitespace.
     268            $segments_to_ignore = array_map( 'trim', explode( ',', $ignore_segments ) );
     269
     270            // Split the path into segments.
     271            $path_segments = array_filter( explode( '/', $path ) );
     272
     273            // Remove segments that should be ignored.
     274            $filtered_segments = array();
     275            foreach ( $path_segments as $segment ) {
     276                if ( ! in_array( $segment, $segments_to_ignore, true ) ) {
     277                    $filtered_segments[] = $segment;
     278                }
     279            }
     280
     281            // Reconstruct the path.
     282            $path = '/' . implode( '/', $filtered_segments );
     283        }
     284
     285        // Apply public URL transformation if configured.
    260286        if ( ! empty( $public_url ) ) {
    261             $parsed_url = wp_parse_url( $url );
    262             $url = "$public_url$parsed_url[path]" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' );
     287            $url = "$public_url$path" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' );
     288        } else {
     289            // If no public URL is set, reconstruct the URL with the filtered path.
     290            $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
     291            $host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
     292            $port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
     293            $query = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
     294            $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
     295
     296            $url = $scheme . $host . $port . $path . $query . $fragment;
    263297        }
    264298
  • siteimprove/trunk/admin/partials/class-siteimprove-admin-settings.php

    r3325770 r3331420  
    4444        register_setting( 'siteimprove', 'siteimprove_disable_new_version', 'Siteimprove_Admin_Settings::validate_siteimprove_disable_new_version' );
    4545        register_setting( 'siteimprove', 'siteimprove_public_url', 'Siteimprove_Admin_Settings::validate_public_url' );
     46        register_setting( 'siteimprove', 'siteimprove_ignore_path_segments', 'Siteimprove_Admin_Settings::validate_ignore_path_segments' );
    4647        register_setting( 'siteimprove', 'siteimprove_api_username', 'Siteimprove_Admin_Settings::validate_api_username' );
    4748        register_setting( 'siteimprove', 'siteimprove_api_key', 'Siteimprove_Admin_Settings::validate_api_key' );
     
    7273            'Siteimprove_Admin_Settings::siteimprove_settings_section_title',
    7374            'siteimprove'
     75        );
     76
     77        // register a new field siteimprove_public_url_field, inside the siteimprove_token section of the settings page.
     78        add_settings_field(
     79            'siteimprove_public_url',
     80            __( 'Public URL', 'siteimprove' ),
     81            'Siteimprove_Admin_Settings::siteimprove_public_url_field',
     82            'siteimprove',
     83            'siteimprove_public_url'
     84        );
     85
     86        // register a new field siteimprove_ignore_path_segments_field, inside the siteimprove_public_url section of the settings page.
     87        add_settings_field(
     88            'siteimprove_ignore_path_segments',
     89            __( 'Ignore Path Segments', 'siteimprove' ),
     90            'Siteimprove_Admin_Settings::siteimprove_ignore_path_segments_field',
     91            'siteimprove',
     92            'siteimprove_public_url'
    7493        );
    7594
     
    240259                                    <p>
    241260                                    <?php
    242                                     esc_html_e( 'Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. Otherwise you can leave this field empty.' );
    243                                     ?>
    244                                     </p>
    245                                     <p>
    246                                     <?php
    247                                     esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' );
     261                                    esc_html_e( 'Configure URL transformation settings. Public URL changes the domain/host of the URL. Ignore Path Segments removes specific path segments from the URL. These settings can be used independently or together.', 'siteimprove' );
    248262                                    ?>
    249263                                    </p>
     
    304318        ?>
    305319                        <input type="text" id="siteimprove_public_url_field" name="siteimprove_public_url" value="<?php echo esc_attr( get_option( 'siteimprove_public_url' ) ); ?>"  size="50" />
     320                        <p>
     321                        <?php
     322                        esc_html_e( '(Optional) Please provide the Public URL for the current site if for any reasons it\'s not the same as the Admin Panel URL. This changes the domain/host of the URL and works independently of the Ignore Path Segments setting.', 'siteimprove' );
     323                        ?>
     324                        </p>
     325                        <p>
     326                        <?php
     327                        esc_html_e( 'Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com', 'siteimprove' );
     328                        ?>
     329                        </p>
     330                        <?php
     331    }
     332
     333    /**
     334     * Form fields
     335     *
     336     * @param mixed $args Field Arguments.
     337     * @return void
     338     */
     339    public static function siteimprove_ignore_path_segments_field( $args ) {
     340        ?>
     341                        <input type="text" id="siteimprove_ignore_path_segments_field" name="siteimprove_ignore_path_segments" value="<?php echo esc_attr( get_option( 'siteimprove_ignore_path_segments' ) ); ?>"  size="50" />
     342                        <p>
     343                        <?php
     344                        esc_html_e( '(Optional) Specify path segments to remove from the URL path. Use comma-separated values (e.g. "cms,staging"). This doe not remove anything from the Public URL set. This can be used to clean up path segments from the CMS URLs to better match the end published URLs scanned in the Siteimprove platform in the plugin requests.', 'siteimprove' );
     345                        ?>
     346                        </p>
     347                        <p>
     348                        <?php
     349                        esc_html_e( 'Example: If your URL is https://staging.mysite.com/cms/blog/staging/mypost and you set the Ignore Path Segments to "cms,staging", the result will be https://staging.mysite.com/blog/mypost.', 'siteimprove' );
     350                        ?>
     351                        </p>
    306352                        <?php
    307353    }
     
    514560
    515561    /**
     562     * Field Validation for Ignore Path Segments
     563     *
     564     * @param string $value Original value posted in settings page.
     565     * @return string
     566     */
     567    public static function validate_ignore_path_segments( $value ) {
     568        if ( ! empty( $value ) ) {
     569            $old_value = get_option( 'siteimprove_ignore_path_segments' );
     570            // Validate that the value contains only alphanumeric characters, hyphens, underscores, and commas.
     571            if ( ! preg_match( '/^[a-zA-Z0-9\-\_,\s]+$/', $value ) ) {
     572                add_settings_error( 'siteimprove_messages', 'siteimprove_ignore_path_segments_error', __( 'Invalid format for Ignore Path Segments field. Only alphanumeric characters, hyphens, underscores, and commas are allowed.', 'siteimprove' ) );
     573                return $old_value;
     574            }
     575        }
     576
     577        return sanitize_text_field( $value );
     578    }
     579
     580    /**
    516581     * Abstractor for any API requests made on the admin page
    517582     *
  • siteimprove/trunk/includes/class-siteimprove.php

    r3325770 r3331420  
    6161
    6262        $this->plugin_name = 'siteimprove';
    63         $this->version     = '2.0.8';
     63        $this->version     = '2.1.0';
    6464
    6565        $this->load_dependencies();
  • siteimprove/trunk/languages/siteimprove.pot

    r3064701 r3331420  
    124124msgid "Unable to check website domain. Please try again later"
    125125msgstr ""
     126
     127#: admin/partials/class-siteimprove-admin-settings.php:78
     128msgid "Ignore Path Segments"
     129msgstr ""
     130
     131#: admin/partials/class-siteimprove-admin-settings.php:260
     132msgid "Configure URL transformation settings. Public URL changes the domain/host of the URL. Ignore Path Segments removes specific path segments from the URL. These settings can be used independently or together."
     133msgstr ""
     134
     135#: admin/partials/class-siteimprove-admin-settings.php:320
     136msgid "(Optional) Please provide the Public URL for the current site if for any reasons it's not the same as the Admin Panel URL. This changes the domain/host of the URL and works independently of the Ignore Path Segments setting."
     137msgstr ""
     138
     139#: admin/partials/class-siteimprove-admin-settings.php:325
     140msgid "Example: Website Admin Panel is hosted at: http://stg-thewebsite.com but the final Public URL will be http://thewebsite.com"
     141msgstr ""
     142
     143#: admin/partials/class-siteimprove-admin-settings.php:340
     144msgid "(Optional) Specify path segments to remove from the URL path. Use comma-separated values (e.g. "cms,staging"). This doe not remove anything from the Public URL set. This can be used to clean up path segments from the CMS URLs to better match the end published URLs scanned in the Siteimprove platform in the plugin requests."
     145msgstr ""
     146
     147#: admin/partials/class-siteimprove-admin-settings.php:345
     148msgid "Example: If your URL is https://staging.mysite.com/cms/blog/staging/mypost and you set the Ignore Path Segments to "cms,staging", the result will be https://staging.mysite.com/blog/mypost."
     149msgstr ""
     150
     151#: admin/partials/class-siteimprove-admin-settings.php:558
     152msgid "Invalid format for Ignore Path Segments field. Only alphanumeric characters, hyphens, underscores, and commas are allowed."
     153msgstr ""
  • siteimprove/trunk/readme.txt

    r3325773 r3331420  
    3535A new Siteimprove menu option will also appear on the left menu bar. Click on this menu option to continue configuring the plugin once you’ve logged in. 
    3636
    37 The token field is automatically filled and should not be changed unless a new token is required. In such cases, please click on “Request new token” to generate a new token.
     37The token field is automatically filled and should not be changed unless a new token is required. In such cases, please click on "Request new token" to generate a new token.
    3838
    3939Public URL is optional to fill in if, for any reason, your published pages are not on the same URL as your configuration panel.
     40
     41Ignore Path Segments is optional and allows you to specify path segments that should be removed when building the public URL. This is useful when your admin panel has additional path segments that shouldn't be included in the public URL (e.g., "wp-admin,staging"). Use comma-separated values.
    4042
    4143When you download the plugin, you automatically will be using the latest experience. If for some reason, you want to use the previous experience of the Siteimprove plugin, uncheck "Use latest experience" in the configuration panel.
     
    8688
    8789== Changelog ==
     90= 2.1.0 =
     91* Added - Ignore Path Segments setting to remove specific path segments when building public URLs
     92* Enhanced - Public URL functionality to handle complex URL transformations
     93
    8894= 2.0.8 =
    8995* Updated - "Tested up to"
  • siteimprove/trunk/siteimprove.php

    r3330388 r3331420  
    1010 * Plugin URI:          https://www.siteimprove.com/integrations/cms-plugin/wordpress/
    1111 * Description:         Integration with Siteimprove.
    12  * Version:             2.0.8
     12 * Version:             v2.1.0
    1313 * Author:              Siteimprove
    1414 * Author URI:          http://www.siteimprove.com/
Note: See TracChangeset for help on using the changeset viewer.