From 676662848b6629eba2f0f95c77b1fe079cde235b Mon Sep 17 00:00:00 2001 From: Scott DeLuzio Date: Wed, 13 Feb 2019 11:33:12 -0700 Subject: [PATCH] Added datepicker filters for customization. --- includes/wcs-scripts-styles.php | 44 ++++++++++++++++++++++++++++++++- js/datepicker.js | 41 +++++++++++++++++++++++++++++- readme.txt | 8 +++--- wp-crm-system.php | 4 +-- 4 files changed, 90 insertions(+), 7 deletions(-) diff --git a/includes/wcs-scripts-styles.php b/includes/wcs-scripts-styles.php index 693588e..d2bb2f5 100644 --- a/includes/wcs-scripts-styles.php +++ b/includes/wcs-scripts-styles.php @@ -12,8 +12,50 @@ function wpcrm_scripts_styles($hook) { $wpcrm_active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'dashboard'; wp_enqueue_script( 'jquery' ); - wp_enqueue_script( 'datepicker' ); + wp_enqueue_script( 'wp-crm-system-datepicker', WP_CRM_SYSTEM_PLUGIN_DIR . '/js/datepicker.js', array( 'jquery' ), WP_CRM_SYSTEM_VERSION ); wp_enqueue_script( 'jquery-ui-datepicker' ); + wp_localize_script( 'wp-crm-system-datepicker', 'wpcrm_system_datepicker_vars', array( + 'append_text' => apply_filters( 'wpcrm_system_datepicker_append_text', '' ), + 'auto_size' => apply_filters( 'wpcrm_system_datepicker_auto_size', false ), + 'button_image' => apply_filters( 'wpcrm_system_datepicker_button_image', '' ), + 'button_image_only' => apply_filters( 'wpcrm_system_datepicker_button_image_only', false ), + 'change_month' => apply_filters( 'wpcrm_system_datepicker_change_month', true ), + 'change_year' => apply_filters( 'wpcrm_system_datepicker_change_year', true ), + 'close_text' => apply_filters( 'wpcrm_system_datepicker_close_text', 'Done' ), + 'constrain_input' => apply_filters( 'wpcrm_system_datepicker_constrain_input', true ), + 'current_text' => apply_filters( 'wpcrm_system_datepicker_current_text', 'Today' ), + 'date_format' => apply_filters( 'wpcrm_system_datepicker_date_format', get_option( 'wpcrm_system_date_format' ) ), + 'day_names' => apply_filters( 'wpcrm_system_datepicker_day_names', array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ) ), + 'day_names_min' => apply_filters( 'wpcrm_system_datepicker_day_names_min', array( 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ) ), + 'day_names_short' => apply_filters( 'wpcrm_system_datepicker_day_names_short', array( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ) ), + 'default_date' => apply_filters( 'wpcrm_system_datepicker_default_date', null ), + 'duration' => apply_filters( 'wpcrm_system_datepicker_duration', 'normal' ), + 'first_day' => apply_filters( 'wpcrm_system_datepicker_first_day', 0 ), + 'go_to_current' => apply_filters( 'wpcrm_system_datepicker_go_to_current', false ), + 'hide_if_no_prev_next' => apply_filters( 'wpcrm_system_datepicker_hide_if_no_prev_next', false ), + 'is_rtl' => apply_filters( 'wpcrm_system_datepicker_is_rtl', false ), + 'max_date' => apply_filters( 'wpcrm_system_datepicker_max_date', null ), + 'min_date' => apply_filters( 'wpcrm_system_datepicker_min_date', null ), + 'month_names' => apply_filters( 'wpcrm_system_datepicker_month_names', array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ) ), + 'month_names_short' => apply_filters( 'wpcrm_system_datepicker_month_names_short', array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ) ), + 'navigation_as_date_format' => apply_filters( 'wpcrm_system_datepicker_navigation_as_date_format', false ), + 'next_text' => apply_filters( 'wpcrm_system_datepicker_next_text', 'Next' ), + 'number_of_months' => apply_filters( 'wpcrm_system_datepicker_number_of_months', array( 1, 1 ) ), + 'prev_text' => apply_filters( 'wpcrm_system_datepicker_prevText', 'Prev' ), + 'select_other_months' => apply_filters( 'wpcrm_system_datepicker_select_other_months', false ), + 'short_year_cutoff' => apply_filters( 'wpcrm_system_datepicker_short_year_cutoff', '+10' ), + 'show_anim' => apply_filters( 'wpcrm_system_datepicker_show_anim', 'show' ), + 'show_button_panel' => apply_filters( 'wpcrm_system_datepicker_show_button_panel', false ), + 'show_current_at_pos' => apply_filters( 'wpcrm_system_datepicker_show_current_at_pos', 0 ), + 'show_month_after_year' => apply_filters( 'wpcrm_system_datepicker_show_month_after_year', false ), + 'show_on' => apply_filters( 'wpcrm_system_datepicker_show_on', 'focus' ), + 'show_other_months' => apply_filters( 'wpcrm_system_datepicker_show_other_months', false ), + 'show_week' => apply_filters( 'wpcrm_system_datepicker_show_week', false ), + 'step_months' => apply_filters( 'wpcrm_system_datepicker_step_months', 1 ), + 'week_header' => apply_filters( 'wpcrm_system_datepicker_week_header', 'Wk' ), + 'year_range' => apply_filters( 'wpcrm_system_datepicker_year_range', '1900:2100' ), + 'year_suffix' => apply_filters( 'wpcrm_system_datepicker_year_suffix', '' ), + )); wp_register_style( 'jquery-ui-datepicker', WP_CRM_SYSTEM_PLUGIN_URL . '/css/jquery-ui.min.css' ); wp_enqueue_style( 'jquery-ui-datepicker' ); diff --git a/js/datepicker.js b/js/datepicker.js index cf8afcd..600954c 100644 --- a/js/datepicker.js +++ b/js/datepicker.js @@ -1,5 +1,44 @@ jQuery(document).ready(function() { jQuery('.datepicker').datepicker({ - dateFormat : 'dd-mm-yy' + appendText: wpcrm_system_datepicker_vars.append_text, + autoSize: wpcrm_system_datepicker_vars.auto_size, + buttonImage: wpcrm_system_datepicker_vars.button_image, + buttonImageOnly: wpcrm_system_datepicker_vars.button_image_only, + changeMonth: wpcrm_system_datepicker_vars.change_month, + changeYear: wpcrm_system_datepicker_vars.change_year, + closeText: wpcrm_system_datepicker_vars.close_text, + constrainInput: wpcrm_system_datepicker_vars.constrain_input, + currentText: wpcrm_system_datepicker_vars.current_text, + dateFormat: wpcrm_system_datepicker_vars.date_format, + dayNames: wpcrm_system_datepicker_vars.day_names, + dayNamesMin: wpcrm_system_datepicker_vars.day_names_min, + dayNamesShort: wpcrm_system_datepicker_vars.day_names_short, + defaultDate: wpcrm_system_datepicker_vars.default_date, + duration: wpcrm_system_datepicker_vars.duration, + firstDay: wpcrm_system_datepicker_vars.first_day, + gotoCurrent: wpcrm_system_datepicker_vars.go_to_current, + hideIfNoPrevNext: wpcrm_system_datepicker_vars.hide_if_no_prev_next, + isRTL: wpcrm_system_datepicker_vars.is_rtl, + maxDate: wpcrm_system_datepicker_vars.max_date, + minDate: wpcrm_system_datepicker_vars.min_date, + monthNames: wpcrm_system_datepicker_vars.month_names, + monthNamesShort: wpcrm_system_datepicker_vars.month_names_short, + navigationAsDateFormat: wpcrm_system_datepicker_vars.navigation_as_date_format, + nextText: wpcrm_system_datepicker_vars.next_text, + numberOfMonths: wpcrm_system_datepicker_vars.number_of_months, + prevText: wpcrm_system_datepicker_vars.prev_text, + selectOtherMonths: wpcrm_system_datepicker_vars.select_other_months, + shortYearCutoff: wpcrm_system_datepicker_vars.short_year_cutoff, + showAnim: wpcrm_system_datepicker_vars.show_anim, + showButtonPanel: wpcrm_system_datepicker_vars.show_button_panel, + showCurrentAtPos: wpcrm_system_datepicker_vars.show_current_at_pos, + showMonthAfterYear: wpcrm_system_datepicker_vars.show_month_after_year, + showOn: wpcrm_system_datepicker_vars.show_on, + showOtherMonths: wpcrm_system_datepicker_vars.show_other_months, + showWeek: wpcrm_system_datepicker_vars.show_week, + stepMonths: wpcrm_system_datepicker_vars.step_months, + weekHeader: wpcrm_system_datepicker_vars.week_header, + yearRange: wpcrm_system_datepicker_vars.year_range, + yearSuffix: wpcrm_system_datepicker_vars.year_suffix }); }); \ No newline at end of file diff --git a/readme.txt b/readme.txt index f33bf86..6f4f45e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: scott.deluzio Tags: WordPress CRM, Free CRM for WordPress, CRM, Free WordPress CRM, CRM for WordPress, gdpr Requires at least: 3.3.0 Tested up to: 5.0.3 -Stable tag: 2.6.5 +Stable tag: 2.6.6 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -92,6 +92,8 @@ Absolutely. There are inexpensive extensions that allow you to import as little Your data is only accessible through the WordPress CRM dashboard. None of it will be accessible through the public facing portion of your website unless you are using our GDPR features (see above). This allows you to provide access to as few or as many people as you need to. == Changelog == += 2.6.6 = +* Added the ability to customize the datepicker via developer filters. See documentation for more details on how to modify the datepicker. = 2.6.5 = * Updated the WPCRM_System_Create class to include custom file fields, which have been introduced in the Custom Fields add-on. = 2.6.4 = @@ -333,5 +335,5 @@ Your data is only accessible through the WordPress CRM dashboard. None of it wil * Initial Release == Upgrade Notice == -= 2.6.5 = -* Updated the WPCRM_System_Create class to include custom file fields, which have been introduced in the Custom Fields add-on. \ No newline at end of file += 2.6.6 = +* Added the ability to customize the datepicker via developer filters. See documentation for more details on how to modify the datepicker. \ No newline at end of file diff --git a/wp-crm-system.php b/wp-crm-system.php index ccbb7da..36dde4a 100644 --- a/wp-crm-system.php +++ b/wp-crm-system.php @@ -3,7 +3,7 @@ Plugin Name: WP-CRM System Plugin URI: https://www.wp-crm.com Description: A complete CRM for WordPress -Version: 2.6.5 +Version: 2.6.6 Author: Scott DeLuzio Author URI: https://www.wp-crm.com Text Domain: wp-crm-system @@ -34,7 +34,7 @@ function wp_crm_plugin_init() { define( 'WP_CRM_SYSTEM', __FILE__ ); } if ( ! defined( 'WP_CRM_SYSTEM_VERSION' ) ) { - define( 'WP_CRM_SYSTEM_VERSION', '2.6.5' ); + define( 'WP_CRM_SYSTEM_VERSION', '2.6.6' ); } if( ! defined( 'WP_CRM_SYSTEM_URL' ) ) { define( 'WP_CRM_SYSTEM_URL', plugins_url( '', __FILE__ ) );