diff --git a/.gitignore b/.gitignore index 6fe2590..e989f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,25 @@ +### OSX ### .DS_Store .DS_Store? +.AppleDouble +.LSOverride + +# Thumbnails ._* -.Spotlight-V100 -.Trashes -Icon? ehthumbs.db Thumbs.db + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Icon must end with two \r. +Icon + + +### Komodo IDE ### *.komodotools *.komodoproject + +### PhpStorm IDE ### *.idea \ No newline at end of file diff --git a/README.txt b/README.txt index 24b673b..8f03f31 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.3 +Stable tag: 1.0.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -16,7 +16,7 @@ Mark Posts plugin provides an easy way to mark and highlight posts, pages and po = Features = -* Set up maker categories and colors +* Set up marker categories and colors * Assign marker categories to posts/pages/cpt * View them within the posts/pages/cpt overview lists * Quick edit, bulk edit and edit all markers @@ -56,6 +56,14 @@ If you find an issue, please [raise an issue](https://github.com/flymke/mark-pos == Frequently Asked Questions == += Can I set specific user roles for specific markers? = + +Check the [Custom Marker Limits](https://github.com/flymke/mark-posts/wiki/Custom-Marker-Limits) wiki page for further information + += Can I export/import markers? = + +Check the [Export & Import](https://github.com/flymke/mark-posts/wiki/Export-&-Import) wiki page for further information + = I'm having issues getting the plugin to work what should I do? = See [Mark Posts on Github](https://github.com/flymke/mark-posts) for detailed rundown of common issues @@ -75,6 +83,10 @@ Visit [Mark Posts on Github](https://github.com/flymke/mark-posts) == Changelog == += 1.0.4 = +* Add `mark_posts_marker_limit` filter for custom marker user roles +* Provide custom color palettes for markers + = 1.0.3 = * Code refactoring diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css index cfc059b..06e938c 100755 --- a/admin/assets/css/admin.css +++ b/admin/assets/css/admin.css @@ -1,66 +1,75 @@ -/* This stylesheet is used to style the admin option form of the plugin. */ - +/* Mark Posts Admin Styles */ .new-markers { - height: 20px; + height: 20px; padding: 10px 0 5px 0; } + .new-markers .js-new-markers-intro { display: none; } + .new-marker, .mark-posts-marker { - background: rgba(255,255,255); /* for IE */ - background: rgba(255,255,255,.65); - color: #444; - line-height: 27px; /* in case of multiple lines for markers*/ - padding: 0 5px; - margin: 0 0 0 3px; + background: rgba(255, 255, 255); /* for IE */ + background: rgba(255, 255, 255, .65); + color: #444; + line-height: 27px; /* in case of multiple lines for markers*/ + padding: 0 5px; + margin: 0 0 0 3px; -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - display: inline-block; - font-weight:bold; + -moz-border-radius: 3px; + border-radius: 3px; + display: inline-block; + font-weight: bold; } + .mark-posts-marker { - margin-top:6px; + margin-top: 6px; } + span.mark-posts-color { - position:absolute; - top:-41px; - right:30px; - width:20px; - height:20px; - display:block; - margin-left:10px; + position: absolute; + top: -41px; + right: 30px; + width: 20px; + height: 20px; + display: block; + margin-left: 10px; } + span.mark-posts-color, #mark_posts_options h3.hndle { - -webkit-transition: 100ms linear; /* Chrome 1-25, Safari 3.2+ */ - -moz-transition: 100ms linear; /* Firefox 4-15 */ - -o-transition: 100ms linear; /* Opera 10.50–12.00 */ - transition: 100ms linear; /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */ + -webkit-transition: 100ms linear; /* Chrome 1-25, Safari 3.2+ */ + -moz-transition: 100ms linear; /* Firefox 4-15 */ + -o-transition: 100ms linear; /* Opera 10.50–12.00 */ + transition: 100ms linear; /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */ } + .mark_posts_pre { - position:absolute; - width:5px; - height:100%; - top:0; - left:0; + position: absolute; + width: 5px; + height: 100%; + top: 0; + left: 0; } + a.mark-posts-initial { - display:inline-block; - margin-left:25px; + display: inline-block; + margin-left: 25px; } + .mark-posts-copy { - margin-top:25px; - padding-top:25px; + margin-top: 25px; + padding-top: 25px; } + #wpbody-content .quick-edit-row-page .inline-edit-col-right.mark-posts-quickedit { - margin-top:0; - width:50%; - float:right; + margin-top: 0; + width: 50%; + float: right; } + .mark-posts-donate { - margin-top:15px; + margin-top: 15px; } \ No newline at end of file diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 04aa988..7c323a9 100755 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -1,29 +1,32 @@ -/* dashboard widget styles */ +/* Mark Posts Dashboard Widget Styles */ #markers_right_now { - overflow: hidden; - padding: 0px; - margin: 0; + overflow: hidden; + padding: 0px; + margin: 0; } + #markers_right_now li { - width: 50%; - float: left; - margin-bottom: 10px; + width: 50%; + float: left; + margin-bottom: 10px; } + #markers_right_now li span { - line-height: 1.4em; - font-size: 13px; + line-height: 1.4em; + font-size: 13px; } + #markers_right_now li span:before { - font: 400 20px/1 dashicons; - content: '\f159'; - speak: none; - display: block; - float: left; - margin: 0 5px 0 0; - padding: 0; - text-indent: 0; - text-align: center; - position: relative; - -webkit-font-smoothing: antialiased; - text-decoration: none!important; + font: 400 20px/1 dashicons; + content: '\f159'; + speak: none; + display: block; + float: left; + margin: 0 5px 0 0; + padding: 0; + text-indent: 0; + text-align: center; + position: relative; + -webkit-font-smoothing: antialiased; + text-decoration: none !important; } diff --git a/admin/assets/js/markposts.js b/admin/assets/js/markposts.js index dd3cb18..1533587 100755 --- a/admin/assets/js/markposts.js +++ b/admin/assets/js/markposts.js @@ -4,7 +4,8 @@ // color picket setup $(function () { $('.my-color-field').wpColorPicker({ - defaultColor: false + defaultColor: false, + palettes: ['#96D754', '#FFFA74', '#FF7150', '#9ABADC', '#FFA74C', '#158A61'] }); }); @@ -56,6 +57,7 @@ var color = $('select#mark_posts_term_id option:selected').data('color'); if (color) $('#mark_posts_options h3.hndle').css('background-color', convertHex(color,25)); + $('span.mark-posts-color').css('background-color', color); $('select#mark_posts_term_id').on('change', function() { var color = $('select#mark_posts_term_id option:selected').data('color'); $('#mark_posts_options h3.hndle').css('background-color', convertHex(color,25)); diff --git a/admin/class-mark-posts-admin.php b/admin/class-mark-posts-admin.php index 002dde9..1e7e774 100755 --- a/admin/class-mark-posts-admin.php +++ b/admin/class-mark-posts-admin.php @@ -276,38 +276,19 @@ public function mark_posts_add_meta_box() { */ public function mark_posts_inner_meta_box( $post ) { - // Add an nonce field so we can check for it later. + // Add an nonce field so we can check for it later wp_nonce_field( 'mark_posts_inner_meta_box', 'mark_posts_inner_meta_box_nonce' ); - // Use get_post_meta to retrieve an existing value from the database. - $value = get_post_meta( $post->ID, 'mark_posts_term_id', true ); - - // Display the form, using the current value. - $content = '

