From 23ad005858b45ad54e403ba681c5032d2e9aacd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Fernanda=20Magallanes?= <35668326+MaferMazu@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:51:27 -0500 Subject: [PATCH] fix: admin enqueue order and bumpversion to 2.0.7 (#102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- CHANGELOG.md | 12 ++++++++++++ README.txt | 2 +- admin/class-openedx-commerce-admin.php | 18 ++++++++++++++++-- includes/class-openedx-commerce.php | 22 ---------------------- openedx-commerce.php | 4 ++-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0555686..4900065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.txt b/README.txt index 3228efd..86d8d56 100644 --- a/README.txt +++ b/README.txt @@ -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 diff --git a/admin/class-openedx-commerce-admin.php b/admin/class-openedx-commerce-admin.php index a70e9ae..80dc75b 100644 --- a/admin/class-openedx-commerce-admin.php +++ b/admin/class-openedx-commerce-admin.php @@ -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' + ); } /** @@ -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' ); } /** @@ -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; @@ -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 ); } diff --git a/includes/class-openedx-commerce.php b/includes/class-openedx-commerce.php index eb3de38..09ac167 100644 --- a/includes/class-openedx-commerce.php +++ b/includes/class-openedx-commerce.php @@ -76,7 +76,6 @@ public function __construct() { $this->define_admin_hooks(); $this->define_public_hooks(); $this->define_plugin_settings_hooks(); - $this->define_enqueue_scripts(); } /** @@ -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' ); @@ -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. * diff --git a/openedx-commerce.php b/openedx-commerce.php index e54e314..e80a667 100644 --- a/openedx-commerce.php +++ b/openedx-commerce.php @@ -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+ @@ -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.