ID); //nonce if($options_values_prev['user_can_set'] == 1 && current_user_can('read')) { $weather_info = isset($_POST['weather-info']) ? true : false; update_user_meta($user->ID, 'weather-info', $weather_info); if (pk_aqp_longitude_filter($_POST['longitude']) && pk_aqp_latitude_filter($_POST['latitude'])) { $longitude = pk_aqp_longitude_filter($_POST['longitude']); $latitude = pk_aqp_latitude_filter($_POST['latitude']); update_user_meta($user->ID, 'longitude', $longitude); update_user_meta($user->ID, 'latitude', $latitude); } else { pk_aqp_display_error(__('Given coordinates are wrong. Please give values in range from -180 to 180 for longitude and from -90 to 90 for latitude', 'air-quality-plugin'), 'error'); } } if(current_user_can('manage_options')) { if (pk_aqp_longitude_filter($_POST['longitude-default']) && pk_aqp_latitude_filter($_POST['latitude-default'])) { $longitude_default = pk_aqp_longitude_filter($_POST['longitude-default']); $latitude_default = pk_aqp_latitude_filter($_POST['latitude-default']); $options['longitude'] = $longitude_default; $options['latitude'] = $latitude_default; } else { pk_aqp_display_error(__('Given coordinates are wrong. Please give values in range from -180 to 180 for longitude and from -90 to 90 for latitude', 'air-quality-plugin'), 'error'); $options['longitude'] = $options_values_prev['longitude']; $options['latitude'] = $options_values_prev['latitude']; } if (preg_match('/^[-_A-za-z0-9]{0,}$/', $_POST['google-maps-key'])) { $google_maps_key = $_POST['google-maps-key']; $options['google_maps_key'] = $google_maps_key; } else { pk_aqp_display_error(__('Wrong Google Maps API key was given', 'air-quality-plugin'), 'error'); $options['google_maps_key'] = $options_values_prev['google_maps_key']; } if (preg_match('/^[A-za-z0-9]{0,}$/', $_POST['waqi-key'])) { $waqi_key = $_POST['waqi-key']; $options['waqi_key'] = $waqi_key; } else { pk_aqp_display_error(__('Wrong waqi.info API key was given', 'air-quality-plugin'), 'error'); $options['waqi_key'] = $options_values_prev['waqi_key']; } $user_can_set = isset($_POST['user-can-set']) ? true : false; $weather_info_default = isset($_POST['weather-info-default']) ? true : false; $options['user_can_set'] = $user_can_set; $options['weather_info'] = $weather_info_default; update_option('pk_aqp_options', $options); } pk_aqp_display_error(__('Saved options', 'air-quality-plugin'), 'updated'); } $options_values = get_option('pk_aqp_options'); $longitude_value = get_user_meta($user->ID, 'longitude', true); $latitude_value = get_user_meta($user->ID, 'latitude', true); $weather_info = get_user_meta($user->ID, 'weather-info', true); $google_api_key = $options_values['google_maps_key']; $admin_script_localization = array( 'google_api_error' => __('Something went wrong during retrieving information from google, try again', 'air-quality-plugin'), 'google_api_authentication_error' => __('There was a problem with your Google Maps API key, probably you do not entered it correctly, or you do not enabled Geocoding API for your key') ); wp_enqueue_style('pk-aqp-admin-style', PK_AQP_DIR_PATH . 'css/style-admin.css', '', PK_AQP_VERSION); wp_enqueue_script('pk-aqp-admin-script', PK_AQP_DIR_PATH . 'js/script-admin.js', array('jquery'), PK_AQP_VERSION); wp_localize_script('pk-aqp-admin-script', 'pk_aqp_admin_l10n', $admin_script_localization); if(!empty($google_api_key)) { wp_enqueue_script('pk-aqp-google-maps-script', "https://maps.googleapis.com/maps/api/js?key=$google_api_key&libraries=places&callback=initAutocomplete", array('jquery', 'pk-aqp-admin-script')); } ?>

ID) ?>

>

()
()
>
>