Plugin Directory

Changeset 3434260


Ignore:
Timestamp:
01/07/2026 10:50:09 AM (2 months ago)
Author:
vzisis
Message:

Update version to 0.3.1. Add new features, pre-publish checklist warning when checklists are incomplete. Tiny activity hint in the checklist sidebar.

Location:
editorial-workflow-manager/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • editorial-workflow-manager/trunk/assets/js/sidebar.js

    r3433414 r3434260  
    11(function () {
    22  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;
    59  const { PanelBody, CheckboxControl, Notice } = wp.components;
    610  const { Fragment, createElement: el, useMemo } = wp.element;
     
    6165  };
    6266
     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
    63122  const SidebarContent = () => {
    64123    const { items, checkedItems, allDone, toggleItem } = useChecklist();
     124
     125    const { lastUpdatedText, lastUpdatedTimeText } = usePostInfo();
    65126
    66127    if (!items.length) {
     
    93154          onChange: () => toggleItem(label),
    94155        })
    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"
    100175  const ChecklistStatusInfo = () => {
    101176    const { items, total, completed, allDone } = useChecklist();
     
    125200  };
    126201
     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
    127228  const EditorialChecklistPlugin = () =>
    128229    el(
     
    143244        el(SidebarContent, null)
    144245      ),
    145       el(ChecklistStatusInfo, null)
     246      el(ChecklistStatusInfo, null),
     247      el(ChecklistPrePublishPanel, null)
    146248    );
    147249
  • editorial-workflow-manager/trunk/editorial-workflow-manager.php

    r3433414 r3434260  
    44 * Plugin Name: Editorial Workflow Manager
    55 * Description: Add editorial checklists and approvals to the WordPress editor.
    6  * Version:     0.3.0
     6 * Version:     0.3.1
    77 * Author:      Vasileios Zisis
    88 * Author URI:  https://profiles.wordpress.org/vzisis/
     
    2020{
    2121
    22     const VERSION = '0.3.0';
     22    const VERSION = '0.3.1';
    2323
    2424    private static $instance = null;
  • editorial-workflow-manager/trunk/includes/class-ediworman-editor-assets.php

    r3433414 r3434260  
    3333                'wp-components',
    3434                'wp-data',
     35                'wp-core-data',
    3536            ],
    3637            EDIWORMAN_VERSION,
  • editorial-workflow-manager/trunk/includes/class-ediworman-meta.php

    r3433414 r3434260  
    99}
    1010
    11 class EDIWORMAN_Meta
    12 {
     11if (! class_exists('EDIWORMAN')) {
    1312
    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
    3014    {
    3115
    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                            ],
    4445                        ],
    4546                    ],
    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        }
    5399    }
    54100}
  • editorial-workflow-manager/trunk/readme.txt

    r3433660 r3434260  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 0.3.0
     7Stable tag: 0.3.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3434  * Landing Page QA
    3535  * 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.
    3943* **Translation-ready** – text domain `editorial-workflow-manager` and `/languages` directory.
    4044
     
    6468   * See `Checklist: X / Y items done` when items are incomplete. 
    6569   * 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.
    6671
    6772== Frequently Asked Questions ==
     
    6974= Does this plugin block publishing if the checklist is incomplete? =
    7075
    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.
     76Not 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.
    7277
    7378= Does this plugin change anything on the front end of my site? =
     
    96101== Changelog ==
    97102
     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
    98107= 0.3.0 =
    99108* First public release.
Note: See TracChangeset for help on using the changeset viewer.