/**
  * Function for displaying the widget on the page.
  *
  * @access  private
  * @since   1.0
  *
  * @param  array $args
  * @param  array $option
  *
  * @return string
  */
 public function widget($args, $option)
 {
     // Only process and display the widget if displaying a single entry.
     if (get_query_var('cn-entry-slug')) {
         // Grab an instance of the Connections object.
         $instance = Connections_Directory();
         // Query the entry.
         $result = $instance->retrieve->entries(array('slug' => urldecode(get_query_var('cn-entry-slug'))));
         // Setup the entry object
         $entry = new cnEntry($result[0]);
         // Query the entry meta.
         $metadata = $entry->getMeta(array('key' => 'hobbies', 'single' => TRUE));
         // If there is no meta; bail.
         if (empty($metadata)) {
             return;
         }
         /**
          * Extract $before_widget, $after_widget, $before_title and $after_title.
          *
          * @var $before_widget
          * @var $after_widget
          * @var $before_title
          * @var $after_title
          */
         extract($args);
         // Setup the default widget options if they were not set when they were added to the sidebar;
         // ie. the user did not click the "Save" button on the widget.
         $title = strlen($option['title']) > 0 ? $option['title'] : __('Hobbies', 'connections_hobbies');
         // Setup the atts to be passed to the method that displays the data.
         $atts = array();
         echo $before_widget;
         echo $before_title . $title . $after_title;
         // Display the income level.
         Connections_Hobbies::block('hobbies', $metadata, NULL, $atts);
         echo $after_widget;
     }
 }
 /**
  * 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);
 }