LLMS_Blocks_Status_Tools

LLMS_Blocks_Status_Tools class.


Source Source

File: libraries/lifterlms-blocks/includes/class-llms-blocks-status-tools.php

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class LLMS_Blocks_Status_Tools {
 
    /**
     * Constructor.
     *
     * @since 1.4.0
     */
    public function __construct() {
 
        if ( class_exists( 'Classic_Editor' ) ) {
 
            add_filter( 'llms_status_tools', array( $this, 'add_tools' ) );
            add_action( 'llms_status_tool', array( $this, 'maybe_toggle_mode' ) );
 
        }
 
    }
 
    /**
     * Add status page tools
     *
     * @since 1.4.0
     *
     * @param array $tools array of tools.
     * @return array
     */
    public function add_tools( $tools ) {
 
        global $llms_blocks_migrate;
        $posts = $llms_blocks_migrate->get_migrated_posts();
 
        if ( $posts->found_posts ) {
 
            $desc  = __( 'Removes block editor code from all courses and lessons which were migrated to the block editor during an upgrade to WordPress 5.0 or later. If you installed the Classic Editor plugin after upgrading and see duplicate content items (such as the course syllabus or lesson mark complete button) this tool will remove the duplicates.', 'lifterlms' );
            $desc .= '<br><br>';
            // Translators: %d = number of affected courses/lessons.
            $desc .= sprintf( __( 'Currently %d courses and/or lessons are affected.', 'lifterlms' ), $posts->found_posts );
 
            $tools['blocks-unmigrate'] = array(
                'description' => $desc,
                'label'       => __( 'Remove LifterLMS Block Code', 'lifterlms' ),
                'text'        => __( 'Remove Block Code', 'lifterlms' ),
            );
 
        }
 
        return $tools;
 
    }
 
    /**
     * Run tool actions on tool page form submission.
     *
     * @since 1.4.0
     *
     * @param string $tool ID of the tool being run.
     * @return void
     */
    public function maybe_toggle_mode( $tool ) {
 
        if ( 'blocks-unmigrate' !== $tool ) {
            return;
        }
 
        do_action( 'llms_blocks_unmigrate_posts' );
 
    }
 
}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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