LLMS_Admin_Assets::admin_scripts()
Enqueue scripts
Return Return
(void)
Source Source
File: includes/admin/class.llms.admin.assets.php
* @since 7.2.0 Use `LLMS_ASSETS_VERSION` for asset versions. * Enqueue reporting scripts on dashboard page. * @since 7.4.1 Enqueue `postbox` script on the new resources page. * * @return void */ public function admin_scripts() { global $post_type; $screen = get_current_screen(); if ( 'widgets' === $screen->id ) { wp_enqueue_script( 'llms-widget-syllabus', LLMS_PLUGIN_URL . 'assets/js/llms-widget-syllabus' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } llms()->assets->register_script( 'llms-select2' ); wp_register_script( 'llms-metaboxes', LLMS_PLUGIN_URL . 'assets/js/llms-metaboxes' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-datepicker', 'llms-admin-scripts', 'llms-select2' ), LLMS_ASSETS_VERSION, true ); if ( ( post_type_exists( $screen->id ) && post_type_supports( $screen->id, 'llms-membership-restrictions' ) ) || 'dashboard_page_llms-setup' === $screen->id ) { wp_enqueue_script( 'llms-metaboxes' ); } $tables = apply_filters( 'llms_load_table_resources_pages', array( 'course', 'lifterlms_page_llms-reporting', 'llms_membership', ) ); if ( in_array( $screen->id, $tables, true ) ) { wp_register_script( 'llms-admin-tables', LLMS_PLUGIN_URL . 'assets/js/llms-admin-tables' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); wp_enqueue_script( 'llms-admin-tables' ); } wp_register_script( 'llms', LLMS_PLUGIN_URL . 'assets/js/llms' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); wp_register_script( 'llms-admin-scripts', LLMS_PLUGIN_URL . 'assets/js/llms-admin' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'llms', 'llms-select2' ), LLMS_ASSETS_VERSION, true ); if ( $this->is_llms_page() ) { llms()->assets->enqueue_script( 'llms' ); wp_enqueue_script( 'jquery-ui-datepicker' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'llms-admin-scripts' ); wp_register_style( 'jquery-ui-flick', LLMS_PLUGIN_URL . 'assets/vendor/jquery-ui-flick/jquery-ui-flick' . LLMS_ASSETS_SUFFIX . '.css', array(), '1.11.2' ); wp_enqueue_style( 'jquery-ui-flick' ); wp_enqueue_script( 'llms-ajax', LLMS_PLUGIN_URL . 'assets/js/llms-ajax' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); wp_enqueue_media(); if ( 'course' === $post_type ) { wp_enqueue_script( 'llms-metabox-fields', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-fields' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } if ( 'course' === $post_type || 'llms_membership' === $post_type ) { wp_enqueue_script( 'llms-metabox-students', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-students' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'llms-select2' ), LLMS_ASSETS_VERSION, true ); wp_enqueue_script( 'llms-metabox-product', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-product' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'llms' ), LLMS_ASSETS_VERSION, true ); wp_enqueue_script( 'llms-metabox-instructors', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-instructors' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'llms' ), LLMS_ASSETS_VERSION, true ); } if ( 'lesson' === $post_type ) { wp_enqueue_script( 'llms-metabox-fields', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-fields' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } if ( in_array( $post_type, array( 'llms_certificate', 'llms_my_certificate' ), true ) ) { wp_enqueue_script( 'llms-metabox-certificate', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-certificate' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } if ( in_array( $post_type, array( 'llms_achievement', 'llms_my_achievement' ), true ) ) { wp_enqueue_script( 'llms-metabox-achievement', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-achievement' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } if ( 'llms_membership' === $post_type ) { wp_enqueue_script( 'llms-metabox-fields', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-fields' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } if ( 'llms_voucher' === $post_type ) { wp_enqueue_script( 'llms-metabox-voucher', LLMS_PLUGIN_URL . 'assets/js/llms-metabox-voucher' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); } $this->maybe_enqueue_reporting( $screen ); wp_enqueue_script( 'llms' ); wp_enqueue_script( 'llms-metaboxes' ); // Load forms advert/compat script. if ( 'edit-llms_form' === $screen->id ) { llms()->assets->enqueue_script( 'llms-admin-forms' ); } } if ( 'dashboard' === $screen->base ) { $this->maybe_enqueue_reporting( $screen ); } if ( 'lifterlms_page_llms-settings' === $screen->id ) { wp_enqueue_media(); wp_enqueue_script( 'llms-admin-settings', LLMS_PLUGIN_URL . 'assets/js/llms-admin-settings' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-sortable' ), LLMS_ASSETS_VERSION, true ); } elseif ( 'admin_page_llms-course-builder' === $screen->id ) { self::register_quill(); wp_enqueue_editor(); wp_enqueue_style( 'llms-builder-styles', LLMS_PLUGIN_URL . 'assets/css/builder' . LLMS_ASSETS_SUFFIX . '.css', array( 'llms-quill-bubble' ), LLMS_ASSETS_VERSION, 'screen' ); wp_style_add_data( 'llms-builder-styles', 'rtl', 'replace' ); wp_style_add_data( 'llms-builder-styles', 'suffix', LLMS_ASSETS_SUFFIX ); wp_enqueue_style( 'webui-popover', LLMS_PLUGIN_URL . 'assets/vendor/webui-popover/jquery.webui-popover' . LLMS_ASSETS_SUFFIX . '.css', array(), '1.2.15' ); wp_style_add_data( 'webui-popover', 'suffix', LLMS_ASSETS_SUFFIX ); wp_enqueue_script( 'webui-popover', LLMS_PLUGIN_URL . 'assets/vendor/webui-popover/jquery.webui-popover' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), LLMS_ASSETS_VERSION, true ); wp_enqueue_style( 'llms-datetimepicker', LLMS_PLUGIN_URL . 'assets/vendor/datetimepicker/jquery.datetimepicker.min.css', array(), '1.3.4' ); wp_enqueue_script( 'llms-datetimepicker', LLMS_PLUGIN_URL . 'assets/vendor/datetimepicker/jquery.datetimepicker.full' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery' ), '1.3.4', true ); if ( apply_filters( 'llms_builder_use_heartbeat', true ) ) { wp_enqueue_script( 'heartbeat' ); } wp_enqueue_script( 'llms-builder', LLMS_PLUGIN_URL . 'assets/js/llms-builder' . LLMS_ASSETS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'backbone', 'underscore', 'post', 'llms-quill' ), LLMS_ASSETS_VERSION, true ); } elseif ( 'lifterlms_page_llms-add-ons' === $screen->id ) { llms()->assets->enqueue_script( 'llms-addons' ); } elseif ( in_array( $screen->id, array( 'lifterlms_page_llms-dashboard', 'lifterlms_page_llms-resources' ), true ) ) { wp_enqueue_script( 'postbox' ); } if (
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Enqueue certificate and achievement related js in llms_my_certificate , llms_my_achievement post types as well. |
5.5.0 | Use LLMS_Assets for the enqueue of llms-admin-add-ons . |
5.0.0 | Clean up duplicate references to llms-select2 and register the script using LLMS_Assets . Remove topModal vendor dependency. Add llms-admin-forms on the forms post table screen. |
4.4.0 | Enqueue the main llms script. |
4.3.3 | Move logic for reporting/analytics scripts to maybe_enqueue_reporting() . |
3.35.1 | Don't reference external scripts & styles. |
3.35.0 | Explicitly set asset versions. |
3.22.0 | Unknown. |
1.0.0 | Introduced. |