" . __('The date format changed in Simple Yearly Archive 1.2.6! Please save the options once to assign the new date format to the system! Don\'t forget to change the date format string!', 'simple-yearly-archive') . "

"; } if( !get_option('sya_dateformatchanged2012') || get_option('sya_dateformatchanged2012') == 0 ) { add_action('admin_notices', 'sya_dateformat_changed_message'); } /** * Notify users that date format string is deprecated * * @since 1.2.7 * @author scripts@schloebe.de */ function sya_dateformat_deprecated_message() { echo "

" . __('You still seem to use the old date format string in Simple Yearly Archive! Please change the date format string to assign the new date format to the system! An example would be " %d/%m "!', 'simple-yearly-archive') . "

"; } if( is_admin() ) { $sya_dateformat_deprecated = strpos(get_option('sya_dateformat'), "%"); if( get_option('sya_dateformatchanged2012') == 1 && ($sya_dateformat_deprecated === false && get_option('sya_dateformat') != '') ) { add_action('admin_notices', 'sya_dateformat_deprecated_message'); } } /** * Add action link(s) to plugins page * * @since 1.1.7 * @author scripts@schloebe.de * @copyright Dion Hulse, http://dd32.id.au/wordpress-plugins/?configure-link */ function sya_filter_plugin_actions($links, $file){ static $this_plugin; if( !$this_plugin ) $this_plugin = plugin_basename(__FILE__); if( $file == $this_plugin ) { $settings_link = '' . __('Settings') . ''; $links = array_merge( array($settings_link), $links); // before other links } return $links; } add_filter('plugin_action_links', 'sya_filter_plugin_actions', 10, 2); /** * Returns the parsed archive contents * * @since 0.7 * @author scripts@schloebe.de * * @param string * @param int|string * @return int|string */ function get_simpleYearlyArchive($format, $excludeCat='', $includeCat='', $dateformat) { global $wpdb, $PHP_SELF, $wp_version; setlocale(LC_TIME, WPLANG); $now = gmdate("Y-m-d H:i:s",(time()+((get_settings('gmt_offset'))*3600))); (!isset($wp_version)) ? $wp_version = get_bloginfo('version') : $wp_version = $wp_version; $allcatids = get_all_category_ids(); $yeararray = array(); if (($format == 'yearly') || ($format == '')) { $modus = ""; } else if($format == 'yearly_act') { $modus = " AND year($wpdb->posts.post_date) = " . date('Y'); } else if($format == 'yearly_past') { $modus = " AND year($wpdb->posts.post_date) < " . date('Y'); } else if(preg_match("/^[0-9]{4}$/", $format)) { $modus = " AND year($wpdb->posts.post_date) = '" . $format . "'"; } $sya_where = ( current_user_can('read_private_posts') ) ? "AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'private')" : "AND $wpdb->posts.post_status = 'publish'"; $ausgabe .= "
"; $jahreMitBeitrag = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.post_date, year($wpdb->posts.post_date) AS `year`, COUNT(ID) as posts FROM $wpdb->posts WHERE $wpdb->posts.post_type = 'post' " . $sya_where . $modus . " GROUP BY year($wpdb->posts.post_date) ORDER BY $wpdb->posts.post_date DESC"); foreach ($jahreMitBeitrag as $aktuellesJahr) { for ($aktuellerMonat = 1; $aktuellerMonat <= 12; $aktuellerMonat++) { $monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat] = $wpdb->get_results("SELECT ID, post_date, post_title, post_excerpt, post_author, comment_count, post_status FROM $wpdb->posts WHERE post_type = 'post' " . $sya_where . " AND year(post_date) = '$aktuellesJahr->year' ORDER BY post_date desc"); } $yeararray[] = $aktuellesJahr->year; } if(get_option('sya_showyearoverview')==TRUE) { $ausgabe .= "

" . implode( ' • ', sya_yearoverview( $yeararray ) ) . "

"; } if (($format == 'yearly') || ($format == 'yearly_act') || ($format == 'yearly_past') || ($format == '') || (preg_match("/^[0-9]{4}$/", $format))) { $before = get_option('sya_prepend'); $after = get_option('sya_append'); ((get_option('sya_excerpt_indent')=='') ? $indent = '0' : $indent = get_option('sya_excerpt_indent')); ((get_option('sya_excerpt_maxchars')=='') ? $maxzeichen = '0' : $maxzeichen = get_option('sya_excerpt_maxchars')); (($dateformat=='') ? $outputdateformat = get_option('sya_dateformat') : $outputdateformat = $dateformat); if ($jahreMitBeitrag) { if ($excludeCat != '' || $includeCat != '') { // there are excluded or included categories $excludeCats = explode( ",", trim($excludeCat) ); if( trim($includeCat) == '' ) $includeCats = array_diff( $allcatids, $excludeCats ); else $includeCats = explode( ",", trim( $includeCat ) ); $syaargs_includecats = implode(",", $includeCats); foreach($jahreMitBeitrag as $aktuellesJahr) { $aktuellerMonat = 1; while ($aktuellerMonat >= 1) { if(get_option('sya_linkyears')==TRUE) { $linkyears_prepend = ''; $linkyears_append = ''; } else { $linkyears_prepend = ''; $linkyears_append = ''; } if ($monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat]) { $listitems = $listyears; $syaargs_status = ( current_user_can('read_private_posts') ) ? "publish,private" : "publish"; if( version_compare($GLOBALS['wp_version'], '2.5.99', '>') ) { $syaargs = array( 'post_type' => 'post', 'numberposts' => -1, 'post_status' => $syaargs_status, 'category' => $syaargs_includecats, 'year' => $aktuellesJahr->year ); } else { $syaargs = array( 'post_type' => 'post', 'numberposts' => -1, 'post_status' => $syaargs_status, 'category' => $syaargs_includecats ); } $syaposts = get_posts( $syaargs ); $wp_dateformat = get_option('date_format'); if( $syaposts ) { foreach( $syaposts as $post ) { setup_postdata( $post ); $post->filter = 'sample'; if ( date(('Y'), strtotime($post->post_date)) == $aktuellesJahr->year ) { $langtitle = $post->post_title; $langtitle = apply_filters("the_title", $post->post_title); if( $post->post_status == 'private' ) { $isprivate = ' class="sya_private"'; $langtitle = sprintf(__('Private: %s'), $langtitle); } else { $isprivate = ''; } $listitems .= ''; $listitems .= ('' . utf8_encode(strftime($outputdateformat, strtotime($post->post_date))) . ' ' . get_option('sya_datetitleseperator') . ' ' . $langtitle . ''); if(get_option('sya_commentcount')==TRUE) { $listitems .= ' (' . $post->comment_count . ')'; } if(get_option('sya_show_categories')==TRUE) { foreach (wp_get_post_categories( $post->ID ) as $cat_id) { $sya_categories[] = get_cat_name( $cat_id ); } $listitems .= ' (' . implode(', ', $sya_categories) . ')'; $sya_categories = ''; } if(get_option('sya_showauthor')==TRUE) { $userinfo = get_userdata( $post->post_author ); $listitems .= ' (' . __('by') . ' ' . $userinfo->display_name . ')'; } if(get_option('sya_excerpt')==TRUE) { if ( $maxzeichen != '0' ) { if ( !empty($post->post_excerpt) ) { $excerpt = substr($post->post_excerpt, 0, strrpos(substr($post->post_excerpt, 0, $maxzeichen), ' ')) . '...'; } } else { $excerpt = $post->post_excerpt; } $listitems .= '
' . strip_tags($excerpt) . '
'; } $listitems .= ''; $excerpt = ''; } clean_object_term_cache( $post->ID, $post->post_type ); } } if (strlen($listitems) > 0) { $ausgabe .= $before . '' . $linkyears_prepend . $aktuellesJahr->year . $linkyears_append; if(get_option('sya_postcount')==TRUE) { $postcount = count( $syaposts ); $ausgabe .= ' (' . $postcount . ')'; } $ausgabe .= $after.''; } } $aktuellerMonat--; } } } else { // there are NO excluded or included categories foreach($jahreMitBeitrag as $aktuellesJahr) { $aktuellerMonat = 1; while ($aktuellerMonat >= 1) { if(get_option('sya_linkyears')==TRUE) { $linkyears_prepend = ''; $linkyears_append = ''; } else { $linkyears_prepend = ''; $linkyears_append = ''; } if ($monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat]) { if(get_option('sya_postcount')==TRUE) { $postcount = count($monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat]); } $listitems = ''; foreach ($monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat] as $post) { $post->filter = 'sample'; $langtitle = $post->post_title; $langtitle = apply_filters("the_title", $post->post_title); if( $post->post_status == 'private' ) { $isprivate = ' class="sya_private"'; $langtitle = sprintf(__('Private: %s'), $langtitle); } else { $isprivate = ''; } $listitems .= ''; $listitems .= ('' . utf8_encode(strftime($outputdateformat, strtotime($post->post_date))) . ' ' . get_option('sya_datetitleseperator') . ' ' . $langtitle . ''); if(get_option('sya_commentcount')==TRUE) { $listitems .= ' (' . $post->comment_count . ')'; } if(get_option('sya_show_categories')==TRUE) { foreach (wp_get_post_categories( $post->ID ) as $cat_id) { $sya_categories[] = get_cat_name( $cat_id ); } $listitems .= ' (' . implode(', ', $sya_categories) . ')'; $sya_categories = ''; } if(get_option('sya_showauthor')==TRUE) { $userinfo = get_userdata( $post->post_author ); $listitems .= ' (' . __('by') . ' ' . $userinfo->display_name . ')'; } if(get_option('sya_excerpt')==TRUE) { if ( $maxzeichen != '0' ) { if ( !empty($post->post_excerpt) ) { $excerpt = substr($post->post_excerpt, 0, strrpos(substr($post->post_excerpt, 0, $maxzeichen), ' ')) . '...'; } } else { $excerpt = $post->post_excerpt; } $listitems .= '
' . strip_tags($excerpt) . '
'; } $listitems .= ''; $excerpt = ''; clean_object_term_cache( $post->ID, $post->post_type ); } if (strlen($listitems) > 0) { $ausgabe .= $before . '' . $linkyears_prepend.$aktuellesJahr->year.$linkyears_append; if(get_option('sya_postcount')==TRUE) { $postcount = count($monateMitBeitrag[$aktuellesJahr->year][$aktuellerMonat]); $ausgabe .= ' (' . $postcount . ')'; } $ausgabe .= $after.'
    '.$listitems.'
'; } } $aktuellerMonat--; } } } } else { $ausgabe .= __('No posts found.'); } } if(get_option('sya_linktoauthor')==TRUE) { $linkvar = __('Plugin by', 'simple-yearly-archive') . ' Oliver Schlöbe'; $ausgabe .= '
' . $linkvar . '
'; } $ausgabe .= "
"; $ausgabe = apply_filters('sya_archive_output', $ausgabe); return $ausgabe; } /** * Echoes the parsed archive contents * * @since 0.7 * @author scripts@schloebe.de * * @param string * @param int|string */ function simpleYearlyArchive($format='yearly', $excludeCat='', $includeCat='', $dateformat='') { echo get_simpleYearlyArchive($format, $excludeCat, $includeCat, $dateformat); } /** * Returns the year overview contents * * @since 1.2.5 * @author scripts@schloebe.de * * @param array $yeararray * @return array */ function sya_yearoverview( $yeararray ) { $years = array(); foreach( $yeararray as $year ) { $years[] = '' . $year . ''; } return $years; } /** * Echoes the plugin version in the website header * * @since 0.8 * @author scripts@schloebe.de */ function sya_header() { echo "\n" . '' . "\n"; } if ( is_admin() ) { add_action('admin_menu', 'sya_add_option_menu'); } add_action('wp_head', 'sya_header'); if( version_compare($wp_version, '2.4.999', '>') ) { /** * This file holds all the author plugins functions */ require_once( dirname(__FILE__) . '/' . 'authorplugins.inc.php' ); } /** * Sets the default options after plugin activation * * @since 0.8 * @author scripts@schloebe.de */ function set_default_options() { add_option('sya_dateformat', '%d/%m'); add_option('sya_datetitleseperator', '-'); add_option('sya_prepend', '

'); add_option('sya_append', '

'); add_option('sya_linkyears', 1); add_option('sya_postcount', 0); add_option('sya_commentcount', 0); add_option('sya_linktoauthor', 1); add_option('sya_excerpt', 0); add_option('sya_excerpt_indent', '0'); add_option('sya_excerpt_maxchars', '0'); add_option('sya_show_categories', 0); add_option('sya_showauthor', 0); add_option('sya_showyearoverview', 0); add_option("sya_dateformatchanged2012", 0); } /** * @since 1.1.7 * @uses function sya_get_resource_url() to display */ if( isset($_GET['resource']) && !empty($_GET['resource'])) { # base64 encoding $resources = array( 'pulldown.gif' => 'R0lGODlhCgAKAKIAADMzM//M/97e3pCQkGZmZu/v7////wAAAC'. 'H5BAEHAAEALAAAAAAKAAoAAAMkGLoc9PA5Ywa9z4ghujBPx41C'. 'uIndU5xeoRZDIctEANz43ewJADs='. ''); if(array_key_exists($_GET['resource'], $resources)) { $content = base64_decode($resources[ $_GET['resource'] ]); $lastMod = filemtime(__FILE__); $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false ); if (isset($client) && (strtotime($client) == $lastMod)) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304); exit; } else { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200); header('Content-Length: '.strlen($content)); header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) ); echo $content; exit; } } } /** * Display Images/Icons base64-encoded * * @since 1.1.7 * @author scripts@schloebe.de * @param $resourceID * @return $resourceURL */ function sya_get_resource_url( $resourceID ) { return trailingslashit( get_bloginfo('url') ) . '?resource=' . $resourceID; } /** * Adds the plugin's options page * * @since 1.1.7 * @author scripts@schloebe.de */ function sya_add_option_menu() { global $wp_version; if ( current_user_can('switch_themes') && function_exists('add_submenu_page') ) { $menutitle = ''; if ( version_compare( $wp_version, '2.6.999', '>' ) ) { $menutitle = '' . ' '; } $menutitle .= __('Simple Yearly Archive', 'simple-yearly-archive'); add_submenu_page('options-general.php', __('Simple Yearly Archive', 'simple-yearly-archive'), $menutitle, 9, __FILE__, 'sya_options_page'); } } /** * Adds the plugin's options page * * @since 0.7 * @author scripts@schloebe.de * @deprecated Deprecated since version 1.1.7 * @see sya_add_option_menu() */ function sya_add_optionpages() { set_default_options(); add_options_page(__('Simple Yearly Archive Options', 'simple-yearly-archive'), __('Simple Yearly Archive', 'simple-yearly-archive'), 8, __FILE__, 'sya_options_page'); } /** * Filters the shortcode from the post content and returns the filtered content * * @since 0.7 * @author scripts@schloebe.de * * @param string * @return string */ function sya_inline($post) { if (substr_count($post, '') > 0) { $sya_archives = get_simpleYearlyArchive($format, $excludeCat); $post = str_replace('', $sya_archives, $post); } return $post; } add_action('the_content', 'sya_inline', 1); if( version_compare($wp_version, '2.4.999', '>') ) { /** * Setups the plugin's shortcode * * @since 1.1.0 * @author scripts@schloebe.de * * @param mixed * @return string */ function syatag_func( $atts ) { extract(shortcode_atts(array( 'type' => 'yearly', 'exclude' => '', 'include' => '', 'dateformat' => '' ), $atts)); return get_simpleYearlyArchive($type, $exclude, $include, $dateformat); } if( function_exists('add_shortcode') ) { add_shortcode('SimpleYearlyArchive', 'syatag_func'); } } /** * Fills the options page with content * * @since 0.7 * @author scripts@schloebe.de */ function sya_options_page() { global $wp_version; if (isset($_POST['action']) === true) { update_option("sya_dateformat", (string)$_POST['sya_dateformat']); update_option("sya_datetitleseperator", (string)$_POST['sya_datetitleseperator']); update_option("sya_linkyears", (bool)$_POST['sya_linkyears']); update_option("sya_postcount", (bool)$_POST['sya_postcount']); update_option("sya_commentcount", (bool)$_POST['sya_commentcount']); update_option("sya_linktoauthor", (bool)$_POST['sya_linktoauthor']); update_option("sya_prepend", (string)$_POST['sya_prepend']); update_option("sya_append", (string)$_POST['sya_append']); update_option("sya_excerpt", (bool)$_POST['sya_excerpt']); update_option("sya_excerpt_indent", (string)$_POST['sya_excerpt_indent']); update_option("sya_excerpt_maxchars", (string)$_POST['sya_excerpt_maxchars']); update_option("sya_show_categories", (bool)$_POST['sya_show_categories']); update_option("sya_showauthor", (bool)$_POST['sya_showauthor']); update_option("sya_showyearoverview", (bool)$_POST['sya_showyearoverview']); update_option("sya_dateformatchanged2012", 1); $successmessage = __('Settings successfully updated!', 'simple-yearly-archive'); echo '

' . $successmessage . '

'; } ?>

|
/>
/>
/>
/>
/>
/>
/>
--
/>
--
/>

/>

=') ) { ?>

www.schloebe.de', 'simple-yearly-archive'); ?>

http://www.schloebe.de/wordpress/simple-yearly-archive-plugin/', 'simple-yearly-archive'); ?>