Plugin Directory

Changeset 3426891


Ignore:
Timestamp:
12/24/2025 01:50:12 PM (3 months ago)
Author:
devsoftbaltic
Message:

Release 2.5.2 - fixed guideline violations, naming, escaping, i18n, sanitization, license

Location:
surveyjs/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • surveyjs/trunk/ajax_handlers/insert_survey.php

    r3403869 r3426891  
    2828                foreach ($client->getSurveys() as $surveyDefinition) {
    2929                    ?>
    30                     <option value="<?php echo sanitize_text_field($surveyDefinition->id) ?>"><?php echo sanitize_text_field($surveyDefinition->name) ?></option>
     30                    <option value="<?php echo esc_attr($surveyDefinition->id) ?>"><?php echo esc_html($surveyDefinition->name) ?></option>
    3131                    <?php
    3232                }
  • surveyjs/trunk/initializer.php

    r3426187 r3426891  
    142142        //                 __CLASS__, 'wps_mysurveys_page'
    143143        //                 ));
    144         add_submenu_page( 'surveyjs-main-menu', __( 'Settings', 'surveyjs-main-menu' ), __( 'Settings', 'surveyjs-main-menu' ), 'manage_options', 'surveyjs-settings', array( 'SurveyJS_SettingsPage', 'surveyjs_render_settings' ) );
     144        add_submenu_page( 'surveyjs-main-menu', esc_html__( 'Settings', 'surveyjs' ), esc_html__( 'Settings', 'surveyjs' ), 'manage_options', 'surveyjs-settings', array( 'SurveyJS_SettingsPage', 'surveyjs_render_settings' ) );
    145145        add_submenu_page('', '', '', 'manage_options', 'surveyjs_editor', array('SurveyJS_Editor', 'render'));
    146146        add_submenu_page('', '', '', 'manage_options', 'surveyjs_results', array('SurveyJS_Results', 'render'));
     
    154154        $url = wp_nonce_url($url, 'surveyjs-insert-survey', '_wpnonce');
    155155        ?>
    156         <a onclick="tb_click.call(this); return false;" href="<?php echo esc_url($url); ?>" class="button" title="<?php _e('Insert Survey', SurveyJS_SurveyJS::$prefix); ?>">
    157             <?php _e('Add Survey', SurveyJS_SurveyJS::$prefix); ?>
     156        <a onclick="tb_click.call(this); return false;" href="<?php echo esc_url($url); ?>" class="button" title="<?php esc_attr_e('Insert Survey', 'surveyjs'); ?>">
     157            <?php esc_html_e('Add Survey', 'surveyjs'); ?>
    158158        </a>
    159159        <?php
     
    175175        ?>
    176176        <div class="wp-sjs-plugin" id="surveyContainer-<?php echo esc_attr($id) ?>">
    177             <div id="surveyElement-<?php echo $id ?>">Survey is loading...</div>
    178             <div id="surveyResult-<?php echo $id ?>"></div>
     177            <div id="surveyElement-<?php echo esc_attr($id) ?>">Survey is loading...</div>
     178            <div id="surveyResult-<?php echo esc_attr($id) ?>"></div>
    179179        </div>
    180180        <script>
     
    182182                url:  "<?php echo esc_url($getSurveyJsonUri)  ?>",
    183183                type: "POST",
    184                 data: { Id: <?php echo $id ?>, _wpnonce: '<?php echo $getSurveyJsonNonce; ?>' },
     184                data: { Id: <?php echo intval($id); ?>, _wpnonce: '<?php echo esc_js( $getSurveyJsonNonce ); ?>' },
    185185                success: function (data) {
    186186                    var json = {}
     
    195195                    }
    196196                    jQuery(document).ready(()=>{
    197                         initSurvey<?php echo $id ?>(json, theme);
     197                        initSurvey<?php echo intval($id); ?>(json, theme);
    198198                    });
    199199                }
    200200            });
    201201
    202             function initSurvey<?php echo $id ?>(json, theme) {
    203                 const survey<?php echo $id ?> = new Survey.Model(json);
     202            function initSurvey<?php echo intval($id); ?>(json, theme) {
     203                const survey<?php echo intval($id); ?> = new Survey.Model(json);
    204204                if (!!theme) {
    205                     survey<?php echo $id ?>.applyTheme(theme);
     205                    survey<?php echo intval($id); ?>.applyTheme(theme);
    206206                }
    207                 window.survey<?php echo $id ?> = survey<?php echo $id ?>;               
    208                 survey<?php echo $id ?>
     207                window.survey<?php echo intval($id); ?> = survey<?php echo intval($id); ?>;               
     208                survey<?php echo intval($id); ?>
    209209                    .onComplete
    210210                    .add(function (sender, options) {
     
    213213                            url:  "<?php echo esc_url($saveResultUri) ?>",
    214214                            type: "POST",
    215                     data: { SurveyId: '<?php echo $id ?>', Json : JSON.stringify(sender.data), _wpnonce: '<?php echo $saveResultNonce; ?>' },
     215                    data: { SurveyId: '<?php echo intval($id); ?>', Json : JSON.stringify(sender.data), _wpnonce: '<?php echo esc_js( $saveResultNonce ); ?>' },
    216216                            success: function (data) {options.showSaveSuccess();},
    217217                            error: function (xhr) {options.showSaveError(xhr.responseText);}
    218218                        });
    219219                        //document
    220                         //    .querySelector("#surveyResult-<?php echo $id ?>")
     220                        //    .querySelector("#surveyResult-<?php echo intval($id); ?>")
    221221                        //    .innerHTML = "result: " + JSON.stringify(sender.data);
    222222                    });
    223223
    224                 survey<?php echo $id ?>.onUploadFiles.add((_, options) => {
     224                survey<?php echo intval($id); ?>.onUploadFiles.add((_, options) => {
    225225                    const formData = new FormData();
    226226                    options.files.forEach((file) => {
    227227                        formData.append(file.name, file);
    228228                    });
    229                 formData.append("_wpnonce", "<?php echo $uploadFilesNonce; ?>");
     229                formData.append("_wpnonce", "<?php echo esc_js( $uploadFilesNonce ); ?>");
    230230
    231231                    fetch("<?php echo esc_url($uploadFileUri) ?>", {
     
    260260                }
    261261
    262                 survey<?php echo $id ?>.onClearFiles.add((_, options) => {
     262                survey<?php echo intval($id); ?>.onClearFiles.add((_, options) => {
    263263                    if (!options.value || options.value.length === 0) {
    264264                        options.callback("success");
     
    283283                });
    284284
    285                 jQuery("#surveyElement-<?php echo $id ?>").Survey({model: survey<?php echo $id ?>/*, css: customCss*/});
     285                jQuery("#surveyElement-<?php echo esc_attr($id) ?>").Survey({model: survey<?php echo intval($id); ?>/*, css: customCss*/});
    286286            }
    287287        </script>       
  • surveyjs/trunk/readme.txt

    r3426296 r3426891  
    11=== SurveyJS: Drag & Drop Form Builder ===
    22Contributors: DevSoft Baltic
    3 Tags: survey, quiz, form builder, survey creator, survey maker, quiz creator
     3Tags: survey, quiz, form builder, survey creator, survey maker
    44Requires at least: 6.4
    55Tested up to: 6.9
    6 Stable tag: trunk
     6Stable tag: 2.5.2
    77Requires PHP: 8.2
    8 License: GPLv2 or later
    9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
    108
    119== Description ==
     
    8280
    8381
    84 = v2.4.1 =
     82= v2.5.2 =
    8583
    8684== Support ==
  • surveyjs/trunk/surveyjs.php

    r3426187 r3426891  
    44Plugin URI: https://wordpress.org/plugins/surveyjs
    55Description: Easy to use, drag & drop Survey Builder with myriad options.
    6 Version: 2.4.1
     6Version: 2.5.2
    77Author: Devsoft Baltic OÜ
    88Author URI: http://devsoftbaltic.com/
     9License: "SEE LICENSE IN LICENSE"
     10License URI: "https://github.com/surveyjs/surveyjs-wordpress/tree/master?tab=License-1-ov-file"
    911*/
    1012?>
  • surveyjs/trunk/views/editor.php

    r3426187 r3426891  
    2121        $renameSurveyNonce = wp_create_nonce('surveyjs-rename-survey');
    2222        $uploadFileNonce = wp_create_nonce('surveyjs-upload-file');
    23         $lk = sanitize_text_field(SurveyJS_SettingsPage::get_license_key());
     23        $lk = SurveyJS_SettingsPage::get_license_key();
    2424        ?>
    2525            <style>
     
    3434            </style>
    3535            <script>
    36                 var surveyName = "<?php echo sanitize_text_field($_GET['name']) ?>";
     36                var surveyName = "<?php echo esc_js( sanitize_text_field($_GET['name']) ); ?>";
    3737                function setSurveyName(name) {
    3838                    var $titleTitle = jQuery("#sjs_editor_title_show");
     
    6464                        url:  "<?php echo esc_url($renameSurveyUri) ?>",
    6565                        type: "POST",
    66                         data: { Id: '<?php echo $surveyId ?>', Name: surveyName, _wpnonce: '<?php echo $renameSurveyNonce; ?>' },
     66                        data: { Id: '<?php echo intval($surveyId); ?>', Name: surveyName, _wpnonce: '<?php echo esc_js($renameSurveyNonce); ?>' },
    6767                        success: function (data) {
    6868                            // if(data.isSuccess) {
     
    7878                    </div>
    7979                </div>
    80                 <h2 style="display:inline-block;"><?php _e( 'Survey: ', 'sjs' ); ?></h2>
     80                <h2 style="display:inline-block;"><?php esc_html_e( 'Survey: ', 'surveyjs' ); ?></h2>
    8181                <h3 style="display:inline-block; margin: 0;">
    8282                    <span id="sjs_editor_title_edit" style="display: none;">
     
    9595                <script type="text/babel">
    9696                    function SurveyCreatorRenderComponent() {
    97                         var lk = '<?php echo $lk ?>';
     97                        var lk = '<?php echo esc_js( $lk ); ?>';
    9898                        Survey.slk(lk);
    9999                        var editorOptions = { showThemeTab: true, showLogicTab: true, showTranslationTab: true, showEmbededSurveyTab: false, showOptions: true, generateValidJSON : false };
     
    107107                                url:  "<?php echo esc_url($saveSurveyUri) ?>",
    108108                                type: "POST",
    109                                 data: { Id: '<?php echo $surveyId ?>', Json: json, Theme: theme, _wpnonce: '<?php echo $saveSurveyNonce; ?>' },
     109                                data: { Id: '<?php echo intval($surveyId); ?>', Json: json, Theme: theme, _wpnonce: '<?php echo esc_js($saveSurveyNonce); ?>' },
    110110                                success: function (data) {
    111111                                    // if(data.isSuccess) {
     
    121121                                url:  "<?php echo esc_url($saveSurveyUri) ?>",
    122122                                type: "POST",
    123                                 data: { Id: '<?php echo $surveyId ?>', Json: json, Theme: theme, _wpnonce: '<?php echo $saveSurveyNonce; ?>' },
     123                                data: { Id: '<?php echo intval($surveyId); ?>', Json: json, Theme: theme, _wpnonce: '<?php echo esc_js($saveSurveyNonce); ?>' },
    124124                                success: function (data) {
    125125                                    // if(data.isSuccess) {
     
    134134                                formData.append("file", file);
    135135                            });
    136                             formData.append("_wpnonce", "<?php echo $uploadFileNonce; ?>");
     136                            formData.append("_wpnonce", "<?php echo esc_js($uploadFileNonce); ?>");
    137137                            jQuery.ajax({
    138138                                url: "<?php echo esc_url($uploadFileUri) ?>",
  • surveyjs/trunk/views/mysurveys.php

    r3403869 r3426891  
    2222                        url:  "<?php echo esc_url($addSurveyUri) ?>",
    2323                        type: "POST",
    24                         data: { Name: "New Survey", _wpnonce: '<?php echo $addSurveyNonce; ?>' },
     24                        data: { Name: "New Survey", _wpnonce: '<?php echo esc_js($addSurveyNonce); ?>' },
    2525                        success: function (data) {
    2626                            window.location = "<?php echo esc_url($editSurveyUri) ?>&id=" + data.Id + "&name=New Survey";
     
    3434                        url:  "<?php echo esc_url($deleteSurveyUri)  ?>",
    3535                        type: "POST",
    36                         data: { Id: id, _wpnonce: '<?php echo $deleteSurveyNonce; ?>' },
     36                        data: { Id: id, _wpnonce: '<?php echo esc_js($deleteSurveyNonce); ?>' },
    3737                        success: function (data) {
    3838                            window.location = "";
     
    4444                        url:  "<?php echo esc_url($cloneSurveyUri)  ?>",
    4545                        type: "POST",
    46                         data: { SurveyParentId: id, _wpnonce: '<?php echo $cloneSurveyNonce; ?>' },
     46                        data: { SurveyParentId: id, _wpnonce: '<?php echo esc_js($cloneSurveyNonce); ?>' },
    4747                        success: function (data) {
    4848                            window.location = "";
     
    5656                    <div class="sv_container">
    5757                        <div class="sv_header">
    58                             <h3><?php _e( 'SurveyJS Wordpress plugin', 'sjs' ); ?></h2></h3>
     58                            <h3><?php esc_html_e( 'SurveyJS Wordpress plugin', 'surveyjs' ); ?></h3>
    5959                            <p>Below you can see the list of available surveys you can edit, run and see the results</p>
    6060                        </div>
     
    7878                                        ?>
    7979                                        <tr>
    80                                             <td><?php echo sanitize_text_field($surveyDefinition->name) ?></td>
     80                                            <td><?php echo esc_html($surveyDefinition->name) ?></td>
    8181                                            <td>
    8282                                                <!-- <a class="sv_button_link" href="<?php echo sanitize_key($surveyDefinition->id) ?>">Run</a> -->
  • surveyjs/trunk/views/results.php

    r3426187 r3426891  
    3434                    <div class="sv_container">
    3535                        <div class="sv_header">
    36                             <h3 class="results-header"><?php echo $surveyName; ?> survey results</h3>
     36                            <h3 class="results-header"><?php echo esc_html($surveyName); ?> survey results</h3>
    3737                        </div>
    3838                        <div class="sv_body">
     
    4646            <script>
    4747                var $ = jQuery;
    48                 var surveyJson = "<?php echo $surveyJson; ?>";
     48                var surveyJson = '<?php echo htmlspecialchars_decode($surveyJson); ?>';
    4949                var survey = new Survey.Model(JSON.parse(surveyJson));
    5050
     
    104104 
    105105                <?php
    106                     echo 'var results = ', json_encode($surveyResults), ';';
     106                    echo 'var results = ', wp_json_encode($surveyResults), ';';
    107107                ?>
    108108
     
    138138                        url:  "<?php echo esc_url($deleteResultUri) ?>",
    139139                        type: "POST",
    140                         data: { ResultId: data.resultId, _wpnonce: '<?php echo $deleteResultNonce; ?>' },
     140                        data: { ResultId: data.resultId, _wpnonce: '<?php echo esc_js($deleteResultNonce); ?>' },
    141141                        success: function (data) {
    142142                            row.remove();
  • surveyjs/trunk/views/settings.php

    r3426187 r3426891  
    1515        $settings = (array) get_option( 'surveyjs-settings' );
    1616        if ( isset( $settings['license_key'] ) ) {
    17             return esc_js( $settings['license_key'] );
     17            return $settings['license_key'];
    1818        }
    1919        return "";
     
    2121
    2222    public function init() {
    23         register_setting( 'surveyjs-settings-group', 'surveyjs-settings' );
     23        register_setting( 'surveyjs-settings-group', 'surveyjs-settings', array(
     24            'type'              => 'array',
     25            'sanitize_callback' => array( $this, 'sanitize_settings' ),
     26        ) );
    2427
    25         add_settings_section( 'sjs-license-key-section', __( 'Set License Key', 'sjs' ), array($this, 'sjs_license_key_section'), 'surveyjs-settings-page' );
    26         add_settings_field( 'license_key', __( 'License Key', 'sjs' ), array($this, 'set_license_key_render'), 'surveyjs-settings-page', 'sjs-license-key-section' );
     28        add_settings_section( 'sjs-license-key-section', esc_html__( 'Set License Key', 'surveyjs' ), array($this, 'sjs_license_key_section'), 'surveyjs-settings-page' );
     29        add_settings_field( 'license_key', esc_html__( 'License Key', 'surveyjs' ), array($this, 'set_license_key_render'), 'surveyjs-settings-page', 'sjs-license-key-section' );
    2730    }
    2831
     32    public function sanitize_settings( $input ) {
     33        $sanitized = array();
     34        if ( isset( $input['license_key'] ) ) {
     35            $sanitized['license_key'] = sanitize_text_field( $input['license_key'] );
     36        }
     37        return $sanitized;
     38    }
     39
    2940    public function sjs_license_key_section() {
    30         _e( 'setting your license key', 'sjs' );
     41        esc_html_e( 'setting your license key', 'surveyjs' );
    3142        if ( isset( $_GET["settings-updated"] ) && sanitize_text_field($_GET["settings-updated"]) ) {
    3243            flush_rewrite_rules( true );
    33             echo "<div style='color: #179d82;'>" . __( 'Successfully updated!', 'sjs' ) . "</div>";
     44            echo "<div style='color: #179d82;'>" . esc_html__( 'Successfully updated!', 'surveyjs' ) . "</div>";
    3445        }
    3546    }
     
    4556        if ($license_key )
    4657        {
    47             echo "<input type='text' placeholder='put the license key here...' name='surveyjs-settings[license_key]' id='surveyjs-settings[license_key]' value='$license_key' style='width: 350px;'/>";
     58            echo "<input type='text' placeholder='put the license key here...' name='surveyjs-settings[license_key]' id='surveyjs-settings[license_key]' value='" . esc_attr( $license_key ) . "' style='width: 350px;'/>";
    4859        } else {
    4960            echo "<input type='text' placeholder='put the license key here...' name='surveyjs-settings[license_key]' id='surveyjs-settings[license_key]' style='width: 350px;'/>";
     
    5465        ?>
    5566        <div class="wrap">
    56             <h2><?php _e( 'SurveyJS Settings', 'sjs' ); ?></h2>
     67            <h2><?php esc_html_e( 'SurveyJS Settings', 'surveyjs' ); ?></h2>
    5768            <form action="options.php" method="POST">
    5869                <?php settings_fields( 'surveyjs-settings-group' ); ?>
Note: See TracChangeset for help on using the changeset viewer.