Plugin Directory


Ignore:
Timestamp:
11/19/2026 09:34:35 PM (35 hours ago)
Author:
codepeople
Message:

New version 1.3.1
Modifications in the changelogs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codepeople-post-map/trunk/include/functions.php

    r3588032 r3812534  
    109109                return wp_kses_post( $v );
    110110        } // End sanitize_description
     111
     112        function sanitize_api_key( $v )
     113        {
     114                if ( ! is_string( $v ) ) return '';
     115                $v = trim( $v );
     116                if ( '' === $v ) return '';
     117                // Google Maps API keys contain only letters, digits, dashes and underscores.
     118                // Removing every other character guarantees the value can never carry
     119                // markup into the admin JavaScript.
     120                return preg_replace( '/[^A-Za-z0-9_\-]/', '', $v );
     121    } // End sanitize_api_key
    111122
    112123        //---------- CREATE MAP ----------
    … …  
    938949                if( !empty( $api_key ) )
    939950                {
    940                         $cpm_global[ 'api_key' ] = trim($api_key);
     951                        $cpm_global[ 'api_key' ] = $this->sanitize_api_key( $api_key );
    941952                }
    942953                wp_localize_script('admin_cpm_script', 'cpm_global', $cpm_global);
    … …  
    9931004        } // End load_header_resources
    9941005
     1006        function help_page(){
     1007                echo("Redirecting to documentation...<script type='text/javascript'>document.location='http://wordpress.dwbooster.com/content-tools/codepeople-post-map?acode=18517';</script>");
     1008                exit;
     1009        }
     1010
     1011        function question_page(){
     1012                echo("Redirecting to documentation...<script type='text/javascript'>document.location='https://wordpress.org/support/plugin/codepeople-post-map/#new-post';</script>");
     1013                exit;
     1014        }
     1015
     1016        function upgrade_page(){
     1017                echo("Redirecting to upgrade page...<script type='text/javascript'>document.location='http://wordpress.dwbooster.com/content-tools/codepeople-post-map?acode=18517#download';</script>");
     1018                exit;
     1019        }
     1020
    9951021        /**
    9961022         * Print the settings page for entering the general setting's data of maps
    9971023         */
    9981024        function settings_page(){
    999                 if (isset($_GET["page"]))
    1000         {
    1001                         if( $_GET["page"] == 'google_maps_cp_upgrade' )
    1002                         {
    1003                                 echo("Redirecting to upgrade page...<script type='text/javascript'>document.location='http://wordpress.dwbooster.com/content-tools/codepeople-post-map?acode=18517#download';</script>");
    1004                                 exit;
    1005                         }
    1006                         elseif( $_GET["page"] == 'google_maps_cp_help')
    1007                         {
    1008                                 echo("Redirecting to documentation...<script type='text/javascript'>document.location='http://wordpress.dwbooster.com/content-tools/codepeople-post-map?acode=18517';</script>");
    1009                                 exit;
    1010                         }
    1011                         elseif( $_GET["page"] == 'google_maps_cp_question')
    1012                         {
    1013                                 echo("Redirecting to documentation...<script type='text/javascript'>document.location='https://wordpress.org/support/plugin/codepeople-post-map/#new-post';</script>");
    1014                                 exit;
    1015                         }
    1016 
    1017         }
     1025                if ( ! current_user_can( 'manage_options' ) ){
     1026                        wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'codepeople-post-map'), 403 );
     1027                }
    10181028
    10191029                // Check if post exists and save the configuraton options
    1020                 if (isset($_POST['cpm_map_noncename']) && wp_verify_nonce($_POST['cpm_map_noncename'],__FILE__)){
     1030                if (
     1031                        isset( $_POST['cpm_map_noncename'] ) &&
     1032                        wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cpm_map_noncename'] ) ), __FILE__ )
     1033                ){
    10211034                        $options = $_POST['cpm_map'];
    10221035                        $options = $this->array_map_recursive('sanitize_text_field', $options);
     1036                        $options['api_key'] = $this->sanitize_api_key( isset($options['api_key']) ? $options['api_key'] : '' );
    10231037                        $options['drag_map'] = ( isset( $options[ 'drag_map' ] ) ) ? true : false;
    10241038            $options['windowhtml'] = $this->get_configuration_option('windowhtml');
    … …  
    15261540
    15271541                $api_key = $this->get_configuration_option( 'api_key' );
    1528                 $output .= 'var cpm_api_key = ' . wp_json_encode( (!empty( $api_key )) ? trim($api_key) : '' ) . ";\n";
     1542                $output .= 'var cpm_api_key = ' . wp_json_encode( (!empty( $api_key )) ? $this->sanitize_api_key( $api_key ) : '' ) . ";\n";
    15291543
    15301544                $output .= "var cpm_global = cpm_global || {};\n";
Note: See TracChangeset for help on using the changeset viewer.