From e78cd33aafbfbcfd38295b2bd0bbf62c9471361c Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 21 Nov 2024 20:18:00 +0300 Subject: [PATCH] Change activation toggle to native WP UI (#327) * remove activation toggle, use quick action links instead with a simple blue line for active rows * simplified deactivation links to have 'lazyblocks_activate_block' or 'lazyblocks_deactivate_block' get * build * display Inactive post state only when status if draft * changed active block row border color * simplified code that shows block status * Update class-blocks.php --------- Co-authored-by: Fellan-91 --- assets/admin/index.scss | 54 ++++--------------------------- build/admin-style-rtl.css | 2 +- build/admin-style.css | 2 +- classes/class-blocks.php | 67 +++++++++++++++++++++++++-------------- classes/class-tools.php | 4 +-- 5 files changed, 55 insertions(+), 74 deletions(-) diff --git a/assets/admin/index.scss b/assets/admin/index.scss index aff17e3d..a31198ab 100644 --- a/assets/admin/index.scss +++ b/assets/admin/index.scss @@ -30,10 +30,6 @@ width: 200px; } - tbody .check-column input { - margin-top: 9px !important; - } - @media screen and (max-width: 782px) { /* Hide column on mobile device */ th.column-lazyblocks_post_icon { @@ -59,52 +55,16 @@ } } - /** - * Toggle switch. - */ - $toggle_width: 28px; - $toggle_circle_size: 13px; - $toggle_margin: 2px; - - .column-lazyblocks_post_activate { - width: 35px; + .lazyblocks-activate-block { + color: #139a35; } - - .lazyblocks-block-activation-switch { - position: relative; - display: block; - background-color: #d9d9d9; - border-radius: 17px; - height: 17px; - margin-top: 12.5px; - width: $toggle_width; - } - - .lazyblocks-block-activation-switch::before { - background-color: #fff; - border-radius: 50%; - content: ""; - display: inline-block; - height: $toggle_circle_size; - margin: $toggle_margin; - transition: transform 0.2s; - width: $toggle_circle_size; - } - - .lazyblocks-active-block { - background-color: #007cba; - } - - .lazyblocks-active-block.lazyblocks-block-activation-switch::before { - transform: translateX($toggle_width - $toggle_circle_size - $toggle_margin * 2); - } - - .lazyblocks-active-block.lazyblocks-block-activation-switch:hover::before { - transform: translateX($toggle_width - $toggle_circle_size - $toggle_margin * 2 - 1px); + .lazyblocks-deactivate-block { + color: #c17d39; } - .lazyblocks-block-activation-switch:hover::before { - transform: translateX(1px); + .lazyblocks-row-active th.check-column { + border-left: 1px solid #007cba; + box-shadow: -1px 0 0 #007cba; } } diff --git a/build/admin-style-rtl.css b/build/admin-style-rtl.css index 1a35b6c1..5148dd10 100644 --- a/build/admin-style-rtl.css +++ b/build/admin-style-rtl.css @@ -1 +1 @@ -.post-type-lazyblocks .lzb-admin-block-icon{align-items:center;background:#e8e8e8;border-radius:8px;color:#4f5052;display:flex;font-size:16px;height:42px;justify-content:center;width:42px}.post-type-lazyblocks .lzb-admin-block-icon .dashicons{font-size:1em;height:1em;width:auto}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{text-align:center;width:42px}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_category{width:200px}.post-type-lazyblocks .wp-list-table tbody .check-column input{margin-top:9px!important}@media screen and (max-width:782px){.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{display:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon{float:left;min-width:42px;width:42px!important}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon:before{content:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-title{clear:right;overflow:hidden}}.post-type-lazyblocks .column-lazyblocks_post_activate{width:35px}.post-type-lazyblocks .lazyblocks-block-activation-switch{background-color:#d9d9d9;border-radius:17px;display:block;height:17px;margin-top:12.5px;position:relative;width:28px}.post-type-lazyblocks .lazyblocks-block-activation-switch:before{background-color:#fff;border-radius:50%;content:"";display:inline-block;height:13px;margin:2px;transition:transform .2s;width:13px}.post-type-lazyblocks .lazyblocks-active-block{background-color:#007cba}.post-type-lazyblocks .lazyblocks-active-block.lazyblocks-block-activation-switch:before{transform:translateX(11px)}.post-type-lazyblocks .lazyblocks-active-block.lazyblocks-block-activation-switch:hover:before{transform:translateX(10px)}.post-type-lazyblocks .lazyblocks-block-activation-switch:hover:before{transform:translateX(1px)}.lzb-admin-toolbar{background-color:#fff;border-bottom:1px solid #d7dbde}@media screen and (max-width:600px){.lzb-admin-toolbar{display:none}}#wpcontent .lzb-admin-toolbar{margin-left:-20px;padding-left:20px}.lzb-admin-toolbar h2{display:inline-block;font-size:14px;line-height:2.5714;margin:0 10px 0 0;padding:5px 0}.lzb-admin-toolbar h2 img{margin-right:5px;margin-top:-5px;opacity:.75;vertical-align:middle}.lzb-admin-toolbar .lzb-admin-toolbar-tab{color:inherit;display:inline-block;font-size:14px;line-height:2.5714;margin:0 2px;padding:5px 10px;text-decoration:none}.lzb-admin-toolbar .lzb-admin-toolbar-tab.is-active{border-bottom:3px solid #007cba;padding-bottom:2px}.lzb-admin-toolbar .lzb-admin-toolbar-tab:focus,.lzb-admin-toolbar .lzb-admin-toolbar-tab:hover{color:#007cba}.lzb-admin-toolbar .lzb-admin-toolbar-tab .dashicons{line-height:2}#adminmenu a[href*="lazyblocks.com/pro/"],.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"],.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]{color:#e24a62;font-weight:700}#adminmenu a[href*="lazyblocks.com/pro/"] .dashicons,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"] .dashicons,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"] .dashicons{transition:none}#adminmenu a[href*="lazyblocks.com/pro/"]:focus,#adminmenu a[href*="lazyblocks.com/pro/"]:hover,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:focus,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:hover,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:focus,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:hover{color:#e11937} +.post-type-lazyblocks .lzb-admin-block-icon{align-items:center;background:#e8e8e8;border-radius:8px;color:#4f5052;display:flex;font-size:16px;height:42px;justify-content:center;width:42px}.post-type-lazyblocks .lzb-admin-block-icon .dashicons{font-size:1em;height:1em;width:auto}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{text-align:center;width:42px}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_category{width:200px}@media screen and (max-width:782px){.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{display:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon{float:left;min-width:42px;width:42px!important}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon:before{content:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-title{clear:right;overflow:hidden}}.post-type-lazyblocks .lazyblocks-activate-block{color:#139a35}.post-type-lazyblocks .lazyblocks-deactivate-block{color:#c17d39}.post-type-lazyblocks .lazyblocks-row-active th.check-column{border-left:1px solid #007cba;box-shadow:-1px 0 0 #007cba}.lzb-admin-toolbar{background-color:#fff;border-bottom:1px solid #d7dbde}@media screen and (max-width:600px){.lzb-admin-toolbar{display:none}}#wpcontent .lzb-admin-toolbar{margin-left:-20px;padding-left:20px}.lzb-admin-toolbar h2{display:inline-block;font-size:14px;line-height:2.5714;margin:0 10px 0 0;padding:5px 0}.lzb-admin-toolbar h2 img{margin-right:5px;margin-top:-5px;opacity:.75;vertical-align:middle}.lzb-admin-toolbar .lzb-admin-toolbar-tab{color:inherit;display:inline-block;font-size:14px;line-height:2.5714;margin:0 2px;padding:5px 10px;text-decoration:none}.lzb-admin-toolbar .lzb-admin-toolbar-tab.is-active{border-bottom:3px solid #007cba;padding-bottom:2px}.lzb-admin-toolbar .lzb-admin-toolbar-tab:focus,.lzb-admin-toolbar .lzb-admin-toolbar-tab:hover{color:#007cba}.lzb-admin-toolbar .lzb-admin-toolbar-tab .dashicons{line-height:2}#adminmenu a[href*="lazyblocks.com/pro/"],.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"],.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]{color:#e24a62;font-weight:700}#adminmenu a[href*="lazyblocks.com/pro/"] .dashicons,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"] .dashicons,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"] .dashicons{transition:none}#adminmenu a[href*="lazyblocks.com/pro/"]:focus,#adminmenu a[href*="lazyblocks.com/pro/"]:hover,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:focus,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:hover,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:focus,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:hover{color:#e11937} diff --git a/build/admin-style.css b/build/admin-style.css index 1a35b6c1..5148dd10 100644 --- a/build/admin-style.css +++ b/build/admin-style.css @@ -1 +1 @@ -.post-type-lazyblocks .lzb-admin-block-icon{align-items:center;background:#e8e8e8;border-radius:8px;color:#4f5052;display:flex;font-size:16px;height:42px;justify-content:center;width:42px}.post-type-lazyblocks .lzb-admin-block-icon .dashicons{font-size:1em;height:1em;width:auto}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{text-align:center;width:42px}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_category{width:200px}.post-type-lazyblocks .wp-list-table tbody .check-column input{margin-top:9px!important}@media screen and (max-width:782px){.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{display:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon{float:left;min-width:42px;width:42px!important}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon:before{content:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-title{clear:right;overflow:hidden}}.post-type-lazyblocks .column-lazyblocks_post_activate{width:35px}.post-type-lazyblocks .lazyblocks-block-activation-switch{background-color:#d9d9d9;border-radius:17px;display:block;height:17px;margin-top:12.5px;position:relative;width:28px}.post-type-lazyblocks .lazyblocks-block-activation-switch:before{background-color:#fff;border-radius:50%;content:"";display:inline-block;height:13px;margin:2px;transition:transform .2s;width:13px}.post-type-lazyblocks .lazyblocks-active-block{background-color:#007cba}.post-type-lazyblocks .lazyblocks-active-block.lazyblocks-block-activation-switch:before{transform:translateX(11px)}.post-type-lazyblocks .lazyblocks-active-block.lazyblocks-block-activation-switch:hover:before{transform:translateX(10px)}.post-type-lazyblocks .lazyblocks-block-activation-switch:hover:before{transform:translateX(1px)}.lzb-admin-toolbar{background-color:#fff;border-bottom:1px solid #d7dbde}@media screen and (max-width:600px){.lzb-admin-toolbar{display:none}}#wpcontent .lzb-admin-toolbar{margin-left:-20px;padding-left:20px}.lzb-admin-toolbar h2{display:inline-block;font-size:14px;line-height:2.5714;margin:0 10px 0 0;padding:5px 0}.lzb-admin-toolbar h2 img{margin-right:5px;margin-top:-5px;opacity:.75;vertical-align:middle}.lzb-admin-toolbar .lzb-admin-toolbar-tab{color:inherit;display:inline-block;font-size:14px;line-height:2.5714;margin:0 2px;padding:5px 10px;text-decoration:none}.lzb-admin-toolbar .lzb-admin-toolbar-tab.is-active{border-bottom:3px solid #007cba;padding-bottom:2px}.lzb-admin-toolbar .lzb-admin-toolbar-tab:focus,.lzb-admin-toolbar .lzb-admin-toolbar-tab:hover{color:#007cba}.lzb-admin-toolbar .lzb-admin-toolbar-tab .dashicons{line-height:2}#adminmenu a[href*="lazyblocks.com/pro/"],.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"],.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]{color:#e24a62;font-weight:700}#adminmenu a[href*="lazyblocks.com/pro/"] .dashicons,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"] .dashicons,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"] .dashicons{transition:none}#adminmenu a[href*="lazyblocks.com/pro/"]:focus,#adminmenu a[href*="lazyblocks.com/pro/"]:hover,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:focus,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:hover,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:focus,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:hover{color:#e11937} +.post-type-lazyblocks .lzb-admin-block-icon{align-items:center;background:#e8e8e8;border-radius:8px;color:#4f5052;display:flex;font-size:16px;height:42px;justify-content:center;width:42px}.post-type-lazyblocks .lzb-admin-block-icon .dashicons{font-size:1em;height:1em;width:auto}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{text-align:center;width:42px}.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_category{width:200px}@media screen and (max-width:782px){.post-type-lazyblocks .wp-list-table th.column-lazyblocks_post_icon{display:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon{float:left;min-width:42px;width:42px!important}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-lazyblocks_post_icon:before{content:none}.post-type-lazyblocks .wp-list-table tr:not(.inline-edit-row,.no-items) td.column-title{clear:right;overflow:hidden}}.post-type-lazyblocks .lazyblocks-activate-block{color:#139a35}.post-type-lazyblocks .lazyblocks-deactivate-block{color:#c17d39}.post-type-lazyblocks .lazyblocks-row-active th.check-column{border-left:1px solid #007cba;box-shadow:-1px 0 0 #007cba}.lzb-admin-toolbar{background-color:#fff;border-bottom:1px solid #d7dbde}@media screen and (max-width:600px){.lzb-admin-toolbar{display:none}}#wpcontent .lzb-admin-toolbar{margin-left:-20px;padding-left:20px}.lzb-admin-toolbar h2{display:inline-block;font-size:14px;line-height:2.5714;margin:0 10px 0 0;padding:5px 0}.lzb-admin-toolbar h2 img{margin-right:5px;margin-top:-5px;opacity:.75;vertical-align:middle}.lzb-admin-toolbar .lzb-admin-toolbar-tab{color:inherit;display:inline-block;font-size:14px;line-height:2.5714;margin:0 2px;padding:5px 10px;text-decoration:none}.lzb-admin-toolbar .lzb-admin-toolbar-tab.is-active{border-bottom:3px solid #007cba;padding-bottom:2px}.lzb-admin-toolbar .lzb-admin-toolbar-tab:focus,.lzb-admin-toolbar .lzb-admin-toolbar-tab:hover{color:#007cba}.lzb-admin-toolbar .lzb-admin-toolbar-tab .dashicons{line-height:2}#adminmenu a[href*="lazyblocks.com/pro/"],.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"],.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]{color:#e24a62;font-weight:700}#adminmenu a[href*="lazyblocks.com/pro/"] .dashicons,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"] .dashicons,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"] .dashicons{transition:none}#adminmenu a[href*="lazyblocks.com/pro/"]:focus,#adminmenu a[href*="lazyblocks.com/pro/"]:hover,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:focus,.lzb-admin-toolbar a[href*="lazyblocks.com/pro/"]:hover,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:focus,.wp-list-table.plugins a[href*="lazyblocks.com/pro/"]:hover{color:#e11937} diff --git a/classes/class-blocks.php b/classes/class-blocks.php index ae101b72..ec05675c 100644 --- a/classes/class-blocks.php +++ b/classes/class-blocks.php @@ -62,7 +62,9 @@ public function __construct() { add_action( 'admin_init', array( $this, 'add_role_caps' ) ); // Additional elements in blocks list table. + add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 ); add_filter( 'disable_months_dropdown', array( $this, 'disable_months_dropdown' ), 10, 2 ); + add_filter( 'post_class', array( $this, 'post_class' ), 10, 3 ); add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 ); add_filter( 'manage_lazyblocks_posts_columns', array( $this, 'manage_posts_columns' ) ); add_filter( 'manage_lazyblocks_posts_custom_column', array( $this, 'manage_posts_custom_column' ), 10, 2 ); @@ -78,7 +80,6 @@ public function __construct() { add_action( 'save_post', array( $this, 'normalize_lazyblocks_post_status' ), 20, 2 ); // Disabled the display of statuses in the list of blocks and replaced the Draft title in the submenu to Inactive. - add_action( 'display_post_states', array( $this, 'disable_post_states' ), 20, 2 ); add_filter( 'views_edit-lazyblocks', array( $this, 'change_activation_views_labels' ) ); // add gutenberg blocks assets. @@ -94,15 +95,19 @@ public function __construct() { } /** - * Disabled display of post statuses in the list of all blocks. + * Display inactive state and disable other post statuses in the list of all blocks. * * @param array $post_states - Block States. * @param WP_Post $post - Post Object with all post parameters. * @return array */ - public function disable_post_states( $post_states, $post ) { + public function display_post_states( $post_states, $post ) { if ( 'lazyblocks' === $post->post_type ) { $post_states = array(); + + if ( 'draft' === $post->post_status ) { + $post_states['lazyblocks-inactive'] = __( 'Inactive', 'lazy-blocks' ); + } } return $post_states; @@ -285,6 +290,26 @@ public function disable_months_dropdown( $return, $post_type ) { return 'lazyblocks' === $post_type ? true : $return; } + /** + * Add active/inactive class to row + * + * @param array $classes Array of post classes. + * @param array $class Additional classes added to the post. + * @param int $post_id The post ID. + * @return array + */ + public function post_class( $classes, $class, $post_id ) { + if ( ! is_admin() ) { + return $classes; + } + + if ( get_post_type( $post_id ) === 'lazyblocks' ) { + $classes[] = get_post_status( $post_id ) === 'publish' ? 'lazyblocks-row-active' : 'lazyblocks-row-inactive'; + } + + return $classes; + } + /** * Add featured image in lazyblocks list * @@ -336,6 +361,22 @@ public function post_row_actions( $actions = array(), $post = null ) { ), esc_html__( 'Export', 'lazy-blocks' ) ), + 'activate' => sprintf( + '%4$s', + add_query_arg( + array( + ( 'publish' === $post->post_status ? 'lazyblocks_deactivate_block' : 'lazyblocks_activate_block' ) => $post->ID, + 'lazyblocks_activate_block_nonce' => wp_create_nonce( 'lzb-activate-block-nonce' ), + ) + ), + sprintf( + // translators: %1$ - post title. + 'publish' === $post->post_status ? esc_html__( 'Deactivate ā€œ%1$sā€', 'lazy-blocks' ) : esc_html__( 'Activate ā€œ%1$sā€', 'lazy-blocks' ), + get_the_title( $post->ID ) + ), + 'publish' === $post->post_status ? 'lazyblocks-deactivate-block' : 'lazyblocks-activate-block', + 'publish' === $post->post_status ? esc_html__( 'Deactivate', 'lazy-blocks' ) : esc_html__( 'Activate', 'lazy-blocks' ) + ), ), array_slice( $actions, 1 ) ); @@ -397,7 +438,6 @@ public function handle_bulk_actions_edit( $redirect, $action, $post_ids ) { public function manage_posts_columns( $columns = array() ) { $columns = array( 'cb' => $columns['cb'], - 'lazyblocks_post_activate' => '', 'lazyblocks_post_icon' => esc_html__( 'Icon', 'lazy-blocks' ), 'title' => $columns['title'], 'lazyblocks_post_category' => esc_html__( 'Category', 'lazy-blocks' ), @@ -415,25 +455,6 @@ public function manage_posts_columns( $columns = array() ) { public function manage_posts_custom_column( $column_name = false ) { global $post; - // Displaying buttons for block activation and deactivation. - if ( 'lazyblocks_post_activate' === $column_name ) { - $classes = 'lazyblocks-block-activation-switch'; - - if ( 'publish' === $post->post_status ) { - $classes .= ' lazyblocks-active-block'; - } - - $link = add_query_arg( - array( - 'lazyblocks_activate_block' => $post->ID, - 'lazyblocks_activate_block_action' => 'publish' === $post->post_status ? 'deactivate' : 'activate', - 'lazyblocks_activate_block_nonce' => wp_create_nonce( 'lzb-activate-block-nonce' ), - ) - ); - - echo ' '; - } - if ( 'lazyblocks_post_icon' === $column_name ) { $icon = $this->prepare_block_icon( $this->get_meta_value_by_id( 'lazyblocks_icon' ) ); $admin_url = get_edit_post_link( $post->ID ); diff --git a/classes/class-tools.php b/classes/class-tools.php index 2c7d6f64..03e0df7f 100644 --- a/classes/class-tools.php +++ b/classes/class-tools.php @@ -343,8 +343,8 @@ public function maybe_activate_block() { return; } - $post_id = filter_input( INPUT_GET, 'lazyblocks_activate_block', FILTER_SANITIZE_NUMBER_INT ); - $action = isset( $_GET['lazyblocks_activate_block_action'] ) ? sanitize_text_field( wp_unslash( $_GET['lazyblocks_activate_block_action'] ) ) : false; + $action = isset( $_GET['lazyblocks_activate_block'] ) ? 'activate' : ( isset( $_GET['lazyblocks_deactivate_block'] ) ? 'deactivate' : false ); + $post_id = filter_input( INPUT_GET, 'activate' === $action ? 'lazyblocks_activate_block' : 'lazyblocks_deactivate_block', FILTER_SANITIZE_NUMBER_INT ); if ( $post_id && $action && current_user_can( 'edit_lazyblock', $post_id ) ) { if ( 'activate' === $action ) {