1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| <?php
/**
* Plugin Name: adel
* Plugin URI:
* Description: Un plugin permettant l'ajout et bientôt la suppression de sponsors
* Version: 0.1
* Author: MOI
* Author URI:
*/
add_action("widgets_init","adel_init");
add_action("gform_post_submission",function() {
global $wpdb;
if(isset($_POST['valider'])){
$nom_entr=$_POST['nom_entr'];
echo 'Ajout de l\'entreprise '. $nom_entr.' fait ';
$wpdb->insert('listsponsor', array('nom' => $_FILES['logo']['name'], 'chemin' => 'uploads/'.$_FILES['logo']['name']), array('%s', '%s'));
if (isset($_POST['check_list']) && $_POST['check_list'] == 'saisie' ) { //strcmp( $_POST['check_list'], "saisie" ) == 0 ) {//$_POST['check_list'] == 'saisie' ) {
$wpdb->update('listsponsor', array('saisie' => '1'), array('nom' => $_FILES['logo']['name']), array('%s'), array('%s'));
}
if (isset($_POST['check_list']) && $_POST['check_list'] == 'index' ) {
$wpdb->update('listsponsor', array('indexe' => '1'), array('nom' => $_FILES['logo']['name']), array('%s'), array('%s'));
}
if (isset($_POST['check_list']) && $_POST['check_list'] == 'testajout' ) {
$wpdb->update('listsponsor', array('testajout' => '1'), array('nom' => $_FILES['logo']['name']), array('%s'), array('%s'));
}
}
}
);
function adel_init() {
register_widget("adel_widget");
}
class adel_widget extends WP_widget {
function adel_widget() {
$option = array(
"classname"=> "adel_widget",
"description" => "Un widget qui permet l'ajout ou la suppression de sponsors sur les pages choisies"
);
$this->WP_widget("adel", "Le widget ADEL", $option);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
echo $before_title."Widget d'ajout ou de suppression de sponsor".$after_title;
echo $after_widget;
}
function update($old, $new) {
return $new;
}
function form($instance) {
?>
<label>Add / Delete Sponsor : </label> <br />
<form name="ajout_entreprise" method="post" action="" enctype="multipart/form-data">
Entrez le nom de l'entreprise : <input type="text" name="nom_entr"/> <br/>
<input type="hidden" name="MAX_FILE_SIZE" value="999999999999999" />
Upload du logo de l'entreprise :
<label for="icone">Icône du fichier (JPG, PNG ou GIF | MAX 1Mo) :</label><br />
<input type="file" name="logo" id="" /><br />
Sur quelle(s) page(s) voulez-vous ajouter ce partenaire ?
<input type="checkbox" name="check_list" value="saisie"><label>saisie</label>
<input type="checkbox" name="check_list" value="index"><label>index</label>
<input type="checkbox" name="check_list" value="testajout"><label>testajout</label>
<input type="submit" name="valider" value="OK"/>
</form>
<?php
print_r($_FILES);
}
}
?> |
Partager