/**
  * Process the content adding the entry phone number details in place of the shortcode.
  *
  * @access  private
  * @since  0.8
  * @param  array  $atts    The shortcode attributes array.
  * @param  string $content The content captured between an open/close shortcode tag.
  * @param  string $tag     The shortcode tag.
  *
  * @return string          The processed content.
  */
 public function phone($atts, $content = '', $tag = 'cn_phone')
 {
     $out = '';
     $defaults = array('preferred' => FALSE, 'type' => NULL);
     $atts = shortcode_atts($defaults, $atts, $tag);
     $search = array('%type%', '%number%');
     $phoneNumbers = $this->entry->getPhoneNumbers($atts);
     foreach ($phoneNumbers as $phone) {
         $replace = array('type' => $phone->name, 'number' => $phone->number);
         $out .= str_ireplace($search, $replace, $content);
     }
     return $out;
 }
 /**
  * Outputs entry data JSON encoded in HTML data attribute.
  * This is an action called by the `cn_action_entry_after` hook.
  *
  * @access public
  * @since  0.8
  *
  * @param array   $atts  Shortcode $atts passed by the `cn_action_entry_after` action hook.
  * @param cnEntry $entry An instance the the cnEntry object.
  *
  * @return string
  */
 public static function JSON($atts, $entry)
 {
     $defaults = array('tag' => 'div', 'before' => '', 'after' => '', 'return' => FALSE, 'show_addresses' => TRUE, 'show_phone_numbers' => TRUE, 'show_email' => TRUE, 'show_im' => TRUE, 'show_social_media' => TRUE, 'show_links' => TRUE, 'show_dates' => TRUE, 'show_bio' => TRUE, 'show_notes' => TRUE);
     $atts = wp_parse_args($atts, $defaults);
     $data = array('type' => $entry->getEntryType(), 'id' => $entry->getId(), 'ruid' => $entry->getRuid(), 'slug' => $entry->getSlug(), 'name' => array('full' => $entry->getName($atts), 'prefix' => $entry->getHonorificPrefix(), 'first' => $entry->getFirstName(), 'middle' => $entry->getMiddleName(), 'last' => $entry->getLastName(), 'suffix' => $entry->getHonorificSuffix()), 'title' => $entry->getTitle(), 'organization' => $entry->getOrganization(), 'department' => $entry->getDepartment(), 'contact_name' => array('full' => $entry->getContactName(), 'first' => $entry->getContactFirstName(), 'last' => $entry->getContactLastName()), 'family_name' => $entry->getFamilyName(), 'family_members' => $entry->getFamilyMembers(), 'categories' => $entry->getCategory(), 'meta' => $entry->getMeta($atts));
     if ($atts['show_addresses']) {
         $data['addresses'] = $entry->getAddresses($atts);
     }
     if ($atts['show_phone_numbers']) {
         $data['phone_numbers'] = $entry->getPhoneNumbers($atts);
     }
     if ($atts['show_email']) {
         $data['email_addresses'] = $entry->getEmailAddresses($atts);
     }
     if ($atts['show_im']) {
         $data['im'] = $entry->getIm($atts);
     }
     if ($atts['show_social_media']) {
         $data['social_media'] = $entry->getSocialMedia($atts);
     }
     if ($atts['show_links']) {
         $data['links'] = $entry->getLinks($atts);
     }
     if ($atts['show_dates']) {
         $data['dates'] = $entry->getDates($atts);
     }
     if ($atts['show_bio']) {
         $data['bio'] = $entry->getBio();
     }
     if ($atts['show_notes']) {
         $data['notes'] = $entry->getNotes();
     }
     $out = sprintf('<%1$s class="cn-entry-data-json" data-entry-data-json=\'%2$s\'></%1$s>', $atts['tag'], htmlspecialchars(json_encode($data), ENT_QUOTES, 'UTF-8'));
     $out = (empty($atts['before']) ? '' : $atts['before']) . $out . (empty($atts['after']) ? '' : $atts['after']) . PHP_EOL;
     return self::echoOrReturn($atts['return'], $out);
 }
 /**
  * Renders the phone metabox.
  *
  * @access public
  * @since  0.8
  *
  * @param  cnEntry $entry   An instance of the cnEntry object.
  * @param  array   $metabox The metabox options array from self::register().
  *
  * @return string The phone metabox.
  */
 public static function phone($entry, $metabox)
 {
     echo '<div class="widgets-sortables ui-sortable" id="phone-numbers">', PHP_EOL;
     // --> Start template <-- \\
     echo '<textarea id="phone-template" style="display: none;">', PHP_EOL;
     self::phoneField(new stdClass());
     echo '</textarea>', PHP_EOL;
     // --> End template <-- \\
     $phoneNumbers = $entry->getPhoneNumbers(array(), FALSE);
     if (!empty($phoneNumbers)) {
         foreach ($phoneNumbers as $phone) {
             $token = str_replace('-', '', cnUtility::getUUID());
             echo '<div class="widget phone" id="phone-row-' . $token . '">', PHP_EOL;
             self::phoneField($phone, $token);
             echo '</div>', PHP_EOL;
         }
     }
     echo '</div>', PHP_EOL;
     echo '<p class="add"><a href="#" class="cn-add cn-button button" data-type="phone" data-container="phone-numbers">', __('Add Phone Number', 'connections'), '</a></p>', PHP_EOL;
 }