Plugin Directory

Changeset 3171336


Ignore:
Timestamp:
10/18/2024 09:50:44 AM (16 months ago)
Author:
urlslab
Message:

Upload v2.130.6

Location:
urlslab/trunk
Files:
75 added
75 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • urlslab/trunk/includes/class-urlslab-url.php

    r3168189 r3171336  
    4242    private $is_blacklisted = null;
    4343
     44    private $fix_double_slashes = false;
     45
    4446    /**
    4547     * @param string $url
     
    4749     * @throws Exception
    4850     */
    49     public function __construct( $url, $add_current_page_protocol = false ) {
     51    public function __construct( $url, $add_current_page_protocol = false, $fix_double_slashes = false ) {
    5052        if ( empty( $url ) ) {
    5153            throw new Exception( 'Empty Input URL' );
    5254        }
     55        $this->fix_double_slashes = $fix_double_slashes;
    5356
    5457        if ( $add_current_page_protocol ) {
     
    208211
    209212        $this->url_components['path'] = $this->resolve_path( $this->url_components['path'] );
    210 
    211         $url                = $this->url_components['host'] . ( $this->url_components['path'] ?? '' );
     213        if ( $this->fix_double_slashes ) {
     214            // replace in path any number of slashes with single slash
     215            $this->url_components['path'] = preg_replace( '/\/+/', '/', $this->url_components['path'] );
     216        }
     217
     218        $url                = $this->url_components['host'] . ( isset( $this->url_components['port'] ) ? ':' . $this->url_components['port'] : '' ) . ( $this->url_components['path'] ?? '' );
    212219        $this->query_params = array();
    213220        if ( isset( $this->url_components['query'] ) ) {
  • urlslab/trunk/includes/data/class-urlslab-data-url.php

    r3168189 r3171336  
    131131    }
    132132
    133     public function get_url(): Urlslab_Url {
    134         return new Urlslab_Url( $this->get_url_name(), true );
     133    public function get_url( $fix_double_slashes = false ): Urlslab_Url {
     134        return new Urlslab_Url( $this->get_url_name(), true, $fix_double_slashes );
    135135    }
    136136
     
    560560        }
    561561        $this->set_scr_status( self::SCR_STATUS_NEW );
     562        return true;
    562563    }
    563564
     
    707708            if ( isset( $results['url'] ) ) {
    708709                try {
    709                     $final_url = new Urlslab_Url( $results['url'], true );
     710                    $final_url = new Urlslab_Url( $results['url'], true, true );
    710711                } catch ( Exception $e ) {
    711                     $final_url = $this->get_url();
     712                    $final_url = $this->get_url( true );
    712713                }
    713714            } else {
    714                 $final_url = $this->get_url();
     715                $final_url = $this->get_url( true );
    715716            }
    716717
  • urlslab/trunk/includes/executor/class-urlslab-executor-generate.php

    r3168189 r3171336  
    1414            $request = new FlowInvokeRequest( array( 'human_input' => $data['input'] ) );
    1515
     16            /** @var Urlslab_Widget_Content_Generator $widget */
     17            $widget = Urlslab_User_Widget::get_instance()->get_widget( Urlslab_Widget_Content_Generator::SLUG );
     18
    1619            $flow_variables = array();
    1720            foreach ( $data as $key => $value ) {
     
    1922                    continue;
    2023                }
    21                 $flow_variables[ $key ] = $value;
     24
     25                $flow_variables[ $key ] = $widget->get_template_value( $value, $data );
    2226            }
    2327            if ( ! empty( $flow_variables ) ) {
  • urlslab/trunk/includes/widget/class-urlslab-widget-content-generator.php

    r3169006 r3171336  
    33
    44class Urlslab_Widget_Content_Generator extends Urlslab_Widget {
    5     public const SLUG                          = 'urlslab-generator';
    6     public const SETTING_NAME_SCHEDULE         = 'urlslab-gen-sched';
     5    public const SLUG = 'urlslab-generator';
     6    public const SETTING_NAME_SCHEDULE = 'urlslab-gen-sched';
    77    public const SETTING_NAME_REFRESH_INTERVAL = 'urlslab-gen-refresh';
    8     public const SETTING_NAME_TRANSLATE        = 'urlslab-gen-translate';
    9     public const SETTING_NAME_TRACK_USAGE      = 'urlslab-gen-track-usage';
     8    public const SETTING_NAME_TRANSLATE = 'urlslab-gen-translate';
     9    public const SETTING_NAME_TRACK_USAGE = 'urlslab-gen-track-usage';
    1010    public const SETTING_NAME_TRANSLATE_FLOW_ID = 'urlslab-gen-translate-flow-id';
    1111
     
    107107            return '';
    108108        }
    109 
    110         $input_variables = $this->get_template_variables( $atts['input'] );
     109        $input_variables = array();
     110        foreach ( $atts as $key => $value ) {
     111            $input_variables = array_merge( $input_variables, $this->get_template_variables( $value ) );
     112        }
     113
    111114        foreach ( $input_variables as $variable ) {
    112115            if ( ! isset( $atts[ $variable ] ) ) {
  • urlslab/trunk/includes/widget/class-urlslab-widget-urls.php

    r3169173 r3171336  
    6969    const SETTING_NAME_SCREENSHOT_REFRESH_INTERVAL = 'urlslab-scr-refresh';
    7070    const SETTING_NAME_SUMMARIZATION_FLOW = 'urlslab-summary-flow';
     71    const SETTING_NAME_FIX_DOUBLESLASH = 'urlslab-fix-doubleslash';
    7172
    7273    private static $page_alternate_links = array();
     
    150151            $this->process_image_alt_text( $document );
    151152        }
     153        $this->fixDoubleSlashesInPath( $document );
    152154    }
    153155
     
    621623            function () {
    622624                return __( 'Ensure all links have the same protocol as the current domain.', 'urlslab' );
     625            },
     626            self::OPTION_TYPE_CHECKBOX,
     627            false,
     628            null,
     629            'validation'
     630        );
     631        $this->add_option_definition(
     632            self::SETTING_NAME_FIX_DOUBLESLASH,
     633            true,
     634            true,
     635            function () {
     636                return __( 'Fix double slashes in URL path', 'urlslab' );
     637            },
     638            function () {
     639                return __( 'Some plugins corrupt urls with double slashes, fix paths in urls and replace duplicate double slashes with single slash', 'urlslab' );
    623640            },
    624641            self::OPTION_TYPE_CHECKBOX,
     
    16101627    }
    16111628
     1629    private function fixDoubleSlashesInPath( DOMDocument $document ) {
     1630        if ( ! $this->get_option( self::SETTING_NAME_FIX_DOUBLESLASH ) ) {
     1631            return;
     1632        }
     1633        $xpath    = new DOMXPath( $document );
     1634        $elements = $xpath->query( '//a[@href and ' . $this->get_xpath_query( array( 'urlslab-skip-doubleslash-fix' ) ) . ']' );
     1635        foreach ( $elements as $dom_elem ) {
     1636            if ( strlen( $dom_elem->getAttribute( 'href' ) ) ) {
     1637                try {
     1638                    $url = new Urlslab_Url( $dom_elem->getAttribute( 'href' ) );
     1639                    if ( false !== strpos( $url->get_url_path(), '//' ) && $url->is_url_valid() ) {
     1640                        $url = new Urlslab_Url( $dom_elem->getAttribute( 'href' ), true, true );
     1641                        $dom_elem->setAttribute( 'href', $url->get_url_with_protocol() );
     1642                    }
     1643                } catch ( Exception $e ) {
     1644                    // noop, just skip link
     1645                }
     1646            }
     1647        }
     1648    }
     1649
     1650
    16121651    private function fixProtocol( DOMDocument $document ) {
    16131652        if ( ! $this->get_option( self::SETTING_NAME_FIX_PROTOCOL ) ) {
  • urlslab/trunk/readme.txt

    r3169741 r3171336  
    55Tested up to: 6.5
    66Requires PHP: 7.4
    7 Stable tag: 2.130.2
     7Stable tag: 2.130.6
    88License: GPLv2
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    144144== Changelog ==
    145145
    146 = 2.130.2 - 2024-10-16 =
     146= 2.130.6 - 2024-10-18 =
    147147
    148148* Experience a smoother user journey with our under-the-hood enhancements.
  • urlslab/trunk/urlslab.php

    r3169741 r3171336  
    1717 * Plugin URI:        https://github.com/QualityUnit/wp-urlslab
    1818 * Description:       URLsLab WordPress Plugin to optimize your website for search engines and enhance automatically content
    19  * Version: 2.130.2
     19 * Version: 2.130.6
    2020 * Requires at least: 6.0
    2121 * Requires PHP:      7.4
     
    3131}
    3232
    33 define( 'URLSLAB_VERSION', '2.130.2' );
     33define( 'URLSLAB_VERSION', '2.130.6' );
    3434define( 'URLSLAB_VERSION_SETTING', 'urlslab_ver' );
    3535define( 'URLSLAB_PLUGIN', __FILE__ );
  • urlslab/trunk/vendor_prefixed/composer/installed.php

    r3169741 r3171336  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '05439920eee7a4591d14fb55ab95ba147dc3e6f3',
     6        'reference' => 'a4353a0124d8d1d33f6e3e7a7813fd0d7fc7d555',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '05439920eee7a4591d14fb55ab95ba147dc3e6f3',
     16            'reference' => 'a4353a0124d8d1d33f6e3e7a7813fd0d7fc7d555',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../',
Note: See TracChangeset for help on using the changeset viewer.