Changeset 3434260
- Timestamp:
- 01/07/2026 10:50:09 AM (2 months ago)
- Location:
- editorial-workflow-manager/trunk
- Files:
-
- 5 edited
-
assets/js/sidebar.js (modified) (5 diffs)
-
editorial-workflow-manager.php (modified) (2 diffs)
-
includes/class-ediworman-editor-assets.php (modified) (1 diff)
-
includes/class-ediworman-meta.php (modified) (1 diff)
-
readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
editorial-workflow-manager/trunk/assets/js/sidebar.js
r3433414 r3434260 1 1 (function () { 2 2 const { registerPlugin } = wp.plugins; 3 const { PluginSidebar, PluginSidebarMoreMenuItem, PluginPostStatusInfo } = 4 wp.editor; 3 const { 4 PluginSidebar, 5 PluginSidebarMoreMenuItem, 6 PluginPostStatusInfo, 7 PluginPrePublishPanel, 8 } = wp.editor; 5 9 const { PanelBody, CheckboxControl, Notice } = wp.components; 6 10 const { Fragment, createElement: el, useMemo } = wp.element; … … 61 65 }; 62 66 67 const usePostInfo = () => { 68 const meta = useSelect( 69 (select) => select('core/editor').getEditedPostAttribute('meta') || {}, 70 [] 71 ); 72 73 let lastEditorId = null; 74 75 if ( 76 meta._ediworman_last_editor !== undefined && 77 meta._ediworman_last_editor !== null 78 ) { 79 const parsed = parseInt(meta._ediworman_last_editor, 10); 80 if (!Number.isNaN(parsed) && parsed > 0) { 81 lastEditorId = parsed; 82 } 83 } 84 85 const post = useSelect( 86 (select) => select('core/editor').getCurrentPost(), 87 [] 88 ); 89 90 const fallbackAuthorId = post && post.author ? post.author : null; 91 const userIdToShow = lastEditorId || fallbackAuthorId; 92 93 const user = useSelect( 94 (select) => { 95 if (!userIdToShow) { 96 return null; 97 } 98 return select('core').getUser(userIdToShow); 99 }, 100 [userIdToShow] 101 ); 102 103 // Build the "when" part from post.modified 104 let lastUpdatedTimeText = null; 105 if (post && post.modified) { 106 const d = new Date(post.modified); 107 if (!Number.isNaN(d.getTime())) { 108 lastUpdatedTimeText = d.toLocaleString(); 109 } 110 } 111 112 if (!user || !user.name) { 113 return { lastUpdatedText: null, lastUpdatedTimeText: null }; 114 } 115 116 return { 117 lastUpdatedText: `Last updated by ${user.name}`, 118 lastUpdatedTimeText, 119 }; 120 }; 121 63 122 const SidebarContent = () => { 64 123 const { items, checkedItems, allDone, toggleItem } = useChecklist(); 124 125 const { lastUpdatedText, lastUpdatedTimeText } = usePostInfo(); 65 126 66 127 if (!items.length) { … … 93 154 onChange: () => toggleItem(label), 94 155 }) 95 ) 96 ); 97 }; 98 99 // This adds a little info line inside "Status & visibility" 156 ), 157 lastUpdatedText && 158 el( 159 'p', 160 { 161 style: { 162 marginTop: '12px', 163 fontSize: '12px', 164 opacity: 0.7, 165 }, 166 }, 167 lastUpdatedTimeText 168 ? `${lastUpdatedText} on ${lastUpdatedTimeText}` 169 : lastUpdatedText 170 ) 171 ); 172 }; 173 174 // Status line in "Status & visibility" 100 175 const ChecklistStatusInfo = () => { 101 176 const { items, total, completed, allDone } = useChecklist(); … … 125 200 }; 126 201 202 // Non-blocking notice in the pre-publish panel 203 const ChecklistPrePublishPanel = () => { 204 const { items, total, completed, allDone } = useChecklist(); 205 206 // Only show when there is a template and the checklist is incomplete. 207 if (!items.length || allDone) { 208 return null; 209 } 210 211 return el( 212 PluginPrePublishPanel, 213 { 214 title: 'Editorial Checklist', 215 initialOpen: true, 216 }, 217 el( 218 Notice, 219 { 220 status: 'warning', 221 isDismissible: false, 222 }, 223 `Checklist incomplete: ${completed} / ${total} items done. You can still publish, but consider reviewing the checklist first.` 224 ) 225 ); 226 }; 227 127 228 const EditorialChecklistPlugin = () => 128 229 el( … … 143 244 el(SidebarContent, null) 144 245 ), 145 el(ChecklistStatusInfo, null) 246 el(ChecklistStatusInfo, null), 247 el(ChecklistPrePublishPanel, null) 146 248 ); 147 249 -
editorial-workflow-manager/trunk/editorial-workflow-manager.php
r3433414 r3434260 4 4 * Plugin Name: Editorial Workflow Manager 5 5 * Description: Add editorial checklists and approvals to the WordPress editor. 6 * Version: 0.3. 06 * Version: 0.3.1 7 7 * Author: Vasileios Zisis 8 8 * Author URI: https://profiles.wordpress.org/vzisis/ … … 20 20 { 21 21 22 const VERSION = '0.3. 0';22 const VERSION = '0.3.1'; 23 23 24 24 private static $instance = null; -
editorial-workflow-manager/trunk/includes/class-ediworman-editor-assets.php
r3433414 r3434260 33 33 'wp-components', 34 34 'wp-data', 35 'wp-core-data', 35 36 ], 36 37 EDIWORMAN_VERSION, -
editorial-workflow-manager/trunk/includes/class-ediworman-meta.php
r3433414 r3434260 9 9 } 10 10 11 class EDIWORMAN_Meta 12 { 11 if (! class_exists('EDIWORMAN')) { 13 12 14 public function __construct() 15 { 16 add_action('init', [$this, 'register_meta']); 17 } 18 19 /** 20 * Register post meta used to store checked checklist items. 21 * 22 * We keep it simple: 23 * - meta key: _ediworman_checked_items 24 * - value: array of strings (the checklist item labels that are checked) 25 * 26 * This meta is exposed in the REST API so the Gutenberg editor sidebar 27 * can read/write it. 28 */ 29 public function register_meta() 13 class EDIWORMAN_Meta 30 14 { 31 15 32 register_post_meta( 33 '', // empty string => applies to all post types. 34 '_ediworman_checked_items', 35 [ 36 'single' => true, 37 'type' => 'array', 38 'default' => [], 39 'show_in_rest' => [ 40 'schema' => [ 41 'type' => 'array', 42 'items' => [ 43 'type' => 'string', 16 public function __construct() 17 { 18 add_action('init', [$this, 'register_meta']); 19 add_action('save_post', [$this, 'capture_last_editor'], 10, 3); 20 } 21 22 /** 23 * Register post meta used by the plugin. 24 * 25 * - _ediworman_checked_items: array of checklist item labels that are checked. 26 * - _ediworman_last_editor: user ID of the last editor (for display only). 27 */ 28 public function register_meta() 29 { 30 31 // Checklist state. 32 register_post_meta( 33 '', 34 '_ediworman_checked_items', 35 [ 36 'single' => true, 37 'type' => 'array', 38 'default' => [], 39 'show_in_rest' => [ 40 'schema' => [ 41 'type' => 'array', 42 'items' => [ 43 'type' => 'string', 44 ], 44 45 ], 45 46 ], 46 ], 47 'auth_callback' => function () { 48 // Only users who can edit posts should be able to modify this. 49 return current_user_can('edit_posts'); 50 }, 51 ] 52 ); 47 'auth_callback' => function () { 48 return current_user_can('edit_posts'); 49 }, 50 ] 51 ); 52 53 // Last editor (user ID). 54 register_post_meta( 55 '', 56 '_ediworman_last_editor', 57 [ 58 'single' => true, 59 'type' => 'integer', 60 'default' => 0, 61 'show_in_rest' => true, 62 'auth_callback' => function () { 63 return current_user_can('edit_posts'); 64 }, 65 ] 66 ); 67 } 68 69 /** 70 * Store the last editor's user ID when a post is saved. 71 * 72 * @param int $post_id 73 * @param WP_Post $post 74 * @param bool $update 75 */ 76 public function capture_last_editor($post_id, $post, $update) 77 { 78 // Don't run on autosave / revisions. 79 if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) { 80 return; 81 } 82 83 // Only for real posts/pages/etc (not our template CPT if you prefer to exclude). 84 // If you want to skip templates, uncomment: 85 // if ( $post->post_type === 'ediworman_template' ) { 86 // return; 87 // } 88 89 // Permission check. 90 if (! current_user_can('edit_post', $post_id)) { 91 return; 92 } 93 94 $user_id = get_current_user_id(); 95 if ($user_id) { 96 update_post_meta($post_id, '_ediworman_last_editor', (int) $user_id); 97 } 98 } 53 99 } 54 100 } -
editorial-workflow-manager/trunk/readme.txt
r3433660 r3434260 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 0.3. 07 Stable tag: 0.3.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 34 34 * Landing Page QA 35 35 * Announcement / News Post 36 * **Soft status notice** – in “Status & visibility”: 37 * `Checklist: X / Y items done` while items are incomplete. 38 * `Checklist complete.` once everything is ticked. 36 * **Soft status notice and pre-publish warning** – 37 * In “Status & visibility”: 38 * `Checklist: X / Y items done` while items are incomplete. 39 * `Checklist complete.` once everything is ticked. 40 * In the pre-publish panel: 41 * Non-blocking warning if the checklist is incomplete when you click Publish. 42 * **Tiny activity hint** – the checklist sidebar shows “Last updated by X on [date/time]”, based on the last saved edit. 39 43 * **Translation-ready** – text domain `editorial-workflow-manager` and `/languages` directory. 40 44 … … 64 68 * See `Checklist: X / Y items done` when items are incomplete. 65 69 * See `Checklist complete.` when all items are ticked. 70 * The checklist sidebar shows “Last updated by X on date/time”, based on the last saved edit. 66 71 67 72 == Frequently Asked Questions == … … 69 74 = Does this plugin block publishing if the checklist is incomplete? = 70 75 71 Not in the free version. The free version only shows a **soft warning** (status text) and the checklist in the sidebar. Hard publish blocking and approval workflows are planned for the Pro version.76 Not in the free version. The free version shows a **soft warning** in the editor: a status line and a **non-blocking pre-publish notice** if the checklist is incomplete. You can still publish. Hard publish blocking and approval workflows are planned for the Pro version. 72 77 73 78 = Does this plugin change anything on the front end of my site? = … … 96 101 == Changelog == 97 102 103 = 0.3.1 = 104 * Added non-blocking pre-publish checklist warning when checklists are incomplete. 105 * Added tiny activity hint in the checklist sidebar (“Last updated by X on date/time”). 106 98 107 = 0.3.0 = 99 108 * First public release.
Note: See TracChangeset
for help on using the changeset viewer.