diff --git a/includes/admin/core/list-tables/roles-list-table.php b/includes/admin/core/list-tables/roles-list-table.php index 9b6929f4..743171c2 100644 --- a/includes/admin/core/list-tables/roles-list-table.php +++ b/includes/admin/core/list-tables/roles-list-table.php @@ -43,21 +43,19 @@ if ( isset( $_GET['action'] ) ) { delete_option( "um_role_{$role_key}_meta" ); /** - * UM hook + * Fires after delete UM role. * - * @type action - * @title um_after_delete_role - * @description After delete role - * @change_log - * ["Since: 2.6.3"] - * @usage add_action( 'um_after_delete_role', 'function_name', 10, 1 ); - * @example - * Make any custom action after deleting UM role. + * function my_custom_um_after_delete_role( $role_key, $role_meta ) { * // your code here * } - * ?> + * add_action( 'um_after_delete_role', 'my_custom_um_after_delete_role', 10, 2 ); */ do_action( 'um_after_delete_role', $role_key, $role_meta ); @@ -135,21 +133,19 @@ if ( isset( $_GET['action'] ) ) { delete_option( "um_role_{$role_key}_meta" ); /** - * UM hook + * Fires after delete UM role meta. * - * @type action - * @title um_after_delete_role_meta - * @description After delete role meta - * @change_log - * ["Since: 2.6.3"] - * @usage add_action( 'um_after_delete_role_meta', 'function_name', 10, 1 ); - * @example - * Make any custom action after deleting UM role meta. + * function my_custom_um_after_delete_role_meta( $role_key, $role_meta ) { * // your code here * } - * ?> + * add_action( 'um_after_delete_role_meta', 'my_custom_um_after_delete_role_meta', 10, 2 ); */ do_action( 'um_after_delete_role_meta', $role_key, $role_meta ); } @@ -400,9 +396,25 @@ class UM_Roles_List_Table extends WP_List_Table { } } + /** + * Filters the role actions in WP ListTable Ultimate Member > Roles screen. + * + * @since 2.6.3 + * @hook um_role_row_actions + * + * @param {array} $actions Action links. + * @param {string} $id Role key. + * + * @example Add custom action to role's row. + * function my_custom_um_role_row_actions( $actions, $id ) { + * $actions['{action_key}'] = "Action Title"; + * return $actions; + * } + * add_action( 'um_role_row_actions', 'my_custom_um_role_row_actions', 10, 2 ); + */ $actions = apply_filters( 'um_role_row_actions', $actions, $id ); - return sprintf('%1$s %2$s', '' . stripslashes( $item['name'] ) . '', $this->row_actions( $actions ) ); + return sprintf( '%1$s %2$s', '' . stripslashes( $item['name'] ) . '', $this->row_actions( $actions ) ); } diff --git a/includes/admin/templates/role/role-edit.php b/includes/admin/templates/role/role-edit.php index 0efc6307..175ba84f 100644 --- a/includes/admin/templates/role/role-edit.php +++ b/includes/admin/templates/role/role-edit.php @@ -1,4 +1,5 @@ -options()->update( 'custom_roles_increment', $auto_increment ); } + + $update = false; } - $role_meta = apply_filters( 'um_role_edit_data', $data, $id ); + /** + * Filters the role meta before save it to DB. + * + * @param {array} $data Role meta. + * @param {string} $id Role key. + * @param {bool} $update Create or update role. "True" if update. + * + * @since 2.6.3 + * @hook um_role_edit_data + * + * @example Add custom metadata for role on saving. + * function my_custom_um_role_edit_data( $data, $id, $update ) { + * $data['{meta_key}'] = {meta_value}; // set your meta key and meta value + * return $data; + * } + * add_action( 'um_role_edit_data', 'my_custom_um_role_edit_data', 10, 3 ); + * @example Force remove role's metadata on saving when update. + * function my_custom_um_role_edit_data( $data, $id, $update ) { + * if ( true === $update ) { + * unset( $data['{meta_key}'] ); // set your meta key + * } + * return $data; + * } + * add_action( 'um_role_edit_data', 'my_custom_um_role_edit_data', 10, 3 ); + */ + $role_meta = apply_filters( 'um_role_edit_data', $data, $id, $update ); unset( $role_meta['id'] ); update_option( "um_role_{$id}_meta", $role_meta ); diff --git a/includes/core/class-blocks.php b/includes/core/class-blocks.php index b1bbed6a..1c8eb590 100644 --- a/includes/core/class-blocks.php +++ b/includes/core/class-blocks.php @@ -81,6 +81,13 @@ if ( ! class_exists( 'um\core\Blocks' ) ) { * @param {bool} $disable_script Disabling block scripts variable. * * @return {bool} It's true for disabling block scripts. + * + * @example Disable block scripts. + * function my_custom_um_disable_blocks_script( $disable_script ) { + * $disable_script = true; + * return $disable_script; + * } + * add_filter( 'um_disable_blocks_script', 'my_custom_um_disable_blocks_script', 10, 1 ); */ $disable_script = apply_filters( 'um_disable_blocks_script', false ); if ( $disable_script ) {