From ed765437b55dbe1a4951a86a7580ec8cc44792d6 Mon Sep 17 00:00:00 2001 From: Julian Ramirez Date: Thu, 3 Aug 2023 14:33:25 -0500 Subject: [PATCH] refactor: styles added to css file --- .../css/openedx-woocommerce-plugin-admin.css | 29 ++++++++++++++- ...oocommerce_Plugin_Enrollment_Info_Form.php | 23 ++---------- includes/Openedx_Woocommerce_Plugin.php | 1 + .../Openedx_Woocommerce_Plugin_Loader.php | 36 +++++++++++++++++++ 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/admin/css/openedx-woocommerce-plugin-admin.css b/admin/css/openedx-woocommerce-plugin-admin.css index 00c8c7f..519fd6c 100644 --- a/admin/css/openedx-woocommerce-plugin-admin.css +++ b/admin/css/openedx-woocommerce-plugin-admin.css @@ -1,4 +1,31 @@ /** * All of the CSS for your admin-specific functionality should be * included in this file. - */ \ No newline at end of file + */ + + #namediv{ + padding: 50px 20px 50px 20px; + } + + .logs_box { + max-width: 100%; + max-height: 477px; + border: 1px solid #ccc; + padding: 10px; + white-space: pre-wrap; + word-wrap: break-word; + overflow: auto; + display: flex; + flex-direction: column-reverse; +} + +.log_entry { + background-color: #f2f2f2; + border: 1px solid #ccc; + padding: 10px; + margin-bottom: 10px; +} + +.logs_box strong { + font-weight: bold; +} \ No newline at end of file diff --git a/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php b/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php index b7bad38..5515a38 100644 --- a/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php +++ b/admin/views/Openedx_Woocommerce_Plugin_Enrollment_Info_Form.php @@ -73,7 +73,7 @@ public function render_enrollment_info_form( $post ) { } ?> -
+

Open edX enrollment request

@@ -230,26 +230,7 @@ public function render_logs_box($post) { ?>
diff --git a/includes/Openedx_Woocommerce_Plugin.php b/includes/Openedx_Woocommerce_Plugin.php index 2df5198..7bb0c46 100644 --- a/includes/Openedx_Woocommerce_Plugin.php +++ b/includes/Openedx_Woocommerce_Plugin.php @@ -184,6 +184,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 ); + $this->loader->wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . '../admin/css/openedx-woocommerce-plugin-admin.css', array(), $this->version, 'all' ); } diff --git a/includes/Openedx_Woocommerce_Plugin_Loader.php b/includes/Openedx_Woocommerce_Plugin_Loader.php index 4315845..d08104e 100644 --- a/includes/Openedx_Woocommerce_Plugin_Loader.php +++ b/includes/Openedx_Woocommerce_Plugin_Loader.php @@ -43,6 +43,8 @@ class Openedx_Woocommerce_Plugin_Loader { */ protected $filters; + protected $styles; + /** * Initialize the collections used to maintain the actions and filters. * @@ -52,6 +54,7 @@ public function __construct() { $this->actions = array(); $this->filters = array(); + $this->styles = array(); } @@ -83,6 +86,21 @@ public function add_filter( $hook, $component, $callback, $priority = 10, $accep $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); } + /** + * Add a new style to the collection to be registered with WordPress. + * + * @since 1.1.1 + * @param string $handle Name of the stylesheet. Should be unique. + * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. + * @param array $deps An array of registered stylesheet handles this stylesheet depends on. + * @param string $ver String specifying the stylesheet version number, if it has one. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the stylesheet. + * @param string $media The media for which this stylesheet has been defined. + * @return array The collection of actions and filters registered with WordPress. + */ + public function wp_enqueue_style( $handle, $src, $deps, $ver, $media ) { + $this->styles = $this->add_style($handle, $src, $deps, $ver, $media); + } + /** * A utility function that is used to register the actions and hooks into a single * collection. @@ -111,6 +129,20 @@ private function add( $hooks, $hook, $component, $callback, $priority, $accepted } + private function add_style( $handle, $src, $deps, $ver, $media ) { + + $hooks[] = array( + 'handle' => $handle, + 'src' => $src, + 'deps' => $deps, + 'ver' => $ver, + 'media' => $media + ); + + return $hooks; + + } + /** * Register the filters and actions with WordPress. * @@ -126,6 +158,10 @@ public function run() { add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); } + foreach ( $this->styles as $hook ) { + wp_enqueue_style( $hook['handle'], $hook['src'], $hook['deps'], $hook['ver'], $hook['media'] ); + } + } }