'', ); /** * PHP5 constructor */ function __construct() { // set option values $this->_set_options(); // load text domain for translations load_plugin_textdomain('anual-archive'); // add actions add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_actions' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'archive_admin_js_scripts' ) ); add_action( 'wp_head', array( $this, 'plugin_head_inject' ) ); // add shortcode add_shortcode('archives', array($this, 'shortcode')); add_shortcode('arcpromat', array($this, 'shortcode')); // Add shortcode support for widgets add_filter('widget_text', 'do_shortcode'); } //plugin header inject function plugin_head_inject(){ // custom css if( !empty( $this->options['custom_css'] ) ){ echo "\n\n"; } } /** * Callback admin_menu */ function admin_menu() { if ( function_exists( 'add_options_page' ) AND current_user_can( 'manage_options' ) ) { // add options page $options_page = add_options_page($this->plugin_options_page_title, $this->plugin_options_menue_title, 'manage_options', $this->plugin_options_slug, array( $this, 'options_page' )); } } /** * Callback admin_init */ function admin_init() { // register settings register_setting( $this->domain, $this->options_name ); } //load scripts on the widget admin page function archive_admin_js_scripts($hook){ global $pagenow; if( $hook == 'widgets.php' && $pagenow != 'customize.php'){ $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) ); wp_register_script('archive-admin-script', $plugin_url.'/js/widget_form.js', array ('jquery'), '0.1', true); wp_enqueue_script('archive-admin-script'); } } /** * Advaned wp_get_archives * adds the ability to order alpha and postbypost Archives * adds archive by decade **/ static function wp_get_archives_advanced( $args = '' ) { global $wpdb, $wp_locale; $defaults = array( 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC', 'alpha_order' => 'ASC', 'post_order' => 'DESC', 'post_type' => 'post', ); $r = wp_parse_args( $args, $defaults ); $post_type_object = get_post_type_object( $r['post_type'] ); if ( ! is_post_type_viewable( $post_type_object ) ) { return; } $r['post_type'] = $post_type_object->name; if ( '' == $r['type'] ) { $r['type'] = 'monthly'; } if ( ! empty( $r['limit'] ) ) { $r['limit'] = absint( $r['limit'] ); $r['limit'] = ' LIMIT ' . $r['limit']; } $order = strtoupper( $r['order'] ); if ( $order !== 'ASC' ) { $order = 'DESC'; } // this is what will separate dates on weekly archive links $archive_week_separator = '–'; $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] ); /** * Filters the SQL WHERE clause for retrieving archives. * * @since 2.2.0 * * @param string $sql_where Portion of SQL query containing the WHERE clause. * @param array $r An array of default arguments. */ $where = apply_filters( 'getarchives_where', $sql_where, $r ); /** * Filters the SQL JOIN clause for retrieving archives. * * @since 2.2.0 * * @param string $sql_join Portion of SQL query containing JOIN clause. * @param array $r An array of default arguments. */ $join = apply_filters( 'getarchives_join', '', $r ); $output = ''; $last_changed = wp_cache_get_last_changed( 'posts' ); $limit = $r['limit']; if ( 'monthly' == $r['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { $after = $r['after']; foreach ( (array) $results as $result ) { $url = get_month_link( $result->year, $result->month ); if ( 'post' !== $r['post_type'] ) { $url = add_query_arg( 'post_type', $r['post_type'], $url ); } /* translators: 1: month name, 2: 4-digit year */ $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year ); if ( $r['show_post_count'] ) { $r['after'] = ' (' . $result->posts . ')' . $after; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } elseif ( 'yearly' == $r['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { $after = $r['after']; foreach ( (array) $results as $result ) { $url = get_year_link( $result->year ); if ( 'post' !== $r['post_type'] ) { $url = add_query_arg( 'post_type', $r['post_type'], $url ); } $text = sprintf( '%d', $result->year ); if ( $r['show_post_count'] ) { $r['after'] = ' (' . $result->posts . ')' . $after; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } elseif ( 'daily' == $r['type'] ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { $after = $r['after']; foreach ( (array) $results as $result ) { $url = get_day_link( $result->year, $result->month, $result->dayofmonth ); if ( 'post' !== $r['post_type'] ) { $url = add_query_arg( 'post_type', $r['post_type'], $url ); } $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth ); $text = mysql2date( get_option( 'date_format' ), $date ); if ( $r['show_post_count'] ) { $r['after'] = ' (' . $result->posts . ')' . $after; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } elseif ( 'weekly' == $r['type'] ) { $week = _wp_mysql_week( '`post_date`' ); $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } $arc_w_last = ''; if ( $results ) { $after = $r['after']; foreach ( (array) $results as $result ) { if ( $result->week != $arc_w_last ) { $arc_year = $result->yr; $arc_w_last = $result->week; $arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) ); $arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] ); $arc_week_end = date_i18n( get_option( 'date_format' ), $arc_week['end'] ); $url = add_query_arg( array( 'm' => $arc_year, 'w' => $result->week, ), home_url( '/' ) ); if ( 'post' !== $r['post_type'] ) { $url = add_query_arg( 'post_type', $r['post_type'], $url ); } $text = $arc_week_start . $archive_week_separator . $arc_week_end; if ( $r['show_post_count'] ) { $r['after'] = ' (' . $result->posts . ')' . $after; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } } elseif ( 'decade' == $r['type'] ) { //$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; $query = "SELECT count(*), decade, decade + 9 FROM (SELECT FLOOR(YEAR(post_date) / 10) * 10 AS decade FROM $wpdb->posts $join $where) t GROUP BY decade $order $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { $after = $r['after']; foreach ( (array) $results as $result ) { $url = get_year_link($result->decade).'?decade='.$result->decade; if ( 'post' !== $r['post_type'] ) { $url = add_query_arg( 'post_type', $r['post_type'], $url ); } $text = sprintf( '%d\'s', $result->decade ); if ( $r['show_post_count'] ) { $r['after'] = ' (' . $result->posts . ')' . $after; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } elseif ( ( 'postbypost' == $r['type'] ) || ( 'alpha' == $r['type'] ) ) { $alpha_order = strtoupper( $r['alpha_order'] ); if ( $alpha_order !== 'ASC' ) { $alpha_order = 'DESC'; } $post_order = strtoupper( $r['post_order'] ); if ( $post_order !== 'DESC' ) { $post_order = 'ASC'; } $orderby = ( 'alpha' == $r['type'] ) ? 'post_title '.$alpha_order. ' ' : 'post_date '.$post_order.', ID DESC '; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { foreach ( (array) $results as $result ) { if ( $result->post_date != '0000-00-00 00:00:00' ) { $url = get_permalink( $result ); if ( $result->post_title ) { /** This filter is documented in wp-includes/post-template.php */ $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) ); } else { $text = $result->ID; } $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] ); } } } } if ( $r['echo'] ) { echo $output; } else { return $output; } } /** * Callback shortcode */ function shortcode($atts, $content = null){ extract(shortcode_atts(array( 'type' => 'yearly', 'limit' => '', 'format' => 'html', //html, option, link 'before' => '', 'after' => '', 'showcount' => '0', 'tag' => 'ul', 'order' => 'DESC', 'alpha_order' => 'ASC', 'post_order' => 'DESC', 'select_text' => '', 'post_type' => 'post', ), $atts)); if ($format == 'option') { if( !empty($select_text) ){ $dtitle = $select_text; } else{ $dtitle = __('Select Year', 'anual-archive'); if ($type == 'monthly'){ $dtitle = __('Select Month', 'anual-archive'); } else if($type == 'weekly'){ $dtitle = __('Select Week', 'anual-archive'); } else if($type == 'daily'){ $dtitle = __('Select Day', 'anual-archive'); } else if($type == 'postbypost' || $type == 'alpha'){ $dtitle = __('Select Post', 'anual-archive'); } } $arc = ''; } else { $arc = '<'.$tag.'>'; $arch_arr = array( 'type' => $type, 'limit' => $limit, 'format' => $format, 'before' => $before, 'after' => $after, 'show_post_count' => $showcount, 'post_type' => $post_type, 'order' => $order, 'alpha_order' => $alpha_order, 'post_order' => $post_order, 'echo' => 0 ); $arc .= WP_Plugin_Annual_Archive::wp_get_archives_advanced($arch_arr); $arc .= ''; } return $arc; } // Add link to options page from plugin list function plugin_actions($links) { $new_links = array(); $new_links[] = '' . __('Settings', 'anual-archive') . ''; return array_merge($new_links, $links); } /** * Admin options page */ function options_page() { $like_it_arr = array( __('really tied the room together', 'anual-archive'), __('made you feel all warm and fuzzy on the inside', 'anual-archive'), __('restored your faith in humanity... even if only for a fleeting second', 'anual-archive'), __('rocked your world', 'provided a positive vision of future living', 'anual-archive'), __('inspired you to commit a random act of kindness', 'anual-archive'), __('encouraged more regular flossing of the teeth', 'anual-archive'), __('helped organize your life in the small ways that matter', 'anual-archive'), __('saved your minutes--if not tens of minutes--writing your own solution', 'anual-archive'), __('brightened your day... or darkened if if you are trying to sleep in', 'anual-archive'), __('caused you to dance a little jig of joy and joyousness', 'anual-archive'), __('inspired you to tweet a little @twinpictues social love', 'anual-archive'), __('tasted great, while also being less filling', 'anual-archive'), __('caused you to shout: "everybody spread love, give me some mo!"', 'anual-archive'), __('helped you keep the funk alive', 'anual-archive'), __('soften hands while you do dishes', 'anual-archive'), __('helped that little old lady find the beef', 'anual-archive') ); $rand_key = array_rand($like_it_arr); $like_it = $like_it_arr[$rand_key]; ?>

plugin_name; ?>


domain ); $this->_set_options(); $options = $this->options; ?>
:
:

