Esempio n. 1
0
 /**
  * Description here.
  *
  * Some sort of images list with some description and post title and date ... eah
  *
  * @return array Array of items or empty array.
  */
 function presscore_get_posts_small_list($attachments_data, $options = array())
 {
     if (empty($attachments_data)) {
         return array();
     }
     global $post;
     $default_options = array('links_rel' => '', 'show_images' => true, 'image_dimensions' => array('w' => 60, 'h' => 60));
     $options = wp_parse_args($options, $default_options);
     $image_args = array('img_class' => '', 'class' => 'alignleft post-rollover', 'custom' => $options['links_rel'], 'options' => array('w' => $options['image_dimensions']['w'], 'h' => $options['image_dimensions']['h'], 'z' => true), 'echo' => false);
     $articles = array();
     $class = '';
     $post_was_changed = false;
     $post_backup = $post;
     foreach ($attachments_data as $data) {
         $new_post = null;
         if (isset($data['parent_id'])) {
             $post_was_changed = true;
             $new_post = get_post($data['parent_id']);
             if ($new_post) {
                 $post = $new_post;
                 setup_postdata($post);
             }
         }
         $permalink = esc_url($data['permalink']);
         $attachment_args = array('href' => $permalink, 'img_meta' => array($data['full'], $data['width'], $data['height']), 'img_id' => empty($data['ID']) ? 0 : $data['ID'], 'echo' => false, 'wrap' => '<a %CLASS% %HREF% %CUSTOM%><img %IMG_CLASS% %SRC% %SIZE% %ALT% /></a>');
         // show something if there is no title
         if (empty($data['title'])) {
             $data['title'] = _x('No title', 'blog small list', 'the7mk2');
         }
         if (!empty($data['parent_id'])) {
             $class = 'post-' . presscore_get_post_format_class(get_post_format($data['parent_id']));
             if (empty($data['ID'])) {
                 $attachment_args['wrap'] = '<a %HREF% %CLASS% %TITLE% style="width:' . $options['image_dimensions']['w'] . 'px; height: ' . $options['image_dimensions']['h'] . 'px;"></a>';
                 $attachment_args['class'] = $image_args['class'] . ' no-avatar';
                 $attachment_args['img_meta'] = array('', 0, 0);
                 $attachment_args['options'] = false;
             }
         }
         $article = sprintf('<article class="%s"><div class="wf-td">%s</div><div class="post-content">%s%s</div></article>', $class, $options['show_images'] ? dt_get_thumb_img(array_merge($image_args, $attachment_args)) : '', '<a href="' . $permalink . '">' . esc_html($data['title']) . '</a><br />', '<time class="text-secondary" datetime="' . get_the_date('c') . '">' . get_the_date(get_option('date_format')) . '</time>');
         $articles[] = $article;
     }
     if ($post_was_changed) {
         $post = $post_backup;
         setup_postdata($post);
     }
     return $articles;
 }
Esempio n. 2
0
 /**
  * Add post format classes to post.
  */
 function presscore_add_post_format_classes($classes = array())
 {
     global $post;
     if ('post' != get_post_type($post)) {
         return $classes;
     }
     $post_format_class = presscore_get_post_format_class();
     if ($post_format_class) {
         $classes[] = $post_format_class;
     }
     return array_unique($classes);
 }