Пример #1
0
function get_the_series_rss($type = 'rss')
{
    $series = get_the_series();
    $home = get_bloginfo_rss('home');
    $the_list = '';
    $series_names = array();
    $filter = 'rss';
    if ('atom' == $type) {
        $filter = 'raw';
    }
    if (!empty($series)) {
        foreach ((array) $series as $serial) {
            $series_names[] = sanitize_term_field('name', $serial->name, $serial->term_id, 'series', $filter);
        }
    }
    $series_names = array_unique($series_names);
    foreach ($series_names as $series_name) {
        if ('rdf' == $type) {
            $the_list .= "\n\t\t<series:name><![CDATA[{$series_name}]]></series:name>\n";
        } elseif ('atom' == $type) {
            $the_list .= sprintf('<series:name scheme="%1$s" term="%2$s" />', esc_attr(apply_filters('get_bloginfo_rss', get_bloginfo('url'))), esc_attr($series_name));
        } else {
            $the_list .= "\n\t\t<series:name><![CDATA[{$series_name}]]></series:name>\n";
        }
    }
    return apply_filters('the_series_rss', $the_list, $type);
}
Пример #2
0
function reset_series_order_on_trash($postid)
{
    $id = (int) $postid;
    $series = get_the_series($id);
    if (!empty($series)) {
        //let's not waste any cycles
        foreach ($series as $ser) {
            wp_reset_series_order_meta_cache($id, $ser->term_id);
        }
    }
}
Пример #3
0
 function widget($args, $instance)
 {
     global $orgseries, $wp_query;
     extract($args, EXTR_SKIP);
     $c = $instance['show-count'] ? '1' : '0';
     $e = $instance['hide-empty'] ? '1' : '0';
     $showpostlist = $instance['postlistdisplay-toggle'] ? '1' : '0';
     $showseriestoc = $instance['seriestocdisplay-toggle'] ? '1' : '0';
     $series_args = $args = apply_filters('widget_seriestoc_args', array('orderby' => 'name', 'show_count' => $c, 'hide_empty' => $e, 'echo' => false));
     $title = $instance['title'];
     if (isset($instance['serieswidget-title']) && count($instance['serieswidget-title']) > 0) {
         $widget_title = $instance['serieswidget-title'];
     } else {
         $widget_title = false;
     }
     $out = '';
     if ($showseriestoc) {
         if ($instance['list-type'] == 'list') {
             $out .= '<ul>';
             $series_args['title_li'] = '';
             $out .= wp_list_series($series_args);
             $out .= '</ul>';
         } elseif ($instance['list-type'] == 'dropdown') {
             $series_args['show_option_all'] = __('Select Series', 'organize-series');
             $series_args['name'] = 'orgseries_dropdown';
             $out = wp_dropdown_series($series_args);
         }
     }
     if ($showpostlist) {
         if ($wp_query->is_single && $showpostlist && ($series = get_the_series())) {
             if ($showseriestoc) {
                 $out .= '<br /><br />';
             }
             $out .= get_series_posts('', 'widget', false, $widget_title);
         }
     }
     if (!empty($out)) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo $out;
         echo $after_widget;
     }
 }
/**
 * 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;
}
function series_issue_manager_publish_intercept($post_ID, $post)
{
    $unpublished = get_option('im_unpublished_series');
    $publishable = TRUE;
    // check if post is in an unpublished series
    foreach (get_the_series($post_ID) as $series) {
        if (in_array($series->term_id, $unpublished)) {
            $publishable = FALSE;
            break;
        }
    }
    // if post is in an unpublished series, change its status to 'pending' instead of 'publish'
    if (!$publishable) {
        if ($post->post_status != 'publish') {
            return;
        }
        wp_update_post(array('ID' => $post_ID, 'post_status' => 'pending'));
    }
    return;
}
Пример #6
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;
    }
}