From d8421b30063a322dea94ad250a69025d0d9bc058 Mon Sep 17 00:00:00 2001 From: Jake Oehler Morrison Date: Tue, 20 Mar 2018 12:35:37 +0000 Subject: [PATCH] Enqueue the datepicker UI when using a date field in the front-end --- includes/admin/class-wp-job-manager-admin.php | 6 +----- templates/form-fields/date-field.php | 3 ++- wp-job-manager.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/includes/admin/class-wp-job-manager-admin.php b/includes/admin/class-wp-job-manager-admin.php index 135f663d6..3880e6703 100644 --- a/includes/admin/class-wp-job-manager-admin.php +++ b/includes/admin/class-wp-job-manager-admin.php @@ -82,14 +82,10 @@ public function conditional_includes() { * Enqueues CSS and JS assets. */ public function admin_enqueue_scripts() { - global $wp_scripts; - $screen = get_current_screen(); if ( in_array( $screen->id, apply_filters( 'job_manager_admin_screen_ids', array( 'edit-job_listing', 'plugins', 'job_listing', 'job_listing_page_job-manager-settings', 'job_listing_page_job-manager-addons' ) ) ) ) { - $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2'; - - wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version ); + wp_enqueue_style( 'jquery-ui' ); wp_enqueue_style( 'job_manager_admin_css', JOB_MANAGER_PLUGIN_URL . '/assets/css/admin.css', array(), JOB_MANAGER_VERSION ); wp_register_script( 'jquery-tiptip', JOB_MANAGER_PLUGIN_URL. '/assets/js/jquery-tiptip/jquery.tipTip.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true ); wp_enqueue_script( 'job_manager_datepicker_js', JOB_MANAGER_PLUGIN_URL. '/assets/js/datepicker.min.js', array( 'jquery', 'jquery-ui-datepicker' ), JOB_MANAGER_VERSION, true ); diff --git a/templates/form-fields/date-field.php b/templates/form-fields/date-field.php index 51c3335b7..0dd2364c5 100644 --- a/templates/form-fields/date-field.php +++ b/templates/form-fields/date-field.php @@ -8,7 +8,7 @@ * @author Automattic * @package WP Job Manager * @category Template - * @version 1.30.0 + * @version 1.30.2 */ if ( ! defined( 'ABSPATH' ) ) { @@ -16,6 +16,7 @@ } wp_enqueue_script( 'wp-job-manager-datepicker' ); +wp_enqueue_style( 'jquery-ui' ); ?> id="" placeholder="" value="" /> diff --git a/wp-job-manager.php b/wp-job-manager.php index b8f5da692..bf0b0821e 100644 --- a/wp-job-manager.php +++ b/wp-job-manager.php @@ -101,6 +101,7 @@ public function __construct() { add_action( 'after_setup_theme', array( $this, 'load_plugin_textdomain' ) ); add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 ); add_action( 'widgets_init', array( $this, 'widgets_init' ) ); + add_action( 'init', array( $this, 'register_shared_assets' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); add_action( 'admin_init', array( $this, 'updater' ) ); add_action( 'wp_logout', array( $this, 'cleanup_job_posting_cookies' ) ); @@ -221,6 +222,16 @@ public function cleanup_job_posting_cookies() { } } + /** + * Registers assets used in both the frontend and WP admin. + */ + public function register_shared_assets() { + global $wp_scripts; + + $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2'; + wp_register_style( 'jquery-ui', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version ); + } + /** * Registers and enqueues scripts and CSS. */ @@ -338,6 +349,7 @@ public function frontend_scripts() { wp_register_script( 'wp-job-manager-job-application', JOB_MANAGER_PLUGIN_URL . '/assets/js/job-application.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true ); wp_register_script( 'wp-job-manager-job-submission', JOB_MANAGER_PLUGIN_URL . '/assets/js/job-submission.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true ); wp_localize_script( 'wp-job-manager-ajax-filters', 'job_manager_ajax_filters', $ajax_data ); + wp_localize_script( 'wp-job-manager-job-dashboard', 'job_manager_job_dashboard', array( 'i18n_confirm_delete' => __( 'Are you sure you want to delete this listing?', 'wp-job-manager' ), ) );