How can i show my plugin in website

  • Unknown's avatar

    Hello everyone,
    I’m posting this topic because I’m currently doing an internship in a company to validate my training as a web developer. So I’m creating a plugin and I’m encountering some problems concerning its display on my site.
    The goal of the plugin is to select a client and, depending on the choice, to display its own information.
    All this information is present in a database. The website that contains the site has as many menus as there are customers. When I click on a customer, I have to be able to display his information.
    So I started to create the plugin. Then by clicking on “Select”, the information is displayed on the screen.
    And it’s for the rest that I block. I don’t know how, depending on the content generated for the client, to be able to display this on a page of the site.
    Here is the code that corresponds to what I have already done :
    `
    <?php
    wp_register_style( “tachesClients.css”, plugins_url(‘css/tachesClients.css’,__FILE__));
    wp_register_script( “tachesClients.js”, plugins_url(‘js/tachesClients.js’,__FILE__), array(‘jquery’));
    wp_enqueue_style( “tachesClients.css”);
    wp_enqueue_script( “tachesClients.js”);
    ?>
    <div class=”wrap”>
    <h1><span class=”dashicons dashicons-admin-users”></span>Sélection du Client</h1>
    <form action=”<?php echo str_replace(‘%7E’,’~’, $_SERVER[‘REQUEST_URI’]);?>” name=”tachesClients” method=”post”><br>
    <?php
    $bdd = new wpdb(‘root’,”,’appchrono’,’localhost’);
    $rows = $bdd->get_results(“select idUser,friendlyName from clients”);
    echo “<select name=’idClient’>”;
    foreach ($rows as $value) :
    echo “<option value=”.$value->idUser.”>”.$value->friendlyName.”</option>”;
    endforeach;
    echo “</select>”;
    ?>
    <input type=”submit” value=”Sélectionner” name=”submit”>
    </form>
    </div>

    <?php
    function contenuAffichage($id){
    if (isset($_POST[‘submit’])){
    $bdd=new wpdb(‘root’,”,’appchrono’,’localhost’);
    $temps = $bdd->get_row(“SELECT tempsContrat FROM clients WHEREIDUSER=”.$id);
    $tTemps = get_object_vars($temps);
    $affichageTemps = convertisseurTemps(implode(“”,$tTemps));
    $contenu = “<p class=’info’ id=’solde’>SOLDE TEMPS RESTANT :</p>
    <p class=’info’ id=’tempsRestant’>”.$affichageTemps.”</p>”;
    $rows = $bdd->get_results(“SELECT IDPACK,DESCRIPTIF,DATEAJOUT FROM packs WHERE IDUSER=”.$id.” AND DESCRIPTIF LIKE ‘%pack assistance%’ ORDER BY packs.DATEAJOUT DESC”);
    $contenu.=”<div class=’info’><p class=’note’>Note : temps minimum d’intervention de 15 minutes par demande.</p>
    <p class=’note’>Si l’intervention résulte d’un bug ou d’un dysfonctionnement du système, aucun débit temps ne sera effectué.</p></div>”;
    foreach ($rows as $values) :
    $contenu .=” <button class=’accordion’ value=”.$values->IDPACK.”>”.$values->DESCRIPTIF.” du “.dateFR($values->DATEAJOUT).”</button>”;
    $lignes = $bdd->get_results(“SELECT DESCRIPTIF,TEMPSINTERVENTION,DATECREATION FROM taches WHERE IDPACK=”.$values->IDPACK.” ORDER BY taches.DATECREATION DESC”);
    $idPack = $values->IDPACK;
    $contenu.=”<div class=’panel’>”;
    foreach ($lignes as $values) :
    $contenu.=”<div id=’listeTaches’>
    <div class=’dateTaches’><b>”.dateFR($values->DATECREATION).”</b> :</div>
    <div class=’commTaches’>”.$values->DESCRIPTIF.”</div>
    <div class=’tempsTaches’>(“.$values->TEMPSINTERVENTION.” min)</div>
    </div><br>”;
    endforeach;
    $lignes = $bdd->get_results(“SELECT IDUSER,DESCRIPTIF,DATEAJOUT FROM packs WHERE IDUSER=”.$id.” AND DESCRIPTIF LIKE ‘%Report solde%’ ANDREPORTPACK= “.$idPack);
    foreach ($lignes as $values) :
    $contenu.=”<div id=’reportPack’>
    <div class=’dateReport’><b>”.dateFR($values->DATEAJOUT).”</b> :</div>
    <div class=’commReport’>”.$values->DESCRIPTIF.”</div>
    </div><br>”;
    endforeach;
    $contenu.=”</div>”;
    endforeach;

    if ($contenu !=””){ $affichage= searchReplace($contenu); }

    return $affichage;
    }
    }
    $idClient = $_POST[‘idClient’];
    echo contenuAffichage($idClient);

    Would you know how I could display client-specific content? I was thinking of using a shortcode but I can’t figure out how it would work for each client.
    Thank you in advance for your answer.
    I look forward to hearing from you,
    Damien

    The blog I need help with is: (visible only to logged in users)

  • Hi there,

    This is the support forums for the hosting provider, WordPress.com. We only provide support for free sites hosted on WordPress.com here, and we cannot help with coding advice.

    For help with the open source WordPress software, you can ask the WordPress.org community at https://wordpress.org/support/forums/. For this you’ll specifically want the Developing WordPress subforum.

    For coding advice you can also try the WordPress stackexchange at https://wordpress.stackexchange.com/

  • The topic ‘How can i show my plugin in website’ is closed to new replies.