LLMS_Admin_Post_Tables::handle_link_actions()

Handle events for our custom postrow actions


Return Return

(void)


Top ↑

Source Source

File: includes/admin/post-types/class.llms.post.tables.php

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
public function handle_link_actions() {
 
    $action = llms_filter_input( INPUT_GET, 'action' );
 
    // Bail early if request doesn't concern us.
    if ( empty( $action ) ) {
        return;
    }
 
    // Bail early if it isn't a clone/ export request.
    if ( 'llms-clone-post' !== $action && 'llms-export-post' !== $action ) {
        return;
    }
 
    $post_id = llms_filter_input( INPUT_GET, 'post' );
 
    // Bail if there's no post ID.
    if ( empty( $post_id ) ) {
        wp_die( __( 'Missing post ID.', 'lifterlms' ) );
    }
 
    $post = get_post( $post_id );
 
    // Bail if post ID is invalid.
    if ( ! $post ) {
        wp_die( __( 'Invalid post ID.', 'lifterlms' ) );
    }
 
    // Bail if the action isn't supported on post type.
    if ( ! post_type_supports( $post->post_type, $action ) ) {
        wp_die( __( 'Action cannot be executed on the current post.', 'lifterlms' ) );
    }
 
    // Bail if user doesn't have permissions.
    if ( ! current_user_can( 'edit_course', $post->ID ) ) {
        wp_die( __( 'You are not authorized to perform this action on the current post.', 'lifterlms' ) );
    }
 
    $post = llms_get_post( $post );
 
    // Run export or clone action as needed.
    switch ( $action ) {
 
        case 'llms-export-post':
            $post->export();
            break;
 
        case 'llms-clone-post':
            $r = $post->clone_post();
            if ( is_wp_error( $r ) ) {
                LLMS_Admin_Notices::flash_notice( $r->get_error_message(), 'error' );
            }
            wp_redirect( admin_url( 'edit.php?post_type=' . $post->get( 'type' ) ) );
            exit;
 
    }
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.33.1 Use edit_course cap instead of edit_post cap.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.