function wp_update_series($series_id, $taxonomy_id) { global $_POST; extract($_POST, EXTR_SKIP); if (empty($series_icon_loc)) { $series_icon_loc = ''; } if (empty($delete_image)) { $delete_image = false; } $series_icon = $series_icon_loc; if (!empty($series_icon) || $series_icon != '') { $build_path = seriesicons_url(); $series_icon = str_replace($build_path, '', $series_icon); } if ($delete_image) { seriesicons_delete($series_id); } else { $series_icon = seriesicons_write($series_id, $series_icon); } }
/** * 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 edit_series_form_fields($series, $taxonomy) { global $orgseries; $series_icon = get_series_icon('fit_width=100&fit_height=100&link=0&expand=true&display=0&series=' . $series->term_id); $icon_loc = series_get_icons($series->term_id); if ($icon_loc || $icon_loc != '') { $series_icon_loc = seriesicons_url() . $icon_loc; } else { $series_icon_loc = ''; } ?> <tr valign="top"> <?php if ($series->term_id != '') { ?> <th scope="row"><?php _e('Current series icon:', 'organize-series'); ?> </th><?php } ?> <td> <?php if ($series_icon != '') { echo $series_icon; } else { echo '<p>' . __('No icon currently', 'organize-series') . '</p>'; } ?> <div id="selected-icon"></div> </td> </tr> <?php if ($series_icon != '') { ?> <tr> <th></th> <td> <p style="width: 50%;"><input style="margin-top: 0px;" name="delete_image" id="delete_image" type="checkbox" value="true" /> <?php _e('Delete image? (note: there will not be an image associated with this series if you select this)', 'organize-series'); ?> </p> </td> </tr> <?php } ?> <tr valign="top"> <th scope="row"><?php _e('Series Icon Upload:', 'organize-series'); ?> </th> <td><label for="series_icon"> <input id="series_icon_loc_display" type="text" size="36" name="series_icon_loc_display" value="" disabled="disabled"/> <input id="upload_image_button" type="button" value="Select Image" /> <p><?php _e('Upload an image for the series.', 'organize-series'); ?> </p> <input id="series_icon_loc" type="hidden" name="series_icon_loc" /> </label> </td> </tr> <?php }