Plugin Directory

Changeset 3218190


Ignore:
Timestamp:
01/07/2025 08:49:37 AM (14 months ago)
Author:
albedo0
Message:

Version 1.10

Location:
boot-modal
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • boot-modal/trunk/boot_modal.php

    r2366537 r3218190  
    44Plugin URI: https://wordpress.org/plugins/boot-modal/
    55Description: A simple plugin to open any page in a Bootstrap modal window.
    6 Version: 1.9.1
     6Version: 1.10
    77Author: Julien Crego
    88Author URI: https://dev.juliencrego.com/boot-modal/
     
    6363        $this->options = get_option('bootmodal_plugin_options');
    6464       
     65        // Check the Bootstrap version and define the 5 by default
     66        if (!isset($this->options['bootstrap_version']) || intval($this->options['bootstrap_version']) < 4) {
     67            $this->options['bootstrap_version'] = 5; 
     68        } else {
     69            $this->options['bootstrap_version'] = intval($this->options['bootstrap_version']);
     70        }
     71
    6572        add_filter('widget_text', 'do_shortcode');
    6673        add_shortcode('bootmodal', array($this,'shortcodeLauncher') );
     
    99106                                ), $atts);
    100107        extract($params);
    101         $this->animation = $params['animation'] ;
    102         $this->postname = $params['post'] ;
    103         $this->buttonclass = $params['buttonclass'];
    104         $this->buttontype = $params['buttontype'];
    105         $this->buttontext = $params['buttontext'];
    106         $this->buttoncloseclass = $params['buttoncloseclass'];
    107         $this->buttonclosetext = $params['buttonclosetext'];
    108         $this->size = $params['size'];
    109         $this->urlkey = $params['urlkey'];
    110         $this->urlvalue = $params['urlvalue'];
    111         $this->dismiss = $params['dismiss'];
     108
     109        $this->animation = esc_attr($params['animation']) ;
     110        $this->postname = esc_attr($params['post']);
     111        $this->buttonclass = esc_attr($params['buttonclass']);
     112        $this->buttontype = esc_attr($params['buttontype']);
     113        $this->buttontext = esc_html($params['buttontext']);
     114        $this->buttoncloseclass = esc_attr($params['buttoncloseclass']);
     115        $this->buttonclosetext = esc_html($params['buttonclosetext']);
     116        $this->size = esc_attr($params['size']);
     117        $this->urlkey = esc_attr($params['urlkey']);
     118        $this->urlvalue = esc_attr($params['urlvalue']);
     119        $this->dismiss = esc_attr($params['dismiss']);
    112120       
    113121        ob_start();
     
    123131
    124132            // Construct link or button
    125             if($this->buttontype=="button" or ($this->buttontype=="" && $this->options['open_button_type']=="button")):
    126                 $this->html_button();
    127             else:
    128                 $this->html_link();
    129             endif;
     133            $this->html_button_or_link();
     134
    130135        } else {
    131136             _e( "Permalink unknow (Boot-modal)", 'bootmodal');
     
    138143   
    139144    public function addBootstrap() {
    140         if( !isset($this->options['bootstrap_version']) or $this->options['bootstrap_version'] == '3') {
    141             wp_enqueue_style('bootstrap-css', 'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css');
    142             wp_enqueue_script('bootstrap-js', 'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js', array('jquery'));
    143         } elseif($this->options['bootstrap_version'] == '4') {
    144             wp_enqueue_style('bootstrap-css', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/css/bootstrap.min.css');
    145             wp_enqueue_script('bootstrap-js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/js/bootstrap.bundle.min.js', array('jquery'));
     145        if($this->options['bootstrap_version'] <= 4) {
     146            // Bootstrap 4.6.2
     147            wp_enqueue_style('bootstrap-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', array(), '4.6.2');
     148            wp_enqueue_script('bootstrap-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js', array('jquery'), '4.6.2', true);
     149        } elseif($this->options['bootstrap_version'] == 5) {
     150            // Bootstrap 5.3.3
     151            wp_enqueue_style('bootstrap-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', array(), '5.3.3');
     152            wp_enqueue_script('bootstrap-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js', array('jquery'), '5.3.3', true);
    146153        }
    147154    }
     
    153160    }
    154161   
    155     public function html_button() {
    156         ?>
    157         <button type="button"
    158                 class="<?php echo($this->buttonclass=="")?$this->options['open_button_class']:$this->buttonclass; ?>"
    159                 data-toggle="modal"
    160                 <?php if($this->dismiss == 'yes') : ?>
    161                     data-dismiss="modal"
     162    public function html_button_or_link() {
     163        // Check the Bootstrap version
     164        if ($this->options['bootstrap_version'] == 5) {
     165            $dataDismiss = "data-bs-dismiss";
     166            $dataTarget = "data-bs-target";
     167            $dataToggle = "data-bs-toggle";
     168        } else {
     169            $dataDismiss = "data-dismiss";
     170            $dataTarget = "data-target";
     171            $dataToggle = "data-toggle";
     172        }
     173   
     174        // Button or link ?
     175        $is_button = ($this->buttontype == "button" || ($this->buttontype == "" && $this->options['open_button_type'] == "button"));
     176       
     177        if ($is_button) {
     178            ?>
     179            <button type="button"
     180                    class="<?php echo ($this->buttonclass == "") ? $this->options['open_button_class'] : $this->buttonclass; ?>"
     181                    <?= $dataToggle ?>="modal"
     182                    <?php if ($this->dismiss == 'yes') : ?>
     183                        <?= $dataDismiss ?>="modal"
     184                    <?php endif; ?>
     185                    <?= $dataTarget ?>="#<?php echo $this->post->post_name; ?>">
     186                <?php echo $this->buttontext; ?>
     187            </button>
     188            <?php
     189        } else {
     190            $url = site_url();
     191            $url_param = ($this->urlkey && $this->urlvalue) ? '?' . esc_attr($this->urlkey) . '=' . esc_attr($this->urlvalue) . '/#' : '/#';
     192            ?>
     193            <a href="<?php echo esc_url($url . '/index.php/' . $this->postname . $url_param); ?>"
     194               class="<?php echo esc_attr(($this->buttonclass == "") ? $this->options['open_button_class'] : $this->buttonclass); ?>"
     195               <?= $dataToggle ?>="modal"
     196               <?php if ($this->dismiss == 'yes') : ?>
     197                    <?= $dataDismiss ?>="modal"
    162198                <?php endif; ?>
    163                 data-target="#<?php echo $this->post->post_name; ?>">
    164             <?php echo $this->buttontext ; ?>
    165         </button>
    166         <?php
    167     }
    168    
    169     public function html_link() {
    170         $url = site_url();
    171         $url_param = ($this->urlkey && $this->urlvalue) ? '?'.$this->urlkey.'='.$this->urlvalue.'/#' : '/#';
    172         ?>
    173         <a href="<?php echo $url.'/index.php/'.$this->postname.$url_param; ?>"
    174            class="<?php echo($this->buttonclass=="")?$this->options['open_button_class']:$this->buttonclass; ?>"
    175            data-toggle="modal"
    176            <?php if($this->dismiss == 'yes') : ?>
    177                 data-dismiss="modal"
    178             <?php endif; ?>
    179            data-target="#<?php echo $this->post->post_name; ?>">
    180             <?php echo $this->buttontext ; ?>
    181         </a>
    182         <?php
    183     }
    184    
     199               <?= $dataTarget ?>="#<?php echo esc_attr($this->post->post_name); ?>">
     200                <?php echo $this->buttontext; ?>
     201            </a>
     202            <?php
     203        }
     204    }
     205
     206    /**
     207     * DEPRECATED : Insert HTML code for Modal with Bootstrap 3
     208     */
    185209    public function html_modal_bootstrap3() {
    186210        ?>
     
    206230        <?php
    207231    }
     232   
    208233    public function html_modal_bootstrap4() {
    209234        ?>
     
    224249                        <button type="button" class="<?php echo ($this->buttoncloseclass) ? $this->buttoncloseclass : $this->options['button_class']; ?>" data-dismiss="modal">
    225250                            <?php if($this->buttonclosetext){echo $this->buttonclosetext ;}elseif($this->options['button_text']!=""){ echo $this->options['button_text'];} else { _e( "Close", 'bootmodal'); } ?>
     251                        </button>
     252                    </div>
     253                </div>
     254            </div>
     255        </div>
     256        <?php
     257    }
     258
     259    public function html_modal_bootstrap5() {
     260        ?>
     261        <div class="modal <?php echo $this->anim_value; ?>"
     262             id="<?php echo $this->post->post_name; ?>" tabindex="-1" aria-labelledby="modalLabel_<?php echo $this->post->post_name; ?>" aria-hidden="true">
     263            <div class="modal-dialog <?php echo $this->size; ?>">
     264                <div class="modal-content">
     265                    <div class="modal-header">
     266                        <h5 class="modal-title" id="modalLabel_<?php echo $this->post->post_name; ?>">
     267                            <?php echo apply_filters('translate_text', $this->post->post_title, $this->locale); ?>
     268                        </h5>
     269                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?php echo ($this->options['button_text'] != "") ? $this->options['button_text'] : _e( "Close", 'bootmodal'); ?>"></button>
     270                    </div>
     271                    <div class="modal-body">
     272                        <?php echo apply_filters('the_content', apply_filters('translate_text', $this->post->post_content, $this->locale)); ?>
     273                    </div>
     274                    <div class="modal-footer">
     275                        <button type="button" class="<?php echo ($this->buttoncloseclass) ? $this->buttoncloseclass : $this->options['button_class']; ?>" data-bs-dismiss="modal">
     276                            <?php echo ($this->buttonclosetext) ? $this->buttonclosetext : (($this->options['button_text'] != "") ? $this->options['button_text'] : _e( "Close", 'bootmodal')); ?>
    226277                        </button>
    227278                    </div>
     
    245296        }
    246297       
    247         if( !isset($this->options['bootstrap_version']) or $this->options['bootstrap_version'] == '3') {
    248             $this->html_modal_bootstrap3();
    249         } elseif($this->options['bootstrap_version'] == '4') {
     298        if( $this->options['bootstrap_version'] <= 4) {
    250299            $this->html_modal_bootstrap4();
     300        } elseif($this->options['bootstrap_version'] == 5) {
     301            $this->html_modal_bootstrap5();
    251302        }
    252303
     
    562613     */
    563614    function load_admin_css() {
    564     wp_enqueue_style( 'bootmodal_admin', plugins_url( $this->plugin_folder.'/css/boot_modal_admin.css'));
     615        wp_enqueue_style( 'bootmodal_admin', plugins_url( $this->plugin_folder.'/css/boot_modal_admin.css'));
    565616    }
    566617
     
    588639                            array('name'=>'bootstrap_version',
    589640                                'description' => __( "Version of bootstrap to use.", 'bootmodal'),
    590                                 'options'=>array( '3' => '3',
    591                                                   '4' => '4')));
     641                                'options'=>array( '4' => '4',
     642                                                  '5' => '5')));
    592643
    593644        // Links params
  • boot-modal/trunk/readme.txt

    r2366537 r3218190  
    44Tags: modal, bootstrap, shortcode
    55Requires at least: 3.0.1
    6 Tested up to: 5.5
     6Tested up to: 6.7
    77Stable tag: trunk
    88License: GPLv2 or later
     
    4646
    4747== Changelog ==
     48= 1.10 =
     49* Corrected Shortcode XSS vulnerability.
     50* Added support for Bootstrap 5.
     51* Removed support for Bootstrap 3.
     52
    4853= 1.9 =
    49 * Add the possibility to choose the version of Bootstrap (3 or 4)
    50 * Use CDN to deliver Bootstrap
    51 * Add Custom CSS
     54* Added the ability to choose the Bootstrap version (3 or 4).
     55* Used CDN to deliver Bootstrap.
     56* Added support for custom CSS.
    5257
    5358= 1.8 =
    54 * Correct issue of position for the button
     59* Fixed button position issue.
    5560
    5661= 1.7 =
    57 * Add the dismiss shortcode option
    58 * Translation corrections
     62* Added the "dismiss" shortcode option.
     63* Translation corrections.
    5964
    6065= 1.6 =
    61 * Add a button in editor to generate the shortcode
    62 * New shortcode option : animation, buttoncloseclass and buttonclosetext
     66* Added a button in the editor to generate the shortcode.
     67* New shortcode options: animation, buttoncloseclass, and buttonclosetext.
    6368
    6469= 1.5 =
    65 * Changes by Christer to :
    66  - take into account multi-lingual pages
    67  - process shortcodes in the page appearing in the modal
    68  - make it possible to send a parameter in the URL for the page being opened in the modal
    69    This makes it possible to customize the content of the page
    70    The parameter consists of a url_key (parameter name) and url_value
    71  Thanks to him !!
    72 * New shortcode option : buttontext
     70* Changes by Christer:
     71  - Added support for multilingual pages.
     72  - Shortcodes are now processed in the page displayed in the modal.
     73  - Added the ability to send parameters in the URL for the page being opened in the modal, enabling content customization. The parameter consists of a url_key (parameter name) and url_value.
     74  Thanks to him!
     75* New shortcode option: buttontext.
    7376
    7477= 1.4.1 =
    75 * Add modification from "Christer_f" published in forum
    76 * Minor corrections
     78* Added changes from "Christer_f" published in the forum.
     79* Minor corrections.
    7780
    7881= 1.4 =
    79 * Correct Warning: substr() expects parameter 1 to be string, array given in wp-includes/functions.php on line 1679
     82* Fixed Warning: substr() expects parameter 1 to be string, array given in wp-includes/functions.php on line 1679.
    8083
    8184= 1.3 =
    82 * Correct issue of position
     85* Fixed position issue.
    8386
    8487
    85 
Note: See TracChangeset for help on using the changeset viewer.