Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: admin enqueue order #102

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions admin/class-openedx-commerce-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public function enqueue_styles() {
* between the defined hooks and the functions defined in this
* class.
*/

wp_enqueue_style(
$this->plugin_name,
plugin_dir_url( __FILE__ ) . '../admin/css/class-openedx-commerce-admin.css',
array(),
$this->version,
'all'
);
}

/**
Expand All @@ -133,6 +141,12 @@ public function enqueue_scripts() {
* between the defined hooks and the functions defined in this
* class.
*/

wp_register_script( 'product-type-script', plugin_dir_url( __FILE__ ) . '../admin/js/product-type.js', array(), $this->version, true );
wp_enqueue_script( 'product-type-script' );

wp_register_script( 'course-id-restriction-script', plugin_dir_url( __FILE__ ) . '../admin/js/course-id-restriction.js', array(), $this->version, true );
wp_enqueue_script( 'course-id-restriction-script' );
}

/**
Expand Down Expand Up @@ -165,7 +179,7 @@ public function render_enrollment_info_form( $post ) {
*
* @return object Post type class object
*/
public function register_post_type( $post_type = '', $plural = '', $single = '', $description = '', array $options ) {
public function register_post_type( $post_type = '', $plural = '', $single = '', $description = '', array $options = array() ) {

if ( ! $post_type || ! $plural || ! $single ) {
return;
Expand All @@ -191,7 +205,7 @@ public function create_post_type(
$plural = '',
$single = '',
$description = '',
array $options
array $options = array()
) {
return new Openedx_Commerce_Post_Type( $post_type, $plural, $single, $description, $options );
}
Expand Down
22 changes: 0 additions & 22 deletions includes/class-openedx-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public function __construct() {
$this->define_admin_hooks();
$this->define_public_hooks();
$this->define_plugin_settings_hooks();
$this->define_enqueue_scripts();
}

/**
Expand Down Expand Up @@ -217,13 +216,6 @@ private function define_admin_hooks() {
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_filter( 'gettext', $this, 'openedx_plugin_custom_post_message', 10, 3 );
$this->loader->wp_enqueue_style(
$this->plugin_name,
plugin_dir_url( __FILE__ ) . '../admin/css/class-openedx-commerce-admin.css',
array(),
$this->version,
'all'
);

// Redirection from enrollment to order and enrollment to order.
$this->loader->add_filter( 'woocommerce_admin_order_item_headers', $plugin_admin, 'add_custom_column_order_items' );
Expand Down Expand Up @@ -264,20 +256,6 @@ private function define_public_hooks() {
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
}

/**
* Register all the hooks related to custom scripts for specific functionalities.
*
* @since 1.11.0
* @access private
*/
private function define_enqueue_scripts() {
wp_register_script( 'product-type-script', plugin_dir_url( __FILE__ ) . '../admin/js/product-type.js', array(), $this->get_version(), true );
wp_enqueue_script( 'product-type-script' );

wp_register_script( 'course-id-restriction-script', plugin_dir_url( __FILE__ ) . '../admin/js/course-id-restriction.js', array(), $this->get_version(), true );
wp_enqueue_script( 'course-id-restriction-script' );
}

/**
* Define the plugin settings hooks.
*
Expand Down
Loading