' . __( 'Mark this post as:', 'mark-posts' ) . '

'; - - // Get Marker terms from DB - $markers_terms = get_terms( 'marker', 'hide_empty=0' ); - $content .= ''; + echo '

' . __( 'Mark this post as:', 'mark-posts' ) . '

'; - if ( ISSET( $color_selected ) ) { - $content .= ''; - } else { - $content .= ''; - } + // Get available markers as select dropdown + $markers = new Mark_Posts_Marker(); + echo $markers->mark_posts_select( $post->ID ); - $content .= '

' . sprintf( __( 'Click here to manage Marker categories.', 'mark-posts' ), esc_url( 'options-general.php?page=mark-posts' ) ) . '

'; + echo ''; + + echo '

' . sprintf( __( 'Click here to manage Marker categories.', 'mark-posts' ), esc_url( 'options-general.php?page=mark-posts' ) ) . '

'; - echo $content; } /** @@ -376,6 +357,7 @@ public function mark_posts_save( $post_id ) { * @since 1.0.0 * * @param $column_name Custom column name e.g. 'mark_posts_term_id' + * @param $post_id */ public function mark_posts_display_quickedit_box( $column_name ) { @@ -388,14 +370,11 @@ public function mark_posts_display_quickedit_box( $column_name ) { diff --git a/admin/class-mark-posts-marker.php b/admin/class-mark-posts-marker.php new file mode 100755 index 0000000..36f5b48 --- /dev/null +++ b/admin/class-mark-posts-marker.php @@ -0,0 +1,78 @@ +, Sven Hofmann + * @license GPL-2.0+ + * @copyright 2014 Michael Schoenrock + */ + + +// If this file is called directly, abort. +if ( ! defined( 'WPINC' ) ) { + die; +} + + +class Mark_Posts_Marker { + + /** + * Build select dropdown with all available markers for the current user + * + * @since 1.0.4 + * + * @param $post_id + * + * @return string select with available markers as option + */ + public function mark_posts_select( $post_id = NULL ) { + + // Retrieve post meta value from the database + if ( isset( $post_id ) ) : + $value = get_post_meta( $post_id, 'mark_posts_term_id', true ); + endif; + + // Get marker terms + $markers_terms = get_terms( 'marker', 'hide_empty=0' ); + + /** + * Filter: 'mark_posts_marker_limit' - Allow custom user capabilities for marker terms + * + * @since 1.0.4 + * + * @param array $limited Array with marker term names and appropriate user capability + */ + $limited = array(); + $limited = apply_filters( 'mark_posts_marker_limit', $limited ); + + // Build select + $select = ''; + + return $select; + + } + +} \ No newline at end of file diff --git a/mark-posts.php b/mark-posts.php index fc6463f..4f9cc2e 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.3 + * Version: 1.0.4 * 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.3' ); + define( 'WP_MARK_POSTS_VERSION', '1.0.4' ); } /* @@ -75,6 +75,7 @@ if ( is_admin() ) { + require_once( plugin_dir_path( __FILE__ ) . 'admin/class-mark-posts-marker.php' ); require_once( plugin_dir_path( __FILE__ ) . 'admin/class-mark-posts-admin.php' ); add_action( 'plugins_loaded', array( 'Mark_Posts_Admin', 'get_instance' ) ); diff --git a/readme.md b/readme.md index 0700879..9bfb796 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ Mark Posts plugin provides an easy way to mark and highlight posts, pages and po ### Features -* Set up maker categories and colors +* Set up marker categories and colors * Assign marker categories to posts/pages/cpt * View them within the posts/pages/cpt overview lists * Quick edit, bulk edit and edit all markers @@ -33,6 +33,13 @@ Mark Posts plugin provides an easy way to mark and highlight posts, pages and po *** +### Wiki + +* [Custom Marker Limits](https://github.com/flymke/mark-posts/wiki/Custom-Marker-Limits) +* [Export & Import Markers](https://github.com/flymke/mark-posts/wiki/Export-&-Import) + +*** + ### Support -If you find an issue, please [raise an issue](https://github.com/flymke/mark-posts/issues/new) on GitHub. \ No newline at end of file +If you find an issue, please [raise an issue](https://github.com/flymke/mark-posts/issues/new) on GitHub.