diff --git a/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php b/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php
index 8f65071..9752e21 100644
--- a/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php
+++ b/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php
@@ -48,7 +48,7 @@ public function render_enrollment_info_form( $post ) {
$order_id = get_post_meta( $post_id, 'order_id', true );
$new_enrollment = false;
- if ( ! $course_id && ! $email ) {
+ if (! $course_id && ! $email) {
$new_enrollment = true;
}
?>
@@ -66,14 +66,15 @@ public function render_enrollment_info_form( $post ) {
- |
+ |
-
-
-
-
+
+
+
|
@@ -120,7 +121,7 @@ public function render_enrollment_info_form( $post ) {
- |
+ |
|
-
-
-
- |
-
-
- |
-
-
- |
-
- No errors ocurred processing this request
- |
-
-
- |
+ |
Edited:
Last edited:
|
+
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+ |
+
@@ -190,32 +197,31 @@ public function render_enrollment_info_form( $post ) {
get_logs();
?>
-
-
-
- -
-
-
-
- -
-
-
-
-
+
post_type, 'side' );
- add_meta_box( 'openedx_enrollment_request_actions', sprintf( __( '%s actions', '' ), 'Open edX Enrollment Requests' ), array( $this, 'render_actions_box' ), $this->post_type, 'side', 'high' );
+ add_meta_box( 'openedx_enrollment_request_actions', 'Enrollment Operation Logs', array( $this, 'render_logs_box' ), $this->post_type, 'side', 'high' );
}
}
diff --git a/includes/Openedx_Woocommerce_Plugin.php b/includes/Openedx_Woocommerce_Plugin.php
index e32e898..119e7a9 100644
--- a/includes/Openedx_Woocommerce_Plugin.php
+++ b/includes/Openedx_Woocommerce_Plugin.php
@@ -107,41 +107,41 @@ private function load_dependencies() {
* The class responsible for orchestrating the actions and filters of the
* core plugin.
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'includes/Openedx_Woocommerce_Plugin_Loader.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'includes/Openedx_Woocommerce_Plugin_Loader.php';
/**
* The class responsible for defining internationalization functionality
* of the plugin.
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'includes/Openedx_Woocommerce_Plugin_i18n.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'includes/Openedx_Woocommerce_Plugin_i18n.php';
/**
* The class responsible for defining all actions that occur in the admin area.
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'admin/Openedx_Woocommerce_Plugin_Admin.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'admin/Openedx_Woocommerce_Plugin_Admin.php';
/**
* The class responsible for defining all actions that occur in the public-facing
* side of the site.
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'public/Openedx_Woocommerce_Plugin_Public.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'public/Openedx_Woocommerce_Plugin_Public.php';
$this->loader = new Openedx_Woocommerce_Plugin_Loader();
/**
* The class responsible for defining the enrollment object
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'includes/model/Openedx_Woocommerce_Plugin_Enrollment.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'includes/model/Openedx_Woocommerce_Plugin_Enrollment.php';
/**
* The class responsible for defining the custom-post-type object
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'includes/model/Openedx_Woocommerce_Plugin_Post_Type.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'includes/model/Openedx_Woocommerce_Plugin_Post_Type.php';
/**
* The class responsible for rendering the enrollment info form
*/
- include_once plugin_dir_path( dirname( __FILE__ )) . 'admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php';
+ include_once plugin_dir_path( dirname(__FILE__)) . 'admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php';
}
@@ -181,6 +181,7 @@ 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 );
}
@@ -200,6 +201,22 @@ private function define_public_hooks() {
}
+ /**
+ * Modify the message displayed when a custom-post-type is updated
+ *
+ * @param string $translated_text translation text
+ * @param string $text text to be translated
+ * @param string $domain text domain
+ * @return string $translated_text post updated message
+ */
+ function openedx_plugin_custom_post_message( $translated_text, $text, $domain ) {
+
+ if ( $domain === 'default' && $text === 'Post updated.' ) {
+ $translated_text = 'Enrollment action executed';
+ }
+ return $translated_text;
+ }
+
/**
* Run the loader to execute all of the hooks with WordPress.
*
diff --git a/includes/model/Openedx_Woocommerce_Plugin_Enrollment.php b/includes/model/Openedx_Woocommerce_Plugin_Enrollment.php
index 21cc719..eaaa242 100644
--- a/includes/model/Openedx_Woocommerce_Plugin_Enrollment.php
+++ b/includes/model/Openedx_Woocommerce_Plugin_Enrollment.php
@@ -58,18 +58,36 @@ public function register_enrollment_custom_post_type(){
'show_in_nav_menus' => true,
'supports' => array( '' ),
'menu_icon' => 'dashicons-admin-post',
+ 'labels' => array(
+ 'name' => 'Open edX Enrollment Requests',
+ 'singular_name' => 'Open edX Enrollment Request',
+ 'menu_name' => 'Open edX Sync',
+ 'all_items' => 'Enrollments Manager',
+ 'add_new_item' => 'Add New Enrollment Request',
+ 'edit_item' => 'Edit Enrollment Request',
+ ),
);
// Register post-type using wrapper custom-post-type function
- $this->parent->register_post_type( 'openedx_enrollment', 'Open edX Enrollment Requests', 'Open edX Enrollment Request', '', $enrollment_cpt_options );
+ $this->parent->register_post_type( 'openedx_enrollment', ' ', ' ', '', $enrollment_cpt_options );
}
- public function unregister_save_hook() {
- remove_action( 'save_post', array( $this, 'save_action' ), 10, 3 );
+ /**
+ * Unregister the save hook to prevent an infinite cycle of hook recursion
+ *
+ * @return void
+ */
+ public function unregisterSaveHook() {
+ remove_action( 'save_post', array($this, 'save_action'), 10, 3 );
}
-
- public function register_save_hook() {
- add_action( 'save_post', array( $this, 'save_action' ), 10, 3 );
+
+ /**
+ * Register the save hook to prevent an infinite cycle of hook recursion
+ *
+ * @return void
+ */
+ public function registerSaveHook() {
+ add_action( 'save_post', array($this, 'save_action'), 10, 3 );
}
/**
@@ -146,14 +164,16 @@ public function save_action( $post_id, $post, $update ) {
}
$enrollment_arr = array(
- 'enrollment_course_id' => sanitize_text_field($_POST['enrollment_course_id'] ?? ''),
- 'enrollment_email' => sanitize_text_field($_POST['enrollment_email'] ?? ''),
- 'enrollment_mode' => sanitize_text_field($_POST['enrollment_mode'] ?? ''),
- 'enrollment_request_type' => sanitize_text_field($_POST['enrollment_request_type'] ?? ''),
- 'enrollment_order_id' => sanitize_text_field($_POST['enrollment_order_id'] ?? ''),
+ 'enrollment_course_id' => sanitize_text_field( $_POST['enrollment_course_id'] ?? '' ),
+ 'enrollment_email' => sanitize_text_field($_POST['enrollment_email'] ?? ''),
+ 'enrollment_mode' => sanitize_text_field($_POST['enrollment_mode'] ?? ''),
+ 'enrollment_request_type' => sanitize_text_field(
+ $_POST['enrollment_request_type'] ?? ''
+ ),
+ 'enrollment_order_id' => sanitize_text_field($_POST['enrollment_order_id'] ?? ''),
);
- $enrollment_action = sanitize_text_field( $_POST['enrollment_action'] ?? '' );
+ $enrollment_action = sanitize_text_field($_POST['enrollment_action'] ?? '');
$this->save_enrollment( $post, $enrollment_arr, $enrollment_action );
}
@@ -223,13 +243,15 @@ public function save_enrollment( $post, $enrollment_arr, $enrollment_action ) {
// Check if old post_meta tags are different from the new ones.
- if ($old_course_id !== $enrollment_course_id || $old_email !== $enrollment_email || $old_mode !== $enrollment_mode) {
+ if ($old_course_id !== $enrollment_course_id ||
+ $old_email !== $enrollment_email ||
+ $old_mode !== $enrollment_mode) {
$this->update_post($post_id);
}
// Only update the post status if it has no custom status yet.
- if ( $post->post_status !== 'enrollment-success' && $post->post_status !== 'enrollment-pending' && $post->post_status !== 'enrollment-error' ) {
- $this->update_post( $post_id, 'enrollment-pending' );
+ if ($post->post_status !== 'enrollment-success' && $post->post_status !== 'enrollment-pending' && $post->post_status !== 'enrollment-error') {
+ $this->update_post($post_id, 'enrollment-pending');
}
}
@@ -239,21 +261,22 @@ public function save_enrollment( $post, $enrollment_arr, $enrollment_action ) {
* @param string $status The status of the request.
* @param int $post_id The post ID.
*/
- public function update_post( $post_id, $status = null ) {
+ public function updatePost( $post_id, $status = null ) {
- $enrollment_course_id = get_post_meta( $post_id, 'course_id', true );
- $enrollment_email = get_post_meta( $post_id, 'email', true );
- $enrollment_mode = get_post_meta( $post_id, 'mode', true );
+ $enrollment_course_id = get_post_meta($post_id, 'course_id', true);
+ $enrollment_email = get_post_meta($post_id, 'email', true);
+ $enrollment_mode = get_post_meta($post_id, 'mode', true);
$post_update = array(
- 'ID' => $post_id,
- 'post_title' => $enrollment_course_id . ' | ' . $enrollment_email . ' | Mode: ' . $enrollment_mode,
+ 'ID' => $post_id,
+ 'post_title'
+ => $enrollment_course_id .' | '. $enrollment_email .' | Mode: '.$enrollment_mode,
);
if ($status) {
$post_update['post_status'] = $status;
}
- $this->wp_update_post( $post_update );
+ $this->wp_update_post($post_update);
}
}