Changeset 3812534 for codepeople-post-map/trunk/include/functions.php
- Timestamp:
- 11/19/2026 09:34:35 PM (35 hours ago)
- File:
-
- 1 edited
-
codepeople-post-map/trunk/include/functions.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codepeople-post-map/trunk/include/functions.php
r3588032 r3812534 109 109 return wp_kses_post( $v ); 110 110 } // 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 111 122 112 123 //---------- CREATE MAP ---------- … … 938 949 if( !empty( $api_key ) ) 939 950 { 940 $cpm_global[ 'api_key' ] = trim($api_key);951 $cpm_global[ 'api_key' ] = $this->sanitize_api_key( $api_key ); 941 952 } 942 953 wp_localize_script('admin_cpm_script', 'cpm_global', $cpm_global); … … 993 1004 } // End load_header_resources 994 1005 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 995 1021 /** 996 1022 * Print the settings page for entering the general setting's data of maps 997 1023 */ 998 1024 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 } 1018 1028 1019 1029 // 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 ){ 1021 1034 $options = $_POST['cpm_map']; 1022 1035 $options = $this->array_map_recursive('sanitize_text_field', $options); 1036 $options['api_key'] = $this->sanitize_api_key( isset($options['api_key']) ? $options['api_key'] : '' ); 1023 1037 $options['drag_map'] = ( isset( $options[ 'drag_map' ] ) ) ? true : false; 1024 1038 $options['windowhtml'] = $this->get_configuration_option('windowhtml'); … … 1526 1540 1527 1541 $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"; 1529 1543 1530 1544 $output .= "var cpm_global = cpm_global || {};\n";
Note:
See TracChangeset
for help on using the changeset viewer.