/** * Default content filter, sets IssueM Page for Articles to default shortcode content if no content exists for page * * @since 1.0.7 * * @return string new content. */ function default_issue_content_filter($content) { global $post; $issuem_settings = get_issuem_settings(); if (!empty($post)) { if ($post->ID == $issuem_settings['page_for_articles'] && empty($content)) { $content = '[issuem_featured_rotator] [issuem_featured_thumbnails max_images="3"] [issuem_articles]'; } else { if ($post->ID == $issuem_settings['page_for_archives'] && empty($content)) { $content = '[issuem_archives orderby="issue_order"]'; } } } return $content; }
/** * Outputs Article HTML for options metabox * * @since 1.0.0 * * @param object $post WordPress post object */ function issuem_article_meta_box($post) { $issuem_settings = get_issuem_settings(); $teaser_text = get_post_meta($post->ID, '_teaser_text', true); $featured_rotator = get_post_meta($post->ID, '_featured_rotator', true); $featured_thumb = get_post_meta($post->ID, '_featured_thumb', true); $issuem_author_name = get_post_meta($post->ID, '_issuem_author_name', true); ?> <div id="issuem-article-metabox"> <p><input id="featured_rotator" type="checkbox" name="featured_rotator" <?php checked($featured_rotator || "on" == $featured_rotator); ?> /> <label for="featured_rotator"><?php _e('Add article to Featured Rotator', 'issuem'); ?> </label></p> <p><input id="featured_thumb" type="checkbox" name="featured_thumb" <?php checked($featured_thumb || "on" == $featured_thumb); ?> /><label for="featured_thumb"><?php _e('Add article to Featured Thumbnails', 'issuem'); ?> </label></p> <p> <label for="teaser_text"><strong><?php _e('Teaser Text', 'issuem'); ?> </strong></label><br> <input class="large-text" type="text" name="teaser_text" value="<?php echo $teaser_text; ?> " /> </p> <?php if (!empty($issuem_settings['issuem_author_name'])) { ?> <p><label for="featured_thumb"><strong><?php _e('IssueM Author Name', 'issuem'); ?> </strong></label><br> <input class="regular-text" type="text" name="issuem_author_name" value="<?php echo $issuem_author_name; ?> " /></p> <?php } ?> </div> <?php }
/** * Displays the widget options in the dashboard * * @since 1.0 * @param array $instance */ function form($instance) { $available_issues = get_terms('issuem_issue', array('hide_empty' => false)); //Defaults $defaults = array('title' => '', 'posts_per_page' => '-1', 'article_format' => '<p class="issuem_widget_category">%CATEGORY[1]%</p>' . "\n" . '<p><a class="issuem_widget_link" href="%URL%">%TITLE%</a></p>' . "\n" . '<p class="issuem_widget_teaser">%TEASER%</p>' . "\n", 'article_category' => 'all', 'orderby' => 'menu_order', 'order' => 'DESC'); extract(wp_parse_args((array) $instance, $defaults)); if (!empty($available_issues)) { ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'issuem'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr(strip_tags($title)); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('posts_per_page'); ?> "><?php _e('Number of Articles to Show:', 'issuem'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('posts_per_page'); ?> " name="<?php echo $this->get_field_name('posts_per_page'); ?> " type="text" value="<?php echo esc_attr(strip_tags($posts_per_page)); ?> " /> <small>-1 = All Articles</small> </p> <?php $issuem_settings = get_issuem_settings(); if (!empty($issuem_settings['use_wp_taxonomies'])) { $cat_type = 'category'; } else { $cat_type = 'issuem_issue_categories'; } $categories = get_terms($cat_type); ?> <p> <label for="<?php echo $this->get_field_id('article_category'); ?> "><?php _e('Select Category to Display:', 'issuem'); ?> </label><br /> <select id="<?php echo $this->get_field_id('article_category'); ?> " name="<?php echo $this->get_field_name('article_category'); ?> "> <option value="all" <?php selected('all', $article_category); ?> ><?php _e('All Categories', 'issuem'); ?> </option> <?php foreach ($categories as $cat) { ?> <option value="<?php echo $cat->slug; ?> " <?php selected($cat->slug, $article_category); ?> ><?php echo $cat->name; ?> </option> <?php } ?> </select> </p> <p> <?php $orderby_options = array('none' => __('None', 'issuem'), 'ID' => __('Article ID', 'issuem'), 'author' => __('Article Author', 'issuem'), 'title' => __('Article Title', 'issuem'), 'name' => __('Article Name', 'issuem'), 'date' => __('Article Publish Date', 'issuem'), 'modified' => __('Article Modified Date', 'issuem'), 'menu_order' => __('Article Order', 'issuem'), 'rand' => __('Random Order', 'issuem'), 'comment_count' => __('Comment Count', 'issuem')); ?> <label for="<?php echo $this->get_field_id('orderby'); ?> "><?php _e('Select Sort Order:', 'issuem'); ?> </label><br /> <select id="<?php echo $this->get_field_id('orderby'); ?> " name="<?php echo $this->get_field_name('orderby'); ?> "> <?php foreach ($orderby_options as $orderby_key => $orderby_title) { ?> <option value="<?php echo $orderby_key; ?> " <?php selected($orderby_key, $orderby); ?> ><?php echo $orderby_title; ?> </option> <?php } ?> </select> </p> <p> <?php $order_options = array('DESC' => __('Descending', 'issuem'), 'ASC' => __('Ascending', 'issuem')); ?> <label for="<?php echo $this->get_field_id('order'); ?> "><?php _e('Select Order Direction:', 'issuem'); ?> </label><br /> <select id="<?php echo $this->get_field_id('order'); ?> " name="<?php echo $this->get_field_name('order'); ?> "> <?php foreach ($order_options as $order_key => $order_title) { ?> <option value="<?php echo $order_key; ?> " <?php selected($order_key, $order); ?> ><?php echo $order_title; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('article_format'); ?> "><?php _e('Article Format:', 'issuem'); ?> </label><br /> <textarea id="<?php echo $this->get_field_id('article_format'); ?> " name="<?php echo $this->get_field_name('article_format'); ?> " cols="70" rows="16"><?php echo $article_format; ?> </textarea> </p> <p><a href="/wp-admin/edit.php?post_type=article&page=issuem-help"><?php _e('See IssueM Help for details on article formatting', 'issuem'); ?> </a></p> <?php } else { _e('You have to create a issue before you can use this widget.', 'issuem'); } }
/** * Outputs Issue Featured Thumbnail Images HTML from shortcode call * * @since 1.0.0 * * @param array $atts Arguments passed through shortcode * @return string HTML output of Issue Featured Rotator Thumbnails */ function do_issuem_featured_thumbs($atts) { global $post; $results = ''; $issuem_settings = get_issuem_settings(); $defaults = array('content_type' => 'teaser', 'posts_per_page' => -1, 'offset' => 0, 'orderby' => 'menu_order', 'order' => 'DESC', 'max_images' => 0, 'issue' => get_active_issuem_issue(), 'article_category' => 'all', 'show_cats' => false); // Merge defaults with passed atts // Extract (make each array element its own PHP var extract(shortcode_atts($defaults, $atts)); $args = array('posts_per_page' => $posts_per_page, 'offset' => $offset, 'post_type' => 'article', 'orderby' => $orderby, 'order' => $order, 'meta_key' => '_featured_thumb', 'issuem_issue' => $issue); if (!empty($issuem_settings['use_wp_taxonomies'])) { $cat_type = 'category'; } else { $cat_type = 'issuem_issue_categories'; } if (!empty($article_category) && 'all' !== $article_category) { $category = array('taxonomy' => $cat_type, 'field' => 'slug', 'terms' => split(',', $article_category)); $args['tax_query'] = array('relation' => 'AND', $issuem_issue, $category); } $featured_articles = get_posts($args); if ($featured_articles) { $results .= '<div id="issuem-featured-article-thumbs-wrap">'; $count = 1; /* start the loop */ foreach ($featured_articles as $article) { if (has_post_thumbnail($article->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($article->ID), 'issuem-featured-thumb-image'); $image = apply_filters('issuem_featured_thumbs_article_image', $image, $article); $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_div', '', $article); $results .= '<div class="issuem-featured-article-thumb">'; $results .= apply_filters('issuem_featured_thumbs_start_thumbnail_div', '', $article); $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_image', '', $article); $results .= apply_filters('issuem_featured_thumbs_thumbnail_image', '<a class="issuem-featured-thumbs-img" href="' . get_permalink($article->ID) . '"><img src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . get_post_meta($article->ID, '_teaser_text', true) . '" /></a>', $article); $results .= apply_filters('issuem_featured_thumbs_after_thumbnail_image', '', $article); if ('true' === $show_cats) { $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_category', '', $article); $results .= apply_filters('issuem_featured_thumbs_thumbnail_category', '<p class="issuem-article-category">' . get_the_term_list($article->ID, $cat_type) . '</p>', $article); $results .= apply_filters('issuem_featured_thumbs_after_thumbnail_category', '', $article); } $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_title', '', $article); $results .= apply_filters('issuem_featured_thumbs_after_thumbnail_title', '<h3 class="issuem-featured-thumb-title"><a href="' . get_permalink($article->ID) . '">' . get_the_title($article->ID) . '</a></h3>', $article); $results .= apply_filters('issuem_featured_thumbs_after_thumbnail_title', '', $article); $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_content', '', $article); switch ($content_type) { case 'excerpt': $results .= apply_filters('issuem_featured_thumbs_thumbnail_content', '<p class="issuem-featured-thumb-content">' . get_issuem_article_excerpt($article->ID) . '</p>', $article); break; case 'teaser': default: $results .= apply_filters('issuem_featured_thumbs_thumbnail_content', '<p class="featured-thumb-content">' . get_post_meta($article->ID, '_teaser_text', true) . '</p>', $article); break; } $results .= apply_filters('issuem_featured_thumbs_after_thumbnail_content', '', $article); $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_byline', '', $article); if ($issuem_settings['show_thumbnail_byline']) { $author_name = get_issuem_author_name($article); $results .= apply_filters('issuem_featured_thumbs_thumbnail_byline', '<p class="featured-thumb-byline">' . sprintf(__('By %s', 'issuem'), apply_filters('issuem_author_name', $author_name, $article->ID)) . '</p>', $article); } $results .= apply_filters('issuem_featured_thumbs_before_thumbnail_byline', '', $article); $results .= apply_filters('issuem_featured_thumbs_end_thumbnail_div', '', $article); $results .= '</div>'; $results .= apply_filters('issuem_featured_article_after_thumbnail_div', '', $article); if (0 != $max_images && $max_images <= $count) { break; } $count++; } } $results .= '</div>'; } return $results; }