Example #1
0
 /**
  * Echo a formatted address
  * @param  array  $address 
  * @return           
  */
 function si_address($address = array())
 {
     $address = si_format_address($address, 'string', '<br/>');
     return apply_filters('si_address', sprintf('<address class="vcard"><span>%s</span></address>', $address), $address);
 }
 /**
  * Display the content for the column
  *
  * @param string  $column_name
  * @param int     $id          post_id
  * @return string
  */
 public static function column_display($column_name, $id)
 {
     $client = SI_Client::get_instance($id);
     if (!is_a($client, 'SI_Client')) {
         return;
         // return for that temp post
     }
     switch ($column_name) {
         case 'info':
             echo '<p>';
             $address = si_format_address($client->get_address(), 'string', '<br/>');
             echo $address;
             if ($address != '') {
                 echo '<br/>';
             }
             echo make_clickable(esc_url($client->get_website()));
             echo '</p>';
             $associated_users = $client->get_associated_users();
             echo '<p>';
             printf('<b>%s</b>: ', __('Users', 'sprout-invoices'));
             if (!empty($associated_users)) {
                 $users_print = array();
                 foreach ($associated_users as $user_id) {
                     $user = get_userdata($user_id);
                     if ($user) {
                         $users_print[] = sprintf('<span class="associated_user"><a href="%s">%s</a></span>', get_edit_user_link($user_id), $user->display_name);
                     }
                 }
             }
             if (!empty($users_print)) {
                 echo implode(', ', $users_print);
             } else {
                 echo __('No associated users', 'sprout-invoices');
             }
             echo '</p>';
             break;
         case 'invoices':
             $invoices = $client->get_invoices();
             $split = 3;
             $split_invoices = array_slice($invoices, 0, $split);
             if (!empty($split_invoices)) {
                 echo '<dl>';
                 foreach ($split_invoices as $invoice_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $invoice_id), get_edit_post_link($invoice_id), get_the_title($invoice_id));
                 }
                 echo '</dl>';
                 if (count($invoices) > $split) {
                     printf('<span class="description">' . __('...%s of <a href="%s">%s</a> most recent shown', 'sprout-invoices') . '</span>', $split, get_edit_post_link($id), count($invoices));
                 }
             } else {
                 printf('<em>%s</em>', __('No invoices', 'sprout-invoices'));
             }
             break;
         case 'estimates':
             $estimates = $client->get_estimates();
             $split = 3;
             $split_estimates = array_slice($estimates, 0, $split);
             if (!empty($split_estimates)) {
                 echo '<dl>';
                 foreach ($split_estimates as $estimate_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $estimate_id), get_edit_post_link($estimate_id), get_the_title($estimate_id));
                 }
                 echo '</dl>';
                 if (count($estimates) > $split) {
                     printf('<span class="description">' . __('...%s of <a href="%s">%s</a> most recent shown', 'sprout-invoices') . '</span>', $split, get_edit_post_link($id), count($estimates));
                 }
             } else {
                 printf('<em>%s</em>', __('No estimates', 'sprout-invoices'));
             }
             break;
         default:
             // code...
             break;
     }
 }
 /**
  * Display the content for the column
  *
  * @param string  $column_name
  * @param int     $id          post_id
  * @return string
  */
 public static function column_display($column_name, $id)
 {
     $client = Sprout_Client::get_instance($id);
     if (!is_a($client, 'Sprout_Client')) {
         return;
         // return for that temp post
     }
     switch ($column_name) {
         case 'sc_client_type':
             sc_type_select($id);
             break;
         case 'sc_client_status':
             sc_status_select($id);
             break;
         case 'lead_info':
             echo '<p>';
             $address = si_format_address($client->get_address(), 'string', '<br/>');
             print $address;
             if ('' !== $address) {
                 echo '<br/>';
             }
             echo make_clickable(esc_url($client->get_website()));
             echo '</p>';
             break;
         case 'contacts':
             $associated_users = $client->get_associated_users();
             echo '<p>';
             printf('<b>%s</b>: ', sc__('User Contacts'));
             if (!empty($associated_users)) {
                 $users_print = array();
                 foreach ($associated_users as $user_id) {
                     $user = get_userdata($user_id);
                     if (!is_a($user, 'WP_User')) {
                         $client->remove_associated_user($user_id);
                         continue;
                     }
                     $users_print[] = sprintf('<span class="associated_user"><a href="%s">%s</a></span>', get_edit_user_link($user_id), sc_get_users_full_name($user_id));
                 }
             }
             if (!empty($users_print)) {
                 print implode(', ', $users_print);
             } else {
                 sc_e('No associated people/users.');
             }
             echo '</p>';
             break;
         default:
             // code...
             break;
     }
 }