diff --git a/README.txt b/README.txt index bfc9129..f654bd3 100755 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: mark, mark posts, highlight, highlight posts, status, post status, overview, post overview, featured, custom posts, featured posts, post, posts Requires at least: 3.7 Tested up to: 3.9 -Stable tag: 1.0.7 +Stable tag: 1.0.8 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -83,6 +83,9 @@ Visit [Mark Posts on Github](https://github.com/flymke/mark-posts) == Changelog == += 1.0.8 = +* Introducing the new Dashboard Widget + = 1.0.7 = * Bugs fixed: * Update marker count if posts get deleted diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 7c323a9..e70ae0d 100755 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -1,22 +1,32 @@ /* Mark Posts Dashboard Widget Styles */ -#markers_right_now { + +h3.mark_posts_headline { + padding: 0 2% 8px 2%; +} + +.markers_right_now { overflow: hidden; - padding: 0px; - margin: 0; + padding: 0; + margin: 0 0 17px 0; } -#markers_right_now li { - width: 50%; - float: left; - margin-bottom: 10px; +.markers_right_now:last-child { + margin-bottom: 0; } -#markers_right_now li span { +.markers_right_now li { + width: 46%; + float: left; + padding: 8px 1% 0 1%; + margin: 0; +} + +.markers_right_now li a { line-height: 1.4em; font-size: 13px; } -#markers_right_now li span:before { +.markers_right_now li a:before { font: 400 20px/1 dashicons; content: '\f159'; speak: none; @@ -29,4 +39,4 @@ position: relative; -webkit-font-smoothing: antialiased; text-decoration: none !important; -} +} \ No newline at end of file diff --git a/admin/class-mark-posts-admin.php b/admin/class-mark-posts-admin.php index fd352c0..3c38b1c 100755 --- a/admin/class-mark-posts-admin.php +++ b/admin/class-mark-posts-admin.php @@ -47,6 +47,7 @@ private function __construct() { */ $plugin = Mark_Posts::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); + $get_mark_posts_setup = get_option( 'mark_posts_settings' ); // Load admin style sheet and JavaScript add_action( 'admin_enqueue_scripts', array( $this, 'mark_posts_enqueue_admin_styles' ) ); @@ -55,8 +56,15 @@ private function __construct() { // Add the options page and menu item add_action( 'admin_menu', array( $this, 'mark_posts_add_plugin_admin_menu' ) ); - // Add dashboard - add_action( 'wp_dashboard_setup', array( $this, 'mark_posts_dashboard_widget' ) ); + /** + * Add dashboard + * + * @since 1.0.8 + */ + $mark_posts_dashboard = $get_mark_posts_setup['mark_posts_dashboard']; + if ( !empty($mark_posts_dashboard) ) : + add_action( 'wp_dashboard_setup', array( $this, 'mark_posts_dashboard_widget' ) ); + endif; // Add an action link pointing to the options page $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_slug . '.php' ); @@ -76,6 +84,8 @@ private function __construct() { add_action( 'save_post', array( $this, 'mark_posts_save_quick_edit' ), 10, 2 ); // Save action for bulk edit add_action( 'wp_ajax_mark_posts_save_bulk_edit', array( $this, 'mark_posts_save_bulk_edit' ) ); + // Trash action + add_action( 'trash_post', array( $this, 'mark_posts_trash' ), 1, 1 ); // Delete action add_action( 'delete_post', array( $this, 'mark_posts_delete' ), 10 ); @@ -84,9 +94,7 @@ private function __construct() { * * @since 1.0.0 */ - $get_mark_posts_setup = get_option( 'mark_posts_settings' ); $mark_posts_posttypes = $get_mark_posts_setup['mark_posts_posttypes']; - foreach ( $mark_posts_posttypes as $post_type ) { add_filter( 'manage_' . $post_type . '_posts_columns', array( $this, 'mark_posts_column_head' ), 10, 2 ); add_action( 'manage_' . $post_type . '_posts_custom_column', array( $this, 'mark_posts_column_content' ), 10, 2 ); @@ -223,7 +231,7 @@ public function mark_posts_custom_dashboard_styles() { echo ''; @@ -350,10 +358,13 @@ public function mark_posts_save( $post_id ) { // Update taxonomy count wp_update_term_count_now(); + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); + } /** - * Update taxonomy count if posts get deleted + * Update taxonomy count if posts get permanently deleted * * @since 1.0.7 * @@ -368,9 +379,23 @@ public function mark_posts_delete ( $post_id ) { else : wp_set_object_terms( $post_id, NULL, 'marker' ); // clear/remove all marker from post with $post_id endif; + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); endif; } + /** + * Update dashboard stats if posts get trashed + * + * @since 1.0.7 + * + * @param $post_id ID of the post e.g. '1' + */ + public function mark_posts_trash ( $post_id ) { + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); + } + /** * Custom quick edit box * @@ -449,6 +474,9 @@ public function mark_posts_save_quick_edit( $post_id, $post ) { else : wp_set_object_terms( $post_id, NULL, 'marker' ); // clear/remove all marker from post with $post_id endif; + + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); endif; endforeach; } @@ -481,6 +509,9 @@ public function mark_posts_save_bulk_edit() { // update terms $term = get_term( $_POST[$mark_field], 'marker' ); wp_set_object_terms( $post_id, $term->name, 'marker' ); + + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); } } diff --git a/admin/views/admin.php b/admin/views/admin.php index d37127f..067d66e 100755 --- a/admin/views/admin.php +++ b/admin/views/admin.php @@ -21,9 +21,11 @@ * Create options * * @since 1.0.0 + * @updated 1.0.8 */ $default_marker_post_types = array( 'posts', 'pages' ); add_option( 'default_mark_posts_posttypes', $default_marker_post_types ); +add_option( 'default_mark_posts_dashboard', array( 'dashboard') ); /** * Declare default colors @@ -51,8 +53,9 @@ function mark_posts_get_marker_terms() { * Misc functions * * @since 1.0.0 + * @updated 1.0.8 */ -function mark_posts_misc_funtions() { +function mark_posts_misc_functions() { // mark all posts if ( $_SERVER["REQUEST_METHOD"] == "GET" && ISSET( $_GET['mark-all-posts-term-id'] ) ) { @@ -100,19 +103,34 @@ function mark_posts_validate_form() { if ( $_SERVER["REQUEST_METHOD"] == "POST" && isset( $_POST['submit'] ) ) { - // update marker posttypes + // get marker posttypes if ( ISSET( $_POST['markertypes'] ) ) { $markertypes = $_POST['markertypes']; } else { $markertypes = array(); } + // update post type settings $get_mark_posts_settings = get_option( 'mark_posts_settings' ); $set_mark_posts_settings = $markertypes; $get_mark_posts_settings['mark_posts_posttypes'] = $set_mark_posts_settings; update_option( 'mark_posts_settings', $get_mark_posts_settings ); + // get marker dashboard + if ( ISSET( $_POST['markerdashboard'] ) ) { + $markerdashboard = $_POST['markerdashboard']; + } else { + $markerdashboard = array(); + } + + // update dashboard settings + $get_mark_posts_settings = get_option( 'mark_posts_settings' ); + $set_mark_posts_settings = $markerdashboard; + $get_mark_posts_settings['mark_posts_dashboard'] = $set_mark_posts_settings; + + update_option( 'mark_posts_settings', $get_mark_posts_settings ); + // news markers $markers = explode( ",", $_POST['markers'] ); $count_markers = count( mark_posts_get_marker_terms() ); @@ -160,6 +178,9 @@ function mark_posts_validate_form() { echo mark_posts_display_settings_updated(); + // Clear transient dashboard stats + delete_transient( 'marker_posts_stats' ); + } } @@ -198,6 +219,20 @@ function mark_posts_get_all_types() { } } +/** + * Get dashboard widget setup + * + * @since 1.0.8 + */ +function mark_posts_dashboard() { + $option = get_option( 'mark_posts_settings' ); + echo '

' . __('Dashboard Widget', 'mark-posts') . '

'; +} + /** * Display all settings * @@ -286,15 +321,21 @@ function mark_posts_show_settings() { submit_button(); ?> +
+

+ + +
- - - + diff --git a/admin/views/dashboard.php b/admin/views/dashboard.php index 26455e4..37961b9 100755 --- a/admin/views/dashboard.php +++ b/admin/views/dashboard.php @@ -14,44 +14,81 @@ die; } - /** - * Get marker terms + * Get available markers * * @since 1.0.0 */ $marker_args = array( 'hide_empty' => true ); -$markers = get_terms( 'marker', $marker_args ); +$markers = get_terms( 'marker', $marker_args ); /** - * Get all markers but trashed + * Build marker stats for each post type * - * @since 1.0.7 + * @since 1.0.8 */ -global $wpdb; -$marker_items = ''; -if ( ! empty( $markers ) ) : - foreach ( $markers as $marker ) : - $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p JOIN $wpdb->term_relationships rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = $marker->term_id AND p.post_status = 'trash' LIMIT 1" ); - $count = $marker->count - $trashed; - if ( $count > 0 ) : - $marker_items .= '
  • ' . $count . ' ' . $marker->name . '
  • '; - endif; - endforeach; -endif; +function get_marker_stats() { + // attempt to get the stats from the transient + if ( false === ( $latest_marker_stats = get_transient( 'marker_posts_stats' ) ) ) { + $marker_args = array( + 'hide_empty' => true + ); + $markers = get_terms( 'marker', $marker_args ); + $get_mark_posts_setup = get_option( 'mark_posts_settings' ); + $mark_posts_posttypes = $get_mark_posts_setup['mark_posts_posttypes']; + $marker_stats = ''; + + foreach ( $mark_posts_posttypes as $mark_posts_posttype ) : + + $marked_posts = ''; + + foreach ( $markers as $marker ) : + $post_args = array( + 'post_type' => $mark_posts_posttype, + 'taxonomy' => $marker->taxonomy, + 'term' => $marker->slug, + 'post_status' => 'publish', + 'posts_per_page' => - 1, + ); + $posts = get_posts( $post_args ); + $posts_count = count( $posts ); + + if ( ! empty( $posts_count ) ) : + $marked_posts .= '
  • '; + $marked_posts .= '' . $posts_count . ' ' . $marker->name . ''; + $marked_posts .= '
  • '; + endif; -?> + endforeach; // end of marker loop -
    - -
    + } else { + return get_transient( 'marker_posts_stats' ); + } +} + +if ( ! empty( $markers ) ) : + echo get_marker_stats(); +else : + _e( 'No marked posts yet.', 'mark-posts' ); +endif; \ No newline at end of file diff --git a/languages/mark-posts-de_DE.mo b/languages/mark-posts-de_DE.mo index 3552600..c55de2c 100644 Binary files a/languages/mark-posts-de_DE.mo and b/languages/mark-posts-de_DE.mo differ diff --git a/languages/mark-posts-de_DE.po b/languages/mark-posts-de_DE.po index bdaecf0..734d91e 100644 --- a/languages/mark-posts-de_DE.po +++ b/languages/mark-posts-de_DE.po @@ -2,31 +2,31 @@ msgid "" msgstr "" "Project-Id-Version: Mark Posts 1.0.0\n" "Report-Msgid-Bugs-To: https://github.com/flymke/mark-posts\n" -"POT-Creation-Date: 2014-04-11 11:18+0100\n" -"PO-Revision-Date: 2014-04-11 11:19+0100\n" +"POT-Creation-Date: 2014-05-25 23:28+0100\n" +"PO-Revision-Date: 2014-05-25 23:28+0100\n" "Last-Translator: Sven Hofmann \n" "Language-Team: \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.6.4\n" +"X-Generator: Poedit 1.6.5\n" "X-Poedit-KeywordsList: __;_e;_n;_x\n" "X-Poedit-Basepath: ../\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-SearchPath-0: .\n" -#: admin/class-mark-posts-admin.php:163 admin/class-mark-posts-admin.php:164 +#: admin/class-mark-posts-admin.php:167 admin/class-mark-posts-admin.php:168 msgid "Mark Posts" msgstr "Mark Posts" -#: admin/class-mark-posts-admin.php:247 +#: admin/class-mark-posts-admin.php:251 msgid "Settings" msgstr "Einstellungen" -#: admin/class-mark-posts-admin.php:268 admin/views/admin.php:301 -#: public/class-mark-posts.php:274 +#: admin/class-mark-posts-admin.php:272 admin/views/admin.php:339 +#: public/class-mark-posts.php:258 msgid "Mark Posts Options" msgstr "Mark Posts Optionen" @@ -34,30 +34,34 @@ msgstr "Mark Posts Optionen" msgid "Mark this post as:" msgstr "Diesen Beitrag markieren als:" -#: admin/class-mark-posts-admin.php:315 +#: admin/class-mark-posts-admin.php:301 #, php-format msgid "Click here to manage Marker categories." msgstr "Hier klicken um Marker Kategorien zu verwalten." -#: admin/class-mark-posts-admin.php:396 admin/class-mark-posts-admin.php:522 -#: public/class-mark-posts.php:301 public/class-mark-posts.php:302 -#: public/class-mark-posts.php:311 +#: admin/class-mark-posts-admin.php:396 admin/class-mark-posts-admin.php:519 +#: public/class-mark-posts.php:285 public/class-mark-posts.php:286 +#: public/class-mark-posts.php:295 msgid "Marker" msgstr "Marker" -#: admin/views/admin.php:173 +#: admin/views/admin.php:191 msgid "Settings saved" msgstr "Einstellungen gespeichert." -#: admin/views/admin.php:226 +#: admin/views/admin.php:230 +msgid "Dashboard Widget" +msgstr "Dashboard Widget" + +#: admin/views/admin.php:258 msgid "Markers" msgstr "Marker" -#: admin/views/admin.php:246 +#: admin/views/admin.php:278 msgid "delete" msgstr "löschen" -#: admin/views/admin.php:247 +#: admin/views/admin.php:279 msgid "" "Do you really want to mark all posts with this marker? Note: This will " "override all your previous set markers. This will only effect the enabled " @@ -67,63 +71,67 @@ msgstr "" "bestehenden Marker werden dadurch überschrieben. Dies betrifft nur die " "aktivierten Post Types." -#: admin/views/admin.php:247 +#: admin/views/admin.php:279 msgid "Mark all posts with this marker" msgstr "Alle Beiträge mit diesem Marker markieren" -#: admin/views/admin.php:262 +#: admin/views/admin.php:294 msgid "Add new Markers" msgstr "Neue Marker hinzufügen" -#: admin/views/admin.php:265 +#: admin/views/admin.php:297 msgid "Add new marker (please separate them by comma):" msgstr "Neue Marker hinzufügen (bitte mit Komma trennen):" -#: admin/views/admin.php:271 +#: admin/views/admin.php:303 msgid "Markers to add:" msgstr "Marker erstellen:" -#: admin/views/admin.php:278 +#: admin/views/admin.php:310 msgid "Enable/Disable Markers" msgstr "Marker aktivieren/deaktivieren" -#: admin/views/admin.php:281 +#: admin/views/admin.php:313 msgid "Enable/Disable markers for specific post types:" msgstr "Marker für bestimmte Beitragstypen aktivieren:" -#: admin/views/dashboard.php:38 +#: admin/views/admin.php:322 +msgid "Enable/Disable Dashboard Widget" +msgstr "Dashboard Widget aktivieren/deaktivieren" + +#: admin/views/dashboard.php:75 admin/views/dashboard.php:79 msgid "No marked posts yet." msgstr "Keine markierten Beiträge vorhanden." -#: public/class-mark-posts.php:303 +#: public/class-mark-posts.php:287 msgid "Search Marker" msgstr "Marker suchen" -#: public/class-mark-posts.php:304 +#: public/class-mark-posts.php:288 msgid "All Markers" msgstr "Alle Marker" -#: public/class-mark-posts.php:305 +#: public/class-mark-posts.php:289 msgid "Parent Marker" msgstr "Eltern Marker" -#: public/class-mark-posts.php:306 +#: public/class-mark-posts.php:290 msgid "Parent Marker:" msgstr "Eltern Marker:" -#: public/class-mark-posts.php:307 +#: public/class-mark-posts.php:291 msgid "Edit Marker" msgstr "Marker bearbeiten" -#: public/class-mark-posts.php:308 +#: public/class-mark-posts.php:292 msgid "Update Marker" msgstr "Marker aktualisieren" -#: public/class-mark-posts.php:309 +#: public/class-mark-posts.php:293 msgid "Add New Marker" msgstr "Neuen Marker hinzufügen" -#: public/class-mark-posts.php:310 +#: public/class-mark-posts.php:294 msgid "New Marker Name" msgstr "Neuer Marker Name" diff --git a/mark-posts.php b/mark-posts.php index 49fd803..d74d8ab 100755 --- a/mark-posts.php +++ b/mark-posts.php @@ -12,7 +12,7 @@ * Plugin Name: Mark Posts * Plugin URI: http://flymke.github.io/mark-posts/ * Description: Simply mark and highlight posts, pages and posts of custom post types within the posts view overview. - * Version: 1.0.7 + * Version: 1.0.8 * Author: Michael Schoenrock, Sven Hofmann * Author URI: http://www.aliquit.de * Contributor: Sven Hofmann @@ -38,7 +38,7 @@ * */ if ( ! defined( 'WP_MARK_POSTS_VERSION' ) ) { - define( 'WP_MARK_POSTS_VERSION', '1.0.7' ); + define( 'WP_MARK_POSTS_VERSION', '1.0.8' ); } /*