示例#1
0
function get_series_rss_link($echo = false, $series_id = '')
{
    $permalink_structure = get_option('permalink_structure');
    //check for series_id and attempt to find it if possible
    if ($series_id == '') {
        $series = get_query_var(SERIES_QUERYVAR);
    }
    if ($series_id == '') {
        return;
    }
    if ('' == $permalink_structure) {
        $link = get_option('home') . '?feed=rss2&' . SERIES_QUERYVAR . '=' . $series_id;
    } else {
        $link = get_series_link($series_id);
        $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
    }
    $link = apply_filters('series_feed_link', $link);
    if ($echo) {
        echo $link;
    }
    return $link;
}
/**
 * get_series_icon() -  Template tag for insertion of series-icons
 *
 * @package Organize Series WordPress Plugin
 * @since 2.0
 *
 * @uses parse_str()
 * @uses stripslaghes_gpc_arr()
 * @uses get_the_series()
 * @uses is_array()
 * @uses series_get_icons()
 * @uses seriesicons_path()
 * @uses seriesicons_url()
 * @uses get_series_link()
 * @uses getimagesize()
 * @uses series_fit_rect()
 *
 * @param int[-1] $fit_width Maximum width (or desired width if $expanded=true) of the image.
 * @param int[-1] $fit_height Macimum height (or desired height if $expanded=true) of the image.
 * @param boolean [false] $expand Whether the image should be expanded to fit the rectangle specified by fit_xxx.
 * @param int $series Series ID. If not specified, the current series is used or the current post's series.
 * @param string $prefix String to echo before the image tag. If no image, no otuput.
 * @param string $suffix String to echo after the image tag. Ignored if no image found.
 * @param string [] $class  Class attribute for the image tag.
 * @param boolean [1] $link If true the image is made a hyperlink (wrapped by anchor tag).
 * @param  boolean [1] $display If true the function will echo the image.  If false the function will return the assembled image as a string.
 *
 * @return mixed|bool|string Will return false if image is not found.  Will return string containing assembled html code for image if $display is false.  Will echo image if the $display param = true.
 */
function get_series_icon($params = '')
{
    global $orgseries;
    parse_str($params, $p);
    if (!isset($p['fit_width'])) {
        $p['fit_width'] = -1;
    }
    if (!isset($p['fit_height'])) {
        $p['fit_height'] = -1;
    }
    if (!isset($p['expand'])) {
        $p['expand'] = false;
    }
    if (!isset($p['series'])) {
        $p['series'] = get_query_var(SERIES_QUERYVAR);
    }
    if (!isset($p['prefix'])) {
        $p['prefix'] = '';
    }
    if (!isset($p['suffix'])) {
        $p['suffix'] = '';
    }
    if (!isset($p['class'])) {
        $p['class'] = 'series-icon-' . $p['series'];
    }
    if (!isset($p['link'])) {
        $p['link'] = 1;
    }
    if (!isset($p['display'])) {
        $p['display'] = 1;
    }
    stripslaghes_gpc_arr($p);
    if (empty($p['series']) && isset($GLOBALS['post'])) {
        $serieslist = get_the_series($GLOBALS['post']->ID);
        if (is_array($serieslist)) {
            $p['series'] = $serieslist[0]->term_id;
        }
    }
    $p['series'] = series_exists($p['series']);
    if (!isset($p['series'])) {
        return;
    }
    //make sure we get the id for the series (in case just the slug is given
    $icon = series_get_icons($p['series']);
    $s_name = get_series_name($p['series']);
    $file = seriesicons_path() . $icon;
    $url = seriesicons_url() . $icon;
    if ($p['link']) {
        $p['prefix'] .= '<a href="' . get_series_link($p['series']) . '">';
        $p['suffix'] = '</a>' . $p['suffix'];
    }
    if (is_file($file)) {
        list($width, $height, $type, $attr) = getimagesize($file);
        list($w, $h) = series_fit_rect($width, $height, $p['fit_width'], $p['fit_height'], $p['expand']);
        $series_icon = $p['prefix'] . '<img class="' . $p['class'] . '" src="' . $url . '" width="' . $w . '" height="' . $h . '"  alt="' . $icon . '" />' . $p['suffix'];
        if ($p['display'] == 1) {
            echo $series_icon;
        } else {
            return $series_icon;
        }
    }
    return false;
}
示例#3
0
function orgSeries_custom_column_action($column_name, $id)
{
    global $orgseries;
    $seriesid = null;
    $series_part = null;
    $series_name = null;
    $column_content = null;
    $post_types = apply_filters('orgseries_posttype_support', array('post'));
    if ($column_name == 'series') {
        $column_content .= '<div class="series_column">';
        $column_content .= '<input type="hidden" name="is_series_save" value="1" />';
        if ($series = get_the_series($id, false)) {
            $seriesid = $series[0]->term_id;
            $series_name = $series[0]->name;
            $series_link = get_series_link($series_name);
            $series_part = get_post_meta($id, SERIES_PART_KEY, TRUE);
            $count = $series[0]->count;
            $draft_posts = get_posts(array('post_type' => $post_types, 'post_status' => array('draft', 'future', 'pending'), 'taxonomy' => 'series', 'term' => $series_name));
            $count_draft_posts = count($draft_posts);
            $drafts_included = '';
            if ($count_draft_posts != 0) {
                $all_serie_posts = $count_draft_posts + $count;
                $drafts_included = "({$all_serie_posts})";
            }
            $post_status = get_post_status($id);
            if ($series && in_array($post_status, array('publish', 'private'))) {
                $column_content .= sprintf(__('Part %1$s of %2$s%6$s in the series <br/><a href="%3$s" title="%4$s">%5$s</a>', 'organize-series'), $series_part, $count, $series_link, $series_name, $series_name, $drafts_included);
                $column_content .= '<div class="hidden" id="inline_series_' . $id . '"><div class="series_inline_edit">' . $seriesid . '</div><div class="series_inline_part">' . $series_part . '</div><div class="series_post_id">' . $id . '</div><div class="series_inline_name">' . $series_name . '</div></div>';
            } else {
                $column_content .= sprintf(__('<a href="%1$s" title="%2$s">%3$s</a> - (currently set as Part %4$s)', 'organize-series'), $series_link, $series_name, $series_name, $series_part);
                $column_content .= '<div class="hidden" id="inline_series_' . $id . '"><div class="series_inline_edit">' . $seriesid . '</div><div class="series_inline_part">' . $series_part . '</div><div class="series_post_id">' . $id . '</div><div class="series_inline_name">' . $series_name . '</div></div>';
            }
        } else {
            $column_content .= '<div class="hidden" id="inline_series_' . $id . '"><div class="series_inline_edit">' . $seriesid . '</div><div class="series_inline_part">' . $series_part . '</div><div class="series_post_id">' . $id . '</div><div class="series_inline_name">' . $series_name . '</div></div>';
            $column_content .= '<em>' . __('No Series', 'organize-series') . '</em>';
        }
        $column_content .= '</div>';
        echo $column_content;
    }
}