post type, custom post type and category. In addition it comes with %svery high level of personal support%s—that alone is well worth the price of admission.', 'anual-archive' ), '', '', '', ''); ?>

Congratulations! You have reach the very bottom of your Dashboard. This is probably least visited corner of your site, and yet here you are, reading this, hoping to be enlightened or rewarded in some way.

Well, we hate to leave you hanging, all disappointed, so here is a little tip or two for you.

Get back to work!

The sooner you finish that task, check that box of your list, wrap your day up, the sooner you can get on with the more important things in life that matter.

Things like:

  • playing with your dog
  • calling your mother
  • changing the sheets on the bed
  • flossing your teeth
  • simply sipping a cool beverage in a hammock

Now get on with it, there is a whole world out there to see!

', 'anual-archive' ); ?>


plugin_name; ?> version; ?>

','', '', '', '', '') ?>

  • ', ''); ?>
  • ', '' ) ?>
  • ', '', '', '', '', ''); ?>

post type or category', 'anual-archive' ), '', ''); ?>

Star Wars Day Discount: Update to Archive-Pro-Matic before May 4th, 2016 using discount code MAYTHE4TH and receive 10% off.

*/ ?>

  1. */ ?>
options_name ); // backwards compatible (old values) if ( empty( $saved_options ) ) { $saved_options = get_option( $this->domain . 'options' ); } // set all options if ( ! empty( $saved_options ) ) { foreach ( $this->options AS $key => $option ) { $this->options[ $key ] = ( empty( $saved_options[ $key ] ) ) ? '' : $saved_options[ $key ]; } } } } // end class WP_Plugin_Template /** * Create instance */ $WP_Plugin_Annual_Archive = new WP_Plugin_Annual_Archive; //Widget class Annual_Archive_Widget extends WP_Widget { /** constructor */ function __construct() { $widget_ops = array( 'classname' => 'Annual_Archive_Widget', 'description' => __( 'Display daily, weekly, monthly or annual archives with a sidebar widget or shortcode', 'anual-archive' ) ); parent::__construct( 'Annual_Archive_Widget', __( 'Annual Archive', 'anual-archive' ), $widget_ops ); } /** Widget */ function widget($args, $instance) { extract( $args ); $format = empty($instance['format']) ? 'html' : apply_filters('widget_format', $instance['format']); $type = empty($instance['type']) ? 'yearly' : apply_filters('widget_type', $instance['type']); $before = empty($instance['before']) ? '' : apply_filters('widget_before', $instance['before']); $after = empty($instance['after']) ? '' : apply_filters('widget_after', $instance['after']); $limit = apply_filters('widget_limit', $instance['limit']); $title = apply_filters('widget_title', empty($instance['title']) ? __('Annual Archive', 'anual-archive') : $instance['title'], $instance, $this->id_base); $count = empty($instance['count']) ? 0 : $instance['count']; $order = empty($instance['order']) ? 'DESC' : apply_filters('widget_order', $instance['order']); $alpha_order = empty($instance['alpha_order']) ? 'ASC' : apply_filters('widget_alpha_order', $instance['alpha_order']); $post_order = empty($instance['post_order']) ? 'DESC' : apply_filters('widget_post_order', $instance['post_order']); $select_text = empty($instance['select_text']) ? '' : apply_filters('widget_slelect_text', $instance['select_text']); $post_type = empty($instance['post_type']) ? 'post' : apply_filters('widget_post_type', $instance['post_type']); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; if ($format == 'option') { if($select_text){ $dtitle = $select_text; } else{ $dtitle = __('Select Year', 'anual-archive'); if ($type == 'monthly'){ $dtitle = __('Select Month', 'anual-archive'); } else if($type == 'weekly'){ $dtitle = __('Select Week', 'anual-archive'); } else if($type == 'daily'){ $dtitle = __('Select Day', 'anual-archive'); } else if($type == 'postbypost' || $type == 'alpha'){ $dtitle = __('Select Post', 'anual-archive'); } } ?>

> /> DESC /> ASC

> /> DESC /> ASC

> /> DESC /> ASC

is_archive){ $start = $decade.'-01-01'; $end = ($decade+9).'-12-31'; $query->set('year', ''); $query->set( 'date_query', array ( 'after' => $start, 'before' => $end, 'inclusive' => true, ) ); } } add_filter( 'pre_get_posts', 'annual_archive_decade_filter' ); //modify the title function annual_archive_decade_title($title) { $decade = get_query_var( 'decade' ); if(!empty($decade)){ $title = __('The').' '.$decade.'\'s'; } return $title; } add_filter( 'get_the_archive_title', 'annual_archive_decade_title'); ?>