daily pastebin goal
49%
SHARE
TWEET

Créer un widget de dashboard WordPress

pskli Apr 2nd, 2013 141 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function custom_dashboard_contact_widget(){
  4.         wp_add_dashboard_widget(
  5.                 'dashboard_widget_recent_contact',
  6.                 __('Messages via formulaire de contact', 'theme'),
  7.                 'custom_dashboard_contact_widget_content',
  8.                 $control_callback = null
  9.         );
  10. }
  11. add_action('wp_dashboard_setup', 'custom_dashboard_contact_widget');
  12.  
  13. function custom_dashboard_contact_widget_content() {
  14.         $args = array(
  15.                 'post_type' => 'contact',
  16.                 'orderby' => 'date',
  17.                 'order' => 'DESC',
  18.                 'numberposts' => 5
  19.         );
  20.  
  21.         $contacts = get_posts($args);
  22.  
  23.         echo '<ol id="dash_widget_contacts">';
  24.  
  25.         foreach ($contacts as $index=>$contact) {
  26.  
  27.                 $title_array = explode(' | ', $contact->post_title);
  28.                 $name = $title_array[0];
  29.                 $email = $title_array[1];
  30.                 $message = $contact->post_content;
  31.  
  32.                 echo '<li>';
  33.                 echo '<h4>';
  34.                 echo $name . ' <small><em><a href="mailto:' . $email . '">' . $email . '</a></em></small>';
  35.                 echo '</h4>';
  36.  
  37.                 echo '<p>' . $message . '</p>';
  38.                 echo '</li>';
  39.  
  40.         }
  41.  
  42.         echo '</ol>';
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top