%POST_THUMBNAIL|50x50%
%DATE% by %AUTHOR%
Filed as: %CATEGORIES|, % '); define( 'PA_TEMPLATE_BEFORE_DEFAULT', ' ' ); define( 'PA_TEMPLATE_AFTER_DEFAULT', '
Thumb Title
' ); define( 'PA_THUMB_DEFAULT', '' ); if ( ! class_exists( 'archivist' ) ) { if ( function_exists( 'add_action' ) && function_exists( 'register_activation_hook' ) ) { add_action( 'plugins_loaded', array( 'archivist', 'get_object' ) ); register_activation_hook( __FILE__, array( 'archivist', 'activation_hook' ) ); } class archivist { static private $classobj = NULL; public $textdomain = 'archivist'; public function __construct() { $this->load_textdomain(); add_shortcode( 'archivist', array( $this, 'shortcode' ) ); add_action( 'admin_menu', array( $this, 'add_menu_entry' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); } public function shortcode( $atts ) { extract( shortcode_atts( array( 'query' => '', 'category' => '', 'tag' => '', ), $atts ) ); if ( $query !== '' ) { return $this->display_by_query( $query ); } elseif ( $category !== '' ) { return $this->display_by_category( $category ); } else { return $this->display_by_tag( $tag ); } } public function register_settings() { register_setting( 'archivist-option-group', 'archivist_css' ); register_setting( 'archivist-option-group', 'archivist_template' ); register_setting( 'archivist-option-group', 'archivist_default_thumb' ); register_setting( 'archivist-option-group', 'archivist_template_after' ); register_setting( 'archivist-option-group', 'archivist_template_before' ); } public function add_menu_entry() { add_submenu_page( 'options-general.php', 'Archivist', 'Archivist', 'edit_post', 'archivist_options_handle', array( $this, 'settings_page' ) ); } function render_element( $post, $template ) { $template = str_replace( '%DATE%', get_the_date(), $template ); $template = str_replace( '%TITLE%', get_the_title(), $template ); $template = str_replace( '%AUTHOR%', get_the_author(), $template ); $template = str_replace( '%TAGS%', get_the_tag_list(), $template ); $template = str_replace( '%PERMALINK%', get_permalink(), $template ); $template = str_replace( '%EXCERPT%', get_the_excerpt(), $template ); $template = str_replace( '%COMMENTS%', get_comments_number(), $template ); $template = str_replace( '%CATEGORIES%', get_the_category_list(), $template ); // categories with custom separator $template = preg_replace_callback( '/%TAGS\|(.*)%/', create_function( '$matches', 'return get_the_tag_list( "", $matches[1], "" );' ), $template ); // categories with custom separator $template = preg_replace_callback( '/%CATEGORIES\|(.*)%/', create_function( '$matches', 'return get_the_category_list( $matches[1] );' ), $template ); // custom post meta $template = preg_replace_callback( '/%POST_META\|(.*)%/', create_function( '$matches', 'global $post; return get_post_meta( $post->ID, "$matches[1]", true );' ), $template ); // custom date format $template = preg_replace_callback( '/%DATE\|(.*)%/', create_function( '$matches', 'return get_the_date($matches[1]);' ), $template ); // custom post thumbnails $template = preg_replace_callback( '/%POST_THUMBNAIL\|(\d+)x(\d+)%/', create_function( '$matches', ' $thumb = get_the_post_thumbnail( $post->ID, array( $matches[ 1 ], $matches[ 2 ] ) ); if ( ! $thumb ) { $default_thumb = get_option( "archivist_default_thumb", PA_THUMB_DEFAULT ); if ( $default_thumb ) { $thumb = "\"Archive"; } } return $thumb;' ), $template ); return $template; } public function display_by_category( $category ) { $parameters = array( 'posts_per_page' => -1, 'category_name' => $category ); $loop = new WP_Query( $parameters ); return $this->display_by_loop( $loop ); } public function display_by_tag( $tag ) { $parameters = array( 'posts_per_page' => -1, 'tag' => $tag ); $loop = new WP_Query( $parameters ); return $this->display_by_loop( $loop ); } public function display_by_query( $query ) { $loop = new WP_Query( $query ); return $this->display_by_loop( $loop ); } private function display_by_loop( $loop ) { $css = get_option( 'archivist_css', PA_CSS_DEFAULT ); $template = get_option( 'archivist_template', PA_TEMPLATE_DEFAULT ); $template_after = get_option( 'archivist_template_after', PA_TEMPLATE_AFTER_DEFAULT ); $template_before = get_option( 'archivist_template_before', PA_TEMPLATE_BEFORE_DEFAULT ); ob_start(); ?>
have_posts() ) : ?> the_post(); ?> render_element( $post, $template ); ?>
textdomain; } public function load_textdomain() { $plugin_dir = basename(dirname(__FILE__)); load_plugin_textdomain( $this->get_textdomain(), FALSE, $plugin_dir . '/languages' ); } private function get_plugin_data( $value = 'Version' ) { $plugin_data = get_plugin_data( __FILE__ ); return $plugin_data[ $value ]; } static public function activation_hook() { global $wp_version; // Load Text-Domain $obj = archivist::get_object(); $obj->load_textdomain(); // check wp version if ( ! version_compare( $wp_version, '3.0', '>=' ) ) { deactivate_plugins( __FILE__ ); wp_die( wp_sprintf( '%s: ' . __( 'Sorry, This plugin requires WordPress 3.0+', $obj->get_textdomain() ), self::get_plugin_data( 'Name' ) ) ); } // check php version if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) { deactivate_plugins( __FILE__ ); // Deactivate ourself wp_die( wp_sprintf( '%1s: ' . __( 'Sorry, This plugin has taken a bold step in requiring PHP 5.3.0+, Your server is currently running PHP %2s, Please bug your host to upgrade to a recent version of PHP which is less bug-prone. At last count, <strong>over 80%% of WordPress installs are using PHP 5.2+</strong>.', $obj->get_textdomain() ), self::get_plugin_data( 'Name' ), PHP_VERSION ) ); } } function settings_page() { $css = get_option( 'archivist_css', PA_CSS_DEFAULT ); $template = get_option( 'archivist_template', PA_TEMPLATE_DEFAULT ); $default_thumb = get_option( 'archivist_default_thumb', PA_THUMB_DEFAULT ); $template_after = get_option( 'archivist_template_after', PA_TEMPLATE_AFTER_DEFAULT ); $template_before = get_option( 'archivist_template_before', PA_TEMPLATE_BEFORE_DEFAULT ); ?>

If you like it, consider to flattr me a beer.', archivist::get_textdomain() ); ?>

Homepage, follow me on Twitter or look at my projects on GitHub.', archivist::get_textdomain() ), 'http://www.FarBeyondProgramming.com/', 'http://www.twitter.com/ericteubert', 'https://github.com/eteubert' ) ?>

%TITLE%



%PERMALINK%



%AUTHOR%



%CATEGORIES%



%CATEGORIES|...%

%CATEGORIES|, %', archivist::get_textdomain() ) ?>

%TAGS%



%TAGS|...%

%TAGS|, %', archivist::get_textdomain() ) ?>

%EXCERPT%



%POST_META|...%

%POST_META|duration%', archivist::get_textdomain() ) ?>

%DATE%



%DATE|...%

%DATE|Y/m/d%', archivist::get_textdomain() ) ?>

%POST_THUMBNAIL|...x...%

%POST_THUMBNAIL|75x75%', archivist::get_textdomain() ) ?>

%COMMENTS%


%POST_THUMBNAIL|...x...% placeholder and the post has no thumbnail, then this image will be used.', archivist::get_textdomain() ) ?>