| Server IP : 145.239.37.162 / Your IP : 216.73.217.46 Web Server : Apache System : Linux webm003.cluster130.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaa ( 38250) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaa/www2024/wp-content/plugins/pop-up-pluginknock/ |
Upload File : |
<?php
/*
Plugin Name: pop-up
Plugin URI: alencrebleue
Description: affiche une pop-up au chargement de la page
Version: 1.0
Author: alencrebleue
Author URI: alencrebleue.com
*/
// creation table BDD gestion des images
function create_plugin_database_table()
{
global $wpdb;
$table_name = $wpdb->prefix . 'popupaeb';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url varchar(55) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
register_activation_hook(__FILE__, 'create_plugin_database_table');
function delete_plugin_database_table()
{
global $wpdb;
$table_name = $wpdb->prefix . 'popupaeb';
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
}
register_deactivation_hook(__FILE__, 'delete_plugin_database_table');
// add to menu
function pop_up_plugin_menu()
{
add_menu_page('Pop-up', 'Pop-up', 'manage_options', 'pop-up-plugin', 'pop_up_content', 'dashicons-info-outline');
}
add_action('admin_menu', 'pop_up_plugin_menu');
// include files for displays
if (is_admin()) {
require_once(plugin_dir_path(__FILE__) . 'admin/class-pop-up-admin.php');
}
if (!is_admin()) {
require_once(plugin_dir_path(__FILE__) . 'public/class-pop-up-public.php');
}
// content display
function pop_up_content()
{
if (is_admin()) {
Pop_up_admin::display();
} else {
Pop_up_public::display();
}
}
add_action('wp_footer', 'pop_up_content');
function pop_up_styles()
{
wp_enqueue_style('pop-up-styles', plugin_dir_url(__FILE__) . 'pop-up-plugin.css');
}
add_action('template_redirect', 'pop_up_styles');
add_action('admin_enqueue_scripts', 'pop_up_styles');
function load_media_files()
{
wp_enqueue_media();
}
add_action('admin_enqueue_scripts', 'load_media_files');
// ne fonctionne pas, envoie ne fonctionne pas
function media_selector_print_scripts()
{
$my_saved_attachment_post_id = get_option('media_selector_attachment_id', 0);
?><script type='text/javascript'>
jQuery(document).ready(function($) {
// Uploading files
var file_frame;
var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
var set_to_post_id = <?php echo $my_saved_attachment_post_id; ?>; // Set this
jQuery('#upload-button').on('click', function(event) {
event.preventDefault();
// If the media frame already exists, reopen it.
if (file_frame) {
// Set the post ID to what we want
file_frame.uploader.uploader.param('post_id', set_to_post_id);
// Open frame
file_frame.open();
return;
} else {
// Set the wp.media post id so the uploader grabs the ID we want when initialised
wp.media.model.settings.post.id = set_to_post_id;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
title: 'Select a image to upload',
button: {
text: 'Use this image',
},
multiple: false // Set to true to allow multiple files to be selected
});
// When an image is selected, run a callback.
file_frame.on('select', function() {
// We set multiple to false so only get one image from the uploader
attachment = file_frame.state().get('selection').first().toJSON();
// Do something with attachment.id and/or attachment.url here
$('#image-url').val(attachment.url);
// Restore the main post ID
wp.media.model.settings.post.id = wp_media_post_id;
});
// Finally, open the modal
file_frame.open();
});
// Restore the main ID when the add media button is pressed
jQuery('a.add_media').on('click', function() {
wp.media.model.settings.post.id = wp_media_post_id;
});
});
</script>
<?php
}
add_action('admin_footer', 'media_selector_print_scripts');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
check_admin_referer('pop_up_save', 'pop_up_nonce');
if (isset($_POST['title'])) {
update_option('title', sanitize_text_field($_POST['title']));
}
if (isset($_POST['link'])) {
update_option('link', esc_url_raw($_POST['link']));
}
if (isset($_POST['text'])) {
update_option('text', sanitize_textarea_field($_POST['text']));
}
if (isset($_POST['meta-box-image'])) {
update_option('meta-box-image', intval($_POST['meta-box-image']));
}
if (isset($_POST['animation_type'])) {
update_option('animation_type', sanitize_text_field($_POST['animation_type']));
}
if (isset($_POST['animation_duration'])) {
update_option('animation_duration', sanitize_text_field($_POST['animation_duration']));
}
// Ajoutez votre message de réussite ici
$query = array(
'updated' => true,
'message' => urlencode('Vos modifications ont été enregistrées avec succès.'),
);
// Redirige vers la même page pour éviter les soumissions multiples
$redirect_url = add_query_arg($query, wp_get_referer());
wp_redirect($redirect_url);
exit;
} ?>