<div id="primary" class="content-area">
    <main id="main" class="site-main container-fluid" role="main">
      <div class="row">

        <div id="donate-ask" class="col-xs-12 col-sm-12 col-md-6 col-lg-5 col-md-push-6 col-lg-push-7">
          <?php 
    $fundraiser->get_form();
    ?>
        </div>
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-7 col-md-pull-6 col-lg-pull-5">
          <h1><?php 
    the_title();
    ?>
</h1>
          <?php 
    echo pods_image($thispod->field('banner_image')['ID'], $size = 'masthead');
    ?>
          <?php 
    echo $fundraiser->get_progressbar();
    the_content();
    ?>
        </div>

      </div>
      <?php 
    // End the loop.
}
?>

    </main><!-- .site-main -->
  </div><!-- .content-area -->
Example #2
0
      <p><?php 
            echo get_custom_excerpt($listing->display('content'));
            ?>
</p>
    </div>
    <?php 
            $position = 'right';
            ?>

  <?php 
        } else {
            ?>
  
    <div class="span6 listing-image left">
      <?php 
            echo pods_image(get_post_meta($listing->field('ID'), 'image', true), 'original');
            ?>
    </div>
    <div class="span6 listing-text right">
      <h2 class="up"><?php 
            echo $listing->display('title');
            ?>
</h2>
      <p><?php 
            echo get_custom_excerpt($listing->display('content'));
            ?>
</p>
    </div>
   <?php 
            $position = 'left';
            ?>
	<article>
		<header class="entry-header">
			<h1 class="entry-title"><?php 
    _e('User Profile', 'twentytwelve');
    ?>
</h1>
		</header>

		<div class="author-info">
			<h2><?php 
    echo $name;
    ?>
</h1>
				<div class="author-avatar">
					<?php 
    echo '<a href="' . pods_image_url($user->picture, 'large') . '">' . pods_image($user->picture, 'thumbnail') . '</a>';
    ?>
				</div><!-- .author-avatar -->
				<div class="author-description">
					<p><strong><?php 
    _e('Email:', 'twentytwelve');
    ?>
</strong> <?php 
    echo '<a href="mailto:' . $email . '">' . $email . '</a>';
    ?>
</p>
					<p><strong><?php 
    _e('Phone:', 'twentytwelve');
    ?>
</strong> <?php 
    echo $phone;
Example #4
0
    if ($slide1['order'] == $slide2['order']) {
        return 0;
    }
    return $slide1['order'] > $slide2['order'] ? 1 : -1;
}
usort($data, 'sortSlides');
?>
<div class="row">
<div class="pagination-centered" id="slideshow">
  <div class="slides">
  <?php 
