Observations
prefix . ‘ashl_bird_observations’;
$charset_collate = $wpdb->get_charset_collate();
$sql = « CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
species varchar(100) NOT NULL,
observation_date datetime NOT NULL,
latitude decimal(10,8) NOT NULL,
longitude decimal(11,8) NOT NULL,
number_of_birds int NOT NULL,
behavior varchar(255),
habitat varchar(100),
comments text,
photo_url varchar(255),
user_id bigint(20) unsigned NOT NULL,
status varchar(20) NOT NULL DEFAULT ‘pending’,
created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) $charset_collate; »;
require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
dbDelta($sql);
}
register_activation_hook(__FILE__, ‘ashl_bird_activate’);
// Chargement des scripts et styles
function ashl_bird_enqueue_scripts() {
wp_enqueue_style(‘ashl-bird-style’, ASHL_BIRD_PLUGIN_URL . ‘assets/css/style.css’);
wp_enqueue_script(‘leaflet’, ‘https://unpkg.com/leaflet@1.7.1/dist/leaflet.js’, array(), null, true);
wp_enqueue_style(‘leaflet’, ‘https://unpkg.com/leaflet@1.7.1/dist/leaflet.css’);
wp_enqueue_script(‘ashl-bird-script’, ASHL_BIRD_PLUGIN_URL . ‘assets/js/script.js’, array(‘jquery’, ‘leaflet’), null, true);
wp_localize_script(‘ashl-bird-script’, ‘ashlBirdAjax’, array(‘ajaxurl’ => admin_url(‘admin-ajax.php’)));
}
add_action(‘wp_enqueue_scripts’, ‘ashl_bird_enqueue_scripts’);
// Shortcode pour le formulaire d’observation
function ashl_bird_form_shortcode() {
ob_start();
include ASHL_BIRD_PLUGIN_DIR . ‘templates/observation-form.php’;
return ob_get_clean();
}
add_shortcode(‘ashl_bird_form’, ‘ashl_bird_form_shortcode’);
// Shortcode pour la carte des observations
function ashl_bird_map_shortcode() {
ob_start();
include ASHL_BIRD_PLUGIN_DIR . ‘templates/observation-map.php’;
return ob_get_clean();
}
add_shortcode(‘ashl_bird_map’, ‘ashl_bird_map_shortcode’);
// Inclure les fichiers nécessaires
require_once ASHL_BIRD_PLUGIN_DIR . ‘includes/database-operations.php’;
require_once ASHL_BIRD_PLUGIN_DIR . ‘includes/api-endpoints.php’;
require_once ASHL_BIRD_PLUGIN_DIR . ‘includes/admin-functions.php’;