Skip to content

Commit

Permalink
fix: admin enqueue order and bumpversion to 2.0.7 (#102)
Browse files Browse the repository at this point in the history
* fix: wp_register_script called incorrectly

* fix: wp_enqueue_style called incorrectly

* fix: options is a required parameter

* docs(bumpversion): v2.0.6 → v2.0.7
  • Loading branch information
MaferMazu authored Nov 5, 2024
1 parent 5429bff commit 23ad005
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v2.0.7 - 2024-11-05

### [2.0.7](https://github.com/openedx/openedx-wordpress-ecommerce/compare/v2.0.6...v2.0.7) (2024-11-05)

#### Bug Fixes

* fix: admin enqueue order (#102)

### Documentation

* docs: add info about tutor-contrib-wordpress plugin (#84)

## v2.0.6 - 2024-10-03

### [2.0.6](https://github.com/openedx/openedx-wordpress-ecommerce/compare/v2.0.5...v2.0.6) (2024-10-03)
Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: openedx, open edx, ecommerce, lms, courses
Requires at least: 6.3
Tested up to: 6.6
Requires PHP: 8.0
Stable tag: 2.0.6
Stable tag: 2.0.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
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
4 changes: 2 additions & 2 deletions openedx-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Open edX Commerce
* Plugin URI: https://github.com/openedx/openedx-wordpress-ecommerce
* Description: Easily connect your WooCommerce store to Open edX.
* Version: 2.0.6
* Version: 2.0.7
* Author: Open edX Community
* Author URI: https://github.com/openedx/openedx-wordpress-ecommerce
* License: GPL-2.0+
Expand Down Expand Up @@ -32,7 +32,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'OPENEDX_COMMERCE_VERSION', '2.0.6' );
define( 'OPENEDX_COMMERCE_VERSION', '2.0.7' );

/**
* The code that runs during plugin activation.
Expand Down

0 comments on commit 23ad005

Please sign in to comment.