From d10a669c195abde9cd9bc97ba3f0d17d9029d7ec Mon Sep 17 00:00:00 2001 From: ingeniumed Date: Wed, 3 Jul 2024 15:32:39 +1000 Subject: [PATCH] Finish off the rest of the code --- common/php/class-module.php | 26 +- dist/custom-status.build.js | 2 +- dist/custom-status.editor.build.css | 2 +- dist/custom-status.style.build.css | 2 +- modules/notifications/class-notifications.php | 368 ++++++------------ modules/notifications/lib/notifications.css | 60 +-- modules/notifications/lib/notifications.js | 20 +- modules/settings/class-settings.php | 190 +++------ modules/settings/lib/settings.css | 66 ++-- modules/settings/lib/settings.js | 117 +----- modules/user-groups/class-user-groups.php | 51 +-- modules/user-groups/lib/user-groups.css | 56 ++- modules/user-groups/lib/user-groups.js | 2 +- 13 files changed, 296 insertions(+), 666 deletions(-) diff --git a/common/php/class-module.php b/common/php/class-module.php index 2c83f78f..94f653eb 100644 --- a/common/php/class-module.php +++ b/common/php/class-module.php @@ -61,7 +61,7 @@ public function is_analytics_enabled() { // filter to disable it. // ToDo: Update the ef prefix. - $is_analytics_enabled = apply_filters( 'ef_should_analytics_be_enabled', $is_analytics_enabled ); + $is_analytics_enabled = apply_filters( 'vw_should_analytics_be_enabled', $is_analytics_enabled ); return $is_analytics_enabled; } @@ -111,7 +111,7 @@ public function get_all_post_types() { * If add_post_type_support() has been used anywhere (legacy support), inherit the state * * @param array $module_post_types Current state of post type options for the module - * @param string $post_type_support What the feature is called for post_type_support (e.g. 'ef_calendar') + * @param string $post_type_support What the feature is called for post_type_support (e.g. 'vw_calendar') * @return array $normalized_post_type_options The setting for each post type, normalized based on rules * * @since 0.7 @@ -144,7 +144,7 @@ public function get_supported_post_types_for_module( $module = null ) { 'public' => true, ); // ToDo: Update the ef prefix. - $pt_args = apply_filters( 'edit_flow_supported_module_post_types_args', $pt_args, $module ); + $pt_args = apply_filters( 'vip_workflow_supported_module_post_types_args', $pt_args, $module ); return get_post_types( $pt_args, 'objects' ); } @@ -291,7 +291,7 @@ public function get_user_meta( $user_id, $key, $string = true ) { $response = null; // ToDo: Update the ef prefix. - $response = apply_filters( 'ef_get_user_meta', $response, $user_id, $key, $string ); + $response = apply_filters( 'vw_get_user_meta', $response, $user_id, $key, $string ); if ( ! is_null( $response ) ) { return $response; } @@ -314,7 +314,7 @@ public function update_user_meta( $user_id, $key, $value, $previous = null ) { $response = null; // ToDo: Update the ef prefix. - $response = apply_filters( 'ef_update_user_meta', $response, $user_id, $key, $value, $previous ); + $response = apply_filters( 'vw_update_user_meta', $response, $user_id, $key, $value, $previous ); if ( ! is_null( $response ) ) { return $response; } @@ -448,8 +448,8 @@ public function users_select_form( $selected = null, $args = null ) { // ToDo: Update the ef prefix. // Set up arguments $defaults = array( - 'list_class' => 'ef-users-select-form', - 'input_id' => 'ef-selected-users', + 'list_class' => 'vw-users-select-form', + 'input_id' => 'vw-selected-users', ); $parsed_args = wp_parse_args( $args, $defaults ); extract( $parsed_args, EXTR_SKIP ); @@ -463,7 +463,7 @@ public function users_select_form( $selected = null, $args = null ) { ), 'orderby' => 'display_name', ); - $args = apply_filters( 'ef_users_select_form_get_users_args', $args ); + $args = apply_filters( 'vw_users_select_form_get_users_args', $args ); $users = get_users( $args ); @@ -482,8 +482,8 @@ public function users_select_form( $selected = null, $args = null ) { ?>
  • @@ -513,7 +513,7 @@ public function users_select_form( $selected = null, $args = null ) { public function add_caps_to_role( $role, $caps ) { // ToDo: Update the ef prefix. // In some contexts, we don't want to add caps to roles - if ( apply_filters( 'ef_kill_add_caps_to_role', false, $role, $caps ) ) { + if ( apply_filters( 'vw_kill_add_caps_to_role', false, $role, $caps ) ) { return; } diff --git a/dist/custom-status.build.js b/dist/custom-status.build.js index 1a26bb46..cf4a7d70 100644 --- a/dist/custom-status.build.js +++ b/dist/custom-status.build.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=React;var n=t.n(e);function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){u=!0,s=t},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw s}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=React;var n=t.n(e);function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){u=!0,s=t},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw s}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n*{flex-basis:45%}.edit-flow-extended-post-status .edit-flow-extended-post-status-note{flex-basis:100%}.edit-flow-extended-post-status-switch-to-draft{flex-basis:100%}.edit-flow-extended-post-status-publish>*{flex-basis:100%} +.vip-workflow-extended-post-status{flex-flow:row wrap}.vip-workflow-extended-post-status>*{flex-basis:45%}.vip-workflow-extended-post-status .vip-workflow-extended-post-status-note{flex-basis:100%}.vip-workflow-extended-post-status-switch-to-draft{flex-basis:100%}.vip-workflow-extended-post-status-publish>*{flex-basis:100%} /*# sourceMappingURL=custom-status.editor.build.css.map*/ \ No newline at end of file diff --git a/dist/custom-status.style.build.css b/dist/custom-status.style.build.css index 2386bc5b..ed284795 100644 --- a/dist/custom-status.style.build.css +++ b/dist/custom-status.style.build.css @@ -1,4 +1,4 @@ -.edit-flow-extended-post-status{flex-flow:row wrap}.edit-flow-extended-post-status>*{flex-basis:45%}.edit-flow-extended-post-status .edit-flow-extended-post-status-note{flex-basis:100%}.edit-flow-extended-post-status-switch-to-draft{flex-basis:100%}.edit-flow-extended-post-status-publish>*{flex-basis:100%} +.vip-workflow-extended-post-status{flex-flow:row wrap}.vip-workflow-extended-post-status>*{flex-basis:45%}.vip-workflow-extended-post-status .vip-workflow-extended-post-status-note{flex-basis:100%}.vip-workflow-extended-post-status-switch-to-draft{flex-basis:100%}.vip-workflow-extended-post-status-publish>*{flex-basis:100%} /*# sourceMappingURL=custom-status.style.build.css.map*/ \ No newline at end of file diff --git a/modules/notifications/class-notifications.php b/modules/notifications/class-notifications.php index 10415dd6..b5c2b926 100644 --- a/modules/notifications/class-notifications.php +++ b/modules/notifications/class-notifications.php @@ -15,23 +15,23 @@ class VW_Notifications extends VW_Module { // Taxonomy name used to store users following posts public $following_users_taxonomy = 'following_users'; // Taxonomy name used to store user groups following posts - public $following_usergroups_taxonomy = VW_User_Groups::taxonomy_key; + public $following_usergroups_taxonomy = VW_User_Groups::TAXONOMY_KEY; public $module; public $edit_post_subscriptions_cap = 'edit_post_subscriptions'; /** - * Register the module with Edit Flow but don't do anything else + * Register the module with VIP Workflow but don't do anything else */ public function __construct() { - // Register the module with Edit Flow + // Register the module with VIP Workflow $this->module_url = $this->get_module_url( __FILE__ ); $args = [ - 'title' => __( 'Notifications', 'edit-flow' ), - 'short_description' => __( 'Update your team of important changes to your content.', 'edit-flow' ), - 'extended_description' => __( 'With email notifications, you can keep everyone updated about what’s happening with a given content. Each status change or editorial comment sends out an email notification to users subscribed to a post. User groups can be used to manage who receives notifications on what. With webhook notifications, all notifications will also be sent to the specified webhook URL(i.e.: Slack incoming webhooks) but will ignore specific user or user groups subscription settings.', 'edit-flow' ), + 'title' => __( 'Notifications', 'vip-workflow' ), + 'short_description' => __( 'Update your team of important changes to your content.', 'vip-workflow' ), + 'extended_description' => __( 'With email notifications, you can keep everyone updated about what’s happening with a given content. Each status change sends out an email notification to users subscribed to a post. User groups can be used to manage who receives notifications on what. With webhook notifications, all notifications will also be sent to the specified webhook URL(i.e.: Slack incoming webhooks) but will ignore specific user or user groups subscription settings.', 'vip-workflow' ), 'module_url' => $this->module_url, 'img_url' => $this->module_url . 'lib/notifications_s128.png', 'slug' => 'notifications', @@ -46,16 +46,16 @@ public function __construct() { 'webhook_url' => '', ], 'configure_page_cb' => 'print_configure_view', - 'post_type_support' => 'ef_notification', + 'post_type_support' => 'vw_notification', 'autoload' => false, 'settings_help_tab' => [ - 'id' => 'ef-notifications-overview', - 'title' => __( 'Overview', 'edit-flow' ), - 'content' => __( '

    Notifications ensure you keep up to date with progress your most important content. Users can be subscribed to notifications on a post one by one or by selecting user groups.

    When enabled, email notifications can be sent when a post changes status or an editorial comment is left by a writer or an editor.

    ', 'edit-flow' ), + 'id' => 'vw-notifications-overview', + 'title' => __( 'Overview', 'vip-workflow' ), + 'content' => __( '

    Notifications ensure you keep up to date with progress your most important content. Users can be subscribed to notifications on a post one by one or by selecting user groups.

    When enabled, email notifications can be sent when a post changes status.

    ', 'vip-workflow' ), ], - 'settings_help_sidebar' => __( '

    For more information:

    Notifications Documentation

    Edit Flow Forum

    Edit Flow on Github

    ', 'edit-flow' ), + 'settings_help_sidebar' => __( '

    For more information:

    VIP Workflow on Github

    ', 'vip-workflow' ), ]; - $this->module = EditFlow()->register_module( 'notifications', $args ); + $this->module = vip_workflow()->register_module( 'notifications', $args ); } /** @@ -67,22 +67,21 @@ public function init() { $this->register_taxonomies(); // Allow users to use a different user capability for editing post subscriptions - $this->edit_post_subscriptions_cap = apply_filters( 'ef_edit_post_subscriptions_cap', $this->edit_post_subscriptions_cap ); + $this->edit_post_subscriptions_cap = apply_filters( 'vw_edit_post_subscriptions_cap', $this->edit_post_subscriptions_cap ); // Set up metabox and related actions add_action( 'add_meta_boxes', [ $this, 'add_post_meta_box' ] ); // Add "access badge" to the subscribers list. - add_action( 'ef_user_subscribe_actions', [ $this, 'display_subscriber_warning_badges' ], 10, 2 ); + add_action( 'vw_user_subscribe_actions', [ $this, 'display_subscriber_warning_badges' ], 10, 2 ); // Saving post actions // self::save_post_subscriptions() is hooked into transition_post_status so we can ensure usergroup data // is properly saved before sending notifs add_action( 'transition_post_status', [ $this, 'save_post_subscriptions' ], 0, 3 ); add_action( 'transition_post_status', [ $this, 'notification_status_change' ], 10, 3 ); - add_action( 'ef_post_insert_editorial_comment', [ $this, 'notification_comment' ] ); add_action( 'delete_user', [ $this, 'delete_user_action' ] ); - add_action( 'ef_send_scheduled_email', [ $this, 'send_single_email' ], 10, 4 ); + add_action( 'vw_send_scheduled_email', [ $this, 'send_single_email' ], 10, 4 ); add_action( 'admin_init', [ $this, 'register_settings' ] ); @@ -91,20 +90,17 @@ public function init() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] ); // Add a "Follow" link to posts - if ( apply_filters( 'ef_notifications_show_follow_link', true ) ) { + if ( apply_filters( 'vw_notifications_show_follow_link', true ) ) { // A little extra JS for the follow button add_action( 'admin_head', [ $this, 'action_admin_head_follow_js' ] ); // Manage Posts add_filter( 'post_row_actions', [ $this, 'filter_post_row_actions' ], 10, 2 ); add_filter( 'page_row_actions', [ $this, 'filter_post_row_actions' ], 10, 2 ); - // Calendar and Story Budget - add_filter( 'ef_calendar_item_actions', [ $this, 'filter_post_row_actions' ], 10, 2 ); - add_filter( 'ef_story_budget_item_actions', [ $this, 'filter_post_row_actions' ], 10, 2 ); } //Ajax for saving notifiction updates add_action( 'wp_ajax_save_notifications', [ $this, 'ajax_save_post_subscriptions' ] ); - add_action( 'wp_ajax_ef_notifications_user_post_subscription', [ $this, 'handle_user_post_subscription' ] ); + add_action( 'wp_ajax_vw_notifications_user_post_subscription', [ $this, 'handle_user_post_subscription' ] ); } /** @@ -132,32 +128,7 @@ public function install() { * @since 0.7 */ public function upgrade( $previous_version ) { - global $edit_flow; - - // Upgrade path to v0.7 - if ( version_compare( $previous_version, '0.7', '<' ) ) { - // Migrate whether notifications were enabled or not - $enabled = get_option( 'edit_flow_notifications_enabled' ); - if ( $enabled ) { - $enabled = 'on'; - } else { - $enabled = 'off'; - } - $edit_flow->update_module_option( $this->module->name, 'enabled', $enabled ); - delete_option( 'edit_flow_notifications_enabled' ); - // Migrate whether to always notify the admin - $always_notify_admin = get_option( 'edit_flow_always_notify_admin' ); - if ( $always_notify_admin ) { - $always_notify_admin = 'on'; - } else { - $always_notify_admin = 'off'; - } - $edit_flow->update_module_option( $this->module->name, 'always_notify_admin', $always_notify_admin ); - delete_option( 'edit_flow_always_notify_admin' ); - - // Technically we've run this code before so we don't want to auto-install new data - $edit_flow->update_module_option( $this->module->name, 'loaded_once', true ); - } + // Nothing to do here yet } /** @@ -195,13 +166,13 @@ public function enqueue_admin_scripts() { if ( $this->is_whitelisted_functional_view() ) { wp_enqueue_script( 'jquery-listfilterizer' ); - wp_enqueue_script( 'edit-flow-notifications-js', $this->module_url . 'lib/notifications.js', [ 'jquery', 'jquery-listfilterizer' ], EDIT_FLOW_VERSION, true ); + wp_enqueue_script( 'vip-workflow-notifications-js', $this->module_url . 'lib/notifications.js', [ 'jquery', 'jquery-listfilterizer' ], VIP_WORKFLOW_VERSION, true ); wp_localize_script( - 'edit-flow-notifications-js', - 'ef_notifications_localization', + 'vip-workflow-notifications-js', + 'vw_notifications_localization', [ - 'no_access' => esc_html__( 'No Access', 'edit-flow' ), - 'no_email' => esc_html__( 'No Email', 'edit-flow' ), + 'no_access' => esc_html__( 'No Access', 'vip-workflow' ), + 'no_email' => esc_html__( 'No Email', 'vip-workflow' ), ] ); } @@ -218,7 +189,7 @@ public function enqueue_admin_styles() { if ( $this->is_whitelisted_functional_view() || $this->is_whitelisted_settings_view() ) { wp_enqueue_style( 'jquery-listfilterizer' ); - wp_enqueue_style( 'edit-flow-notifications-css', $this->module->module_url . 'lib/notifications.css', false, EDIT_FLOW_VERSION ); + wp_enqueue_style( 'vip-workflow-notifications-css', $this->module->module_url . 'lib/notifications.css', false, VIP_WORKFLOW_VERSION ); } } @@ -234,7 +205,7 @@ public function action_admin_head_follow_js() { /** * Action to Follow / Unfollow posts on the manage posts screen */ - $('.wp-list-table, #ef-calendar-view, #ef-story-budget-wrap').on( 'click', '.ef_follow_link a', function(e){ + $('.wp-list-table').on( 'click', '.vw_follow_link a', function(e){ e.preventDefault(); @@ -282,7 +253,7 @@ public function filter_post_row_actions( $actions, $post ) { $parts = $this->get_follow_action_parts( $post ); - $actions['ef_follow_link'] = '' . $parts['text'] . ''; + $actions['vw_follow_link'] = '' . $parts['text'] . ''; return $actions; } @@ -294,23 +265,23 @@ public function filter_post_row_actions( $actions, $post ) { */ private function get_follow_action_parts( $post ) { $args = [ - 'action' => 'ef_notifications_user_post_subscription', + 'action' => 'vw_notifications_user_post_subscription', 'post_id' => $post->ID, ]; $following_users = $this->get_following_users( $post->ID ); if ( in_array( wp_get_current_user()->user_login, $following_users ) ) { $args['method'] = 'unfollow'; - $title_text = __( 'Click to unfollow updates to this post', 'edit-flow' ); - $follow_text = __( 'Following', 'edit-flow' ); + $title_text = __( 'Click to unfollow updates to this post', 'vip-workflow' ); + $follow_text = __( 'Following', 'vip-workflow' ); } else { $args['method'] = 'follow'; - $title_text = __( 'Follow updates to this post', 'edit-flow' ); - $follow_text = __( 'Follow', 'edit-flow' ); + $title_text = __( 'Follow updates to this post', 'vip-workflow' ); + $follow_text = __( 'Follow', 'vip-workflow' ); } // wp_nonce_url() has encoding issues: http://core.trac.wordpress.org/ticket/20771 - $args['_wpnonce'] = wp_create_nonce( 'ef_notifications_user_post_subscription' ); + $args['_wpnonce'] = wp_create_nonce( 'vw_notifications_user_post_subscription' ); return [ 'title' => $title_text, @@ -330,7 +301,7 @@ public function add_post_meta_box() { $usergroup_post_types = $this->get_post_types_for_module( $this->module ); foreach ( $usergroup_post_types as $post_type ) { - add_meta_box( 'edit-flow-notifications', __( 'Notifications', 'edit-flow' ), [ $this, 'notifications_meta_box' ], $post_type, 'advanced' ); + add_meta_box( 'vip-workflow-notifications', __( 'Notifications', 'vip-workflow' ), [ $this, 'notifications_meta_box' ], $post_type, 'advanced' ); } } @@ -340,35 +311,35 @@ public function add_post_meta_box() { * @todo add_cap to set subscribers for posts; default to Admin and editors */ public function notifications_meta_box() { - global $post, $post_ID, $edit_flow; + global $post, $post_ID, $vip_workflow; ?> -
    +
    -

    -
    -

    +

    +
    +

    get_following_users( $post->ID, 'id' ); $select_form_args = [ - 'list_class' => 'ef-post_following_list', + 'list_class' => 'vw-post_following_list', ]; $this->users_select_form( $followers, $select_form_args ); ?>
    - module_enabled( 'user_groups' ) && in_array( $this->get_current_post_type(), $this->get_post_types_for_module( $edit_flow->user_groups->module ) ) ) : ?> -
    -

    + module_enabled( 'user_groups' ) && in_array( $this->get_current_post_type(), $this->get_post_types_for_module( $vip_workflow->user_groups->module ) ) ) : ?> +
    +

    get_following_usergroups( $post->ID, 'ids' ); - $edit_flow->user_groups->usergroups_select_form( $following_usergroups ); + $vip_workflow->user_groups->usergroups_select_form( $following_usergroups ); ?>
    - - + +
    user_can_be_notified( get_user_by( 'id', $user_id ), $post->ID ) ) { // span.post_following_list-no_access is also added in notifications.js after AJAX that ticks/unticks a user - echo '' . esc_html__( 'No Access', 'edit-flow' ) . ''; + echo '' . esc_html__( 'No Access', 'vip-workflow' ) . ''; } // Add No Email span if they have no email $user_object = get_user_by( 'id', $user_id ); if ( ! is_a( $user_object, 'WP_User' ) || empty( $user_object->user_email ) ) { // span.post_following_list-no_email is also added in notifications.js after AJAX that ticks/unticks a user - echo '' . esc_html__( 'No Email', 'edit-flow' ) . ''; + echo '' . esc_html__( 'No Email', 'vip-workflow' ) . ''; } } @@ -408,18 +379,18 @@ public function display_subscriber_warning_badges( $user_id, $checked ) { * Called when a notification editorial metadata checkbox is checked. Handles saving of a user/usergroup to a post. */ public function ajax_save_post_subscriptions() { - global $edit_flow; + global $vip_workflow; // Verify nonce. if ( ! isset( $_POST['_nonce'] ) || ! wp_verify_nonce( $_POST['_nonce'], 'save_user_usergroups' ) ) { - die( esc_html__( 'Nonce check failed. Please ensure you can add users or user groups to a post.', 'edit-flow' ) ); + die( esc_html__( 'Nonce check failed. Please ensure you can add users or user groups to a post.', 'vip-workflow' ) ); } $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; $post = get_post( $post_id ); $valid_post = ! is_null( $post ) && ! wp_is_post_revision( $post_id ) && ! wp_is_post_autosave( $post_id ); - if ( ! isset( $_POST['ef_notifications_name'] ) || ! $valid_post || ! current_user_can( $this->edit_post_subscriptions_cap ) ) { + if ( ! isset( $_POST['vw_notifications_name'] ) || ! $valid_post || ! current_user_can( $this->edit_post_subscriptions_cap ) ) { die(); } @@ -428,9 +399,9 @@ public function ajax_save_post_subscriptions() { $user_group_ids = array_map( 'intval', $_POST['user_group_ids'] ); } - if ( 'ef-selected-users[]' === $_POST['ef_notifications_name'] ) { + if ( 'vw-selected-users[]' === $_POST['vw_notifications_name'] ) { // Prevent auto-subscribing users that have opted out of notifications. - add_filter( 'ef_notification_auto_subscribe_current_user', '__return_false', PHP_INT_MAX ); + add_filter( 'vw_notification_auto_subscribe_current_user', '__return_false', PHP_INT_MAX ); $this->save_post_following_users( $post, $user_group_ids ); if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['post_id'] ) ) { @@ -461,11 +432,11 @@ function ( $user_id ) use ( $post_id ) { wp_send_json_success( $json_success ); } // Remove auto-subscribe prevention behavior from earlier. - remove_filter( 'ef_notification_auto_subscribe_current_user', '__return_false', PHP_INT_MAX ); + remove_filter( 'vw_notification_auto_subscribe_current_user', '__return_false', PHP_INT_MAX ); } - $groups_enabled = $this->module_enabled( 'user_groups' ) && in_array( get_post_type( $post_id ), $this->get_post_types_for_module( $edit_flow->user_groups->module ) ); - if ( 'following_usergroups[]' === $_POST['ef_notifications_name'] && $groups_enabled ) { + $groups_enabled = $this->module_enabled( 'user_groups' ) && in_array( get_post_type( $post_id ), $this->get_post_types_for_module( $vip_workflow->user_groups->module ) ); + if ( 'following_usergroups[]' === $_POST['vw_notifications_name'] && $groups_enabled ) { $this->save_post_following_usergroups( $post, $user_group_ids ); } @@ -479,7 +450,7 @@ function ( $user_id ) use ( $post_id ) { */ public function handle_user_post_subscription() { - if ( ! empty( $_GET['_wpnonce'] ) && ! wp_verify_nonce( $_GET['_wpnonce'], 'ef_notifications_user_post_subscription' ) ) { + if ( ! empty( $_GET['_wpnonce'] ) && ! wp_verify_nonce( $_GET['_wpnonce'], 'vw_notifications_user_post_subscription' ) ) { $this->print_ajax_response( 'error', $this->module->messages['nonce-failed'] ); } @@ -514,18 +485,18 @@ public function handle_user_post_subscription() { * @param int $post ID of the post */ public function save_post_subscriptions( $new_status, $old_status, $post ) { - global $edit_flow; + global $vip_workflow; if ( ! empty( $_POST['_wpnonce'] ) && ! wp_verify_nonce( $_POST['_wpnonce'], 'editpost' ) ) { $this->print_ajax_response( 'error', $this->module->messages['nonce-failed'] ); } // only if has edit_post_subscriptions cap - if ( ( ! wp_is_post_revision( $post ) && ! wp_is_post_autosave( $post ) ) && isset( $_POST['ef-save_followers'] ) && current_user_can( $this->edit_post_subscriptions_cap ) ) { - $users = isset( $_POST['ef-selected-users'] ) ? $_POST['ef-selected-users'] : []; + if ( ( ! wp_is_post_revision( $post ) && ! wp_is_post_autosave( $post ) ) && isset( $_POST['vw-save_followers'] ) && current_user_can( $this->edit_post_subscriptions_cap ) ) { + $users = isset( $_POST['vw-selected-users'] ) ? $_POST['vw-selected-users'] : []; $usergroups = isset( $_POST['following_usergroups'] ) ? $_POST['following_usergroups'] : []; $this->save_post_following_users( $post, $users ); - if ( $this->module_enabled( 'user_groups' ) && in_array( $this->get_current_post_type(), $this->get_post_types_for_module( $edit_flow->user_groups->module ) ) ) { + if ( $this->module_enabled( 'user_groups' ) && in_array( $this->get_current_post_type(), $this->get_post_types_for_module( $vip_workflow->user_groups->module ) ) ) { $this->save_post_following_usergroups( $post, $usergroups ); } } @@ -543,12 +514,12 @@ public function save_post_following_users( $post, $users = null ) { // Add current user to following users $user = wp_get_current_user(); - if ( $user && apply_filters( 'ef_notification_auto_subscribe_current_user', true, 'subscription_action' ) ) { + if ( $user && apply_filters( 'vw_notification_auto_subscribe_current_user', true, 'subscription_action' ) ) { $users[] = $user->ID; } // Add post author to following users - if ( apply_filters( 'ef_notification_auto_subscribe_post_author', true, 'subscription_action' ) ) { + if ( apply_filters( 'vw_notification_auto_subscribe_post_author', true, 'subscription_action' ) ) { $users[] = $post->post_author; } @@ -577,10 +548,10 @@ public function save_post_following_usergroups( $post, $usergroups = null ) { * Set up and send post status change notification email */ public function notification_status_change( $new_status, $old_status, $post ) { - global $edit_flow; + global $vip_workflow; // Kill switch for notification - if ( ! apply_filters( 'ef_notification_status_change', $new_status, $old_status, $post ) || ! apply_filters( "ef_notification_{$post->post_type}_status_change", $new_status, $old_status, $post ) ) { + if ( ! apply_filters( 'vw_notification_status_change', $new_status, $old_status, $post ) || ! apply_filters( "vw_notification_{$post->post_type}_status_change", $new_status, $old_status, $post ) ) { return false; } @@ -590,7 +561,7 @@ public function notification_status_change( $new_status, $old_status, $post ) { } // No need to notify if it's a revision, auto-draft, or if post status wasn't changed - $ignored_statuses = apply_filters( 'ef_notification_ignored_statuses', [ $old_status, 'inherit', 'auto-draft' ], $post->post_type ); + $ignored_statuses = apply_filters( 'vw_notification_ignored_statuses', [ $old_status, 'inherit', 'auto-draft' ], $post->post_type ); if ( ! in_array( $new_status, $ignored_statuses ) ) { @@ -598,21 +569,21 @@ public function notification_status_change( $new_status, $old_status, $post ) { $current_user = wp_get_current_user(); $post_author = get_userdata( $post->post_author ); - //$duedate = $edit_flow->post_metadata->get_post_meta($post->ID, 'duedate', true); + //$duedate = $vip_workflow->post_metadata->get_post_meta($post->ID, 'duedate', true); $blogname = get_option( 'blogname' ); $body = ''; $post_id = $post->ID; - $post_title = ef_draft_or_post_title( $post_id ); + $post_title = vw_draft_or_post_title( $post_id ); $post_type = get_post_type_object( $post->post_type )->labels->singular_name; if ( 0 != $current_user->ID ) { $current_user_display_name = $current_user->display_name; $current_user_email = sprintf( '(%s)', $current_user->user_email ); } else { - $current_user_display_name = __( 'WordPress Scheduler', 'edit-flow' ); + $current_user_display_name = __( 'WordPress Scheduler', 'vip-workflow' ); $current_user_email = ''; } @@ -643,19 +614,19 @@ public function notification_status_change( $new_status, $old_status, $post ) { if ( 'new' == $old_status || 'auto-draft' == $old_status ) { $old_status_friendly_name = 'New'; /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] New %2$s Created: "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] New %2$s Created: "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( 'A new %1$s (#%2$s "%3$s") was created by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user->display_name, $current_user->user_email ) . "\r\n"; + $body .= sprintf( __( 'A new %1$s (#%2$s "%3$s") was created by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user->display_name, $current_user->user_email ) . "\r\n"; } elseif ( 'trash' == $new_status ) { /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] %2$s Trashed: "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] %2$s Trashed: "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( '%1$s #%2$s "%3$s" was moved to the trash by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; + $body .= sprintf( __( '%1$s #%2$s "%3$s" was moved to the trash by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; } elseif ( 'trash' == $old_status ) { /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] %2$s Restored (from Trash): "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] %2$s Restored (from Trash): "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( '%1$s #%2$s "%3$s" was restored from trash by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; + $body .= sprintf( __( '%1$s #%2$s "%3$s" was restored from trash by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; } elseif ( 'future' == $new_status ) { /* translators: 1: site name, 2: post type, 3. post title */ $subject = sprintf( __( '[%1$s] %2$s Scheduled: "%3$s"' ), $blogname, $post_type, $post_title ); @@ -663,39 +634,39 @@ public function notification_status_change( $new_status, $old_status, $post ) { $body .= sprintf( __( '%1$s #%2$s "%3$s" was scheduled by %4$s %5$s. It will be published on %6$s' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email, $this->get_scheduled_datetime( $post ) ) . "\r\n"; } elseif ( 'publish' == $new_status ) { /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] %2$s Published: "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] %2$s Published: "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( '%1$s #%2$s "%3$s" was published by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; + $body .= sprintf( __( '%1$s #%2$s "%3$s" was published by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; } elseif ( 'publish' == $old_status ) { /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] %2$s Unpublished: "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] %2$s Unpublished: "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( '%1$s #%2$s "%3$s" was unpublished by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; + $body .= sprintf( __( '%1$s #%2$s "%3$s" was unpublished by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; } else { /* translators: 1: site name, 2: post type, 3. post title */ - $subject = sprintf( __( '[%1$s] %2$s Status Changed for "%3$s"', 'edit-flow' ), $blogname, $post_type, $post_title ); + $subject = sprintf( __( '[%1$s] %2$s Status Changed for "%3$s"', 'vip-workflow' ), $blogname, $post_type, $post_title ); /* translators: 1: post type, 2: post id, 3. post title, 4. user name, 5. user email */ - $body .= sprintf( __( 'Status was changed for %1$s #%2$s "%3$s" by %4$s %5$s', 'edit-flow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; + $body .= sprintf( __( 'Status was changed for %1$s #%2$s "%3$s" by %4$s %5$s', 'vip-workflow' ), $post_type, $post_id, $post_title, $current_user_display_name, $current_user_email ) . "\r\n"; } /* translators: 1: date, 2: time, 3: timezone */ - $body .= sprintf( __( 'This action was taken on %1$s at %2$s %3$s', 'edit-flow' ), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ), get_option( 'timezone_string' ) ) . "\r\n"; + $body .= sprintf( __( 'This action was taken on %1$s at %2$s %3$s', 'vip-workflow' ), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ), get_option( 'timezone_string' ) ) . "\r\n"; // Email body $body .= "\r\n"; /* translators: 1: old status, 2: new status */ - $body .= sprintf( __( '%1$s => %2$s', 'edit-flow' ), $old_status_friendly_name, $new_status_friendly_name ); + $body .= sprintf( __( '%1$s => %2$s', 'vip-workflow' ), $old_status_friendly_name, $new_status_friendly_name ); $body .= "\r\n\r\n"; $body .= "--------------------\r\n\r\n"; /* translators: 1: post type */ - $body .= sprintf( __( '== %s Details ==', 'edit-flow' ), $post_type ) . "\r\n"; + $body .= sprintf( __( '== %s Details ==', 'vip-workflow' ), $post_type ) . "\r\n"; /* translators: 1: post title */ - $body .= sprintf( __( 'Title: %s', 'edit-flow' ), $post_title ) . "\r\n"; + $body .= sprintf( __( 'Title: %s', 'vip-workflow' ), $post_title ) . "\r\n"; if ( ! empty( $post_author ) ) { /* translators: 1: author name, 2: author email */ - $body .= sprintf( __( 'Author: %1$s (%2$s)', 'edit-flow' ), $post_author->display_name, $post_author->user_email ) . "\r\n"; + $body .= sprintf( __( 'Author: %1$s (%2$s)', 'vip-workflow' ), $post_author->display_name, $post_author->user_email ) . "\r\n"; } $edit_link = htmlspecialchars_decode( get_edit_post_link( $post_id ) ); @@ -705,13 +676,11 @@ public function notification_status_change( $new_status, $old_status, $post ) { $view_link = htmlspecialchars_decode( get_permalink( $post_id ) ); } $body .= "\r\n"; - $body .= __( '== Actions ==', 'edit-flow' ) . "\r\n"; - /* translators: 1: edit link */ - $body .= sprintf( __( 'Add editorial comment: %s', 'edit-flow' ), $edit_link . '#editorialcomments/add' ) . "\r\n"; + $body .= __( '== Actions ==', 'vip-workflow' ) . "\r\n"; /* translators: 1: edit link */ - $body .= sprintf( __( 'Edit: %s', 'edit-flow' ), $edit_link ) . "\r\n"; + $body .= sprintf( __( 'Edit: %s', 'vip-workflow' ), $edit_link ) . "\r\n"; /* translators: 1: view link */ - $body .= sprintf( __( 'View: %s', 'edit-flow' ), $view_link ) . "\r\n"; + $body .= sprintf( __( 'View: %s', 'vip-workflow' ), $view_link ) . "\r\n"; $body .= $this->get_notification_footer( $post ); @@ -719,7 +688,7 @@ public function notification_status_change( $new_status, $old_status, $post ) { if ( 'on' === $this->module->options->send_to_webhook ) { /* translators: 1: user name, 2: post type, 3: post id, 4: edit link, 5: post title, 6: old status, 7: new status */ - $format = __( '*%1$s* changed the status of *%2$s #%3$s - <%4$s|%5$s>* from *%6$s* to *%7$s*', 'edit-flow' ); + $format = __( '*%1$s* changed the status of *%2$s #%3$s - <%4$s|%5$s>* from *%6$s* to *%7$s*', 'vip-workflow' ); $text = sprintf( $format, $current_user->display_name, $post_type, $post_id, $edit_link, $post_title, $old_status_friendly_name, $new_status_friendly_name ); $this->send_to_webhook( $text, 'status-change', $current_user, $post ); @@ -727,115 +696,14 @@ public function notification_status_change( $new_status, $old_status, $post ) { } } - /** - * Set up and set editorial comment notification email - * - * @param WP_Comment $comment - * @return boolean|null|void - */ - public function notification_comment( $comment ) { - - $post = get_post( $comment->comment_post_ID ); - - $supported_post_types = $this->get_post_types_for_module( $this->module ); - if ( ! in_array( $post->post_type, $supported_post_types ) ) { - return; - } - - // Kill switch for notification - if ( ! apply_filters( 'ef_notification_editorial_comment', $comment, $post ) ) { - return false; - } - - $user = get_userdata( $post->post_author ); - $current_user = wp_get_current_user(); - - $post_id = $post->ID; - $post_type = get_post_type_object( $post->post_type )->labels->singular_name; - $post_title = ef_draft_or_post_title( $post_id ); - - // Fetch the text list of people who were notified from comment meta @see VW_Editorial_Comments->maybe_output_comment_meta() - $notification_list = get_comment_meta( $comment->comment_ID, 'notification_list', true ); - - // Check if this a reply - //$parent_ID = isset( $comment->comment_parent_ID ) ? $comment->comment_parent_ID : 0; - //if($parent_ID) $parent = get_comment($parent_ID); - - // Set user to follow post, but make it filterable - if ( apply_filters( 'ef_notification_auto_subscribe_current_user', true, 'comment' ) ) { - $this->follow_post_user( $post, (int) $current_user->ID ); - } - - // Set the post author to follow the post but make it filterable - if ( apply_filters( 'ef_notification_auto_subscribe_post_author', true, 'comment' ) ) { - $this->follow_post_user( $post, (int) $post->post_author ); - } - - $blogname = get_option( 'blogname' ); - - /* translators: 1: blog name, 2: post title */ - $subject = sprintf( __( '[%1$s] New Editorial Comment: "%2$s"', 'edit-flow' ), $blogname, $post_title ); - - /* translators: 1: post id, 2: post title, 3. post type */ - $body = sprintf( __( 'A new editorial comment was added to %3$s #%1$s "%2$s"', 'edit-flow' ), $post_id, $post_title, $post_type ) . "\r\n\r\n"; - /* translators: 1: comment author, 2: author email, 3: date, 4: time */ - $body .= sprintf( __( '%1$s (%2$s) said on %3$s at %4$s:', 'edit-flow' ), $current_user->display_name, $current_user->user_email, mysql2date( get_option( 'date_format' ), $comment->comment_date ), mysql2date( get_option( 'time_format' ), $comment->comment_date ) ) . "\r\n"; - $body .= "\r\n" . $comment->comment_content . "\r\n"; - - // @TODO: mention if it was a reply - /* - if($parent) { - - } - */ - - - $body .= "\r\n--------------------\r\n"; - // Insert the notification list from comment meta @see VW_Editorial_Comments->maybe_output_comment_meta() - if ( $notification_list ) { - $body .= esc_html__( 'Notified', 'edit-flow' ) . ': ' . esc_html( $notification_list ) . "\n"; - } - - $edit_link = htmlspecialchars_decode( get_edit_post_link( $post_id ) ); - $view_link = htmlspecialchars_decode( get_permalink( $post_id ) ); - - $body .= "\r\n"; - $body .= __( '== Actions ==', 'edit-flow' ) . "\r\n"; - /* translators: 1: edit link */ - $body .= sprintf( __( 'Reply: %s', 'edit-flow' ), $edit_link . '#editorialcomments/reply/' . $comment->comment_ID ) . "\r\n"; - /* translators: 1: edit link */ - $body .= sprintf( __( 'Add editorial comment: %s', 'edit-flow' ), $edit_link . '#editorialcomments/add' ) . "\r\n"; - /* translators: 1: edit link */ - $body .= sprintf( __( 'Edit: %s', 'edit-flow' ), $edit_link ) . "\r\n"; - /* translators: 1: view link */ - $body .= sprintf( __( 'View: %s', 'edit-flow' ), $view_link ) . "\r\n"; - - /* translators: 1: post type */ - $body .= "\r\n" . sprintf( __( 'You can see all editorial comments on this %s here: ', 'edit-flow' ), $post_type ) . "\r\n"; - $body .= $edit_link . '#editorialcomments' . "\r\n\r\n"; - - $body .= $this->get_notification_footer( $post ); - - $this->send_email( 'comment', $post, $subject, $body ); - - if ( 'on' === $this->module->options->send_to_webhook ) { - /* translators: 1: comment author, 2: post type, 3: post id, 4: edit link, 5: post title, 6: comment content */ - $format = __( '*%1$s* left a comment on *%2$s #%3$s - <%4$s|%5$s>*', 'edit-flow' ) . "\n\n"; - $format .= '%6$s'; - $text = sprintf( $format, $comment->comment_author, $post_type, $post_id, $edit_link, $post_title, $comment->comment_content ); - - $this->send_to_webhook( $text, 'comment', $current_user, $comment ); - } - } - public function get_notification_footer( $post ) { $body = ''; $body .= "\r\n--------------------\r\n"; /* translators: 1: post title */ - $body .= sprintf( __( 'You are receiving this email because you are subscribed to "%s".', 'edit-flow' ), ef_draft_or_post_title( $post->ID ) ); + $body .= sprintf( __( 'You are receiving this email because you are subscribed to "%s".', 'vip-workflow' ), vw_draft_or_post_title( $post->ID ) ); $body .= "\r\n"; /* translators: 1: date */ - $body .= sprintf( __( 'This email was sent %s.', 'edit-flow' ), date( 'r' ) ); + $body .= sprintf( __( 'This email was sent %s.', 'vip-workflow' ), date( 'r' ) ); $body .= "\r\n \r\n"; $body .= get_option( 'blogname' ) . ' | ' . get_bloginfo( 'url' ) . ' | ' . admin_url( '/' ) . "\r\n"; return $body; @@ -853,9 +721,9 @@ public function send_email( $action, $post, $subject, $message, $message_headers $recipients = explode( ',', $recipients ); } - $subject = apply_filters( 'ef_notification_send_email_subject', $subject, $action, $post ); - $message = apply_filters( 'ef_notification_send_email_message', $message, $action, $post ); - $message_headers = apply_filters( 'ef_notification_send_email_message_headers', $message_headers, $action, $post ); + $subject = apply_filters( 'vw_notification_send_email_subject', $subject, $action, $post ); + $message = apply_filters( 'vw_notification_send_email_message', $message, $action, $post ); + $message_headers = apply_filters( 'vw_notification_send_email_message_headers', $message_headers, $action, $post ); if ( VW_NOTIFICATION_USE_CRON ) { $this->schedule_emails( $recipients, $subject, $message, $message_headers ); @@ -870,9 +738,9 @@ public function send_email( $action, $post, $subject, $message, $message_headers * Send notifications to Slack * * @param string $message Message to be sent to webhook - * @param string $action Action being taken. Currently only `status-change` and `comment` + * @param string $action Action being taken. Currently only `status-change` * @param WP_User $user User who is taking the action - * @param WP_Post|WP_Comment $post Post or comment that the action is being taken on + * @param WP_Post $post Post that the action is being taken on */ public function send_to_webhook( $message, $action, $user, $post ) { $webhook_url = $this->module->options->webhook_url; @@ -888,7 +756,7 @@ public function send_to_webhook( $message, $action, $user, $post ) { ]; // apply filters to the payload - $payload = apply_filters( 'ef_notification_send_to_webhook_payload', $payload, $action, $user, $post ); + $payload = apply_filters( 'vw_notification_send_to_webhook_payload', $payload, $action, $user, $post ); // Send the notification $response = wp_remote_post( @@ -918,7 +786,7 @@ public function schedule_emails( $recipients, $subject, $message, $message_heade $send_time = time(); foreach ( $recipients as $recipient ) { - wp_schedule_single_event( $send_time, 'ef_send_scheduled_email', [ $recipient, $subject, $message, $message_headers ] ); + wp_schedule_single_event( $send_time, 'vw_send_scheduled_email', [ $recipient, $subject, $message, $message_headers ] ); $send_time += $time_offset; } } @@ -943,7 +811,7 @@ public function send_single_email( $to, $subject, $message, $message_headers = ' * @return string|array Recipients to receive notification. */ private function _get_notification_recipients( $post, $string = false ) { - global $edit_flow; + global $vip_workflow; $post_id = $post->ID; if ( ! $post_id ) { @@ -960,7 +828,7 @@ private function _get_notification_recipients( $post, $string = false ) { if ( $this->module_enabled( 'user_groups' ) ) { $usergroups = $this->get_following_usergroups( $post_id, 'ids' ); foreach ( (array) $usergroups as $usergroup_id ) { - $usergroup = $edit_flow->user_groups->get_usergroup_by( 'id', $usergroup_id ); + $usergroup = $vip_workflow->user_groups->get_usergroup_by( 'id', $usergroup_id ); foreach ( (array) $usergroup->user_ids as $user_id ) { $usergroup_user = get_user_by( 'id', $user_id ); if ( $this->user_can_be_notified( $usergroup_user, $post_id ) ) { @@ -984,7 +852,7 @@ private function _get_notification_recipients( $post, $string = false ) { // Process the recipients for this email to be sent. foreach ( $recipients as $key => $user_email ) { // Don't send the email to the current user unless we've explicitly indicated they should receive it. - if ( false === apply_filters( 'ef_notification_email_current_user', false ) && wp_get_current_user()->user_email == $user_email ) { + if ( false === apply_filters( 'vw_notification_email_current_user', false ) && wp_get_current_user()->user_email == $user_email ) { unset( $recipients[ $key ] ); } } @@ -996,7 +864,7 @@ private function _get_notification_recipients( $post, $string = false ) { * @param WP_Post $post * @param bool $string True if the recipients list will later be returned as a string. */ - $recipients = apply_filters( 'ef_notification_recipients', $recipients, $post, $string ); + $recipients = apply_filters( 'vw_notification_recipients', $recipients, $post, $string ); // If string set to true, return comma-delimited. if ( $string && is_array( $recipients ) ) { @@ -1030,7 +898,7 @@ public function user_can_be_notified( $user, $post_id ) { * @param WP_User|bool $user The user object, otherwise false. * @param int $post_id The post the user will be notified about. */ - return (bool) apply_filters( 'ef_notification_user_can_be_notified', $can_be_notified, $user, $post_id ); + return (bool) apply_filters( 'vw_notification_user_can_be_notified', $can_be_notified, $user, $post_id ); } /** @@ -1259,7 +1127,7 @@ public function get_following_users( $post_id, $return = 'user_login' ) { * @return array $usergroups All of the usergroup slugs */ public function get_following_usergroups( $post_id, $return = 'all' ) { - global $edit_flow; + global $vip_workflow; // Workaround for the fact that get_object_terms doesn't return just slugs if ( 'slugs' == $return ) { @@ -1309,7 +1177,7 @@ public function get_user_following_posts( $user = 0, $args = null ) { 'order' => 'DESC', 'post_status' => 'any', ]; - $post_args = apply_filters( 'ef_user_following_posts_query_args', $post_args ); + $post_args = apply_filters( 'vw_user_following_posts_query_args', $post_args ); $posts = get_posts( $post_args ); return $posts; } @@ -1322,10 +1190,10 @@ public function get_user_following_posts( $user = 0, $args = null ) { */ public function register_settings() { add_settings_section( $this->module->options_group_name . '_general', false, '__return_false', $this->module->options_group_name ); - add_settings_field( 'post_types', __( 'Post types for notifications:', 'edit-flow' ), [ $this, 'settings_post_types_option' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); - add_settings_field( 'always_notify_admin', __( 'Always notify blog admin', 'edit-flow' ), [ $this, 'settings_always_notify_admin_option' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); - add_settings_field( 'send_to_webhook', __( 'Send to Webhook', 'edit-flow' ), [ $this, 'settings_send_to_webhook' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); - add_settings_field( 'webhook_url', __( 'Webhook URL', 'edit-flow' ), [ $this, 'settings_webhook_url' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); + add_settings_field( 'post_types', __( 'Post types for notifications:', 'vip-workflow' ), [ $this, 'settings_post_types_option' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); + add_settings_field( 'always_notify_admin', __( 'Always notify blog admin', 'vip-workflow' ), [ $this, 'settings_always_notify_admin_option' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); + add_settings_field( 'send_to_webhook', __( 'Send to Webhook', 'vip-workflow' ), [ $this, 'settings_send_to_webhook' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); + add_settings_field( 'webhook_url', __( 'Webhook URL', 'vip-workflow' ), [ $this, 'settings_webhook_url' ], $this->module->options_group_name, $this->module->options_group_name . '_general' ); } /** @@ -1334,8 +1202,8 @@ public function register_settings() { * @since 0.7 */ public function settings_post_types_option() { - global $edit_flow; - $edit_flow->settings->helper_option_custom_post_type( $this->module ); + global $vip_workflow; + $vip_workflow->settings->helper_option_custom_post_type( $this->module ); } /** @@ -1345,8 +1213,8 @@ public function settings_post_types_option() { */ public function settings_always_notify_admin_option() { $options = [ - 'off' => __( 'Disabled', 'edit-flow' ), - 'on' => __( 'Enabled', 'edit-flow' ), + 'off' => __( 'Disabled', 'vip-workflow' ), + 'on' => __( 'Enabled', 'vip-workflow' ), ]; echo ''; foreach ( $options as $value => $label ) { @@ -1429,9 +1297,9 @@ public function print_configure_view() { module->options_group_name ); ?> module->options_group_name ); ?> module->name ) . '" />'; + echo ''; ?> -

    +

    ' ).addClass( 'post_following_list-no_access' ); - span.text( ef_notifications_localization.no_access ); + span.text( vw_notifications_localization.no_access ); $( container ).parent().prepend( span ); warning_background = true; } @@ -28,7 +28,7 @@ jQuery( document ).ready( function ( $ ) { ); if ( user_has_no_email ) { var span = $( '' ).addClass( 'post_following_list-no_email' ); - span.text( ef_notifications_localization.no_email ); + span.text( vw_notifications_localization.no_email ); $( container ).parent().prepend( span ); warning_background = true; } @@ -36,15 +36,15 @@ jQuery( document ).ready( function ( $ ) { $( document ).on( 'click', - '.ef-post_following_list li input:checkbox, .ef-following_usergroups li input:checkbox', + '.vw-post_following_list li input:checkbox, .vw-following_usergroups li input:checkbox', function () { const user_group_ids = []; const parent_this = $( this ); - params.ef_notifications_name = $( this ).attr( 'name' ); - params._nonce = $( '#ef_notifications_nonce' ).val(); + params.vw_notifications_name = $( this ).attr( 'name' ); + params._nonce = $( '#vw_notifications_nonce' ).val(); $( this ) - .parents( '.ef-post_following_list' ) + .parents( '.vw-post_following_list' ) .find( 'input:checked' ) .map( function () { user_group_ids.push( $( this ).val() ); @@ -76,11 +76,11 @@ jQuery( document ).ready( function ( $ ) { .animate( { backgroundColor: backgroundHighlightColor }, 200 ) .animate( { backgroundColor }, 200 ); - // This event is used to show an updated list of who will be notified of editorial comments and status updates. - $( '#ef-post_following_box' ).trigger( 'following_list_updated' ); + // This event is used to show an updated list of who will be notified of status updates. + $( '#vw-post_following_box' ).trigger( 'following_list_updated' ); }, error( r ) { - $( '#ef-post_following_users_box' ) + $( '#vw-post_following_users_box' ) .prev() .append( '

    There was an error. Please reload the page.

    ' ); }, diff --git a/modules/settings/class-settings.php b/modules/settings/class-settings.php index c1bf8cb4..daea89e0 100644 --- a/modules/settings/class-settings.php +++ b/modules/settings/class-settings.php @@ -1,33 +1,32 @@ module_url = $this->get_module_url( __FILE__ ); $args = array( - 'title' => __( 'Edit Flow', 'edit-flow' ), - 'short_description' => __( 'Edit Flow redefines your WordPress publishing workflow.', 'edit-flow' ), - 'extended_description' => __( 'Enable any of the features below to take control of your workflow. Custom statuses, email notifications, editorial comments, and more help you and your team save time so everyone can focus on what matters most: the content.', 'edit-flow' ), + 'title' => __( 'VIP Workflow', 'vip-workflow' ), + 'short_description' => __( 'VIP Workflow redefines your WordPress publishing workflow.', 'vip-workflow' ), + 'extended_description' => __( 'Enable any of the features below to take control of your workflow. Custom statuses, email notifications, and more help you and your team save time so everyone can focus on what matters most: the content.', 'vip-workflow' ), 'module_url' => $this->module_url, 'img_url' => $this->module_url . 'lib/eflogo_s128.png', 'slug' => 'settings', - 'settings_slug' => 'ef-settings', + 'settings_slug' => 'vw-settings', 'default_options' => array( 'enabled' => 'on', - 'vip_features' => $this->is_vip_site() ? 'on' : 'off', ), 'configure_page_cb' => 'print_default_settings', 'autoload' => true, ); - $this->module = EditFlow()->register_module( 'settings', $args ); + $this->module = vip_workflow()->register_module( 'settings', $args ); } /** @@ -41,21 +40,19 @@ public function init() { add_action( 'admin_print_scripts', array( $this, 'action_admin_print_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); - - add_action( 'wp_ajax_change_edit_flow_module_state', array( $this, 'ajax_change_edit_flow_module_state' ) ); } /** * Add necessary things to the admin menu */ public function action_admin_menu() { - global $edit_flow; + global $vip_workflow; - $ef_logo = 'lib/eflogo_s32w.png'; + $vw_logo = 'lib/eflogo_s32w.png'; - add_menu_page( $this->module->title, $this->module->title, 'manage_options', $this->module->settings_slug, array( $this, 'settings_page_controller' ), $this->module->module_url . $ef_logo ); + add_menu_page( $this->module->title, $this->module->title, 'manage_options', $this->module->settings_slug, array( $this, 'settings_page_controller' ), $this->module->module_url . $vw_logo ); - foreach ( $edit_flow->modules as $mod_name => $mod_data ) { + foreach ( $vip_workflow->modules as $mod_name => $mod_data ) { if ( isset( $mod_data->options->enabled ) && 'on' == $mod_data->options->enabled && $mod_data->configure_page_cb && $mod_name != $this->module->name ) { add_submenu_page( $this->module->settings_slug, $mod_data->title, $mod_data->title, 'manage_options', $mod_data->settings_slug, array( $this, 'settings_page_controller' ) ); @@ -65,7 +62,7 @@ public function action_admin_menu() { public function action_admin_enqueue_scripts() { if ( $this->is_whitelisted_settings_view() ) { - wp_enqueue_script( 'edit-flow-settings-js', $this->module_url . 'lib/settings.js', array( 'jquery' ), EDIT_FLOW_VERSION, true ); + wp_enqueue_script( 'vip-workflow-settings-js', $this->module_url . 'lib/settings.js', array( 'jquery' ), VIP_WORKFLOW_VERSION, true ); } } @@ -74,7 +71,7 @@ public function action_admin_enqueue_scripts() { */ public function action_admin_print_styles() { if ( $this->is_whitelisted_settings_view() ) { - wp_enqueue_style( 'edit_flow-settings-css', $this->module_url . 'lib/settings.css', false, EDIT_FLOW_VERSION ); + wp_enqueue_style( 'vip_workflow-settings-css', $this->module_url . 'lib/settings.css', false, VIP_WORKFLOW_VERSION ); } } @@ -86,54 +83,21 @@ public function action_admin_print_styles() { public function action_admin_print_scripts() { ?> get_module_by( 'slug', $slug ); - - if ( ! $module ) { - die( '-1' ); - } - - if ( 'enable' == $module_action ) { - $return = $edit_flow->update_module_option( $module->name, 'enabled', 'on' ); - } else if ( 'disable' == $module_action ) { - $return = $edit_flow->update_module_option( $module->name, 'enabled', 'off' ); - } - - if ( $return ) { - die( '1' ); - } else { - die( '-1' ); - } - } - /** - * Handles all settings and configuration page requests. Required element for Edit Flow + * Handles all settings and configuration page requests. Required element for VIP Workflow */ public function settings_page_controller() { - global $edit_flow; + global $vip_workflow; $page_requested = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : 'settings'; - $requested_module = $edit_flow->get_module_by( 'settings_slug', $page_requested ); + $requested_module = $vip_workflow->get_module_by( 'settings_slug', $page_requested ); if ( ! $requested_module ) { - wp_die( esc_html__( 'Not a registered Edit Flow module', 'edit-flow' ) ); + wp_die( esc_html__( 'Not a registered VIP Workflow module', 'vip-workflow' ) ); } $configure_callback = $requested_module->configure_page_cb; @@ -141,26 +105,13 @@ public function settings_page_controller() { // Don't show the settings page for the module if the module isn't activated if ( ! $this->module_enabled( $requested_module_name ) ) { - /* translators: 1: link to the settings page for Edit Flow */ - echo '

    ' . wp_kses( sprintf( __( 'Module not enabled. Please enable it from the Edit Flow settings page.', 'edit-flow' ), esc_url( EDIT_FLOW_SETTINGS_PAGE ) ), 'a' ) . '

    '; + /* translators: 1: link to the settings page for VIP Workflow */ + echo '

    ' . wp_kses( sprintf( __( 'Module not enabled. Please enable it from the VIP Workflow settings page.', 'vip-workflow' ), esc_url( VIP_WORKFLOW_SETTINGS_PAGE ) ), 'a' ) . '

    '; return; } $this->print_default_header( $requested_module ); - $edit_flow->$requested_module_name->$configure_callback(); - $this->print_default_footer( $requested_module ); - } - - /** - * Register settings for notifications so we can partially use the Settings API - * We use the Settings API for form generation, but not saving because we have our - * own way of handling the data. - * - * @since 0.10.0 - */ - public function register_settings() { - add_settings_section( $this->module->options_group_name . '_general', false, '__return_false', $this->module->options_group_name ); - add_settings_field( 'vip_features', __( 'Turn on WordPress VIP features', 'edit-flow' ), array( $this, 'settings_vip_features_option' ), $this->module->options_group_name, $this->module->options_group_name . '_general' ); + $vip_workflow->$requested_module_name->$configure_callback(); } /** @@ -179,7 +130,7 @@ public function print_default_header( $current_module ) { $message = false; } if ( $message && isset( $current_module->messages[ $message ] ) ) { - $display_text = '' . esc_html( $current_module->messages[ $message ] ) . ''; + $display_text = '' . esc_html( $current_module->messages[ $message ] ) . ''; } // If there's been an error, let's display it @@ -193,7 +144,7 @@ public function print_default_header( $current_module ) { $error = false; } if ( $error && isset( $current_module->messages[ $error ] ) ) { - $display_text = '' . esc_html( $current_module->messages[ $error ] ) . ''; + $display_text = '' . esc_html( $current_module->messages[ $error ] ) . ''; } if ( $current_module->img_url ) { @@ -202,13 +153,13 @@ public function print_default_header( $current_module ) { $page_icon = '

    '; } ?> -
    +
    name ) : ?> -

    title ); ?>

    +

    title ); ?>

    -

    +

    @@ -224,67 +175,38 @@ public function print_default_header( $current_module ) { //phpcs:enable:WordPress.Security.NonceVerification.Missing /** - * Adds Settings page for Edit Flow. + * Adds Settings page for VIP Workflow. */ public function print_default_settings() { ?> -
    +
    print_modules(); ?>
    module->options_group_name ); ?> module->options_group_name ); ?> module->name ) . '" />'; + echo ''; ?>

    __( 'Disabled', 'edit-flow' ), - 'on' => __( 'Enabled', 'edit-flow' ), - ); - echo ''; - } - - public function print_default_footer( $current_module ) { - ?> - slug ) : ?> -
    -

    Edit Flow is produced by Daniel Bachhuber, Mo Jangda, and Scott Bressler, with special help from Andrew Spittle and Andrew Witherspoon.', 'edit-flow' ), 'a' ); ?> - -
    -
    Noun Project.', 'edit-flow' ), 'a' ); ?> -
    Please give us your feedback, ideas, bug reports and comments in the WordPress.org forums.', 'edit-flow' ), 'a' ); ?> -

    -
    - - modules_count ) { - echo '
    ' . esc_html__( 'There are no Edit Flow modules registered', 'edit-flow' ) . '
    '; + if ( ! $vip_workflow->modules_count ) { + echo '
    ' . esc_html__( 'There are no VIP Workflow modules registered', 'vip-workflow' ) . '
    '; } else { - foreach ( $edit_flow->modules as $mod_name => $mod_data ) { + foreach ( $vip_workflow->modules as $mod_name => $mod_data ) { if ( $mod_data->autoload ) { continue; } $classes = array( - 'edit-flow-module', + 'vip-workflow-module', ); if ( 'on' == $mod_data->options->enabled ) { $classes[] = 'module-enabled'; @@ -305,28 +227,18 @@ public function print_modules() { } else { echo '

    ' . esc_html( $mod_data->short_description ) . '

    '; } - echo '

    '; + echo '

    '; if ( $mod_data->configure_page_cb ) { $configure_url = add_query_arg( 'page', $mod_data->settings_slug, get_admin_url( null, 'admin.php' ) ); - echo ''; } - echo 'options->enabled ) { - echo ' style="display:none;"'; - } - echo ' value="' . esc_textarea( __( 'Enable', 'edit-flow' ) ) . '" />'; - echo 'options->enabled ) { - echo ' style="display:none;"'; - } - echo ' value="' . esc_textarea( __( 'Disable', 'edit-flow' ) ) . '" />'; echo '

    '; - wp_nonce_field( 'change-edit-flow-module-nonce', 'change-module-nonce-' . $mod_data->slug, false ); + wp_nonce_field( 'change-vip-workflow-module-nonce', 'change-module-nonce-' . $mod_data->slug, false ); echo ''; echo '
    '; } @@ -356,7 +268,7 @@ public function helper_print_error_or_description( $field, $description ) { /** * Generate an option field to turn post type support on/off for a given module * - * @param object $module Edit Flow module we're generating the option field for + * @param object $module VIP Workflow module we're generating the option field for * @param {missing} * * @since 0.7 @@ -387,7 +299,7 @@ public function helper_option_custom_post_type( $module, $args = array() ) { // Leave a note to the admin as a reminder that add_post_type_support has been used somewhere in their code if ( post_type_supports( $post_type, $module->post_type_support ) ) { /* translators: 1: post type, 2: post type support */ - echo '   ' . esc_html( sprintf( __( 'Disabled because add_post_type_support( \'%1$s\', \'%2$s\' ) is included in a loaded file.', 'edit-flow' ), $post_type, $module->post_type_support ) ) . ''; + echo '   ' . esc_html( sprintf( __( 'Disabled because add_post_type_support( \'%1$s\', \'%2$s\' ) is included in a loaded file.', 'vip-workflow' ), $post_type, $module->post_type_support ) ) . ''; } echo '
    '; } @@ -401,32 +313,32 @@ public function helper_option_custom_post_type( $module, $args = array() ) { */ public function helper_settings_validate_and_save() { - if ( ! isset( $_POST['action'], $_POST['_wpnonce'], $_POST['option_page'], $_POST['_wp_http_referer'], $_POST['edit_flow_module_name'], $_POST['submit'] ) || ! is_admin() ) { + if ( ! isset( $_POST['action'], $_POST['_wpnonce'], $_POST['option_page'], $_POST['_wp_http_referer'], $_POST['vip_workflow_module_name'], $_POST['submit'] ) || ! is_admin() ) { return false; } - global $edit_flow; - $module_name = sanitize_key( $_POST['edit_flow_module_name'] ); + global $vip_workflow; + $module_name = sanitize_key( $_POST['vip_workflow_module_name'] ); if ( 'update' != $_POST['action'] - || $_POST['option_page'] != $edit_flow->$module_name->module->options_group_name ) { + || $_POST['option_page'] != $vip_workflow->$module_name->module->options_group_name ) { return false; } - if ( ! current_user_can( 'manage_options' ) || ! wp_verify_nonce( $_POST['_wpnonce'], $edit_flow->$module_name->module->options_group_name . '-options' ) ) { + if ( ! current_user_can( 'manage_options' ) || ! wp_verify_nonce( $_POST['_wpnonce'], $vip_workflow->$module_name->module->options_group_name . '-options' ) ) { wp_die( esc_html__( 'Cheatin’ uh?' ) ); } - $new_options = ( isset( $_POST[ $edit_flow->$module_name->module->options_group_name ] ) ) ? $_POST[ $edit_flow->$module_name->module->options_group_name ] : array(); + $new_options = ( isset( $_POST[ $vip_workflow->$module_name->module->options_group_name ] ) ) ? $_POST[ $vip_workflow->$module_name->module->options_group_name ] : array(); // Only call the validation callback if it exists? - if ( method_exists( $edit_flow->$module_name, 'settings_validate' ) ) { - $new_options = $edit_flow->$module_name->settings_validate( $new_options ); + if ( method_exists( $vip_workflow->$module_name, 'settings_validate' ) ) { + $new_options = $vip_workflow->$module_name->settings_validate( $new_options ); } // Cast our object and save the data. - $new_options = (object) array_merge( (array) $edit_flow->$module_name->module->options, $new_options ); - $edit_flow->update_all_module_options( $edit_flow->$module_name->module->name, $new_options ); + $new_options = (object) array_merge( (array) $vip_workflow->$module_name->module->options, $new_options ); + $vip_workflow->update_all_module_options( $vip_workflow->$module_name->module->name, $new_options ); // Redirect back to the settings page that was submitted without any previous messages $goback = add_query_arg( 'message', 'settings-updated', remove_query_arg( array( 'message' ), wp_get_referer() ) ); diff --git a/modules/settings/lib/settings.css b/modules/settings/lib/settings.css index 80f45171..d86fef8d 100644 --- a/modules/settings/lib/settings.css +++ b/modules/settings/lib/settings.css @@ -1,4 +1,4 @@ -/* @override http://localhost:8888/wpplugindev/wp-content/plugins/edit-flow/css/settings.css?ver=0.6.4 */ +/* @override http://localhost:8888/wpplugindev/wp-content/plugins/vip-workflow/css/settings.css?ver=0.6.4 */ .float-right { float:right; @@ -20,7 +20,7 @@ clear: both; } -.edit-flow-modules { +.vip-workflow-modules { width: 100%; overflow: hidden; margin-top: 20px; @@ -28,7 +28,7 @@ flex-wrap: wrap; } -.edit-flow-modules .edit-flow-module { +.vip-workflow-modules .vip-workflow-module { width: 250px; min-height: 150px; position: relative; @@ -43,14 +43,14 @@ margin-bottom: 15px; } -.edit-flow-modules .edit-flow-module p { +.vip-workflow-modules .vip-workflow-module p { font-size: 12px; color: #3d3d3d; line-height: 150%; font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif; } -.edit-flow-modules .edit-flow-module h4 { +.vip-workflow-modules .vip-workflow-module h4 { color: #000000; font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif; font-size: 17px; @@ -61,19 +61,19 @@ padding: 0; } -.edit-flow-modules .edit-flow-module .edit-flow-module-actions { +.vip-workflow-modules .vip-workflow-module .vip-workflow-module-actions { position: absolute; bottom: 0px; left: 10px; width: 250px; } -.edit-flow-modules .edit-flow-module .button-primary:hover { +.vip-workflow-modules .vip-workflow-module .button-primary:hover { color: #FFFFFF; border-color: #3B5D0C; } -.edit-flow-modules .edit-flow-module .button-primary.configure-edit-flow-module { +.vip-workflow-modules .vip-workflow-module .button-primary.configure-vip-workflow-module { color: #f1f1f1; border: solid 1px #666; background: #DDD; @@ -85,76 +85,76 @@ float: right; } -.edit-flow-modules .edit-flow-module .button-primary.enable-disable-edit-flow-module { +.vip-workflow-modules .vip-workflow-module .button-primary.enable-disable-vip-workflow-module { float: left; } -.edit-flow-modules .edit-flow-module .button-primary.configure-edit-flow-module:hover { +.vip-workflow-modules .vip-workflow-module .button-primary.configure-vip-workflow-module:hover { color: #FFF; border-color: #444; } -.edit-flow-admin a.cancel-settings-link { +.vip-workflow-admin a.cancel-settings-link { margin-left: 10px; } -.edit-flow-admin .inline-edit-row fieldset label span.title { +.vip-workflow-admin .inline-edit-row fieldset label span.title { width: 6em; } -.edit-flow-admin .inline-edit-row fieldset label span.input-text-wrap { +.vip-workflow-admin .inline-edit-row fieldset label span.input-text-wrap { margin-left: 6em; } -.edit-flow-admin .explanation, -.edit-flow-admin .explanation p { +.vip-workflow-admin .explanation, +.vip-workflow-admin .explanation p { font-size: 16px; line-height: 22px; } -.edit-flow-admin .explanation { +.vip-workflow-admin .explanation { margin-bottom: 1em; } -.edit-flow-admin .explanation p { +.vip-workflow-admin .explanation p { margin: 0.5em 0; } -.edit-flow-admin .tablenav { +.vip-workflow-admin .tablenav { display: none; } /* Display drag handles for the cursor on sortable list tables for our custom taxonomies */ -.edit-flow-admin table.wp-list-table tbody.ui-sortable tr.term-static { +.vip-workflow-admin table.wp-list-table tbody.ui-sortable tr.term-static { cursor: move; } -.edit-flow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper td, -.edit-flow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper .row-actions { +.vip-workflow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper td, +.vip-workflow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper .row-actions { visibility: hidden; } -.edit-flow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper { +.vip-workflow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper { border: 1px solid #DFDFDF; } -.edit-flow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper td.column-name { +.vip-workflow-admin table.wp-list-table tbody.ui-sortable tr.ui-sortable-helper td.column-name { visibility: visible; border-bottom: none; } /* Display disabled inputs with a very light gray background */ -.edit-flow-admin input[disabled] { +.vip-workflow-admin input[disabled] { background-color: #eee; } -.edit-flow-modules .edit-flow-module input.button, -.edit-flow-modules .edit-flow-module a.button { +.vip-workflow-modules .vip-workflow-module input.button, +.vip-workflow-modules .vip-workflow-module a.button { font-weight: normal; margin: 0; } -.edit-flow-modules .edit-flow-module a.button-primary { +.vip-workflow-modules .vip-workflow-module a.button-primary { float: right; } @@ -194,7 +194,7 @@ h3.nav-tab-wrapper { font-style: normal; } -.edit-flow-message { +.vip-workflow-message { position: relative; top: -5px; margin-left: 25px; @@ -202,26 +202,26 @@ h3.nav-tab-wrapper { font-size: 12px; line-height: 20px; padding-left: 25px; - padding-right: 25px; + padding-right: 25px; padding-top: 5px; padding-bottom: 4px; -moz-border-radius: 3px; -webkit-border-radius: 3px; - border-radius: 3px; + border-radius: 3px; } -.edit-flow-updated-message { +.vip-workflow-updated-message { background-color: #FFFFE0; border: 1px solid #E6DB55; } -.edit-flow-error-message { +.vip-workflow-error-message { background-color: #FFEBE8; border: 1px solid #CC0000; } /* Admin Menu Icon */ -#adminmenu .toplevel_page_ef-settings .wp-menu-image img { +#adminmenu .toplevel_page_vw-settings .wp-menu-image img { width: 16px; height: 16px; } diff --git a/modules/settings/lib/settings.js b/modules/settings/lib/settings.js index 3d6e0986..77027942 100644 --- a/modules/settings/lib/settings.js +++ b/modules/settings/lib/settings.js @@ -1,120 +1,25 @@ // Hide a given message -function edit_flow_hide_message() { - jQuery( '.edit-flow-message' ).fadeOut( function () { +function vip_workflow_hide_message() { + jQuery( '.vip-workflow-message' ).fadeOut( function () { jQuery( this ).remove(); } ); } jQuery( document ).ready( function () { - // Restore the Edit Flow submenu if there are no modules enabled + // Restore the VIP Workflow submenu if there are no modules enabled // We need it down below for dynamically rebuilding the link list when on the settings page - const ef_settings_submenu_html = - '
    Edit Flow
    '; - if ( jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).length == 0 ) { - jQuery( 'li#toplevel_page_ef-settings' ).addClass( + const vw_settings_submenu_html = + '
    VIP Workflow
    '; + if ( jQuery( 'li#toplevel_page_vw-settings .wp-submenu' ).length == 0 ) { + jQuery( 'li#toplevel_page_vw-settings' ).addClass( 'wp-has-submenu wp-has-current-submenu wp-menu-open' ); - jQuery( 'li#toplevel_page_ef-settings' ).append( ef_settings_submenu_html ); - jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).show(); + jQuery( 'li#toplevel_page_vw-settings' ).append( vw_settings_submenu_html ); + jQuery( 'li#toplevel_page_vw-settings .wp-submenu' ).show(); } // Set auto-removal to 8 seconds - if ( jQuery( '.edit-flow-message' ).length > 0 ) { - setTimeout( edit_flow_hide_message, 8000 ); + if ( jQuery( '.vip-workflow-message' ).length > 0 ) { + setTimeout( vip_workflow_hide_message, 8000 ); } - - jQuery( '.enable-disable-edit-flow-module' ).on( 'click', function () { - if ( jQuery( this ).hasClass( 'button-primary' ) ) { - var module_action = 'enable'; - } else if ( jQuery( this ).hasClass( 'button-remove' ) ) { - var module_action = 'disable'; - } - - const slug = jQuery( this ).closest( '.edit-flow-module' ).attr( 'id' ); - const change_module_nonce = jQuery( '#' + slug + ' #change-module-nonce-' + slug ).val(); - const data = { - action: 'change_edit_flow_module_state', - module_action, - slug, - change_module_nonce, - }; - - jQuery.post( ajaxurl, data, function ( response ) { - if ( response == 1 ) { - jQuery( '#' + slug + ' .enable-disable-edit-flow-module' ).hide(); - if ( module_action == 'disable' ) { - jQuery( '#' + slug ) - .addClass( 'module-disabled' ) - .removeClass( 'module-enabled' ); - jQuery( '#' + slug + ' .enable-disable-edit-flow-module.button-primary' ).show(); - jQuery( '#' + slug + ' a.configure-edit-flow-module' ) - .hide() - .addClass( 'hidden' ); - // If there was a configuration URL in the module, let's hide it from the left nav too - if ( jQuery( '#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { - var configure_url = jQuery( '#' + slug + ' a.configure-edit-flow-module' ) - .attr( 'href' ) - .replace( ef_admin_url, '' ); - var top_level_menu = jQuery( '#' + adminpage ); - jQuery( '.wp-submenu-wrap li a', top_level_menu ).each( function () { - if ( jQuery( this ).attr( 'href' ) == configure_url ) { - jQuery( this ) - .closest( 'li' ) - .fadeOut( function () { - jQuery( this ).remove(); - } ); - } - } ); - } - } else if ( module_action == 'enable' ) { - jQuery( '#' + slug ) - .addClass( 'module-enabled' ) - .removeClass( 'module-disabled' ); - jQuery( '#' + slug + ' .enable-disable-edit-flow-module.button-remove' ).show(); - jQuery( '#' + slug + ' a.configure-edit-flow-module' ) - .show() - .removeClass( 'hidden' ); - // If there was a configuration URL in the module, let's go through the complex process of adding it again to the left nav - if ( jQuery( '#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { - // Identify the order it should be in - let link_order = 0; - let counter = 0; - jQuery( '.edit-flow-module.has-configure-link' ).each( function ( key, item ) { - if ( - jQuery( this ).attr( 'id' ) == slug && - ! jQuery( 'a.configure-edit-flow-module', this ).hasClass( 'hidden' ) - ) { - link_order = counter; - } - if ( ! jQuery( 'a.configure-edit-flow-module', this ).hasClass( 'hidden' ) ) { - counter++; - } - } ); - // Build the HTML for the new link - var configure_url = jQuery( '#' + slug + ' a.configure-edit-flow-module' ) - .attr( 'href' ) - .replace( ef_admin_url, '' ); - var top_level_menu = jQuery( '#' + adminpage ); - const html_title = jQuery( '#' + slug + ' h4' ).html(); - const html_insert = - '
  • '; - jQuery( '.wp-submenu-wrap ul li', top_level_menu ).each( function ( key, item ) { - if ( key == link_order ) { - jQuery( this ).after( html_insert ); - } - } ); - // Trick way to do a fade in: add a class of 'ef-settings-fade-in' and run it after the action - jQuery( '.ef-settings-fade-in' ).fadeIn().removeClass( 'ef-settings-fade-in' ); - } - } - } - return false; - } ); - - return false; - } ); } ); diff --git a/modules/user-groups/class-user-groups.php b/modules/user-groups/class-user-groups.php index fefd1c9e..f0a29871 100644 --- a/modules/user-groups/class-user-groups.php +++ b/modules/user-groups/class-user-groups.php @@ -148,52 +148,7 @@ public function install() { * @since 0.7 */ public function upgrade( $previous_version ) { - global $vip_workflow; - - // Upgrade path to v0.7 - if ( version_compare( $previous_version, '0.7', '<' ) ) { - global $wpdb; - - // Set all of the user group terms to our new taxonomy - $wpdb->update( $wpdb->term_taxonomy, array( 'taxonomy' => self::TAXONOMY_KEY ), array( 'taxonomy' => 'following_usergroups' ) ); - - // Get all of the users who are a part of user groups and assign them to their new user group values - $query = "SELECT * FROM $wpdb->usermeta WHERE meta_key='wp_vw_usergroups';"; - // There's no userdata here in this query and it's an upgrade query - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared - $usergroup_users = $wpdb->get_results( $query ); - - // Sort all of the users based on their usergroup(s) - $users_to_add = array(); - foreach ( (array) $usergroup_users as $usergroup_user ) { - if ( is_object( $usergroup_user ) ) { - $users_to_add[ $usergroup_user->meta_value ][] = (int) $usergroup_user->user_id; - } - } - // Add user IDs to each usergroup - foreach ( $users_to_add as $usergroup_slug => $users_array ) { - $usergroup = $this->get_usergroup_by( 'slug', $usergroup_slug ); - $this->add_users_to_usergroup( $users_array, $usergroup->term_id ); - } - // Update the term slugs for each user group - $all_usergroups = $this->get_usergroups(); - foreach ( $all_usergroups as $usergroup ) { - $new_slug = str_replace( 'vw_', self::TERM_PREFIX, $usergroup->slug ); - $this->update_usergroup( $usergroup->term_id, array( 'slug' => $new_slug ) ); - } - - // Delete all of the previous usermeta values - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key='wp_vw_usergroups';" ); - - // Technically we've run this code before so we don't want to auto-install new data - $vip_workflow->update_module_option( $this->module->name, 'loaded_once', true ); - - } - // Upgrade path to v0.7.4 - if ( version_compare( $previous_version, '0.7.4', '<' ) ) { - // Usergroup descriptions become base64_encoded, instead of maybe json_encoded. - $this->upgrade_074_term_descriptions( self::TAXONOMY_KEY ); - } + // Nothing to do here yet } /** @@ -253,10 +208,6 @@ public function enqueue_admin_styles() { } } - /** - * Module ??? - */ - /** * Handles a POST request to add a new Usergroup. Redirects to edit view after * for admin to add users to usergroup diff --git a/modules/user-groups/lib/user-groups.css b/modules/user-groups/lib/user-groups.css index 23a66ab3..edb6a28d 100644 --- a/modules/user-groups/lib/user-groups.css +++ b/modules/user-groups/lib/user-groups.css @@ -1,34 +1,34 @@ /** Post subscriptions **/ -.ef-post_following_list { +.vw-post_following_list { } - .ef-post_following_list li { + .vw-post_following_list li { padding: 10px 5px 5px 5px; margin: 0; border-bottom: 1px solid #ccc; } - .ef-post_following_list li:hover { + .vw-post_following_list li:hover { background: #EAF2FA; } - .ef-post_following_list li input { + .vw-post_following_list li input { float: right; } - .ef-post_following_list .ef-user_displayname, - .ef-post_following_list .ef-usergroup_name { + .vw-post_following_list .vw-user_displayname, + .vw-post_following_list .vw-usergroup_name { display: block; font-size: 14px; } - .ef-post_following_list .ef-user_useremail, - .ef-post_following_list .ef-usergroup_description { + .vw-post_following_list .vw-user_useremail, + .vw-post_following_list .vw-usergroup_description { display: block; color: #ccc; font-size: 12px; } -#ef-post_following_box { - margin:10px 0; +#vw-post_following_box { + margin:10px 0; } - #ef-post_following_box h4 { + #vw-post_following_box h4 { background: #F1F1F1; font-weight: bold; padding: 8px; @@ -37,47 +37,41 @@ -moz-border-radius: 3px; } - #ef-post_following_box label.ef-select_all_box { + #vw-post_following_box label.vw-select_all_box { float: right; margin: -20px 10px; } - #ef-post_following_box label.ef-select_all_box input { + #vw-post_following_box label.vw-select_all_box input { margin-bottom: 5px; } - - #ef-post_following_users_box, - #ef-post_following_usergroups_box { - width: 49%; + + #vw-post_following_users_box, + #vw-post_following_usergroups_box { + width: 49%; } - #ef-post_following_users_box { + #vw-post_following_users_box { float: left; margin-right:10px; } - #ef-post_following_usergroups_box { + #vw-post_following_usergroups_box { float: right; } - #ef-post_following_users_box .ef-post_following_list, - #ef-post_following_usergroups_box .ef-post_following_list { + #vw-post_following_users_box .vw-post_following_list, + #vw-post_following_usergroups_box .vw-post_following_list { height: 300px; overflow: auto; } - #ef-post_following_users_box .list-filterizer-tools, - #ef-post_following_usergroups_box .list-filterizer-tools { + #vw-post_following_users_box .list-filterizer-tools, + #vw-post_following_usergroups_box .list-filterizer-tools { margin-top: 5px; } - /** User Groups **/ #profile-page #post_following_usergroups { width: 300px; } -#ef-usergroup-users form.quicksearch, -#ef-post_following_users_box form.quicksearch { - display: none; -} - -#ef-usergroup-users h4 { +#vw-usergroup-users h4 { margin-top: 0; -} \ No newline at end of file +} diff --git a/modules/user-groups/lib/user-groups.js b/modules/user-groups/lib/user-groups.js index a7766cad..eeab2456 100644 --- a/modules/user-groups/lib/user-groups.js +++ b/modules/user-groups/lib/user-groups.js @@ -1,3 +1,3 @@ jQuery( document ).ready( function () { - jQuery( '#ef-usergroup-users ul' ).listFilterizer(); + jQuery( '#vw-usergroup-users ul' ).listFilterizer(); } );