The plugin generated 2 characters of unexpected output during activation. If you
-
When I try to activate my plugin it shows me this warning, although in version 3.4 it worked fine, without warnings while activating.
My activation function code:
<?php /* * Plugin Name: Google Maps Plugin * Description: Google Maps * Version: 1.0 */ if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb']; $wpdb->gm_maps_table=$wpdb->prefix . "gm_maps"; $wpdb->gm_marker_table=$wpdb->prefix . "gm_marker_table"; $wpdb->gm_driving_table=$wpdb->prefix . "gm_directions_table"; $wpdb->gm_styled_maps_table=$wpdb->prefix . "gm_styled_maps"; require_once(plugin_dir_path(__FILE__) . 'extract_images.php'); require_once(plugin_dir_path(__FILE__) . 'driving.php'); require_once(plugin_dir_path(__FILE__) . 'styled_maps.php'); function gm_activate(){ global $wpdb; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); //create maps table $query="CREATE TABLE IF NOT EXISTS {$wpdb->gm_maps_table}(id int(100) NOT NULL AUTO_INCREMENT, map_title varchar(255) DEFAULT 'Map', map_width int(11) DEFAULT 400, map_height int(11) DEFAULT 400, map_start_lat varchar(20) DEFAULT NULL, map_start_lng varchar(20) DEFAULT NULL, styled_map tinyint(1) DEFAULT 1, map_type varchar(20) DEFAULT 'ROADMAP', start_zoom int(2) DEFAULT 8, UNIQUE KEY id (id));"; dbDelta($query); //first map if table is empty $check=$wpdb->get_results("SELECT * FROM {$wpdb->gm_maps_table}"); if(!$check){ $wpdb->insert($wpdb->gm_maps_table, array('id'=>1, 'map_title'=>"First map", 'map_height'=>300, 'map_width'=>300, 'map_start_lat'=>"44.5435289", 'map_start_lng'=>"26.8569689", 'styled_map'=>0, 'map_type'=>"ROADMAP")); } //create marker table $query="CREATE TABLE IF NOT EXISTS {$wpdb->gm_marker_table}(id int(100) NOT NULL AUTO_INCREMENT, marker_title varchar(255) NOT NULL DEFAULT 'marker', map_id varchar(255), m_start_lat varchar(20) DEFAULT NULL, m_start_lng varchar(20) DEFAULT NULL, text text(10000), icon_type varchar(255) DEFAULT 'gm_default', icon varchar(255) DEFAULT 'gm_default_marker.png', UNIQUE KEY id (id));"; dbDelta($query); //first marker if marker table is empty $check=$wpdb->get_results("SELECT * FROM {$wpdb->gm_marker_table}"); if(!$check){ $wpdb->insert($wpdb->gm_marker_table, array('map_id'=>1, 'm_start_lat'=>44, 'm_start_lng'=>26, 'text'=>"first marker", 'icon_type'=>"default", 'icon'=>'gm_default_marker.png')); } //create driving table $query="CREATE TABLE IF NOT EXISTS {$wpdb->gm_driving_table}( id int(100) NOT NULL AUTO_INCREMENT, map_name varchar(255) DEFAULT 'Directions map', height int(4) DEFAULT 300, width int(4) DEFAULT 300, map_type varchar(255) DEFAULT 'ROADMAP', map_center varchar(255) NOT NULL, zoom int(3) DEFAULT 8, value text(1000), dir_panel int(1) DEFAULT 1, travel_mode varchar(255) DEFAULT 'DRIVING', UNIQUE KEY id (id));"; dbDelta($query); $check=$wpdb->get_results("SELECT * FROM {$wpdb->gm_driving_table}"); if(!$check){ $wpdb->insert($wpdb->gm_driving_table, array('id'=>1, 'map_name'=>'First directions map', 'height'=>600, 'width'=>600, 'map_center'=>'40.66110427536902,-73.936015', 'value'=>'{\"start\":{\"lat\":40.70473,\"lng\":-73.90690000000001},\"end\":{\"lat\":40.61745000000001,\"lng\":-73.96512999999999},\"waypoints\":[{\"location\":{\"lat\":40.6766196,\"lng\":-73.96393560000001},\"stopover\":false}]}', 'travel_mode'=>'DRIVING', 'dir_panel'=>1, 'zoom'=>12)); } //create styled maps table $query="CREATE TABLE IF NOT EXISTS {$wpdb->gm_styled_maps_table}(id int(100) NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL DEFAULT 'Styled map', value text(10000), UNIQUE KEY id (id));"; dbDelta($query); $str=json_encode(array(array("featureType"=>'road', "elementType"=>'geometry', "stylers"=>array(array("visibility"=>'on', "color"=>'#808080', "hue"=>'#00ffff'))))); $check=$wpdb->get_results("SELECT * FROM {$wpdb->gm_styled_maps_table}"); if(!$check){ $wpdb->insert($wpdb->gm_styled_maps_table, array('id'=>1, 'name'=>"First styled map", 'value'=>$str)); } } register_activation_hook(__FILE__, 'gm_activate'); ?>
I’ve checked on white spaces before and after <?php ?>.
Anyone can help me to fix this problem?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘The plugin generated 2 characters of unexpected output during activation. If you’ is closed to new replies.