foreach ($data as $slide) {
    ?>
    <div class="slide">  
      <?php 
    echo pods_image(get_post_meta($slide['id'], 'image', true), 'original');
    ?>

      <h3><?php 
    echo $slide['title'];
    ?>
</h3> 
      
      <div class="slide-subtitle">
        <?php 
    echo $slide['subtitle'];
    ?>
      </div>
      
      <a href="<?php 
    echo $slide['link'];
Example #5
0
 /**
  * Take over the avatar served from WordPress
  *
  * @param string $avatar Default Avatar Image output from WordPress
  * @param int|string|object $id_or_email A user ID, email address, or comment object
  * @param int $size Size of the avatar image
  * @param string $default URL to a default image to use if no avatar is available
  * @param string $alt Alternate text to use in image tag. Defaults to blank
  * @return string <img> tag for the user's avatar
  */
 public function get_avatar($avatar, $id_or_email, $size, $default = '', $alt = '')
 {
     $_user_ID = 0;
     if (is_numeric($id_or_email) && 0 < $id_or_email) {
         $_user_ID = (int) $id_or_email;
     } elseif (is_object($id_or_email) && isset($id_or_email->user_id) && 0 < $id_or_email->user_id) {
         $_user_ID = (int) $id_or_email->user_id;
     } elseif (is_object($id_or_email) && isset($id_or_email->ID) && isset($id_or_email->user_login) && 0 < $id_or_email->ID) {
         $_user_ID = (int) $id_or_email->ID;
     } elseif (!is_object($id_or_email) && false !== strpos($id_or_email, '@')) {
         $_user = get_user_by('email', $id_or_email);
         if (!empty($_user)) {
             $_user_ID = (int) $_user->ID;
         }
     }
     if (0 < $_user_ID && !empty(PodsMeta::$user)) {
         $avatar_cached = pods_cache_get($_user_ID . '-' . $size, 'pods_avatars');
         if (!empty($avatar_cached)) {
             $avatar = $avatar_cached;
         } else {
             $avatar_field = pods_transient_get('pods_avatar_field');
             $user = current(PodsMeta::$user);
             if (empty($avatar_field)) {
                 foreach ($user['fields'] as $field) {
                     if ('avatar' == $field['type']) {
                         $avatar_field = $field['name'];
                         pods_transient_set('pods_avatar_field', $avatar_field);
                         break;
                     }
                 }
             } elseif (!isset($user['fields'][$avatar_field])) {
                 $avatar_field = false;
             }
             if (!empty($avatar_field)) {
                 $user_avatar = get_user_meta($_user_ID, $avatar_field . '.ID', true);
                 if (!empty($user_avatar)) {
                     $attributes = array('alt' => '', 'class' => 'avatar avatar-' . $size . ' photo');
                     if (!empty($alt)) {
                         $attributes['alt'] = $alt;
                     }
                     $user_avatar = pods_image($user_avatar, array($size, $size), 0, $attributes);
                     if (!empty($user_avatar)) {
                         $avatar = $user_avatar;
                         pods_cache_set($_user_ID . '-' . $size, $avatar, 'pods_avatars');
                     }
                 }
             }
         }
     }
     return $avatar;
 }
Example #6
0
 /**
  * Return image(s) markup
  *
  * @param int $id
  * @param mixed $value
  * @param string $name
  * @param array $options
  * @param array $pod
  * @param string $image_size
  *
  * @return string
  * @since 2.3
  */
 public function images($id, $value, $name = null, $options = null, $pod = null, $image_size = null)
 {
     $images = '';
     if (empty($value) || !is_array($value)) {
         return $images;
     }
     foreach ($value as $v) {
         $images .= pods_image($v, $image_size);
     }
     return $images;
 }
function pods_user_profile_display($user)
{
    //Escape all of the meta data we need into variables
    $name = esc_attr($user->user_firstname) . '&nbsp;' . esc_attr($user->user_lastname);
    $title = esc_attr($user->title);
    $email = esc_attr($user->user_email);
    $phone = esc_attr($user->phone_number);
    $street_1 = esc_attr($user->street_address_line_1);
    $street_2 = esc_attr($user->street_address_line_2);
    $city = esc_attr($user->city);
    $state = esc_attr($user->state);
    $zip = esc_attr($user->zip_code);
    $website = esc_url($user->user_url);
    $twitter = esc_url($user->twitter);
    $linkedin = esc_url($user->linkedin);
    ?>
	<div class="author-info">
		<h2><?php 
    echo $name;
    ?>
</h1>
			<div class="author-avatar">
				<?php 
    echo '<a href="' . pods_image_url($user->picture, 'large') . '">' . pods_image($user->picture, 'thumbnail') . '</a>';
    ?>
			</div><!-- .author-avatar -->
			<div class="author-description">
				<p><strong><?php 
    _e('Email:', 'twentytwelve');
    ?>
</strong> <?php 
    echo '<a href="mailto:' . $email . '">' . $email . '</a>';
    ?>
</p>
				<p><strong><?php 
    _e('Phone:', 'twentytwelve');
    ?>
</strong> <?php 
    echo $phone;
    ?>
</p>
				<div><p><strong><?php 
    _e('Address:', 'twentytwelve');
    ?>
 </strong></p>
					<?php 
    echo '<p>' . $street_1 . '</p>' . '<p>' . $street_2 . '</p>' . '<p>' . $city . ', ' . $state . ' ' . $zip . '</p>';
    ?>
</div>
				<p><strong><?php 
    _e('Website:', 'twentytwelve');
    ?>
</strong> <?php 
    echo '<a href="' . $website . '">' . $website . '</a>';
    ?>
</p>
				<p><strong><?php 
    _e('Twitter:', 'twentytwelve');
    ?>
</strong> <?php 
    echo '<a href="' . $twitter . '">' . $twitter . '</a>';
    ?>
</p>
				<p><strong><?php 
    _e('LinkedIn:', 'twentytwelve');
    ?>
 </strong> <?php 
    echo '<a href="' . $linkedin . '">' . $linkedin . '</a>';
    ?>
</p>
			</div><!-- .author-description	-->
	</div><!-- .author-info -->
<?php 
}
Example #8
0
 /**
  * Return the value for a field.
  *
  * If you are getting a field for output in a theme, most of the time you will want to use display() instead.
  *
  * This function will return arrays for relationship and file fields.
  *
  * @param string|array $name The field name, or an associative array of parameters
  * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item, or an associative array of parameters
  * @param boolean $raw (optional) Whether to return the raw value, or to run through the field type's display method, or an associative array of parameters
  *
  * @return mixed|null Value returned depends on the field type, null if the field doesn't exist, false if no value returned for tableless fields
  * @since 2.0
  * @link http://pods.io/docs/field/
  */
 public function field($name, $single = null, $raw = false)
 {
     global $sitepress;
     $defaults = array('name' => $name, 'orderby' => null, 'single' => $single, 'params' => null, 'in_form' => false, 'raw' => $raw, 'raw_display' => false, 'display' => false, 'get_meta' => false, 'output' => null, 'deprecated' => false, 'args' => array());
     if (is_array($name) || is_object($name)) {
         $defaults['name'] = null;
         $params = (object) array_merge($defaults, (array) $name);
     } elseif (is_array($single) || is_object($single)) {
         $defaults['single'] = null;
         $params = (object) array_merge($defaults, (array) $single);
     } elseif (is_array($raw) || is_object($raw)) {
         $defaults['raw'] = false;
         $params = (object) array_merge($defaults, (array) $raw);
     } else {
         $params = (object) $defaults;
     }
     if ($params->in_form) {
         $params->output = 'ids';
     } elseif (null === $params->output) {
         $params->output = $this->do_hook('field_related_output_type', 'arrays', $this->row, $params);
     }
     if (in_array($params->output, array('id', 'name', 'object', 'array', 'pod'))) {
         $params->output .= 's';
     }
     // Support old $orderby variable
     if (null !== $params->single && is_string($params->single) && empty($params->orderby)) {
         pods_deprecated('Pods::field', '2.0', 'Use $params[ \'orderby\' ] instead');
         $params->orderby = $params->single;
         $params->single = false;
     }
     if (null !== $params->single) {
         $params->single = (bool) $params->single;
     }
     if (is_array($params->name) || strlen(trim($params->name)) < 1) {
         return null;
     }
     $params->name = trim($params->name);
     $params->full_name = $params->name;
     $value = null;
     if (isset($this->row_override[$params->name])) {
         $value = $this->row_override[$params->name];
     }
     if (false === $this->row()) {
         if (false !== $this->data()) {
             $this->fetch();
         } else {
             return $value;
         }
     }
     if ($this->data->field_id == $params->name) {
         if (isset($this->row[$params->name])) {
             return $this->row[$params->name];
         } elseif (null !== $value) {
             return $value;
         }
         return 0;
     }
     $tableless_field_types = PodsForm::tableless_field_types();
     $simple_tableless_objects = PodsForm::field_method('pick', 'simple_objects');
     $params->traverse = array();
     if (in_array($params->name, array('_link', 'detail_url')) || in_array($params->name, array('permalink', 'the_permalink')) && in_array($this->pod_data['type'], array('post_type', 'media'))) {
         if (0 < strlen($this->detail_page)) {
             $value = get_home_url() . '/' . $this->do_magic_tags($this->detail_page);
         } elseif (in_array($this->pod_data['type'], array('post_type', 'media'))) {
             $value = get_permalink($this->id());
         } elseif ('taxonomy' == $this->pod_data['type']) {
             $value = get_term_link($this->id(), $this->pod_data['name']);
         } elseif ('user' == $this->pod_data['type']) {
             $value = get_author_posts_url($this->id());
         } elseif ('comment' == $this->pod_data['type']) {
             $value = get_comment_link($this->id());
         }
     }
     $field_data = false;
     $field_type = false;
     $first_field = explode('.', $params->name);
     $first_field = $first_field[0];
     if (isset($this->fields[$first_field])) {
         $field_data = $this->fields[$first_field];
         $field_type = 'field';
     } elseif (isset($this->pod_data['object_fields']) && !empty($this->pod_data['object_fields'])) {
         if (isset($this->pod_data['object_fields'][$first_field])) {
             $field_data = $this->pod_data['object_fields'][$first_field];
             $field_type = 'object_field';
         } else {
             foreach ($this->pod_data['object_fields'] as $object_field => $object_field_opt) {
                 if (in_array($first_field, $object_field_opt['alias'])) {
                     if ($first_field == $params->name) {
                         $params->name = $object_field;
                     }
                     $first_field = $object_field;
                     $field_data = $object_field_opt;
                     $field_type = 'object_field';
                     break;
                 }
             }
         }
     }
     // Simple fields have no other output options
     if ('pick' == $field_data['type'] && in_array($field_data['pick_object'], $simple_tableless_objects)) {
         $params->output = 'arrays';
     }
     if (empty($value) && in_array($field_data['type'], $tableless_field_types)) {
         $params->raw = true;
         $value = false;
         if ('arrays' != $params->output && isset($this->row['_' . $params->output . '_' . $params->name])) {
             $value = $this->row['_' . $params->output . '_' . $params->name];
         } elseif ('arrays' == $params->output && isset($this->row[$params->name])) {
             $value = $this->row[$params->name];
         }
         if (false !== $value && !is_array($value) && 'pick' == $field_data['type'] && in_array($field_data['pick_object'], $simple_tableless_objects)) {
             $value = PodsForm::field_method('pick', 'simple_value', $params->name, $value, $field_data, $this->pod_data, $this->id(), true);
         }
     }
     if (empty($value) && isset($this->row[$params->name]) && (!in_array($field_data['type'], $tableless_field_types) || 'arrays' == $params->output)) {
         if (empty($field_data) || in_array($field_data['type'], array('boolean', 'number', 'currency'))) {
             $params->raw = true;
         }
         $value = $this->row[$params->name];
     } elseif (empty($value)) {
         $object_field_found = false;
         if ('object_field' == $field_type) {
             $object_field_found = true;
             if (isset($this->row[$first_field])) {
                 $value = $this->row[$first_field];
             } elseif (in_array($field_data['type'], $tableless_field_types)) {
                 $this->fields[$first_field] = $field_data;
                 $object_field_found = false;
             } else {
                 return null;
             }
         }
         if ('post_type' == $this->pod_data['type'] && !isset($this->fields[$params->name])) {
             if (!isset($this->fields['post_thumbnail']) && ('post_thumbnail' == $params->name || 0 === strpos($params->name, 'post_thumbnail.'))) {
                 $size = 'thumbnail';
                 if (0 === strpos($params->name, 'post_thumbnail.')) {
                     $field_names = explode('.', $params->name);
                     if (isset($field_names[1])) {
                         $size = $field_names[1];
                     }
                 }
                 // Pods will auto-get the thumbnail ID if this isn't an attachment
                 $value = pods_image($this->id(), $size, 0, null, true);
                 $object_field_found = true;
             } elseif (!isset($this->fields['post_thumbnail_url']) && ('post_thumbnail_url' == $params->name || 0 === strpos($params->name, 'post_thumbnail_url.'))) {
                 $size = 'thumbnail';
                 if (0 === strpos($params->name, 'post_thumbnail_url.')) {
                     $field_names = explode('.', $params->name);
                     if (isset($field_names[1])) {
                         $size = $field_names[1];
                     }
                 }
                 // Pods will auto-get the thumbnail ID if this isn't an attachment
                 $value = pods_image_url($this->id(), $size, 0, true);
                 $object_field_found = true;
             } elseif (0 === strpos($params->name, 'image_attachment.')) {
                 $size = 'thumbnail';
                 $image_id = 0;
                 $field_names = explode('.', $params->name);
                 if (isset($field_names[1])) {
                     $image_id = $field_names[1];
                 }
                 if (isset($field_names[2])) {
                     $size = $field_names[2];
                 }
                 if (!empty($image_id)) {
                     $value = pods_image($image_id, $size, 0, null, true);
                     if (!empty($value)) {
                         $object_field_found = true;
                     }
                 }
             } elseif (0 === strpos($params->name, 'image_attachment_url.')) {
                 $size = 'thumbnail';
                 $image_id = 0;
                 $field_names = explode('.', $params->name);
                 if (isset($field_names[1])) {
                     $image_id = $field_names[1];
                 }
                 if (isset($field_names[2])) {
                     $size = $field_names[2];
                 }
                 if (!empty($image_id)) {
                     $value = pods_image_url($image_id, $size, 0, true);
                     if (!empty($value)) {
                         $object_field_found = true;
                     }
                 }
             }
         } elseif ('user' == $this->pod_data['type'] && !isset($this->fields[$params->name])) {
             if (!isset($this->fields['avatar']) && ('avatar' == $params->name || 0 === strpos($params->name, 'avatar.'))) {
                 $size = null;
                 if (0 === strpos($params->name, 'avatar.')) {
                     $field_names = explode('.', $params->name);
                     if (isset($field_names[1])) {
                         $size = (int) $field_names[1];
                     }
                 }
                 if (!empty($size)) {
                     $value = get_avatar($this->id(), $size);
                 } else {
                     $value = get_avatar($this->id());
                 }
                 $object_field_found = true;
             }
         } elseif (0 === strpos($params->name, 'image_attachment.')) {
             $size = 'thumbnail';
             $image_id = 0;
             $field_names = explode('.', $params->name);
             if (isset($field_names[1])) {
                 $image_id = $field_names[1];
             }
             if (isset($field_names[2])) {
                 $size = $field_names[2];
             }
             if (!empty($image_id)) {
                 $value = pods_image($image_id, $size, 0, null, true);
                 if (!empty($value)) {
                     $object_field_found = true;
                 }
             }
         } elseif (0 === strpos($params->name, 'image_attachment_url.')) {
             $size = 'thumbnail';
             $image_id = 0;
             $field_names = explode('.', $params->name);
             if (isset($field_names[1])) {
                 $image_id = $field_names[1];
             }
             if (isset($field_names[2])) {
                 $size = $field_names[2];
             }
             if (!empty($image_id)) {
                 $value = pods_image_url($image_id, $size, 0, true);
                 if (!empty($value)) {
                     $object_field_found = true;
                 }
             }
         }
         if (false === $object_field_found) {
             $params->traverse = array($params->name);
             if (false !== strpos($params->name, '.')) {
                 $params->traverse = explode('.', $params->name);
                 $params->name = $params->traverse[0];
             }
             if (isset($this->fields[$params->name]) && isset($this->fields[$params->name]['type'])) {
                 $v = $this->do_hook('field_' . $this->fields[$params->name]['type'], null, $this->fields[$params->name], $this->row, $params);
                 if (null !== $v) {
                     return $v;
                 }
             }
             $simple = false;
             $simple_data = array();
             if (isset($this->fields[$params->name])) {
                 if ('meta' == $this->pod_data['storage']) {
                     if (!in_array($this->fields[$params->name]['type'], $tableless_field_types)) {
                         $simple = true;
                     }
                 }
                 if (in_array($this->fields[$params->name]['type'], $tableless_field_types)) {
                     $params->raw = true;
                     if ('pick' == $this->fields[$params->name]['type'] && in_array($this->fields[$params->name]['pick_object'], $simple_tableless_objects)) {
                         $simple = true;
                         $params->single = true;
                     }
                 } elseif (in_array($this->fields[$params->name]['type'], array('boolean', 'number', 'currency'))) {
                     $params->raw = true;
                 }
             }
             if (!isset($this->fields[$params->name]) || !in_array($this->fields[$params->name]['type'], $tableless_field_types) || $simple) {
                 if (null === $params->single) {
                     if (isset($this->fields[$params->name]) && !in_array($this->fields[$params->name]['type'], $tableless_field_types)) {
                         $params->single = true;
                     } else {
                         $params->single = false;
                     }
                 }
                 $no_conflict = pods_no_conflict_check($this->pod_data['type']);
                 if (!$no_conflict) {
                     pods_no_conflict_on($this->pod_data['type']);
                 }
                 if (in_array($this->pod_data['type'], array('post_type', 'media'))) {
                     $id = $this->id();
                     // Support for WPML 'duplicated' translation handling
                     if (is_object($sitepress) && $sitepress->is_translated_post_type($this->pod_data['name'])) {
                         $master_post_id = (int) get_post_meta($id, '_icl_lang_duplicate_of', true);
                         if (0 < $master_post_id) {
                             $id = $master_post_id;
                         }
                     }
                     $value = get_post_meta($id, $params->name, $params->single);
                     $single_multi = pods_var($this->fields[$params->name]['type'] . '_format_type', $this->fields[$params->name]['options'], 'single');
                     if ($simple && !is_array($value) && 'single' != $single_multi) {
                         $value = get_post_meta($id, $params->name);
                     }
                 } elseif (in_array($this->pod_data['type'], array('user', 'comment'))) {
                     $value = get_metadata($this->pod_data['type'], $this->id(), $params->name, $params->single);
                     $single_multi = pods_var($this->fields[$params->name]['type'] . '_format_type', $this->fields[$params->name]['options'], 'single');
                     if ($simple && !is_array($value) && 'single' != $single_multi) {
                         $value = get_metadata($this->pod_data['type'], $this->id(), $params->name);
                     }
                 } elseif ('settings' == $this->pod_data['type']) {
                     $value = get_option($this->pod_data['name'] . '_' . $params->name, null);
                 }
                 // Handle Simple Relationships
                 if ($simple) {
                     if (null === $params->single) {
                         $params->single = false;
                     }
                     $value = PodsForm::field_method('pick', 'simple_value', $params->name, $value, $this->fields[$params->name], $this->pod_data, $this->id(), true);
                 }
                 if (!$no_conflict) {
                     pods_no_conflict_off($this->pod_data['type']);
                 }
             } else {
                 // Dot-traversal
                 $pod = $this->pod;
                 $ids = array($this->id());
                 $all_fields = array();
                 $lookup = $params->traverse;
                 if (!empty($lookup)) {
                     unset($lookup[0]);
                     foreach ($this->fields as $field) {
                         if (!in_array($field['type'], $tableless_field_types) || in_array($field['name'], $lookup)) {
                             continue;
                         }
                         $lookup[] = $field['name'];
                     }
                 }
                 // Get fields matching traversal names
                 if (!empty($lookup)) {
                     $fields = $this->api->load_fields(array('name' => $lookup, 'type' => $tableless_field_types, 'object_fields' => true));
                     if (!empty($fields)) {
                         foreach ($fields as $field) {
                             if (!empty($field)) {
                                 if (!isset($all_fields[$field['pod']])) {
                                     $all_fields[$field['pod']] = array();
                                 }
                                 $all_fields[$field['pod']][$field['name']] = $field;
                             }
                         }
                     }
                     if (isset($this->pod_data['object_fields']) && !empty($this->pod_data['object_fields'])) {
                         foreach ($this->pod_data['object_fields'] as $object_field => $object_field_opt) {
                             if (in_array($object_field_opt['type'], $tableless_field_types)) {
                                 $all_fields[$this->pod][$object_field] = $object_field_opt;
                             }
                         }
                     }
                 }
                 $last_type = $last_object = $last_pick_val = '';
                 $last_options = array();
                 $single_multi = pods_var($this->fields[$params->name]['type'] . '_format_type', $this->fields[$params->name]['options'], 'single');
                 if ('multi' == $single_multi) {
                     $limit = (int) pods_var($this->fields[$params->name]['type'] . '_limit', $this->fields[$params->name]['options'], 0);
                 } else {
                     $limit = 1;
                 }
                 $last_limit = 0;
                 // Loop through each traversal level
                 foreach ($params->traverse as $key => $field) {
                     $last_loop = false;
                     if (count($params->traverse) <= $key + 1) {
                         $last_loop = true;
                     }
                     $field_exists = isset($all_fields[$pod][$field]);
                     $simple = false;
                     $last_options = array();
                     if ($field_exists && 'pick' == $all_fields[$pod][$field]['type'] && in_array($all_fields[$pod][$field]['pick_object'], $simple_tableless_objects)) {
                         $simple = true;
                         $last_options = $all_fields[$pod][$field];
                     }
                     // Tableless handler
                     if ($field_exists && (!in_array($all_fields[$pod][$field]['type'], array('pick', 'taxonomy')) || !$simple)) {
                         $type = $all_fields[$pod][$field]['type'];
                         $pick_object = $all_fields[$pod][$field]['pick_object'];
                         $pick_val = $all_fields[$pod][$field]['pick_val'];
                         if ('table' == $pick_object) {
                             $pick_val = pods_var('pick_table', $all_fields[$pod][$field]['options'], $pick_val, null, true);
                         } elseif ('__current__' == $pick_val) {
                             $pick_val = $pod;
                         }
                         $last_limit = 0;
                         if (in_array($type, $tableless_field_types)) {
                             $single_multi = pods_var("{$type}_format_type", $all_fields[$pod][$field]['options'], 'single');
                             if ('multi' == $single_multi) {
                                 $last_limit = (int) pods_var("{$type}_limit", $all_fields[$pod][$field]['options'], 0);
                             } else {
                                 $last_limit = 1;
                             }
                         }
                         $last_type = $type;
                         $last_object = $pick_object;
                         $last_pick_val = $pick_val;
                         $last_options = $all_fields[$pod][$field];
                         // Temporary hack until there's some better handling here
                         $last_limit = $last_limit * count($ids);
                         // Get related IDs
                         if (!isset($all_fields[$pod][$field]['pod_id'])) {
                             $all_fields[$pod][$field]['pod_id'] = 0;
                         }
                         if (isset($all_fields[$pod][$field]['id'])) {
                             $ids = $this->api->lookup_related_items($all_fields[$pod][$field]['id'], $all_fields[$pod][$field]['pod_id'], $ids, $all_fields[$pod][$field]);
                         }
                         // No items found
                         if (empty($ids)) {
                             return false;
                         } elseif (0 < $last_limit) {
                             $ids = array_slice($ids, 0, $last_limit);
                         }
                         // Get $pod if related to a Pod
                         if (!empty($pick_object) && !empty($pick_val)) {
                             if ('pod' == $pick_object) {
                                 $pod = $pick_val;
                             } else {
                                 $check = $this->api->get_table_info($pick_object, $pick_val);
                                 if (!empty($check) && !empty($check['pod'])) {
                                     $pod = $check['pod']['name'];
                                 }
                             }
                         }
                     } else {
                         // Invalid field
                         if (0 == $key) {
                             return false;
                         }
                         $last_loop = true;
                     }
                     if ($last_loop) {
                         $object_type = $last_object;
                         $object = $last_pick_val;
                         if (in_array($last_type, PodsForm::file_field_types())) {
                             $object_type = 'media';
                             $object = 'attachment';
                         }
                         $data = array();
                         $table = $this->api->get_table_info($object_type, $object, null, null, $last_options);
                         $join = $where = array();
                         if (!empty($table['join'])) {
                             $join = (array) $table['join'];
                         }
                         if (!empty($table['where']) || !empty($ids)) {
                             foreach ($ids as $id) {
                                 $where[$id] = '`t`.`' . $table['field_id'] . '` = ' . (int) $id;
                             }
                             if (!empty($where)) {
                                 $where = array(implode(' OR ', $where));
                             }
                             if (!empty($table['where'])) {
                                 $where = array_merge($where, array_values((array) $table['where']));
                             }
                         }
                         /**
                          * @var $related_obj Pods
                          */
                         $related_obj = false;
                         if ('pod' == $object_type) {
                             $related_obj = pods($object, null, false);
                         } elseif (isset($table['pod']) && !empty($table['pod'])) {
                             $related_obj = pods($table['pod']['name'], null, false);
                         }
                         if (!empty($table['table']) || !empty($related_obj)) {
                             $sql = array('select' => '*, `t`.`' . $table['field_id'] . '` AS `pod_item_id`', 'table' => $table['table'], 'join' => $join, 'where' => $where, 'orderby' => $params->orderby, 'pagination' => false, 'search' => false, 'limit' => -1);
                             // Output types
                             if (in_array($params->output, array('ids', 'objects', 'pods'))) {
                                 $sql['select'] = '`t`.`' . $table['field_id'] . '` AS `pod_item_id`';
                             } elseif ('names' == $params->output && !empty($table['field_index'])) {
                                 $sql['select'] = '`t`.`' . $table['field_index'] . '` AS `pod_item_index`, `t`.`' . $table['field_id'] . '` AS `pod_item_id`';
                             }
                             if (is_array($params->params) && !empty($params->params)) {
                                 $where = $sql['where'];
                                 $sql = array_merge($sql, $params->params);
                                 if (isset($params->params['where'])) {
                                     $sql['where'] = array_merge((array) $where, (array) $params->params['where']);
                                 }
                             }
                             if (empty($related_obj)) {
                                 if (!is_object($this->alt_data)) {
                                     $this->alt_data = pods_data(null, 0, true, true);
                                 }
                                 $item_data = $this->alt_data->select($sql);
                             } else {
                                 $item_data = $related_obj->find($sql)->data();
                             }
                             $items = array();
                             if (!empty($item_data)) {
                                 foreach ($item_data as $item) {
                                     if (is_array($item)) {
                                         $item = (object) $item;
                                     }
                                     if (empty($item->pod_item_id)) {
                                         continue;
                                     }
                                     // Bypass pass field
                                     if (isset($item->user_pass)) {
                                         unset($item->user_pass);
                                     }
                                     // Get Item ID
                                     $item_id = $item->pod_item_id;
                                     // Cleanup
                                     unset($item->pod_item_id);
                                     // Output types
                                     if ('ids' == $params->output) {
                                         $item = (int) $item_id;
                                     } elseif ('names' == $params->output && !empty($table['field_index'])) {
                                         $item = $item->pod_item_index;
                                     } elseif ('objects' == $params->output) {
                                         if (in_array($object_type, array('post_type', 'media'))) {
                                             $item = get_post($item_id);
                                         } elseif ('taxonomy' == $object_type) {
                                             $item = get_term($item_id, $object);
                                         } elseif ('user' == $object_type) {
                                             $item = get_userdata($item_id);
                                             if (!empty($item)) {
                                                 // Get other vars
                                                 $roles = $item->roles;
                                                 $caps = $item->caps;
                                                 $allcaps = $item->allcaps;
                                                 $item = $item->data;
                                                 // Set other vars
                                                 $item->roles = $roles;
                                                 $item->caps = $caps;
                                                 $item->allcaps = $allcaps;
                                                 unset($item->user_pass);
                                             }
                                         } elseif ('comment' == $object_type) {
                                             $item = get_comment($item_id);
                                         } else {
                                             $item = (object) $item;
                                         }
                                     } elseif ('pods' == $params->output) {
                                         $item = pods($object, (int) $item_id);
                                     } else {
                                         // arrays
                                         $item = get_object_vars((object) $item);
                                     }
                                     // Pass item data into $data
                                     $items[$item_id] = $item;
                                 }
                                 // Cleanup
                                 unset($item_data);
                                 // Return all of the data in the order expected
                                 if (empty($params->orderby)) {
                                     foreach ($ids as $id) {
                                         if (isset($items[$id])) {
                                             $data[$id] = $items[$id];
                                         }
                                     }
                                 }
                             }
                         }
                         if (in_array($last_type, $tableless_field_types) || in_array($last_type, array('boolean', 'number', 'currency'))) {
                             $params->raw = true;
                         }
                         if (empty($data)) {
                             $value = false;
                         } else {
                             $object_type = $table['type'];
                             if (in_array($table['type'], array('post_type', 'attachment', 'media'))) {
                                 $object_type = 'post';
                             }
                             $no_conflict = true;
                             if (in_array($object_type, array('post', 'user', 'comment', 'settings'))) {
                                 $no_conflict = pods_no_conflict_check($object_type);
                                 if (!$no_conflict) {
                                     pods_no_conflict_on($object_type);
                                 }
                             }
                             // Return entire array
                             if (false !== $field_exists && (in_array($last_type, $tableless_field_types) && !$simple)) {
                                 $value = $data;
                             } else {
                                 $value = array();
                                 foreach ($data as $item_id => $item) {
                                     // $field is 123x123, needs to be _src.123x123
                                     $full_field = implode('.', array_splice($params->traverse, $key));
                                     if ((false !== strpos($full_field, '_src') || 'guid' == $field) && (in_array($table['type'], array('attachment', 'media')) || in_array($last_type, PodsForm::file_field_types())) || (in_array($field, array('_link', 'detail_url')) || in_array($field, array('permalink', 'the_permalink')) && in_array($last_type, PodsForm::file_field_types()))) {
                                         $size = 'full';
                                         if (false !== strpos($full_field, '_src.') && 5 < strlen($full_field)) {
                                             $size = substr($full_field, 5);
                                         } elseif (false !== strpos($full_field, '_src_relative.') && 14 < strlen($full_field)) {
                                             $size = substr($full_field, 14);
                                         } elseif (false !== strpos($full_field, '_src_schemeless.') && 16 < strlen($full_field)) {
                                             $size = substr($full_field, 16);
                                         }
                                         $value_url = pods_image_url($item_id, $size);
                                         if (false !== strpos($full_field, '_src_relative') && !empty($value_url)) {
                                             $value_url_parsed = parse_url($value_url);
                                             $value_url = $value_url_parsed['path'];
                                         } elseif (false !== strpos($full_field, '_src_schemeless') && !empty($value_url)) {
                                             $value_url = str_replace(array('http://', 'https://'), '//', $value_url);
                                         }
                                         if (!empty($value_url)) {
                                             $value[] = $value_url;
                                         }
                                         $params->raw_display = true;
                                     } elseif (false !== strpos($full_field, '_img') && (in_array($table['type'], array('attachment', 'media')) || in_array($last_type, PodsForm::file_field_types()))) {
                                         $size = 'full';
                                         if (false !== strpos($full_field, '_img.') && 5 < strlen($full_field)) {
                                             $size = substr($full_field, 5);
                                         }
                                         $value[] = pods_image($item_id, $size);
                                         $params->raw_display = true;
                                     } elseif (in_array($field, array('_link', 'detail_url')) || in_array($field, array('permalink', 'the_permalink')) && 'post' == $object_type) {
                                         if ('pod' == $object_type) {
                                             if (is_object($related_obj)) {
                                                 $related_obj->fetch($item_id);
                                                 $value[] = $related_obj->field('detail_url');
                                             } else {
                                                 $value[] = '';
                                             }
                                         } elseif ('post' == $object_type) {
                                             $value[] = get_permalink($item_id);
                                         } elseif ('taxonomy' == $object_type) {
                                             $value[] = get_term_link($item_id, $object);
                                         } elseif ('user' == $object_type) {
                                             $value[] = get_author_posts_url($item_id);
                                         } elseif ('comment' == $object_type) {
                                             $value[] = get_comment_link($item_id);
                                         } else {
                                             $value[] = '';
                                         }
                                         $params->raw_display = true;
                                     } elseif (is_array($item) && isset($item[$field])) {
                                         if ($table['field_id'] == $field) {
                                             $value[] = (int) $item[$field];
                                         } else {
                                             $value[] = $item[$field];
                                         }
                                     } elseif (is_object($item) && isset($item->{$field})) {
                                         if ($table['field_id'] == $field) {
                                             $value[] = (int) $item->{$field};
                                         } else {
                                             $value[] = $item->{$field};
                                         }
                                     } elseif ('post' == $object_type) {
                                         // Support for WPML 'duplicated' translation handling
                                         if (is_object($sitepress) && $sitepress->is_translated_post_type($object)) {
                                             $master_post_id = (int) get_post_meta($item_id, '_icl_lang_duplicate_of', true);
                                             if (0 < $master_post_id) {
                                                 $item_id = $master_post_id;
                                             }
                                         }
                                         $value[] = get_post_meta($item_id, $field, true);
                                     } elseif (in_array($object_type, array('post', 'user', 'comment'))) {
                                         $value[] = get_metadata($object_type, $item_id, $field, true);
                                     } elseif ('settings' == $object_type) {
                                         $value[] = get_option($object . '_' . $field);
                                     }
                                 }
                             }
                             if (in_array($object_type, array('post', 'user', 'comment', 'settings')) && !$no_conflict) {
                                 pods_no_conflict_off($object_type);
                             }
                             // Handle Simple Relationships
                             if ($simple) {
                                 if (null === $params->single) {
                                     $params->single = false;
                                 }
                                 $value = PodsForm::field_method('pick', 'simple_value', $field, $value, $last_options, $all_fields[$pod], 0, true);
                             } elseif (false === $params->in_form && !empty($value)) {
                                 $value = array_values($value);
                             }
                             // Return a single column value
                             if (false === $params->in_form && 1 == $limit && !empty($value) && is_array($value) && 1 == count($value)) {
                                 $value = current($value);
                             }
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (!empty($params->traverse) && 1 < count($params->traverse)) {
         $field_names = implode('.', $params->traverse);
         $this->row[$field_names] = $value;
     } elseif ('arrays' != $params->output && in_array($field_data['type'], $tableless_field_types)) {
         $this->row['_' . $params->output . '_' . $params->full_name] = $value;
     } elseif ('arrays' == $params->output || !in_array($field_data['type'], $tableless_field_types)) {
         $this->row[$params->full_name] = $value;
     }
     if ($params->single && is_array($value) && 1 == count($value)) {
         $value = current($value);
     }
     // @todo Expand this into traversed fields too
     if (!empty($field_data) && ($params->display || !$params->raw) && !$params->in_form && !$params->raw_display) {
         if ($params->display || ($params->get_meta || $params->deprecated) && !in_array($field_data['type'], $tableless_field_types)) {
             $field_data['options'] = pods_var_raw('options', $field_data, array(), null, true);
             $post_temp = false;
             if ('post_type' == pods_var('type', $this->pod_data) && 0 < $this->id() && (!isset($GLOBALS['post']) || empty($GLOBALS['post']))) {
                 global $post_ID, $post;
                 $post_temp = true;
                 $old_post = $GLOBALS['post'];
                 $old_ID = $GLOBALS['post_ID'];
                 $post = get_post($this->id());
                 $post_ID = $this->id();
             }
             $filter = pods_var_raw('display_filter', $field_data['options']);
             if (0 < strlen($filter)) {
                 $args = array($filter, $value);
                 $filter_args = pods_var_raw('display_filter_args', $field_data['options']);
                 if (!empty($filter_args)) {
                     $args = array_merge($args, compact($filter_args));
                 }
                 $value = call_user_func_array('apply_filters', $args);
             } elseif (1 == pods_var('display_process', $field_data['options'], 1)) {
                 $value = PodsForm::display($field_data['type'], $value, $params->name, array_merge($field_data, $field_data['options']), $this->pod_data, $this->id());
             }
             if ($post_temp) {
                 $post = $old_post;
                 $post_ID = $old_ID;
             }
         } else {
             $value = PodsForm::value($field_data['type'], $value, $params->name, array_merge($field_data, $field_data['options']), $this->pod_data, $this->id());
         }
     }
     $value = $this->do_hook('field', $value, $this->row, $params);
     return $value;
 }
Example #9
0
<?php

$case = pods('case_study', array('limit' => 1, 'where' => 'featured.meta_value = 1'));
?>

<?php 
while ($case->fetch()) {
    ?>
<div class="row case-study">
  <div class="span5 case-study-image">
    <?php 
    echo pods_image(get_post_meta($case->field('ID'), 'featured_image', true), 'original');
    ?>
  </div>
  <div class="span5 case-study-body">
    <h2 class="light">Case Study:</h2>
    <h1 class="white large"><?php 
    echo $case->display('title');
    ?>
</h1>
    <p><?php 
    echo $case->display('excerpt');
    ?>
</p>
    <a class="button-white" href="<?php 
    echo $case->field('permalink');
    ?>
">Learn More</a>
    <a class="button-white" href="<?php 
    echo get_permalink(get_page_by_path('case-studies'));
    ?>
<?php

/**
 * For Pods using meta storage, the array returned by get_post_meta() can be used with pods_image()
 *
 * NOTE: This example uses get_the_ID(), which only works in the loop. If not in the loop, you must specify the attachment ID some other way.
 */
$img = get_post_meta(get_the_ID(), 'NAME_OF_IMAGE_FIELD', true);
echo '<img src="' . pods_image($img['ID']) . '" >';
 /**
  * Take over the avatar served from WordPress
  *
  * @param string $avatar Default Avatar Image output from WordPress
  * @param int|string|object $id_or_email A user ID, email address, or comment object
  * @param int $size Size of the avatar image
  * @param string $default URL to a default image to use if no avatar is available
  * @param string $alt Alternate text to use in image tag. Defaults to blank
  * @return string <img> tag for the user's avatar
  */
 public function get_avatar($avatar, $id_or_email, $size, $default = '', $alt = '')
 {
     // Don't replace for the Avatars section of the Discussion settings page
     if (is_admin()) {
         $current_screen = get_current_screen();
         if (!is_null($current_screen) && 'options-discussion' == $current_screen->id && 32 == $size) {
             return $avatar;
         }
     }
     $_user_ID = 0;
     if (is_numeric($id_or_email) && 0 < $id_or_email) {
         $_user_ID = (int) $id_or_email;
     } elseif (is_object($id_or_email) && isset($id_or_email->user_id) && 0 < $id_or_email->user_id) {
         $_user_ID = (int) $id_or_email->user_id;
     } elseif (is_object($id_or_email) && isset($id_or_email->ID) && isset($id_or_email->user_login) && 0 < $id_or_email->ID) {
         $_user_ID = (int) $id_or_email->ID;
     } elseif (!is_object($id_or_email) && false !== strpos($id_or_email, '@')) {
         $_user = get_user_by('email', $id_or_email);
         if (!empty($_user)) {
             $_user_ID = (int) $_user->ID;
         }
     }
     // Include PodsMeta if not already included
     pods_meta();
     if (0 < $_user_ID && !empty(PodsMeta::$user)) {
         $avatar_cached = pods_cache_get($_user_ID . '-' . $size, 'pods_avatars');
         if (!empty($avatar_cached)) {
             $avatar = $avatar_cached;
         } else {
             $avatar_field = pods_transient_get('pods_avatar_field');
             $user = current(PodsMeta::$user);
             if (empty($avatar_field)) {
                 foreach ($user['fields'] as $field) {
                     if ('avatar' == $field['type']) {
                         $avatar_field = $field['name'];
                         pods_transient_set('pods_avatar_field', $avatar_field);
                         break;
                     }
                 }
             } elseif (!isset($user['fields'][$avatar_field])) {
                 $avatar_field = false;
             }
             if (!empty($avatar_field)) {
                 $user_avatar = get_user_meta($_user_ID, $avatar_field . '.ID', true);
                 if (!empty($user_avatar)) {
                     $attributes = array('alt' => '', 'class' => 'avatar avatar-' . $size . ' photo');
                     if (!empty($alt)) {
                         $attributes['alt'] = $alt;
                     }
                     $user_avatar = pods_image($user_avatar, array($size, $size), 0, $attributes);
                     if (!empty($user_avatar)) {
                         $avatar = $user_avatar;
                         pods_cache_set($_user_ID . '-' . $size, $avatar, 'pods_avatars');
                     }
                 }
             }
         }
     }
     return $avatar;
 }
<?php

/**
 * Output all images from a multi-select image field
 */
//If using in a Pods template skip this line, which presumes this is being used inside the main WordPress loop in a theme template file.
$obj = pods('POD_NAME', get_the_id());
$photos = $obj->field('photos');
foreach ($photos as $photo) {
    echo '<img src="' . pods_image($photo) . '" /><br />';
}
	</header><!-- .entry-header -->

	<div class="entry-content">
		<?php 
//main post content
the_content();
/**
 * Pods Fields
 */
/*cover images */
//get the field
$cover_images = $pods->field('cover_images');
if ($cover_images) {
    echo '<div class="cover-images>';
    foreach ($cover_images as $cover_image) {
        echo '<div class="cover-image">' . pods_image($cover_image) . '</div>';
    }
    echo '</div>';
}
/* Get author name and image as link */
//get the relationship field
$author = $pods->field('book_author');
//store name and ID
$author_id = $author['ID'];
$author_name = $author['post_title'];
//get the 'photo' field for author image
$author_photo = get_post_meta($author_id, 'photo');
//make sure we have a photo
if ($author_photo) {
    //get url of photo
    $photo_url = wp_get_attachment_url($author_photo[0]['ID']);