wp_set_post_lock example

if ( isset( $translated[ $field ] ) ) {
                $translated[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field$translated[ $field ] );
            }
        }

        wp_update_post( $translated );
    }

    // Now that we have an ID we can fix any attachment anchor hrefs.     _fix_attachment_links( $post_id );

    wp_set_post_lock( $post_id );

    if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
        if ( ! empty( $post_data['sticky'] ) ) {
            stick_post( $post_id );
        } else {
            unstick_post( $post_id );
        }
    }

    return $post_id;
}

/* translators: %s: User's display name. */
                'text' => sprintf( __( '%s has taken over and is currently editing.' )$user->display_name ),
            );

            if ( get_option( 'show_avatars' ) ) {
                $error['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 64 ) );
                $error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) );
            }

            $send['lock_error'] = $error;
        } else {
            $new_lock = wp_set_post_lock( $post_id );

            if ( $new_lock ) {
                $send['new_lock'] = implode( ':', $new_lock );
            }
        }

        $response['wp-refresh-post-lock'] = $send;
    }

    return $response;
}

if ( ! current_user_can( 'edit_post', $post_id ) ) {
            wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
        }

        if ( 'trash' === $post->post_status ) {
            wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ) );
        }

        if ( ! empty( $_GET['get-post-lock'] ) ) {
            check_admin_referer( 'lock-post_' . $post_id );
            wp_set_post_lock( $post_id );
            wp_redirect( get_edit_post_link( $post_id, 'url' ) );
            exit;
        }

        $post_type = $post->post_type;
        if ( 'post' === $post_type ) {
            $parent_file   = 'edit.php';
            $submenu_file  = 'edit.php';
            $post_new_file = 'post-new.php';
        } elseif ( 'attachment' === $post_type ) {
            $parent_file   = 'upload.php';
            
'avatar' => get_avatar_url( $user_id, array( 'size' => 128 ) ),
            'name'   => $user->display_name,
        );
    }

    $lock_details = array(
        'isLocked' => $locked,
        'user'     => $user_details,
    );
} else {
    // Lock the post.     $active_post_lock = wp_set_post_lock( $post->ID );
    if ( $active_post_lock ) {
        $active_post_lock = esc_attr( implode( ':', $active_post_lock ) );
    }

    $lock_details = array(
        'isLocked'       => false,
        'activePostLock' => $active_post_lock,
    );
}

/** * Filters the body placeholder text. * * @since 5.0.0 * @since 5.8.0 Changed the default placeholder text. * * @param string $text Placeholder text. Default 'Type / to choose a block'. * @param WP_Post $post Post object. */
Home | Imprint | This part of the site doesn't use cookies.