- added comments;

This commit is contained in:
Mykyta Synelnikov
2023-06-08 13:52:11 +03:00
parent 78d326fc47
commit 336e807a50
3 changed files with 75 additions and 27 deletions
@@ -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
* <?php
* add_action( 'um_after_delete_role', 'um_after_delete_role', 10, 1 );
* function um_after_delete_role( $role_key ) {
* @since 2.6.3
* @hook um_after_delete_role
*
* @param {string} $role_key Role key.
* @param {array} $role_meta Role meta.
*
* @example <caption>Make any custom action after deleting UM role.</caption>
* 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
* <?php
* add_action( 'um_after_delete_role_meta', 'um_after_delete_role_meta', 10, 1 );
* function um_after_delete_role_meta( $role_key ) {
* @since 2.6.3
* @hook um_after_delete_role_meta
*
* @param {string} $role_key Role key.
* @param {array} $role_meta Role meta.
*
* @example <caption>Make any custom action after deleting UM role meta.</caption>
* 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 <caption>Add custom action to role's row.</caption>
* function my_custom_um_role_row_actions( $actions, $id ) {
* $actions['{action_key}'] = "<a href="{action_link}">Action Title</a>";
* 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', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $id ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
return sprintf( '%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $id ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
}
+31 -2
View File
@@ -1,4 +1,5 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -124,6 +125,7 @@ if ( ! empty( $_POST['role'] ) ) {
if ( '' === $error ) {
$update = true;
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
$roles = get_option( 'um_roles', array() );
$roles[] = $id;
@@ -134,9 +136,36 @@ if ( ! empty( $_POST['role'] ) ) {
$auto_increment++;
UM()->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 <caption>Add custom metadata for role on saving.</caption>
* 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 <caption>Force remove role's metadata on saving when update.</caption>
* 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 );
+7
View File
@@ -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 <caption>Disable block scripts.</caption>
* 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 ) {