Version Description
- ACF PRO 5.0+ is no longer supported, ACF PRO has its own date and time picker
- Update plugin to WPCS standards.
Download this release
Release Info
Developer | PerS |
Plugin | Date and Time Picker Field |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.18.1 to 2.1.0
- acf-date-time-picker.php +62 -0
- acf-date_time_picker.php +0 -81
- css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- css/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- css/images/ui-icons_222222_256x240.png +0 -0
- css/images/ui-icons_2e83ff_256x240.png +0 -0
- css/images/ui-icons_454545_256x240.png +0 -0
- css/images/ui-icons_888888_256x240.png +0 -0
- css/images/ui-icons_cd0a0a_256x240.png +0 -0
- date-time-picker-v3.php +514 -0
- date-time-picker-v4.php +472 -0
- date_time_picker-v3.php +0 -503
- date_time_picker-v4.php +0 -477
- date_time_picker-v5.php +0 -411
- js/localization/jquery-ui-timepicker-da.js +0 -0
- js/localization/jquery-ui-timepicker-hr.js +0 -0
- js/timepicker.js +131 -148
- lang/acf-date_time_picker.po +0 -159
- readme.txt +26 -7
acf-date-time-picker.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Advanced Custom Fields: Date and Time Picker
|
4 |
+
* Plugin URI: https://github.com/soderlind/acf-field-date-time-picker
|
5 |
+
* Description: Date and Time Picker field for Advanced Custom Fields
|
6 |
+
* Version: 2.1.0
|
7 |
+
* Author: Per Soderlind
|
8 |
+
* Author URI: http://soderlind.no
|
9 |
+
* License: GPLv2 or later
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
* Text Domain: acf-field-date-time-picker
|
12 |
+
* Domain Path: /languages
|
13 |
+
*/
|
14 |
+
define( 'ACFFIELDDATETIMEPICKER_VERSION', '2.1.0' );
|
15 |
+
/**
|
16 |
+
* Class acfFieldDateTimePickerPlugin
|
17 |
+
*/
|
18 |
+
if ( ! class_exists( 'ACFFieldDateTimePickerPlugin' ) ) :
|
19 |
+
class ACFFieldDateTimePickerPlugin {
|
20 |
+
/**
|
21 |
+
* Construct
|
22 |
+
*
|
23 |
+
* @description:
|
24 |
+
* @since: 3.6
|
25 |
+
* @created: 1/04/13
|
26 |
+
*/
|
27 |
+
function __construct() {
|
28 |
+
|
29 |
+
load_plugin_textdomain( 'acf-field-date-time-picker', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
30 |
+
// version 4+
|
31 |
+
add_action( 'acf/register_fields', array( $this, 'register_fields' ) );
|
32 |
+
// version 3-
|
33 |
+
add_action( 'init', array( $this, 'init' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Init
|
38 |
+
*
|
39 |
+
* @description:
|
40 |
+
* @since: 3.6
|
41 |
+
* @created: 1/04/13
|
42 |
+
*/
|
43 |
+
function init() {
|
44 |
+
if ( function_exists( 'register_field' ) ) {
|
45 |
+
register_field( 'acf_field_date_time_picker', dirname( __File__ ) . '/date-time-picker-v3.php' );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* register_fields
|
51 |
+
*
|
52 |
+
* @description:
|
53 |
+
* @since: 3.6
|
54 |
+
* @created: 1/04/13
|
55 |
+
*/
|
56 |
+
function register_fields() {
|
57 |
+
require_once( 'date-time-picker-v4.php' );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
new ACFFieldDateTimePickerPlugin();
|
62 |
+
endif;
|
acf-date_time_picker.php
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Advanced Custom Fields: Date and Time Picker
|
4 |
-
Plugin URI: https://github.com/soderlind/acf-field-date-time-picker
|
5 |
-
Description: Date and Time Picker field for Advanced Custom Fields
|
6 |
-
Version: 2.0.18.1
|
7 |
-
Author: Per Soderlind
|
8 |
-
Author URI: http://soderlind.no
|
9 |
-
License: GPLv2 or later
|
10 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
-
Text Domain: acf-field-date-time-picker
|
12 |
-
Domain Path: /languages
|
13 |
-
*/
|
14 |
-
|
15 |
-
|
16 |
-
class acf_field_date_time_picker_plugin
|
17 |
-
{
|
18 |
-
/*
|
19 |
-
* Construct
|
20 |
-
*
|
21 |
-
* @description:
|
22 |
-
* @since: 3.6
|
23 |
-
* @created: 1/04/13
|
24 |
-
*/
|
25 |
-
|
26 |
-
function __construct()
|
27 |
-
{
|
28 |
-
load_plugin_textdomain( 'acf-field-date-time-picker', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
29 |
-
|
30 |
-
// version 5+
|
31 |
-
add_action('acf/include_field_types', array($this, 'include_field_types'));
|
32 |
-
|
33 |
-
// version 4+
|
34 |
-
add_action('acf/register_fields', array($this, 'register_fields'));
|
35 |
-
|
36 |
-
|
37 |
-
// version 3-
|
38 |
-
add_action( 'init', array( $this, 'init' ));
|
39 |
-
}
|
40 |
-
|
41 |
-
|
42 |
-
/*
|
43 |
-
* Init
|
44 |
-
*
|
45 |
-
* @description:
|
46 |
-
* @since: 3.6
|
47 |
-
* @created: 1/04/13
|
48 |
-
*/
|
49 |
-
|
50 |
-
function init()
|
51 |
-
{
|
52 |
-
if(function_exists('register_field'))
|
53 |
-
{
|
54 |
-
register_field('acf_field_date_time_picker', dirname(__File__) . '/date_time_picker-v3.php');
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
/*
|
59 |
-
* register_fields
|
60 |
-
*
|
61 |
-
* @description:
|
62 |
-
* @since: 3.6
|
63 |
-
* @created: 1/04/13
|
64 |
-
*/
|
65 |
-
|
66 |
-
function register_fields()
|
67 |
-
{
|
68 |
-
include_once('date_time_picker-v4.php');
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
function include_field_types()
|
73 |
-
{
|
74 |
-
include_once('date_time_picker-v5.php');
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
new acf_field_date_time_picker_plugin();
|
80 |
-
|
81 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/images/ui-bg_flat_0_aaaaaa_40x100.png
CHANGED
File without changes
|
css/images/ui-bg_flat_75_ffffff_40x100.png
CHANGED
File without changes
|
css/images/ui-bg_glass_55_fbf9ee_1x400.png
CHANGED
File without changes
|
css/images/ui-bg_glass_65_ffffff_1x400.png
CHANGED
File without changes
|
css/images/ui-bg_glass_75_dadada_1x400.png
CHANGED
File without changes
|
css/images/ui-bg_glass_75_e6e6e6_1x400.png
CHANGED
File without changes
|
css/images/ui-bg_glass_95_fef1ec_1x400.png
CHANGED
File without changes
|
css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
CHANGED
File without changes
|
css/images/ui-icons_222222_256x240.png
CHANGED
File without changes
|
css/images/ui-icons_2e83ff_256x240.png
CHANGED
File without changes
|
css/images/ui-icons_454545_256x240.png
CHANGED
File without changes
|
css/images/ui-icons_888888_256x240.png
CHANGED
File without changes
|
css/images/ui-icons_cd0a0a_256x240.png
CHANGED
File without changes
|
date-time-picker-v3.php
ADDED
@@ -0,0 +1,514 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ACFFieldDateTimePicker extends acf_Field {
|
4 |
+
// vars
|
5 |
+
var $settings // will hold info such as dir / path
|
6 |
+
, $defaults // will hold default field options
|
7 |
+
, $domain; // holds the language domain
|
8 |
+
|
9 |
+
|
10 |
+
/*--------------------------------------------------------------------------------------
|
11 |
+
*
|
12 |
+
* Constructor
|
13 |
+
* - This function is called when the field class is initalized on each page.
|
14 |
+
* - Here you can add filters / actions and setup any other functionality for your field
|
15 |
+
*
|
16 |
+
* @author Elliot Condon
|
17 |
+
* @since 2.2.0
|
18 |
+
*
|
19 |
+
*-------------------------------------------------------------------------------------*/
|
20 |
+
|
21 |
+
function __construct( $parent ) {
|
22 |
+
// do not delete!
|
23 |
+
parent::__construct( $parent );
|
24 |
+
|
25 |
+
// set name / title
|
26 |
+
$this->name = 'date_time_picker';
|
27 |
+
$this->title = __( 'Date and Time Picker' );
|
28 |
+
$this->domain = 'acf-field-date-time-picker';
|
29 |
+
$this->defaults = array(
|
30 |
+
'label' => __( 'Choose Time', $this->domain ),
|
31 |
+
'time_format' => 'hh:mm',
|
32 |
+
'show_date' => 'true',
|
33 |
+
'date_format' => 'yy-mm-dd',
|
34 |
+
'show_week_number' => 'false',
|
35 |
+
'picker' => 'slider',
|
36 |
+
'save_as_timestamp' => 'true',
|
37 |
+
'get_as_timestamp' => 'false',
|
38 |
+
);
|
39 |
+
|
40 |
+
$this->settings = array(
|
41 |
+
'path' => $this->helpers_get_path( __FILE__ ),
|
42 |
+
'dir' => $this->helpers_get_dir( __FILE__ ),
|
43 |
+
'version' => ACFFIELDDATETIMEPICKER_VERSION,
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
/*
|
48 |
+
* helpers_get_path
|
49 |
+
*
|
50 |
+
* @description: calculates the path (works for plugin / theme folders)
|
51 |
+
* @since: 3.6
|
52 |
+
* @created: 30/01/13
|
53 |
+
*/
|
54 |
+
|
55 |
+
function helpers_get_path( $file ) {
|
56 |
+
|
57 |
+
return trailingslashit( dirname( $file ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/*
|
61 |
+
* helpers_get_dir
|
62 |
+
*
|
63 |
+
* @description: calculates the directory (works for plugin / theme folders)
|
64 |
+
* @since: 3.6
|
65 |
+
* @created: 30/01/13
|
66 |
+
*/
|
67 |
+
|
68 |
+
function helpers_get_dir( $file ) {
|
69 |
+
|
70 |
+
$dir = trailingslashit( dirname( $file ) );
|
71 |
+
$count = 0;
|
72 |
+
|
73 |
+
// sanitize for Win32 installs
|
74 |
+
$dir = str_replace( '\\', '/', $dir );
|
75 |
+
|
76 |
+
// if file is in plugins folder
|
77 |
+
$wp_plugin_dir = str_replace( '\\', '/', WP_PLUGIN_DIR );
|
78 |
+
$dir = str_replace( $wp_plugin_dir, WP_PLUGIN_URL, $dir, $count );
|
79 |
+
|
80 |
+
if ( $count < 1 ) {
|
81 |
+
// if file is in wp-content folder
|
82 |
+
$wp_content_dir = str_replace( '\\', '/', WP_CONTENT_DIR );
|
83 |
+
$dir = str_replace( $wp_content_dir, WP_CONTENT_URL, $dir, $count );
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( $count < 1 ) {
|
87 |
+
// if file is in ??? folder
|
88 |
+
$wp_dir = str_replace( '\\', '/', ABSPATH );
|
89 |
+
$dir = str_replace( $wp_dir, site_url( '/' ), $dir );
|
90 |
+
}
|
91 |
+
|
92 |
+
return $dir;
|
93 |
+
}
|
94 |
+
|
95 |
+
/*--------------------------------------------------------------------------------------
|
96 |
+
*
|
97 |
+
* create_options
|
98 |
+
* - this function is called from core/field_meta_box.php to create extra options
|
99 |
+
* for your field
|
100 |
+
*
|
101 |
+
* @params
|
102 |
+
* - $key (int) - the $_POST obejct key required to save the options to the field
|
103 |
+
* - $field (array) - the field object
|
104 |
+
*
|
105 |
+
* @author Elliot Condon
|
106 |
+
* @since 2.2.0
|
107 |
+
*
|
108 |
+
*-------------------------------------------------------------------------------------*/
|
109 |
+
|
110 |
+
function create_options( $key, $field ) {
|
111 |
+
|
112 |
+
$field = array_merge( $this->defaults, $field );
|
113 |
+
?>
|
114 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
|
115 |
+
<td class="label">
|
116 |
+
<label for=""><?php _e( 'Date and Time Picker?', $this->domain ); ?></label>
|
117 |
+
</td>
|
118 |
+
<td>
|
119 |
+
<?php
|
120 |
+
$this->parent->create_field(array(
|
121 |
+
'type' => 'radio',
|
122 |
+
'name' => 'fields[' . $key . '][show_date]',
|
123 |
+
'value' => $field['show_date'],
|
124 |
+
'layout' => 'horizontal',
|
125 |
+
'choices' => array(
|
126 |
+
'true' => __( 'Date and Time Picker', $this->domain ),
|
127 |
+
'false' => __( 'Time Picker', $this->domain ),
|
128 |
+
),
|
129 |
+
));
|
130 |
+
?>
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
|
134 |
+
<td class="label">
|
135 |
+
<label><?php _e( 'Date Format', $this->domain ); ?></label>
|
136 |
+
<p class="description"><?php _e( 'eg. mm/dd/yy. read more about', $this->domain ); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
|
137 |
+
</td>
|
138 |
+
<td>
|
139 |
+
<?php
|
140 |
+
$this->parent->create_field(array(
|
141 |
+
'type' => 'text',
|
142 |
+
'name' => 'fields[' . $key . '][date_format]',
|
143 |
+
'value' => $field['date_format'],
|
144 |
+
));
|
145 |
+
?>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
|
149 |
+
<td class="label">
|
150 |
+
<label><?php _e( 'Time Format', $this->domain ); ?></label>
|
151 |
+
<p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', $this->domain ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
|
152 |
+
</td>
|
153 |
+
<td>
|
154 |
+
<?php
|
155 |
+
$this->parent->create_field(array(
|
156 |
+
'type' => 'text',
|
157 |
+
'name' => 'fields[' . $key . '][time_format]',
|
158 |
+
'value' => $field['time_format'],
|
159 |
+
));
|
160 |
+
?>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
164 |
+
<td class="label">
|
165 |
+
<label for=""><?php _e( 'Display Week Number?', $this->domain ); ?></label>
|
166 |
+
</td>
|
167 |
+
<td>
|
168 |
+
<?php
|
169 |
+
$this->parent->create_field(array(
|
170 |
+
'type' => 'radio',
|
171 |
+
'name' => 'fields[' . $key . '][show_week_number]',
|
172 |
+
'value' => $field['show_week_number'],
|
173 |
+
'layout' => 'horizontal',
|
174 |
+
'choices' => array(
|
175 |
+
'true' => __( 'Yes', $this->domain ),
|
176 |
+
'false' => __( 'No', $this->domain ),
|
177 |
+
),
|
178 |
+
));
|
179 |
+
?>
|
180 |
+
</td>
|
181 |
+
</tr>
|
182 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
183 |
+
<td class="label">
|
184 |
+
<label for=""><?php _e( 'Time Picker Style?', $this->domain ); ?></label>
|
185 |
+
</td>
|
186 |
+
<td>
|
187 |
+
<?php
|
188 |
+
$this->parent->create_field(array(
|
189 |
+
'type' => 'radio',
|
190 |
+
'name' => 'fields[' . $key . '][picker]',
|
191 |
+
'value' => $field['picker'],
|
192 |
+
'layout' => 'horizontal',
|
193 |
+
'choices' => array(
|
194 |
+
'slider' => __( 'Slider', $this->domain ),
|
195 |
+
'select' => __( 'Dropdown', $this->domain ),
|
196 |
+
),
|
197 |
+
));
|
198 |
+
?>
|
199 |
+
</td>
|
200 |
+
</tr>
|
201 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
202 |
+
<td class="label">
|
203 |
+
<label for=""><?php _e( 'Save as timestamp?', $this->domain ); ?></label>
|
204 |
+
<p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', $this->domain ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
|
205 |
+
</td>
|
206 |
+
<td>
|
207 |
+
<?php
|
208 |
+
$this->parent->create_field(array(
|
209 |
+
'type' => 'radio',
|
210 |
+
'name' => 'fields[' . $key . '][save_as_timestamp]',
|
211 |
+
'value' => $field['save_as_timestamp'],
|
212 |
+
'layout' => 'horizontal',
|
213 |
+
'choices' => array(
|
214 |
+
'true' => __( 'Yes', $this->domain ),
|
215 |
+
'false' => __( 'No', $this->domain ),
|
216 |
+
),
|
217 |
+
));
|
218 |
+
?>
|
219 |
+
</td>
|
220 |
+
</tr>
|
221 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
222 |
+
<td class="label">
|
223 |
+
<label for=""><?php _e( 'Get field as a timestamp?', $this->domain ); ?></label>
|
224 |
+
<p class="description"><?php printf(__( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%s" target="_blank">the_field()</a> or <a href="%s" target="_blank">get_field()</a> ', $this->domain ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
|
225 |
+
'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
|
226 |
+
</td>
|
227 |
+
<td>
|
228 |
+
<?php
|
229 |
+
$this->parent->create_field(array(
|
230 |
+
'type' => 'radio',
|
231 |
+
'name' => 'fields[' . $key . '][get_as_timestamp]',
|
232 |
+
'value' => $field['get_as_timestamp'],
|
233 |
+
'layout' => 'horizontal',
|
234 |
+
'choices' => array(
|
235 |
+
'true' => __( 'Yes', $this->domain ),
|
236 |
+
'false' => __( 'No', $this->domain ),
|
237 |
+
),
|
238 |
+
));
|
239 |
+
?>
|
240 |
+
</td>
|
241 |
+
</tr>
|
242 |
+
<?php
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
/*--------------------------------------------------------------------------------------
|
247 |
+
*
|
248 |
+
* create_field
|
249 |
+
* - this function is called on edit screens to produce the html for this field
|
250 |
+
*
|
251 |
+
* @author Elliot Condon
|
252 |
+
* @since 2.2.0
|
253 |
+
*
|
254 |
+
*-------------------------------------------------------------------------------------*/
|
255 |
+
|
256 |
+
function create_field( $field ) {
|
257 |
+
|
258 |
+
$field = array_merge( $this->defaults, $field );
|
259 |
+
|
260 |
+
if ( true != $field['show_date'] ) {
|
261 |
+
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
|
262 |
+
} else {
|
263 |
+
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
/*--------------------------------------------------------------------------------------
|
268 |
+
*
|
269 |
+
* update_value
|
270 |
+
* - this function is called when saving a post object that your field is assigned to.
|
271 |
+
* the function will pass through the 3 parameters for you to use.
|
272 |
+
*
|
273 |
+
* @params
|
274 |
+
* - $post_id (int) - usefull if you need to save extra data or manipulate the current
|
275 |
+
* post object
|
276 |
+
* - $field (array) - usefull if you need to manipulate the $value based on a field option
|
277 |
+
* - $value (mixed) - the new value of your field.
|
278 |
+
*
|
279 |
+
* @author Elliot Condon
|
280 |
+
* @since 2.2.0
|
281 |
+
*
|
282 |
+
*-------------------------------------------------------------------------------------*/
|
283 |
+
|
284 |
+
function update_value( $post_id, $field, $value ) {
|
285 |
+
|
286 |
+
$field = array_merge( $this->defaults, $field );
|
287 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] ) {
|
288 |
+
if ( preg_match( '/^dd?\//', $field['date_format'] ) ) { //if start with dd/ or d/ (not supported by strtotime())
|
289 |
+
$value = str_replace( '/', '-', $value );
|
290 |
+
}
|
291 |
+
$value = strtotime( $value );
|
292 |
+
}
|
293 |
+
|
294 |
+
parent::update_value( $post_id, $field, $value );
|
295 |
+
}
|
296 |
+
|
297 |
+
/*--------------------------------------------------------------------------------------
|
298 |
+
*
|
299 |
+
* get_value
|
300 |
+
* - called from the edit page to get the value of your field. This function is useful
|
301 |
+
* if your field needs to collect extra data for your create_field() function.
|
302 |
+
*
|
303 |
+
* @params
|
304 |
+
* - $post_id (int) - the post ID which your value is attached to
|
305 |
+
* - $field (array) - the field object.
|
306 |
+
*
|
307 |
+
* @author Elliot Condon
|
308 |
+
* @since 2.2.0
|
309 |
+
*
|
310 |
+
*-------------------------------------------------------------------------------------*/
|
311 |
+
|
312 |
+
function get_value( $post_id, $field ) {
|
313 |
+
|
314 |
+
$field = array_merge( $this->defaults, $field );
|
315 |
+
$value = parent::get_value( $post_id, $field );
|
316 |
+
|
317 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] && $this->isValidTimeStamp( $value ) ) {
|
318 |
+
if ( 'true' == $field['show_date'] ) {
|
319 |
+
$value = date( sprintf( '%s %s', $this->js_to_php_dateformat( $field['date_format'] ), $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
320 |
+
} else {
|
321 |
+
$value = date( sprintf( '%s', $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
return $value;
|
326 |
+
}
|
327 |
+
|
328 |
+
function get_value_for_api( $post_id, $field ) {
|
329 |
+
|
330 |
+
$field = array_merge( $this->defaults, $field );
|
331 |
+
$value = parent::get_value( $post_id, $field );
|
332 |
+
|
333 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] && 'true' != $field['get_as_timestamp'] && $this->isValidTimeStamp( $value ) ) {
|
334 |
+
if ( 'true' == $field['show_date'] ) {
|
335 |
+
$value = date( sprintf( '%s %s', $this->js_to_php_dateformat( $field['date_format'] ), $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
336 |
+
} else {
|
337 |
+
$value = date( sprintf( '%s', $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
return $value;
|
342 |
+
}
|
343 |
+
|
344 |
+
function js_to_php_dateformat( $date_format ) {
|
345 |
+
|
346 |
+
$chars = array(
|
347 |
+
// Day
|
348 |
+
'dd' => 'd',
|
349 |
+
'd' => 'j',
|
350 |
+
'DD' => 'l',
|
351 |
+
'D' => 'D',
|
352 |
+
'o' => 'z',
|
353 |
+
// Month
|
354 |
+
'mm' => 'm',
|
355 |
+
'm' => 'n',
|
356 |
+
'MM' => 'F',
|
357 |
+
'M' => 'M',
|
358 |
+
// Year
|
359 |
+
'yy' => 'Y',
|
360 |
+
'y' => 'y',
|
361 |
+
);
|
362 |
+
|
363 |
+
return strtr( (string) $date_format, $chars );
|
364 |
+
}
|
365 |
+
|
366 |
+
function js_to_php_timeformat( $time_format ) {
|
367 |
+
|
368 |
+
$chars = array(
|
369 |
+
//hour
|
370 |
+
'HH' => 'H',
|
371 |
+
'H' => 'G',
|
372 |
+
'hh' => 'h',
|
373 |
+
'h' => 'g',
|
374 |
+
//minute
|
375 |
+
'mm' => 'i',
|
376 |
+
'm' => 'i',
|
377 |
+
//second
|
378 |
+
'ss' => 's',
|
379 |
+
's' => 's',
|
380 |
+
//am/pm
|
381 |
+
'TT' => 'A',
|
382 |
+
'T' => 'A',
|
383 |
+
'tt' => 'a',
|
384 |
+
't' => 'a',
|
385 |
+
);
|
386 |
+
|
387 |
+
return strtr( (string) $time_format, $chars );
|
388 |
+
}
|
389 |
+
|
390 |
+
function isValidTimeStamp( $timestamp ) {
|
391 |
+
|
392 |
+
return ( (string) (int) $timestamp === (string) $timestamp );
|
393 |
+
}
|
394 |
+
|
395 |
+
/*--------------------------------------------------------------------------------------
|
396 |
+
*
|
397 |
+
* admin_print_scripts / admin_print_styles
|
398 |
+
* - this function is called in the admin_print_scripts / admin_print_styles where
|
399 |
+
* your field is created. Use this function to register css and javascript to assist
|
400 |
+
* your create_field() function.
|
401 |
+
*
|
402 |
+
* @author Elliot Condon
|
403 |
+
* @since 3.0.0
|
404 |
+
*
|
405 |
+
*-------------------------------------------------------------------------------------*/
|
406 |
+
|
407 |
+
function admin_print_scripts() {
|
408 |
+
|
409 |
+
global $wp_locale;
|
410 |
+
|
411 |
+
$has_locale = false;
|
412 |
+
$js_locale = $this->get_js_locale( get_locale() );
|
413 |
+
wp_enqueue_script('jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
414 |
+
'acf-datepicker',
|
415 |
+
'jquery-ui-slider',
|
416 |
+
), $this->settings['version'], true);
|
417 |
+
|
418 |
+
if ( file_exists( dirname( __FILE__ ) . '/js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
419 |
+
wp_enqueue_script('timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
420 |
+
'jquery-ui-timepicker'
|
421 |
+
), $this->settings['version'], true);
|
422 |
+
wp_enqueue_script('timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
423 |
+
'timepicker-localization'
|
424 |
+
), $this->settings['version'], true);
|
425 |
+
$has_locale = true;
|
426 |
+
} else {
|
427 |
+
wp_enqueue_script('timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
428 |
+
'jquery-ui-timepicker'
|
429 |
+
), $this->settings['version'], true);
|
430 |
+
}
|
431 |
+
|
432 |
+
if ( ! $has_locale && 'en' != $js_locale ) {
|
433 |
+
$timepicker_locale = array(
|
434 |
+
'closeText' => __( 'Done', $this->domain ),
|
435 |
+
'currentText' => __( 'Today', $this->domain ),
|
436 |
+
'prevText' => __( 'Prev', $this->domain ),
|
437 |
+
'nextText' => __( 'Next', $this->domain ),
|
438 |
+
'monthStatus' => __( 'Show a different month', $this->domain ),
|
439 |
+
'weekHeader' => __( 'Wk', $this->domain ),
|
440 |
+
'timeText' => __( 'Time', $this->domain ),
|
441 |
+
'hourText' => __( 'Hour', $this->domain ),
|
442 |
+
'minuteText' => __( 'Minute', $this->domain ),
|
443 |
+
'secondText' => __( 'Second', $this->domain ),
|
444 |
+
'millisecText' => __( 'Millisecond', $this->domain ),
|
445 |
+
'timezoneText' => __( 'Time Zone', $this->domain ),
|
446 |
+
'isRTL' => $wp_locale->is_rtl(),
|
447 |
+
);
|
448 |
+
}
|
449 |
+
$timepicker_wp_locale = array(
|
450 |
+
'monthNames' => $this->strip_array_indices( $wp_locale->month ),
|
451 |
+
'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev ),
|
452 |
+
'dayNames' => $this->strip_array_indices( $wp_locale->weekday ),
|
453 |
+
'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev ),
|
454 |
+
'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial ),
|
455 |
+
'showMonthAfterYear' => false,
|
456 |
+
'showWeek' => false,
|
457 |
+
'firstDay' => get_option( 'start_of_week' ),
|
458 |
+
);
|
459 |
+
|
460 |
+
$l10n = (isset( $timepicker_locale )) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
|
461 |
+
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
|
462 |
+
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
|
467 |
+
* @param array $ArrayToStrip
|
468 |
+
* @return array
|
469 |
+
*/
|
470 |
+
function strip_array_indices( $array_to_strip ) {
|
471 |
+
|
472 |
+
foreach ( $array_to_strip as $obj_array_item ) {
|
473 |
+
$new_array[] = $obj_array_item;
|
474 |
+
}
|
475 |
+
|
476 |
+
return $new_array;
|
477 |
+
}
|
478 |
+
|
479 |
+
function get_js_locale( $locale ) {
|
480 |
+
|
481 |
+
$dir_path = $this->settings['path'] . 'js/localization/';
|
482 |
+
$exclude_list = array( '.', '..' );
|
483 |
+
$languages = $this->ps_preg_filter( '/jquery-ui-timepicker-(.*?)\.js/', '$1', array_diff( scandir( $dir_path ), $exclude_list ) );
|
484 |
+
|
485 |
+
$locale = strtolower( str_replace( '_', '-', $locale ) );
|
486 |
+
|
487 |
+
if ( false !== strpos( $locale, '-' ) ) {
|
488 |
+
$l = explode( '-', $locale );
|
489 |
+
$pattern = array( '/' . $locale . '/', '/' . $l[0] . '/', '/' . $l[1] . '/' );
|
490 |
+
} else {
|
491 |
+
$pattern = array( '/' . $locale . '/' );
|
492 |
+
}
|
493 |
+
$res = $this->ps_preg_filter( $pattern, '$0', $languages, -1, $count );
|
494 |
+
|
495 |
+
return ($count) ? implode( '', $res ) : 'en';
|
496 |
+
}
|
497 |
+
|
498 |
+
function ps_preg_filter( $pattern, $replace, $subject, $limit = -1, &$count = 0 ) {
|
499 |
+
|
500 |
+
if ( function_exists( 'preg_filter' ) ) {
|
501 |
+
return preg_filter( $pattern, $replace, $subject, $limit, $count );
|
502 |
+
} else {
|
503 |
+
return array_diff( preg_replace( $pattern, $replace, $subject, $limit, $count ), $subject );
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
function admin_print_styles() {
|
508 |
+
|
509 |
+
wp_enqueue_style( 'jquery-style', $this->settings['dir'] . 'css/jquery-ui.css' );
|
510 |
+
wp_enqueue_style('timepicker', $this->settings['dir'] . 'css/jquery-ui-timepicker-addon.css', array(
|
511 |
+
'jquery-style'
|
512 |
+
), $this->settings['version']);
|
513 |
+
}
|
514 |
+
}
|
date-time-picker-v4.php
ADDED
@@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
|
4 |
+
class ACFFieldDateTimePicker extends acf_field
|
5 |
+
{
|
6 |
+
// vars
|
7 |
+
var $settings // will hold info such as dir / path
|
8 |
+
, $defaults // will hold default field options
|
9 |
+
, $domain // holds the language domain
|
10 |
+
, $lang;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* __construct
|
14 |
+
*
|
15 |
+
* Set name / label needed for actions / filters
|
16 |
+
*
|
17 |
+
* @since 3.6
|
18 |
+
* @date 23/01/13
|
19 |
+
*/
|
20 |
+
function __construct() {
|
21 |
+
// vars
|
22 |
+
$this->name = 'date_time_picker';
|
23 |
+
$this->label = __( 'Date and Time Picker' );
|
24 |
+
$this->category = __( 'jQuery', $this->domain ); // Basic, Content, Choice, etc
|
25 |
+
$this->domain = 'acf-field-date-time-picker';
|
26 |
+
$this->defaults = array(
|
27 |
+
'label' => __( 'Choose Time', $this->domain ),
|
28 |
+
'time_format' => 'h:mm tt',
|
29 |
+
'show_date' => 'true',
|
30 |
+
'date_format' => 'm/d/y',
|
31 |
+
'show_week_number' => 'false',
|
32 |
+
'picker' => 'slider',
|
33 |
+
'save_as_timestamp' => 'true',
|
34 |
+
'get_as_timestamp' => 'false',
|
35 |
+
);
|
36 |
+
|
37 |
+
// do not delete!
|
38 |
+
parent::__construct();
|
39 |
+
|
40 |
+
// settings
|
41 |
+
$this->settings = array(
|
42 |
+
'path' => apply_filters( 'acf/helpers/get_path', __FILE__ ),
|
43 |
+
'dir' => apply_filters( 'acf/helpers/get_dir', __FILE__ ),
|
44 |
+
'version' => ACFFIELDDATETIMEPICKER_VERSION,
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* create_options()
|
50 |
+
*
|
51 |
+
* Create extra options for your field. This is rendered when editing a field.
|
52 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
53 |
+
*
|
54 |
+
* @type action
|
55 |
+
* @since 3.6
|
56 |
+
* @date 23/01/13
|
57 |
+
*
|
58 |
+
* @param $field - an array holding all the field's data
|
59 |
+
*/
|
60 |
+
function create_options( $field ) {
|
61 |
+
|
62 |
+
$field = array_merge( $this->defaults, $field );
|
63 |
+
$key = $field['name'];
|
64 |
+
?>
|
65 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
|
66 |
+
<td class="label">
|
67 |
+
<label for=""><?php _e( 'Date and Time Picker?', $this->domain ); ?></label>
|
68 |
+
</td>
|
69 |
+
<td>
|
70 |
+
<?php
|
71 |
+
do_action('acf/create_field', array(
|
72 |
+
'type' => 'radio',
|
73 |
+
'name' => 'fields[' . $key . '][show_date]',
|
74 |
+
'value' => $field['show_date'],
|
75 |
+
'layout' => 'horizontal',
|
76 |
+
'choices' => array(
|
77 |
+
'true' => __( 'Date and Time Picker', $this->domain ),
|
78 |
+
'false' => __( 'Time Picker', $this->domain ),
|
79 |
+
),
|
80 |
+
));
|
81 |
+
?>
|
82 |
+
</td>
|
83 |
+
</tr>
|
84 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
|
85 |
+
<td class="label">
|
86 |
+
<label><?php _e( 'Date Format', $this->domain ); ?></label>
|
87 |
+
<p class="description"><?php printf( __( 'eg. mm/dd/yy. read more about <a href="%s" target="_blank">formatting date</a>', $this->domain ), 'http://docs.jquery.com/UI/Datepicker/formatDate' ); ?></p>
|
88 |
+
</td>
|
89 |
+
<td>
|
90 |
+
<?php
|
91 |
+
do_action('acf/create_field', array(
|
92 |
+
'type' => 'text',
|
93 |
+
'name' => 'fields[' . $key . '][date_format]',
|
94 |
+
'value' => $field['date_format'],
|
95 |
+
));
|
96 |
+
/*
|
97 |
+
do_action('acf/create_field', array(
|
98 |
+
'type' => 'select',
|
99 |
+
'name' => 'fields['.$key.'][date_format]',
|
100 |
+
'value' => $field['date_format'],
|
101 |
+
'choices' => array(
|
102 |
+
'm/d/y' => 'm/d/y (5/27/13)'
|
103 |
+
, 'mm/dd/yy' => 'mm/dd/yy (05/27/2013)'
|
104 |
+
, 'yy/mm/dd' => 'yy/mm/dd (2013/05/27)'
|
105 |
+
, 'yy-mm-dd' => 'yy-mm-dd (2013-05-27)'
|
106 |
+
, 'dd.mm.yy' => 'dd.mm.yy (27.05.2013)'
|
107 |
+
, 'dd-mm-yy' => 'dd-mm-yy (27-05-2013)'
|
108 |
+
, 'yy-M-dd' => 'yy-M-dd (2013-May-27)'
|
109 |
+
)
|
110 |
+
));
|
111 |
+
*/
|
112 |
+
?>
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
|
116 |
+
<td class="label">
|
117 |
+
<label><?php _e( 'Time Format', $this->domain ); ?></label>
|
118 |
+
<p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', $this->domain ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
|
119 |
+
</td>
|
120 |
+
<td>
|
121 |
+
<?php
|
122 |
+
do_action('acf/create_field', array(
|
123 |
+
'type' => 'text',
|
124 |
+
'name' => 'fields[' . $key . '][time_format]',
|
125 |
+
'value' => $field['time_format'],
|
126 |
+
));
|
127 |
+
/*
|
128 |
+
do_action('acf/create_field', array(
|
129 |
+
'type' => 'select',
|
130 |
+
'name' => 'fields['.$key.'][time_format]',
|
131 |
+
'value' => $field['time_format'],
|
132 |
+
'choices' => array(
|
133 |
+
'h:mm tt' => 'h:mm tt (9:59 am)'
|
134 |
+
, 'hh:mm tt' => 'hh:mm tt (09:59 am)'
|
135 |
+
, 'H:mm' => 'H:mm (9:59)'
|
136 |
+
, 'HH:mm' => 'HH:mm (09:59)'
|
137 |
+
)
|
138 |
+
));
|
139 |
+
*/
|
140 |
+
?>
|
141 |
+
</td>
|
142 |
+
</tr>
|
143 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
144 |
+
<td class="label">
|
145 |
+
<label for=""><?php _e( 'Display Week Number?', $this->domain ); ?></label>
|
146 |
+
</td>
|
147 |
+
<td>
|
148 |
+
<?php
|
149 |
+
do_action('acf/create_field', array(
|
150 |
+
'type' => 'radio',
|
151 |
+
'name' => 'fields[' . $key . '][show_week_number]',
|
152 |
+
'value' => $field['show_week_number'],
|
153 |
+
'layout' => 'horizontal',
|
154 |
+
'choices' => array(
|
155 |
+
'true' => __( 'Yes', $this->domain ),
|
156 |
+
'false' => __( 'No', $this->domain ),
|
157 |
+
),
|
158 |
+
));
|
159 |
+
?>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
163 |
+
<td class="label">
|
164 |
+
<label for=""><?php _e( 'Time Picker style?', $this->domain ); ?></label>
|
165 |
+
</td>
|
166 |
+
<td>
|
167 |
+
<?php
|
168 |
+
do_action('acf/create_field', array(
|
169 |
+
'type' => 'radio',
|
170 |
+
'name' => 'fields[' . $key . '][picker]',
|
171 |
+
'value' => $field['picker'],
|
172 |
+
'layout' => 'horizontal',
|
173 |
+
'choices' => array(
|
174 |
+
'slider' => __( 'Slider', $this->domain ),
|
175 |
+
'select' => __( 'Dropdown', $this->domain ),
|
176 |
+
),
|
177 |
+
));
|
178 |
+
?>
|
179 |
+
</td>
|
180 |
+
</tr>
|
181 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
182 |
+
<td class="label">
|
183 |
+
<label for=""><?php _e( 'Save as timestamp?', $this->domain ); ?></label>
|
184 |
+
<p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', $this->domain ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
|
185 |
+
</td>
|
186 |
+
<td>
|
187 |
+
<?php
|
188 |
+
do_action('acf/create_field', array(
|
189 |
+
'type' => 'radio',
|
190 |
+
'name' => 'fields[' . $key . '][save_as_timestamp]',
|
191 |
+
'value' => $field['save_as_timestamp'],
|
192 |
+
'layout' => 'horizontal',
|
193 |
+
'choices' => array(
|
194 |
+
'true' => __( 'Yes', $this->domain ),
|
195 |
+
'false' => __( 'No', $this->domain ),
|
196 |
+
),
|
197 |
+
));
|
198 |
+
?>
|
199 |
+
</td>
|
200 |
+
</tr>
|
201 |
+
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
202 |
+
<td class="label">
|
203 |
+
<label for=""><?php _e( 'Get field as timestamp?', $this->domain ); ?></label>
|
204 |
+
<p class="description"><?php printf(__( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%s" target="_blank">the_field()</a> or <a href="%s" target="_blank">get_field()</a> ', $this->domain ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
|
205 |
+
'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
|
206 |
+
</td>
|
207 |
+
<td>
|
208 |
+
<?php
|
209 |
+
do_action('acf/create_field', array(
|
210 |
+
'type' => 'radio',
|
211 |
+
'name' => 'fields[' . $key . '][get_as_timestamp]',
|
212 |
+
'value' => $field['get_as_timestamp'],
|
213 |
+
'layout' => 'horizontal',
|
214 |
+
'choices' => array(
|
215 |
+
'true' => __( 'Yes', $this->domain ),
|
216 |
+
'false' => __( 'No', $this->domain ),
|
217 |
+
),
|
218 |
+
));
|
219 |
+
?>
|
220 |
+
</td>
|
221 |
+
</tr>
|
222 |
+
<?php
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* create_field()
|
227 |
+
*
|
228 |
+
* Create the HTML interface for your field
|
229 |
+
*
|
230 |
+
* @param $field - an array holding all the field's data
|
231 |
+
*
|
232 |
+
* @type action
|
233 |
+
* @since 3.6
|
234 |
+
* @date 23/01/13
|
235 |
+
*/
|
236 |
+
function create_field( $field ) {
|
237 |
+
|
238 |
+
if ( 'true' !== $field['show_date'] ) {
|
239 |
+
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
|
240 |
+
} else {
|
241 |
+
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
//function load_field_defaults( $field ) { return $field; }
|
246 |
+
|
247 |
+
function format_value( $value, $post_id, $field ) {
|
248 |
+
|
249 |
+
$field = array_merge( $this->defaults, $field );
|
250 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] && $this->isValidTimeStamp( $value ) ) {
|
251 |
+
if ( 'true' == $field['show_date'] ) {
|
252 |
+
$value = date_i18n( sprintf( '%s %s', $this->js_to_php_dateformat( $field['date_format'] ), $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
253 |
+
} else {
|
254 |
+
$value = date_i18n( sprintf( '%s', $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
255 |
+
}
|
256 |
+
}
|
257 |
+
return $value;
|
258 |
+
}
|
259 |
+
|
260 |
+
function format_value_for_api( $value, $post_id, $field ) {
|
261 |
+
|
262 |
+
$field = array_merge( $this->defaults, $field );
|
263 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] && 'true' != $field['get_as_timestamp'] && $this->isValidTimeStamp( $value ) ) {
|
264 |
+
if ( 'true' == $field['show_date'] ) {
|
265 |
+
$value = date_i18n( sprintf( '%s %s', $this->js_to_php_dateformat( $field['date_format'] ), $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
266 |
+
} else {
|
267 |
+
$value = date_i18n( sprintf( '%s', $this->js_to_php_timeformat( $field['time_format'] ) ), $value );
|
268 |
+
}
|
269 |
+
}
|
270 |
+
return $value;
|
271 |
+
}
|
272 |
+
|
273 |
+
function js_to_php_dateformat( $date_format ) {
|
274 |
+
|
275 |
+
$chars = array(
|
276 |
+
// Day
|
277 |
+
'dd' => 'd',
|
278 |
+
'd' => 'j',
|
279 |
+
'DD' => 'l',
|
280 |
+
'D' => 'D',
|
281 |
+
'o' => 'z',
|
282 |
+
// Month
|
283 |
+
'mm' => 'm',
|
284 |
+
'm' => 'n',
|
285 |
+
'MM' => 'F',
|
286 |
+
'M' => 'M',
|
287 |
+
// Year
|
288 |
+
'yy' => 'Y',
|
289 |
+
'y' => 'y',
|
290 |
+
);
|
291 |
+
|
292 |
+
return strtr( (string) $date_format, $chars );
|
293 |
+
}
|
294 |
+
|
295 |
+
function js_to_php_timeformat( $time_format ) {
|
296 |
+
|
297 |
+
$chars = array(
|
298 |
+
//hour
|
299 |
+
'HH' => 'H',
|
300 |
+
'H' => 'G',
|
301 |
+
'hh' => 'h',
|
302 |
+
'h' => 'g',
|
303 |
+
//minute
|
304 |
+
'mm' => 'i',
|
305 |
+
'm' => 'i',
|
306 |
+
//second
|
307 |
+
'ss' => 's',
|
308 |
+
's' => 's',
|
309 |
+
//am/pm
|
310 |
+
'TT' => 'A',
|
311 |
+
'T' => 'A',
|
312 |
+
'tt' => 'a',
|
313 |
+
't' => 'a',
|
314 |
+
);
|
315 |
+
|
316 |
+
return strtr( (string) $time_format, $chars );
|
317 |
+
}
|
318 |
+
|
319 |
+
function isValidTimeStamp( $timestamp ) {
|
320 |
+
|
321 |
+
return ( (string) (int) $timestamp === (string) $timestamp );
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* update_value()
|
326 |
+
*
|
327 |
+
* This filter is appied to the $value before it is updated in the db
|
328 |
+
*
|
329 |
+
* @type filter
|
330 |
+
* @since 3.6
|
331 |
+
* @date 23/01/13
|
332 |
+
*
|
333 |
+
* @param $value - the value which will be saved in the database
|
334 |
+
* @param $post_id - the $post_id of which the value will be saved
|
335 |
+
* @param $field - the field array holding all the field options
|
336 |
+
*
|
337 |
+
* @return $value - the modified value
|
338 |
+
*/
|
339 |
+
function update_value( $value, $post_id, $field ) {
|
340 |
+
|
341 |
+
$field = array_merge( $this->defaults, $field );
|
342 |
+
if ( '' != $value && 'true' == $field['save_as_timestamp'] ) {
|
343 |
+
if ( preg_match( '/^dd?\//', $field['date_format'] ) ) { //if start with dd/ or d/ (not supported by strtotime())
|
344 |
+
$value = str_replace( '/', '-', $value );
|
345 |
+
}
|
346 |
+
$value = strtotime( $value );
|
347 |
+
}
|
348 |
+
|
349 |
+
return $value;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* input_admin_enqueue_scripts()
|
354 |
+
*
|
355 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
356 |
+
* Use this action to add css + javascript to assist your create_field() action.
|
357 |
+
*
|
358 |
+
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
359 |
+
* @type action
|
360 |
+
* @since 3.6
|
361 |
+
* @date 23/01/13
|
362 |
+
*/
|
363 |
+
function input_admin_enqueue_scripts() {
|
364 |
+
global $wp_locale;
|
365 |
+
|
366 |
+
$has_locale = false;
|
367 |
+
$js_locale = $this->get_js_locale( get_locale() );
|
368 |
+
|
369 |
+
wp_enqueue_script('jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
370 |
+
'acf-input',
|
371 |
+
'jquery-ui-slider',
|
372 |
+
), $this->settings['version'], true);
|
373 |
+
|
374 |
+
if ( file_exists( $this->settings['path'] . '/js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
375 |
+
wp_enqueue_script('timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
376 |
+
'jquery-ui-timepicker'
|
377 |
+
), $this->settings['version'], true);
|
378 |
+
wp_enqueue_script('timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
379 |
+
'timepicker-localization'
|
380 |
+
), $this->settings['version'], true);
|
381 |
+
$has_locale = true;
|
382 |
+
} else {
|
383 |
+
wp_enqueue_script('timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
384 |
+
'jquery-ui-timepicker'
|
385 |
+
), $this->settings['version'], true);
|
386 |
+
}
|
387 |
+
|
388 |
+
if ( ! $has_locale && 'en' != $js_locale ) {
|
389 |
+
$timepicker_locale = array(
|
390 |
+
'closeText' => __( 'Done', $this->domain ),
|
391 |
+
'currentText' => __( 'Today', $this->domain ),
|
392 |
+
'prevText' => __( 'Prev', $this->domain ),
|
393 |
+
'nextText' => __( 'Next', $this->domain ),
|
394 |
+
'monthStatus' => __( 'Show a different month', $this->domain ),
|
395 |
+
'weekHeader' => __( 'Wk', $this->domain ),
|
396 |
+
'timeText' => __( 'Time', $this->domain ),
|
397 |
+
'hourText' => __( 'Hour', $this->domain ),
|
398 |
+
'minuteText' => __( 'Minute', $this->domain ),
|
399 |
+
'secondText' => __( 'Second', $this->domain ),
|
400 |
+
'millisecText' => __( 'Millisecond', $this->domain ),
|
401 |
+
'timezoneText' => __( 'Time Zone', $this->domain ),
|
402 |
+
'isRTL' => $wp_locale->is_rtl(),
|
403 |
+
);
|
404 |
+
}
|
405 |
+
$timepicker_wp_locale = array(
|
406 |
+
'monthNames' => $this->strip_array_indices( $wp_locale->month ),
|
407 |
+
'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev ),
|
408 |
+
'dayNames' => $this->strip_array_indices( $wp_locale->weekday ),
|
409 |
+
'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev ),
|
410 |
+
'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial ),
|
411 |
+
'showMonthAfterYear' => false,
|
412 |
+
'showWeek' => false,
|
413 |
+
'firstDay' => get_option( 'start_of_week' ),
|
414 |
+
);
|
415 |
+
|
416 |
+
$l10n = (isset( $timepicker_locale )) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
|
417 |
+
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
|
418 |
+
|
419 |
+
wp_enqueue_style('jquery-style', $this->settings['dir'] . 'css/jquery-ui.css', array(
|
420 |
+
'acf-datepicker'
|
421 |
+
), $this->settings['version']);
|
422 |
+
wp_enqueue_style('timepicker', $this->settings['dir'] . 'css/jquery-ui-timepicker-addon.css', array(
|
423 |
+
'jquery-style'
|
424 |
+
), $this->settings['version']);
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
|
429 |
+
* @param array $ArrayToStrip
|
430 |
+
* @return array
|
431 |
+
*/
|
432 |
+
function strip_array_indices( $array_to_strip ) {
|
433 |
+
|
434 |
+
foreach ( $array_to_strip as $obj_array_item ) {
|
435 |
+
$new_array[] = $obj_array_item;
|
436 |
+
}
|
437 |
+
|
438 |
+
return $new_array;
|
439 |
+
}
|
440 |
+
|
441 |
+
function get_js_locale( $locale ) {
|
442 |
+
|
443 |
+
$dir_path = $this->settings['path'] . 'js/localization/';
|
444 |
+
$exclude_list = array( '.', '..' );
|
445 |
+
$languages = $this->ps_preg_filter( '/jquery-ui-timepicker-(.*?)\.js/', '$1', array_diff( scandir( $dir_path ), $exclude_list ) );
|
446 |
+
|
447 |
+
$locale = strtolower( str_replace( '_', '-', $locale ) );
|
448 |
+
|
449 |
+
if ( false !== strpos( $locale, '-' ) ) {
|
450 |
+
$l = explode( '-', $locale );
|
451 |
+
$pattern = array( '/' . $locale . '/', '/' . $l[0] . '/', '/' . $l[1] . '/' );
|
452 |
+
} else {
|
453 |
+
$pattern = array( '/' . $locale . '/' );
|
454 |
+
}
|
455 |
+
$res = $this->ps_preg_filter( $pattern, '$0', $languages, -1, $count );
|
456 |
+
|
457 |
+
return ($count) ? implode( '', $res ) : 'en';
|
458 |
+
}
|
459 |
+
|
460 |
+
function ps_preg_filter( $pattern, $replace, $subject, $limit = -1, &$count = 0 ) {
|
461 |
+
|
462 |
+
if ( function_exists( 'preg_filter' ) ) {
|
463 |
+
return preg_filter( $pattern, $replace, $subject, $limit, $count );
|
464 |
+
} else {
|
465 |
+
return array_diff( preg_replace( $pattern, $replace, $subject, $limit, $count ), $subject );
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
+
// create field
|
471 |
+
new ACFFieldDateTimePicker();
|
472 |
+
endif;
|
date_time_picker-v3.php
DELETED
@@ -1,503 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_date_time_picker extends acf_Field {
|
4 |
-
|
5 |
-
// vars
|
6 |
-
var $settings // will hold info such as dir / path
|
7 |
-
, $defaults // will hold default field options
|
8 |
-
, $domain; // holds the language domain
|
9 |
-
|
10 |
-
|
11 |
-
/*--------------------------------------------------------------------------------------
|
12 |
-
*
|
13 |
-
* Constructor
|
14 |
-
* - This function is called when the field class is initalized on each page.
|
15 |
-
* - Here you can add filters / actions and setup any other functionality for your field
|
16 |
-
*
|
17 |
-
* @author Elliot Condon
|
18 |
-
* @since 2.2.0
|
19 |
-
*
|
20 |
-
*-------------------------------------------------------------------------------------*/
|
21 |
-
|
22 |
-
function __construct( $parent ) {
|
23 |
-
// do not delete!
|
24 |
-
parent::__construct( $parent );
|
25 |
-
|
26 |
-
// set name / title
|
27 |
-
$this->name = 'date_time_picker';
|
28 |
-
$this->title = __( 'Date and Time Picker' );
|
29 |
-
$this->domain = 'acf-field-date-time-picker';
|
30 |
-
$this->defaults = array(
|
31 |
-
'label' => __( 'Choose Time', $this->domain )
|
32 |
-
, 'time_format' => 'hh:mm'
|
33 |
-
, 'show_date' => 'true'
|
34 |
-
, 'date_format' => 'yy-mm-dd'
|
35 |
-
, 'show_week_number' => 'false'
|
36 |
-
, 'picker' => 'slider'
|
37 |
-
, 'save_as_timestamp' => 'true'
|
38 |
-
, 'get_as_timestamp' => 'false'
|
39 |
-
);
|
40 |
-
|
41 |
-
$this->settings = array(
|
42 |
-
'path' => $this->helpers_get_path( __FILE__ )
|
43 |
-
, 'dir' => $this->helpers_get_dir( __FILE__ )
|
44 |
-
, 'version' => '2.0.9'
|
45 |
-
);
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/*
|
50 |
-
* helpers_get_path
|
51 |
-
*
|
52 |
-
* @description: calculates the path (works for plugin / theme folders)
|
53 |
-
* @since: 3.6
|
54 |
-
* @created: 30/01/13
|
55 |
-
*/
|
56 |
-
|
57 |
-
function helpers_get_path( $file ) {
|
58 |
-
return trailingslashit(dirname($file));
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
/*
|
64 |
-
* helpers_get_dir
|
65 |
-
*
|
66 |
-
* @description: calculates the directory (works for plugin / theme folders)
|
67 |
-
* @since: 3.6
|
68 |
-
* @created: 30/01/13
|
69 |
-
*/
|
70 |
-
|
71 |
-
function helpers_get_dir( $file ) {
|
72 |
-
$dir = trailingslashit(dirname($file));
|
73 |
-
$count = 0;
|
74 |
-
|
75 |
-
|
76 |
-
// sanitize for Win32 installs
|
77 |
-
$dir = str_replace('\\' ,'/', $dir);
|
78 |
-
|
79 |
-
|
80 |
-
// if file is in plugins folder
|
81 |
-
$wp_plugin_dir = str_replace('\\' ,'/', WP_PLUGIN_DIR);
|
82 |
-
$dir = str_replace($wp_plugin_dir, WP_PLUGIN_URL, $dir, $count);
|
83 |
-
|
84 |
-
|
85 |
-
if( $count < 1 )
|
86 |
-
{
|
87 |
-
// if file is in wp-content folder
|
88 |
-
$wp_content_dir = str_replace('\\' ,'/', WP_CONTENT_DIR);
|
89 |
-
$dir = str_replace($wp_content_dir, WP_CONTENT_URL, $dir, $count);
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
if( $count < 1 )
|
94 |
-
{
|
95 |
-
// if file is in ??? folder
|
96 |
-
$wp_dir = str_replace('\\' ,'/', ABSPATH);
|
97 |
-
$dir = str_replace($wp_dir, site_url('/'), $dir);
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
return $dir;
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
/*--------------------------------------------------------------------------------------
|
107 |
-
*
|
108 |
-
* create_options
|
109 |
-
* - this function is called from core/field_meta_box.php to create extra options
|
110 |
-
* for your field
|
111 |
-
*
|
112 |
-
* @params
|
113 |
-
* - $key (int) - the $_POST obejct key required to save the options to the field
|
114 |
-
* - $field (array) - the field object
|
115 |
-
*
|
116 |
-
* @author Elliot Condon
|
117 |
-
* @since 2.2.0
|
118 |
-
*
|
119 |
-
*-------------------------------------------------------------------------------------*/
|
120 |
-
|
121 |
-
function create_options( $key, $field ) {
|
122 |
-
|
123 |
-
|
124 |
-
$field = array_merge( $this->defaults, $field );
|
125 |
-
?>
|
126 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
|
127 |
-
<td class="label">
|
128 |
-
<label for=""><?php _e( "Date and Time Picker?", $this->domain ); ?></label>
|
129 |
-
</td>
|
130 |
-
<td>
|
131 |
-
<?php
|
132 |
-
$this->parent->create_field( array(
|
133 |
-
'type' => 'radio'
|
134 |
-
, 'name' => 'fields['.$key.'][show_date]'
|
135 |
-
, 'value' => $field['show_date']
|
136 |
-
, 'layout' => 'horizontal'
|
137 |
-
, 'choices' => array(
|
138 |
-
'true' => __( 'Date and Time Picker', $this->domain )
|
139 |
-
, 'false' => __( 'Time Picker', $this->domain )
|
140 |
-
)
|
141 |
-
) );
|
142 |
-
?>
|
143 |
-
</td>
|
144 |
-
</tr>
|
145 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
|
146 |
-
<td class="label">
|
147 |
-
<label><?php _e( "Date Format", $this->domain ); ?></label>
|
148 |
-
<p class="description"><?php _e( "eg. mm/dd/yy. read more about", $this->domain ); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
|
149 |
-
</td>
|
150 |
-
<td>
|
151 |
-
<?php
|
152 |
-
$this->parent->create_field( array(
|
153 |
-
'type' => 'text'
|
154 |
-
, 'name' => 'fields[' . $key . '][date_format]'
|
155 |
-
, 'value' => $field['date_format']
|
156 |
-
) );
|
157 |
-
?>
|
158 |
-
</td>
|
159 |
-
</tr>
|
160 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
|
161 |
-
<td class="label">
|
162 |
-
<label><?php _e( "Time Format", $this->domain );?></label>
|
163 |
-
<p class="description"><?php printf( __( "eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting time</a>", $this->domain ), "http://trentrichardson.com/examples/timepicker/#tp-formatting" );?></p>
|
164 |
-
</td>
|
165 |
-
<td>
|
166 |
-
<?php
|
167 |
-
$this->parent->create_field( array(
|
168 |
-
'type' => 'text'
|
169 |
-
, 'name' => 'fields[' . $key . '][time_format]'
|
170 |
-
, 'value' => $field['time_format']
|
171 |
-
) );
|
172 |
-
?>
|
173 |
-
</td>
|
174 |
-
</tr>
|
175 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
176 |
-
<td class="label">
|
177 |
-
<label for=""><?php _e( "Display Week Number?", $this->domain ); ?></label>
|
178 |
-
</td>
|
179 |
-
<td>
|
180 |
-
<?php
|
181 |
-
$this->parent->create_field( array(
|
182 |
-
'type' => 'radio'
|
183 |
-
, 'name' => 'fields['.$key.'][show_week_number]'
|
184 |
-
, 'value' => $field['show_week_number']
|
185 |
-
, 'layout' => 'horizontal'
|
186 |
-
, 'choices' => array(
|
187 |
-
'true' => __( 'Yes', $this->domain )
|
188 |
-
, 'false' => __( 'No', $this->domain )
|
189 |
-
)
|
190 |
-
) );
|
191 |
-
?>
|
192 |
-
</td>
|
193 |
-
</tr>
|
194 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
195 |
-
<td class="label">
|
196 |
-
<label for=""><?php _e( "Time Picker Style?", $this->domain ); ?></label>
|
197 |
-
</td>
|
198 |
-
<td>
|
199 |
-
<?php
|
200 |
-
$this->parent->create_field( array(
|
201 |
-
'type' => 'radio'
|
202 |
-
, 'name' => 'fields['.$key.'][picker]'
|
203 |
-
, 'value' => $field['picker']
|
204 |
-
, 'layout' => 'horizontal'
|
205 |
-
, 'choices' => array(
|
206 |
-
'slider' => __( 'Slider', $this->domain )
|
207 |
-
, 'select' => __( 'Dropdown', $this->domain )
|
208 |
-
)
|
209 |
-
) );
|
210 |
-
?>
|
211 |
-
</td>
|
212 |
-
</tr>
|
213 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
214 |
-
<td class="label">
|
215 |
-
<label for=""><?php _e( "Save as timestamp?", $this->domain ); ?></label>
|
216 |
-
<p class="description"><?php printf( __( "Most users should leave this untouched, only set it to \"No\" if you need a date and time format not supported by <a href=\"%s\" target=\"_blank\">strtotime</a>", $this->domain ), "http://php.net/manual/en/function.strtotime.php" );?></p>
|
217 |
-
</td>
|
218 |
-
<td>
|
219 |
-
<?php
|
220 |
-
$this->parent->create_field( array(
|
221 |
-
'type' => 'radio'
|
222 |
-
, 'name' => 'fields['.$key.'][save_as_timestamp]'
|
223 |
-
, 'value' => $field['save_as_timestamp']
|
224 |
-
, 'layout' => 'horizontal'
|
225 |
-
, 'choices' => array(
|
226 |
-
'true' => __( 'Yes', $this->domain )
|
227 |
-
, 'false' => __( 'No', $this->domain )
|
228 |
-
)
|
229 |
-
) );
|
230 |
-
?>
|
231 |
-
</td>
|
232 |
-
</tr>
|
233 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
234 |
-
<td class="label">
|
235 |
-
<label for=""><?php _e( "Get field as a timestamp?", $this->domain ); ?></label>
|
236 |
-
<p class="description"><?php printf( __( "Most users should leave this untouched, only set it to \"Yes\" if you need get the date and time field as a timestamp using <a href=\"%s\" target=\"_blank\">the_field()</a> or <a href=\"%s\" target=\"_blank\">get_field()</a> ", $this->domain ), "http://www.advancedcustomfields.com/resources/functions/the_field/", "http://www.advancedcustomfields.com/resources/functions/get_field/" );?></p>
|
237 |
-
</td>
|
238 |
-
<td>
|
239 |
-
<?php
|
240 |
-
$this->parent->create_field( array(
|
241 |
-
'type' => 'radio'
|
242 |
-
, 'name' => 'fields['.$key.'][get_as_timestamp]'
|
243 |
-
, 'value' => $field['get_as_timestamp']
|
244 |
-
, 'layout' => 'horizontal'
|
245 |
-
, 'choices' => array(
|
246 |
-
'true' => __( 'Yes', $this->domain )
|
247 |
-
, 'false' => __( 'No', $this->domain )
|
248 |
-
)
|
249 |
-
) );
|
250 |
-
?>
|
251 |
-
</td>
|
252 |
-
</tr>
|
253 |
-
<?php
|
254 |
-
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/*--------------------------------------------------------------------------------------
|
259 |
-
*
|
260 |
-
* create_field
|
261 |
-
* - this function is called on edit screens to produce the html for this field
|
262 |
-
*
|
263 |
-
* @author Elliot Condon
|
264 |
-
* @since 2.2.0
|
265 |
-
*
|
266 |
-
*-------------------------------------------------------------------------------------*/
|
267 |
-
|
268 |
-
function create_field( $field ) {
|
269 |
-
$field = array_merge( $this->defaults, $field );
|
270 |
-
|
271 |
-
if ( $field['show_date'] != 'true' ) {
|
272 |
-
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
|
273 |
-
} else {
|
274 |
-
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
|
279 |
-
/*--------------------------------------------------------------------------------------
|
280 |
-
*
|
281 |
-
* update_value
|
282 |
-
* - this function is called when saving a post object that your field is assigned to.
|
283 |
-
* the function will pass through the 3 parameters for you to use.
|
284 |
-
*
|
285 |
-
* @params
|
286 |
-
* - $post_id (int) - usefull if you need to save extra data or manipulate the current
|
287 |
-
* post object
|
288 |
-
* - $field (array) - usefull if you need to manipulate the $value based on a field option
|
289 |
-
* - $value (mixed) - the new value of your field.
|
290 |
-
*
|
291 |
-
* @author Elliot Condon
|
292 |
-
* @since 2.2.0
|
293 |
-
*
|
294 |
-
*-------------------------------------------------------------------------------------*/
|
295 |
-
|
296 |
-
function update_value($post_id, $field, $value) {
|
297 |
-
$field = array_merge($this->defaults, $field);
|
298 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true') {
|
299 |
-
if (preg_match('/^dd?\//',$field['date_format'] )) { //if start with dd/ or d/ (not supported by strtotime())
|
300 |
-
$value = str_replace('/', '-', $value);
|
301 |
-
}
|
302 |
-
$value = strtotime( $value );
|
303 |
-
}
|
304 |
-
|
305 |
-
parent::update_value($post_id, $field, $value);
|
306 |
-
}
|
307 |
-
|
308 |
-
|
309 |
-
/*--------------------------------------------------------------------------------------
|
310 |
-
*
|
311 |
-
* get_value
|
312 |
-
* - called from the edit page to get the value of your field. This function is useful
|
313 |
-
* if your field needs to collect extra data for your create_field() function.
|
314 |
-
*
|
315 |
-
* @params
|
316 |
-
* - $post_id (int) - the post ID which your value is attached to
|
317 |
-
* - $field (array) - the field object.
|
318 |
-
*
|
319 |
-
* @author Elliot Condon
|
320 |
-
* @since 2.2.0
|
321 |
-
*
|
322 |
-
*-------------------------------------------------------------------------------------*/
|
323 |
-
|
324 |
-
function get_value($post_id, $field){
|
325 |
-
$field = array_merge($this->defaults, $field);
|
326 |
-
$value = parent::get_value($post_id, $field);
|
327 |
-
|
328 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $this->isValidTimeStamp($value)) {
|
329 |
-
if ( $field['show_date'] == 'true') {
|
330 |
-
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
331 |
-
} else {
|
332 |
-
$value = date(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
return $value;
|
337 |
-
}
|
338 |
-
|
339 |
-
function get_value_for_api($post_id, $field){
|
340 |
-
$field = array_merge($this->defaults, $field);
|
341 |
-
$value = parent::get_value($post_id, $field);
|
342 |
-
|
343 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
|
344 |
-
if ( $field['show_date'] == 'true') {
|
345 |
-
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
346 |
-
} else {
|
347 |
-
$value = date(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
348 |
-
}
|
349 |
-
}
|
350 |
-
|
351 |
-
return $value;
|
352 |
-
}
|
353 |
-
|
354 |
-
function js_to_php_dateformat($date_format) {
|
355 |
-
$chars = array(
|
356 |
-
// Day
|
357 |
-
'dd' => 'd', 'd' => 'j', 'DD' => 'l', 'D' => 'D', 'o' => 'z',
|
358 |
-
// Month
|
359 |
-
'mm' => 'm', 'm' => 'n', 'MM' => 'F', 'M' => 'M',
|
360 |
-
// Year
|
361 |
-
'yy' => 'Y', 'y' => 'y',
|
362 |
-
);
|
363 |
-
|
364 |
-
return strtr((string)$date_format, $chars);
|
365 |
-
}
|
366 |
-
|
367 |
-
|
368 |
-
function js_to_php_timeformat($time_format) {
|
369 |
-
|
370 |
-
$chars = array(
|
371 |
-
//hour
|
372 |
-
'HH' => 'H', 'H' => 'G', 'hh' => 'h' , 'h' => 'g',
|
373 |
-
//minute
|
374 |
-
'mm' => 'i', 'm' => 'i',
|
375 |
-
//second
|
376 |
-
'ss' => 's', 's' => 's',
|
377 |
-
//am/pm
|
378 |
-
'TT' => 'A', 'T' => 'A', 'tt' => 'a', 't' => 'a'
|
379 |
-
);
|
380 |
-
|
381 |
-
return strtr((string)$time_format, $chars);
|
382 |
-
}
|
383 |
-
|
384 |
-
function isValidTimeStamp($timestamp) {
|
385 |
-
return ((string)(int)$timestamp === (string)$timestamp);
|
386 |
-
}
|
387 |
-
|
388 |
-
/*--------------------------------------------------------------------------------------
|
389 |
-
*
|
390 |
-
* admin_print_scripts / admin_print_styles
|
391 |
-
* - this function is called in the admin_print_scripts / admin_print_styles where
|
392 |
-
* your field is created. Use this function to register css and javascript to assist
|
393 |
-
* your create_field() function.
|
394 |
-
*
|
395 |
-
* @author Elliot Condon
|
396 |
-
* @since 3.0.0
|
397 |
-
*
|
398 |
-
*-------------------------------------------------------------------------------------*/
|
399 |
-
|
400 |
-
function admin_print_scripts() {
|
401 |
-
global $wp_locale;
|
402 |
-
|
403 |
-
$has_locale = false;
|
404 |
-
$js_locale = $this->get_js_locale(get_locale());
|
405 |
-
wp_enqueue_script( 'jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
406 |
-
'acf-datepicker',
|
407 |
-
'jquery-ui-slider'
|
408 |
-
), $this->settings['version'], true );
|
409 |
-
|
410 |
-
if ( file_exists( dirname( __FILE__ ) . '/js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
411 |
-
wp_enqueue_script( 'timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
412 |
-
'jquery-ui-timepicker'
|
413 |
-
), $this->settings['version'], true );
|
414 |
-
wp_enqueue_script( 'timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
415 |
-
'timepicker-localization'
|
416 |
-
), $this->settings['version'], true );
|
417 |
-
$has_locale = true;
|
418 |
-
} else {
|
419 |
-
wp_enqueue_script( 'timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
420 |
-
'jquery-ui-timepicker'
|
421 |
-
), $this->settings['version'], true );
|
422 |
-
}
|
423 |
-
|
424 |
-
if ( ! $has_locale && $js_locale != 'en' ) {
|
425 |
-
$timepicker_locale = array(
|
426 |
-
'closeText' => __( 'Done', $this->domain )
|
427 |
-
, 'currentText' => __( 'Today', $this->domain )
|
428 |
-
, 'prevText' => __( 'Prev', $this->domain )
|
429 |
-
, 'nextText' => __( 'Next', $this->domain )
|
430 |
-
, 'monthStatus' => __( 'Show a different month', $this->domain )
|
431 |
-
, 'weekHeader' => __( 'Wk', $this->domain )
|
432 |
-
, 'timeText' => __( "Time", $this->domain )
|
433 |
-
, 'hourText' => __( "Hour", $this->domain )
|
434 |
-
, 'minuteText' => __( "Minute", $this->domain )
|
435 |
-
, 'secondText' => __( "Second", $this->domain )
|
436 |
-
, 'millisecText' => __( "Millisecond", $this->domain )
|
437 |
-
, 'timezoneText' => __( "Time Zone", $this->domain )
|
438 |
-
, 'isRTL' => $wp_locale->is_rtl()
|
439 |
-
);
|
440 |
-
}
|
441 |
-
$timepicker_wp_locale = array(
|
442 |
-
'monthNames' => $this->strip_array_indices( $wp_locale->month )
|
443 |
-
, 'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev )
|
444 |
-
, 'dayNames' => $this->strip_array_indices( $wp_locale->weekday )
|
445 |
-
, 'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev )
|
446 |
-
, 'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial )
|
447 |
-
, 'showMonthAfterYear' => false
|
448 |
-
, 'showWeek' => false
|
449 |
-
, 'firstDay' => get_option( 'start_of_week' )
|
450 |
-
);
|
451 |
-
|
452 |
-
$l10n = ( isset( $timepicker_locale ) ) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
|
453 |
-
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
|
454 |
-
|
455 |
-
}
|
456 |
-
|
457 |
-
/**
|
458 |
-
* helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
|
459 |
-
* @param array $ArrayToStrip
|
460 |
-
* @return array
|
461 |
-
*/
|
462 |
-
function strip_array_indices( $ArrayToStrip ) {
|
463 |
-
foreach ( $ArrayToStrip as $objArrayItem ) {
|
464 |
-
$NewArray[] = $objArrayItem;
|
465 |
-
}
|
466 |
-
|
467 |
-
return $NewArray;
|
468 |
-
}
|
469 |
-
|
470 |
-
function get_js_locale($locale) {
|
471 |
-
$dir_path = $this->settings['path'] . 'js/localization/';
|
472 |
-
$exclude_list = array(".", "..");
|
473 |
-
$languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
|
474 |
-
|
475 |
-
$locale = strtolower(str_replace("_", "-", $locale));
|
476 |
-
|
477 |
-
if (false !== strpos($locale,'-')) {
|
478 |
-
$l = explode("-",$locale);
|
479 |
-
$pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
|
480 |
-
} else {
|
481 |
-
$pattern = array('/' . $locale . '/');
|
482 |
-
}
|
483 |
-
$res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
|
484 |
-
|
485 |
-
return ($count) ? implode("", $res) : 'en';
|
486 |
-
}
|
487 |
-
|
488 |
-
|
489 |
-
function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
|
490 |
-
if (function_exists('preg_filter'))
|
491 |
-
return preg_filter($pattern, $replace, $subject,$limit,$count);
|
492 |
-
else
|
493 |
-
return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
|
494 |
-
}
|
495 |
-
|
496 |
-
|
497 |
-
function admin_print_styles() {
|
498 |
-
wp_enqueue_style( 'jquery-style', $this->settings['dir'] . 'css/jquery-ui.css' );
|
499 |
-
wp_enqueue_style( 'timepicker', $this->settings['dir'] . 'css/jquery-ui-timepicker-addon.css', array(
|
500 |
-
'jquery-style'
|
501 |
-
), $this->settings['version'] );
|
502 |
-
}
|
503 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date_time_picker-v4.php
DELETED
@@ -1,477 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_date_time_picker extends acf_field
|
4 |
-
{
|
5 |
-
// vars
|
6 |
-
var $settings // will hold info such as dir / path
|
7 |
-
, $defaults // will hold default field options
|
8 |
-
, $domain // holds the language domain
|
9 |
-
, $lang;
|
10 |
-
|
11 |
-
/*
|
12 |
-
* __construct
|
13 |
-
*
|
14 |
-
* Set name / label needed for actions / filters
|
15 |
-
*
|
16 |
-
* @since 3.6
|
17 |
-
* @date 23/01/13
|
18 |
-
*/
|
19 |
-
|
20 |
-
function __construct()
|
21 |
-
{
|
22 |
-
// vars
|
23 |
-
$this->name = 'date_time_picker';
|
24 |
-
$this->label = __('Date and Time Picker');
|
25 |
-
$this->category = __("jQuery", $this->domain); // Basic, Content, Choice, etc
|
26 |
-
$this->domain = 'acf-field-date-time-picker';
|
27 |
-
$this->defaults = array(
|
28 |
-
'label' => __( 'Choose Time', $this->domain )
|
29 |
-
, 'time_format' => 'h:mm tt'
|
30 |
-
, 'show_date' => 'true'
|
31 |
-
, 'date_format' => 'm/d/y'
|
32 |
-
, 'show_week_number' => 'false'
|
33 |
-
, 'picker' => 'slider'
|
34 |
-
, 'save_as_timestamp' => 'true'
|
35 |
-
, 'get_as_timestamp' => 'false'
|
36 |
-
);
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
// do not delete!
|
41 |
-
parent::__construct();
|
42 |
-
|
43 |
-
|
44 |
-
// settings
|
45 |
-
$this->settings = array(
|
46 |
-
'path' => apply_filters('acf/helpers/get_path', __FILE__)
|
47 |
-
, 'dir' => apply_filters('acf/helpers/get_dir', __FILE__)
|
48 |
-
, 'version' => '2.0.9'
|
49 |
-
);
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/*
|
55 |
-
* create_options()
|
56 |
-
*
|
57 |
-
* Create extra options for your field. This is rendered when editing a field.
|
58 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
59 |
-
*
|
60 |
-
* @type action
|
61 |
-
* @since 3.6
|
62 |
-
* @date 23/01/13
|
63 |
-
*
|
64 |
-
* @param $field - an array holding all the field's data
|
65 |
-
*/
|
66 |
-
|
67 |
-
function create_options( $field )
|
68 |
-
{
|
69 |
-
$field = array_merge($this->defaults, $field);
|
70 |
-
$key = $field['name'];
|
71 |
-
?>
|
72 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
|
73 |
-
<td class="label">
|
74 |
-
<label for=""><?php _e( "Date and Time Picker?", $this->domain ); ?></label>
|
75 |
-
</td>
|
76 |
-
<td>
|
77 |
-
<?php
|
78 |
-
do_action('acf/create_field', array(
|
79 |
-
'type' => 'radio'
|
80 |
-
, 'name' => 'fields['.$key.'][show_date]'
|
81 |
-
, 'value' => $field['show_date']
|
82 |
-
, 'layout' => 'horizontal'
|
83 |
-
, 'choices' => array(
|
84 |
-
'true' => __( 'Date and Time Picker', $this->domain )
|
85 |
-
, 'false' => __( 'Time Picker', $this->domain )
|
86 |
-
)
|
87 |
-
) );
|
88 |
-
?>
|
89 |
-
</td>
|
90 |
-
</tr>
|
91 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
|
92 |
-
<td class="label">
|
93 |
-
<label><?php _e( "Date Format", $this->domain ); ?></label>
|
94 |
-
<p class="description"><?php printf(__("eg. mm/dd/yy. read more about <a href=\"%s\" target=\"_blank\">formatting date</a>", $this->domain ),"http://docs.jquery.com/UI/Datepicker/formatDate");?></p>
|
95 |
-
</td>
|
96 |
-
<td>
|
97 |
-
<?php
|
98 |
-
do_action('acf/create_field', array(
|
99 |
-
'type' => 'text'
|
100 |
-
, 'name' => 'fields[' . $key . '][date_format]'
|
101 |
-
, 'value' => $field['date_format']
|
102 |
-
) );
|
103 |
-
/*
|
104 |
-
do_action('acf/create_field', array(
|
105 |
-
'type' => 'select',
|
106 |
-
'name' => 'fields['.$key.'][date_format]',
|
107 |
-
'value' => $field['date_format'],
|
108 |
-
'choices' => array(
|
109 |
-
'm/d/y' => 'm/d/y (5/27/13)'
|
110 |
-
, 'mm/dd/yy' => 'mm/dd/yy (05/27/2013)'
|
111 |
-
, 'yy/mm/dd' => 'yy/mm/dd (2013/05/27)'
|
112 |
-
, 'yy-mm-dd' => 'yy-mm-dd (2013-05-27)'
|
113 |
-
, 'dd.mm.yy' => 'dd.mm.yy (27.05.2013)'
|
114 |
-
, 'dd-mm-yy' => 'dd-mm-yy (27-05-2013)'
|
115 |
-
, 'yy-M-dd' => 'yy-M-dd (2013-May-27)'
|
116 |
-
)
|
117 |
-
));
|
118 |
-
*/
|
119 |
-
?>
|
120 |
-
</td>
|
121 |
-
</tr>
|
122 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
|
123 |
-
<td class="label">
|
124 |
-
<label><?php _e( "Time Format", $this->domain );?></label>
|
125 |
-
<p class="description"><?php printf(__("eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting time</a>", $this->domain ),"http://trentrichardson.com/examples/timepicker/#tp-formatting");?></p>
|
126 |
-
</td>
|
127 |
-
<td>
|
128 |
-
<?php
|
129 |
-
do_action('acf/create_field', array(
|
130 |
-
'type' => 'text'
|
131 |
-
, 'name' => 'fields[' . $key . '][time_format]'
|
132 |
-
, 'value' => $field['time_format']
|
133 |
-
) );
|
134 |
-
/*
|
135 |
-
do_action('acf/create_field', array(
|
136 |
-
'type' => 'select',
|
137 |
-
'name' => 'fields['.$key.'][time_format]',
|
138 |
-
'value' => $field['time_format'],
|
139 |
-
'choices' => array(
|
140 |
-
'h:mm tt' => 'h:mm tt (9:59 am)'
|
141 |
-
, 'hh:mm tt' => 'hh:mm tt (09:59 am)'
|
142 |
-
, 'H:mm' => 'H:mm (9:59)'
|
143 |
-
, 'HH:mm' => 'HH:mm (09:59)'
|
144 |
-
)
|
145 |
-
));
|
146 |
-
*/
|
147 |
-
?>
|
148 |
-
</td>
|
149 |
-
</tr>
|
150 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
151 |
-
<td class="label">
|
152 |
-
<label for=""><?php _e( "Display Week Number?", $this->domain ); ?></label>
|
153 |
-
</td>
|
154 |
-
<td>
|
155 |
-
<?php
|
156 |
-
do_action('acf/create_field', array(
|
157 |
-
'type' => 'radio'
|
158 |
-
, 'name' => 'fields['.$key.'][show_week_number]'
|
159 |
-
, 'value' => $field['show_week_number']
|
160 |
-
, 'layout' => 'horizontal'
|
161 |
-
, 'choices' => array(
|
162 |
-
'true' => __( 'Yes', $this->domain )
|
163 |
-
, 'false' => __( 'No', $this->domain )
|
164 |
-
)
|
165 |
-
) );
|
166 |
-
?>
|
167 |
-
</td>
|
168 |
-
</tr>
|
169 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
170 |
-
<td class="label">
|
171 |
-
<label for=""><?php _e( "Time Picker style?", $this->domain ); ?></label>
|
172 |
-
</td>
|
173 |
-
<td>
|
174 |
-
<?php
|
175 |
-
do_action('acf/create_field', array(
|
176 |
-
'type' => 'radio'
|
177 |
-
, 'name' => 'fields['.$key.'][picker]'
|
178 |
-
, 'value' => $field['picker']
|
179 |
-
, 'layout' => 'horizontal'
|
180 |
-
, 'choices' => array(
|
181 |
-
'slider' => __( 'Slider', $this->domain )
|
182 |
-
, 'select' => __( 'Dropdown', $this->domain )
|
183 |
-
)
|
184 |
-
) );
|
185 |
-
?>
|
186 |
-
</td>
|
187 |
-
</tr>
|
188 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
189 |
-
<td class="label">
|
190 |
-
<label for=""><?php _e( "Save as timestamp?", $this->domain ); ?></label>
|
191 |
-
<p class="description"><?php printf( __( "Most users should leave this untouched, only set it to \"No\" if you need a date and time format not supported by <a href=\"%s\" target=\"_blank\">strtotime</a>", $this->domain ), "http://php.net/manual/en/function.strtotime.php" );?></p>
|
192 |
-
</td>
|
193 |
-
<td>
|
194 |
-
<?php
|
195 |
-
do_action('acf/create_field', array(
|
196 |
-
'type' => 'radio'
|
197 |
-
, 'name' => 'fields['.$key.'][save_as_timestamp]'
|
198 |
-
, 'value' => $field['save_as_timestamp']
|
199 |
-
, 'layout' => 'horizontal'
|
200 |
-
, 'choices' => array(
|
201 |
-
'true' => __( 'Yes', $this->domain )
|
202 |
-
, 'false' => __( 'No', $this->domain )
|
203 |
-
)
|
204 |
-
) );
|
205 |
-
?>
|
206 |
-
</td>
|
207 |
-
</tr>
|
208 |
-
<tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
|
209 |
-
<td class="label">
|
210 |
-
<label for=""><?php _e( "Get field as timestamp?", $this->domain ); ?></label>
|
211 |
-
<p class="description"><?php printf( __( "Most users should leave this untouched, only set it to \"Yes\" if you need get the date and time field as a timestamp using <a href=\"%s\" target=\"_blank\">the_field()</a> or <a href=\"%s\" target=\"_blank\">get_field()</a> ", $this->domain ), "http://www.advancedcustomfields.com/resources/functions/the_field/", "http://www.advancedcustomfields.com/resources/functions/get_field/" );?></p>
|
212 |
-
</td>
|
213 |
-
<td>
|
214 |
-
<?php
|
215 |
-
do_action('acf/create_field', array(
|
216 |
-
'type' => 'radio'
|
217 |
-
, 'name' => 'fields['.$key.'][get_as_timestamp]'
|
218 |
-
, 'value' => $field['get_as_timestamp']
|
219 |
-
, 'layout' => 'horizontal'
|
220 |
-
, 'choices' => array(
|
221 |
-
'true' => __( 'Yes', $this->domain )
|
222 |
-
, 'false' => __( 'No', $this->domain )
|
223 |
-
)
|
224 |
-
) );
|
225 |
-
?>
|
226 |
-
</td>
|
227 |
-
</tr>
|
228 |
-
<?php
|
229 |
-
}
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
/*
|
234 |
-
* create_field()
|
235 |
-
*
|
236 |
-
* Create the HTML interface for your field
|
237 |
-
*
|
238 |
-
* @param $field - an array holding all the field's data
|
239 |
-
*
|
240 |
-
* @type action
|
241 |
-
* @since 3.6
|
242 |
-
* @date 23/01/13
|
243 |
-
*/
|
244 |
-
|
245 |
-
function create_field( $field ) {
|
246 |
-
|
247 |
-
if ( $field['show_date'] !== 'true' ) {
|
248 |
-
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
|
249 |
-
} else {
|
250 |
-
echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
//function load_field_defaults( $field ) { return $field; }
|
255 |
-
|
256 |
-
function format_value($value, $post_id, $field)
|
257 |
-
{
|
258 |
-
$field = array_merge($this->defaults, $field);
|
259 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $this->isValidTimeStamp($value)) {
|
260 |
-
if ( $field['show_date'] == 'true') {
|
261 |
-
$value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
262 |
-
} else {
|
263 |
-
$value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
264 |
-
}
|
265 |
-
}
|
266 |
-
return $value;
|
267 |
-
}
|
268 |
-
|
269 |
-
function format_value_for_api($value, $post_id, $field)
|
270 |
-
{
|
271 |
-
$field = array_merge($this->defaults, $field);
|
272 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
|
273 |
-
if ( $field['show_date'] == 'true') {
|
274 |
-
$value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
275 |
-
} else {
|
276 |
-
$value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
277 |
-
}
|
278 |
-
}
|
279 |
-
return $value;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
function js_to_php_dateformat($date_format) {
|
284 |
-
$chars = array(
|
285 |
-
// Day
|
286 |
-
'dd' => 'd', 'd' => 'j', 'DD' => 'l','D' => 'D', 'o' => 'z',
|
287 |
-
// Month
|
288 |
-
'mm' => 'm', 'm' => 'n', 'MM' => 'F', 'M' => 'M',
|
289 |
-
// Year
|
290 |
-
'yy' => 'Y', 'y' => 'y',
|
291 |
-
);
|
292 |
-
|
293 |
-
return strtr((string)$date_format, $chars);
|
294 |
-
}
|
295 |
-
|
296 |
-
|
297 |
-
function js_to_php_timeformat($time_format) {
|
298 |
-
|
299 |
-
$chars = array(
|
300 |
-
//hour
|
301 |
-
'HH' => 'H', 'H' => 'G', 'hh' => 'h' , 'h' => 'g',
|
302 |
-
//minute
|
303 |
-
'mm' => 'i', 'm' => 'i',
|
304 |
-
//second
|
305 |
-
'ss' => 's', 's' => 's',
|
306 |
-
//am/pm
|
307 |
-
'TT' => 'A', 'T' => 'A', 'tt' => 'a', 't' => 'a'
|
308 |
-
);
|
309 |
-
|
310 |
-
return strtr((string)$time_format, $chars);
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
function isValidTimeStamp($timestamp) {
|
315 |
-
return ((string)(int)$timestamp === (string)$timestamp);
|
316 |
-
}
|
317 |
-
|
318 |
-
/*
|
319 |
-
* update_value()
|
320 |
-
*
|
321 |
-
* This filter is appied to the $value before it is updated in the db
|
322 |
-
*
|
323 |
-
* @type filter
|
324 |
-
* @since 3.6
|
325 |
-
* @date 23/01/13
|
326 |
-
*
|
327 |
-
* @param $value - the value which will be saved in the database
|
328 |
-
* @param $post_id - the $post_id of which the value will be saved
|
329 |
-
* @param $field - the field array holding all the field options
|
330 |
-
*
|
331 |
-
* @return $value - the modified value
|
332 |
-
*/
|
333 |
-
|
334 |
-
// function update_value( $value, $post_id, $field ) {
|
335 |
-
// $field = array_merge($this->defaults, $field);
|
336 |
-
// if ($value != '' && $field['save_as_timestamp'] == 'true') {
|
337 |
-
// $value = strtotime( $value );
|
338 |
-
// }
|
339 |
-
// return $value;
|
340 |
-
// }
|
341 |
-
|
342 |
-
function update_value( $value, $post_id, $field ) {
|
343 |
-
$field = array_merge($this->defaults, $field);
|
344 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true') {
|
345 |
-
if (preg_match('/^dd?\//',$field['date_format'] )) { //if start with dd/ or d/ (not supported by strtotime())
|
346 |
-
$value = str_replace('/', '-', $value);
|
347 |
-
}
|
348 |
-
$value = strtotime( $value );
|
349 |
-
}
|
350 |
-
|
351 |
-
return $value;
|
352 |
-
}
|
353 |
-
|
354 |
-
/*
|
355 |
-
* input_admin_enqueue_scripts()
|
356 |
-
*
|
357 |
-
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
358 |
-
* Use this action to add css + javascript to assist your create_field() action.
|
359 |
-
*
|
360 |
-
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
361 |
-
* @type action
|
362 |
-
* @since 3.6
|
363 |
-
* @date 23/01/13
|
364 |
-
*/
|
365 |
-
|
366 |
-
function input_admin_enqueue_scripts() {
|
367 |
-
|
368 |
-
global $wp_locale;
|
369 |
-
|
370 |
-
$has_locale = false;
|
371 |
-
$js_locale = $this->get_js_locale(get_locale());
|
372 |
-
|
373 |
-
wp_enqueue_script( 'jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
374 |
-
'acf-input',
|
375 |
-
'jquery-ui-slider'
|
376 |
-
), $this->settings['version'], true );
|
377 |
-
|
378 |
-
if ( file_exists( $this->settings['path'] . '/js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
379 |
-
wp_enqueue_script( 'timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
380 |
-
'jquery-ui-timepicker'
|
381 |
-
), $this->settings['version'], true );
|
382 |
-
wp_enqueue_script( 'timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
383 |
-
'timepicker-localization'
|
384 |
-
), $this->settings['version'], true );
|
385 |
-
$has_locale = true;
|
386 |
-
} else {
|
387 |
-
wp_enqueue_script( 'timepicker', $this->settings['dir'] . 'js/timepicker.js', array(
|
388 |
-
'jquery-ui-timepicker'
|
389 |
-
), $this->settings['version'], true );
|
390 |
-
}
|
391 |
-
|
392 |
-
if ( ! $has_locale && $js_locale != 'en' ) {
|
393 |
-
$timepicker_locale = array(
|
394 |
-
'closeText' => __( 'Done', $this->domain )
|
395 |
-
, 'currentText' => __( 'Today', $this->domain )
|
396 |
-
, 'prevText' => __( 'Prev', $this->domain )
|
397 |
-
, 'nextText' => __( 'Next', $this->domain )
|
398 |
-
, 'monthStatus' => __( 'Show a different month', $this->domain )
|
399 |
-
, 'weekHeader' => __( 'Wk', $this->domain )
|
400 |
-
, 'timeText' => __( "Time", $this->domain )
|
401 |
-
, 'hourText' => __( "Hour", $this->domain )
|
402 |
-
, 'minuteText' => __( "Minute", $this->domain )
|
403 |
-
, 'secondText' => __( "Second", $this->domain )
|
404 |
-
, 'millisecText' => __( "Millisecond", $this->domain )
|
405 |
-
, 'timezoneText' => __( "Time Zone", $this->domain )
|
406 |
-
, 'isRTL' => $wp_locale->is_rtl()
|
407 |
-
);
|
408 |
-
}
|
409 |
-
$timepicker_wp_locale = array(
|
410 |
-
'monthNames' => $this->strip_array_indices( $wp_locale->month )
|
411 |
-
, 'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev )
|
412 |
-
, 'dayNames' => $this->strip_array_indices( $wp_locale->weekday )
|
413 |
-
, 'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev )
|
414 |
-
, 'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial )
|
415 |
-
, 'showMonthAfterYear' => false
|
416 |
-
, 'showWeek' => false
|
417 |
-
, 'firstDay' => get_option( 'start_of_week' )
|
418 |
-
);
|
419 |
-
|
420 |
-
$l10n = ( isset( $timepicker_locale ) ) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
|
421 |
-
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
|
422 |
-
|
423 |
-
wp_enqueue_style('jquery-style', $this->settings['dir'] . 'css/jquery-ui.css',array(
|
424 |
-
'acf-datepicker'
|
425 |
-
),$this->settings['version']);
|
426 |
-
wp_enqueue_style('timepicker', $this->settings['dir'] . 'css/jquery-ui-timepicker-addon.css',array(
|
427 |
-
'jquery-style'
|
428 |
-
),$this->settings['version']);
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
|
433 |
-
* @param array $ArrayToStrip
|
434 |
-
* @return array
|
435 |
-
*/
|
436 |
-
function strip_array_indices( $ArrayToStrip ) {
|
437 |
-
foreach ( $ArrayToStrip as $objArrayItem ) {
|
438 |
-
$NewArray[] = $objArrayItem;
|
439 |
-
}
|
440 |
-
|
441 |
-
return $NewArray;
|
442 |
-
}
|
443 |
-
|
444 |
-
function get_js_locale($locale) {
|
445 |
-
$dir_path = $this->settings['path'] . 'js/localization/';
|
446 |
-
$exclude_list = array(".", "..");
|
447 |
-
$languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
|
448 |
-
|
449 |
-
$locale = strtolower(str_replace("_", "-", $locale));
|
450 |
-
|
451 |
-
if (false !== strpos($locale,'-')) {
|
452 |
-
$l = explode("-",$locale);
|
453 |
-
$pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
|
454 |
-
} else {
|
455 |
-
$pattern = array('/' . $locale . '/');
|
456 |
-
}
|
457 |
-
$res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
|
458 |
-
|
459 |
-
return ($count) ? implode("", $res) : 'en';
|
460 |
-
}
|
461 |
-
|
462 |
-
|
463 |
-
function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
|
464 |
-
if (function_exists('preg_filter'))
|
465 |
-
return preg_filter($pattern, $replace, $subject,$limit,$count);
|
466 |
-
else
|
467 |
-
return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
|
468 |
-
}
|
469 |
-
|
470 |
-
|
471 |
-
}
|
472 |
-
|
473 |
-
|
474 |
-
// create field
|
475 |
-
new acf_field_date_time_picker();
|
476 |
-
|
477 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date_time_picker-v5.php
DELETED
@@ -1,411 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_date_time_picker extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'date_time_picker';
|
19 |
-
$this->label = __('Date and Time Picker');
|
20 |
-
$this->domain = 'acf-field-date-time-picker';
|
21 |
-
$this->category = __("jQuery", $this->domain); // Basic, Content, Choice, etc
|
22 |
-
$this->defaults = array(
|
23 |
-
'label' => __( 'Choose Time', $this->domain )
|
24 |
-
, 'time_format' => 'h:mm tt'
|
25 |
-
, 'show_date' => 'true'
|
26 |
-
, 'date_format' => 'm/d/y'
|
27 |
-
, 'show_week_number' => 'false'
|
28 |
-
, 'picker' => 'slider'
|
29 |
-
, 'save_as_timestamp' => 'true'
|
30 |
-
, 'get_as_timestamp' => 'false'
|
31 |
-
);
|
32 |
-
|
33 |
-
$this->version = '2.0.15';
|
34 |
-
$this->dir = plugin_dir_url( __FILE__ );
|
35 |
-
$this->path = plugin_dir_path(__FILE__);
|
36 |
-
|
37 |
-
// do not delete!
|
38 |
-
parent::__construct();
|
39 |
-
}
|
40 |
-
|
41 |
-
|
42 |
-
/*
|
43 |
-
* create_options()
|
44 |
-
*
|
45 |
-
* Create extra options for your field. This is rendered when editing a field.
|
46 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
47 |
-
*
|
48 |
-
* @type action
|
49 |
-
* @since 3.6
|
50 |
-
* @date 23/01/13
|
51 |
-
*
|
52 |
-
* @param $field - an array holding all the field's data
|
53 |
-
*/
|
54 |
-
|
55 |
-
function render_field_settings( $field )
|
56 |
-
{
|
57 |
-
$field = array_merge($this->defaults, $field);
|
58 |
-
$key = $field['name'];
|
59 |
-
|
60 |
-
acf_render_field_setting( $field, array(
|
61 |
-
'type' => 'radio'
|
62 |
-
, 'label' => __( "Date and Time Picker?", $this->domain)
|
63 |
-
, 'name' => 'show_date'
|
64 |
-
, 'value' => $field['show_date']
|
65 |
-
, 'layout' => 'horizontal'
|
66 |
-
, 'choices' => array(
|
67 |
-
'true' => __( 'Date and Time Picker', $this->domain )
|
68 |
-
, 'false' => __( 'Time Picker', $this->domain )
|
69 |
-
)
|
70 |
-
) );
|
71 |
-
|
72 |
-
acf_render_field_setting( $field, array(
|
73 |
-
'type' => 'text'
|
74 |
-
, 'label' => __( "Date Format", $this->domain )
|
75 |
-
, 'instructions' => sprintf(__("eg. mm/dd/yy. read more about <a href=\"%s\" target=\"_blank\">formatting date</a>", $this->domain ),"http://docs.jquery.com/UI/Datepicker/formatDate")
|
76 |
-
, 'name' => 'date_format'
|
77 |
-
, 'value' => $field['date_format']
|
78 |
-
) );
|
79 |
-
|
80 |
-
acf_render_field_setting( $field, array(
|
81 |
-
'type' => 'text'
|
82 |
-
, 'label' => __( "Time Format", $this->domain )
|
83 |
-
, 'instructions' => sprintf(__("eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting time</a>", $this->domain ),"http://trentrichardson.com/examples/timepicker/#tp-formatting")
|
84 |
-
, 'name' => 'time_format'
|
85 |
-
, 'value' => $field['time_format']
|
86 |
-
) );
|
87 |
-
|
88 |
-
acf_render_field_setting( $field, array(
|
89 |
-
'type' => 'radio'
|
90 |
-
, 'label' => __( "Display Week Number?", $this->domain )
|
91 |
-
, 'name' => 'show_week_number'
|
92 |
-
, 'value' => $field['show_week_number']
|
93 |
-
, 'layout' => 'horizontal'
|
94 |
-
, 'choices' => array(
|
95 |
-
'true' => __( 'Yes', $this->domain )
|
96 |
-
, 'false' => __( 'No', $this->domain )
|
97 |
-
)
|
98 |
-
) );
|
99 |
-
|
100 |
-
acf_render_field_setting( $field, array(
|
101 |
-
'type' => 'radio'
|
102 |
-
, 'label' => __( "Time Picker style?", $this->domain )
|
103 |
-
, 'name' => 'picker'
|
104 |
-
, 'value' => $field['picker']
|
105 |
-
, 'layout' => 'horizontal'
|
106 |
-
, 'choices' => array(
|
107 |
-
'slider' => __( 'Slider', $this->domain )
|
108 |
-
, 'select' => __( 'Dropdown', $this->domain )
|
109 |
-
)
|
110 |
-
) );
|
111 |
-
|
112 |
-
acf_render_field_setting( $field, array(
|
113 |
-
'type' => 'radio'
|
114 |
-
, 'label' => __( "Save as timestamp?", $this->domain )
|
115 |
-
, 'instructions' => sprintf( __( "Most users should leave this untouched, only set it to \"No\" if you need a date and time format not supported by <a href=\"%s\" target=\"_blank\">strtotime</a>", $this->domain ), "http://php.net/manual/en/function.strtotime.php" )
|
116 |
-
, 'name' => 'save_as_timestamp'
|
117 |
-
, 'value' => $field['save_as_timestamp']
|
118 |
-
, 'layout' => 'horizontal'
|
119 |
-
, 'choices' => array(
|
120 |
-
'true' => __( 'Yes', $this->domain )
|
121 |
-
, 'false' => __( 'No', $this->domain )
|
122 |
-
)
|
123 |
-
) );
|
124 |
-
|
125 |
-
acf_render_field_setting( $field, array(
|
126 |
-
'type' => 'radio'
|
127 |
-
, 'label' => __( "Get field as timestamp?", $this->domain )
|
128 |
-
, 'instructions' => sprintf( __( "Most users should leave this untouched, only set it to \"Yes\" if you need get the date and time field as a timestamp using <a href=\"%s\" target=\"_blank\">the_field()</a> or <a href=\"%s\" target=\"_blank\">get_field()</a> ", $this->domain ), "http://www.advancedcustomfields.com/resources/functions/the_field/", "http://www.advancedcustomfields.com/resources/functions/get_field/" )
|
129 |
-
, 'name' => 'get_as_timestamp'
|
130 |
-
, 'value' => $field['get_as_timestamp']
|
131 |
-
, 'layout' => 'horizontal'
|
132 |
-
, 'choices' => array(
|
133 |
-
'true' => __( 'Yes', $this->domain )
|
134 |
-
, 'false' => __( 'No', $this->domain )
|
135 |
-
)
|
136 |
-
) );
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
/*
|
142 |
-
* create_field()
|
143 |
-
*
|
144 |
-
* Create the HTML interface for your field
|
145 |
-
*
|
146 |
-
* @param $field - an array holding all the field's data
|
147 |
-
*
|
148 |
-
* @type action
|
149 |
-
* @since 3.6
|
150 |
-
* @date 23/01/13
|
151 |
-
*/
|
152 |
-
|
153 |
-
function render_field( $field ) {
|
154 |
-
|
155 |
-
if ( $field['show_date'] !== 'true' ) {
|
156 |
-
$value = $field['save_as_timestamp'] && $this->isValidTimeStamp($field['value']) ? date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $field['value']) : $field['value'];
|
157 |
-
echo '<input type="text" value="' . $value . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
|
158 |
-
} else {
|
159 |
-
$value = $field['save_as_timestamp'] && $this->isValidTimeStamp($field['value']) ? $value = date_i18n(sprintf("%s %s", $this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $field['value']) : $field['value'];
|
160 |
-
echo '<input type="text" value="' . $value . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
function format_value($value, $post_id, $field)
|
165 |
-
{
|
166 |
-
$field = array_merge($this->defaults, $field);
|
167 |
-
|
168 |
-
/*if ($value != '' && $field['save_as_timestamp'] == 'true' && $this->isValidTimeStamp($value)) {
|
169 |
-
if ( $field['show_date'] == 'true') {
|
170 |
-
$value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
171 |
-
} else {
|
172 |
-
$value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
173 |
-
}
|
174 |
-
}*/
|
175 |
-
|
176 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
|
177 |
-
if ( $field['show_date'] == 'true') {
|
178 |
-
$value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
179 |
-
} else {
|
180 |
-
$value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
181 |
-
}
|
182 |
-
}
|
183 |
-
return $value;
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
function js_to_php_dateformat($date_format) {
|
188 |
-
$chars = array(
|
189 |
-
// Day
|
190 |
-
'dd' => 'd', 'd' => 'j', 'DD' => 'l','D' => 'D', 'o' => 'z',
|
191 |
-
// Month
|
192 |
-
'mm' => 'm', 'm' => 'n', 'MM' => 'F', 'M' => 'M',
|
193 |
-
// Year
|
194 |
-
'yy' => 'Y', 'y' => 'y',
|
195 |
-
);
|
196 |
-
|
197 |
-
return strtr((string)$date_format, $chars);
|
198 |
-
}
|
199 |
-
|
200 |
-
|
201 |
-
function js_to_php_timeformat($time_format) {
|
202 |
-
|
203 |
-
$chars = array(
|
204 |
-
//hour
|
205 |
-
'HH' => 'H', 'H' => 'G', 'hh' => 'h' , 'h' => 'g',
|
206 |
-
//minute
|
207 |
-
'mm' => 'i', 'm' => 'i',
|
208 |
-
//second
|
209 |
-
'ss' => 's', 's' => 's',
|
210 |
-
//am/pm
|
211 |
-
'TT' => 'A', 'T' => 'A', 'tt' => 'a', 't' => 'a'
|
212 |
-
);
|
213 |
-
|
214 |
-
return strtr((string)$time_format, $chars);
|
215 |
-
}
|
216 |
-
|
217 |
-
|
218 |
-
function isValidTimeStamp($timestamp) {
|
219 |
-
return ((string)(int)$timestamp === (string)$timestamp);
|
220 |
-
}
|
221 |
-
|
222 |
-
/*
|
223 |
-
* load_value()
|
224 |
-
*
|
225 |
-
* This filter is applied to the $value after it is loaded from the db
|
226 |
-
*
|
227 |
-
* @type filter
|
228 |
-
* @since 3.6
|
229 |
-
* @date 23/01/13
|
230 |
-
*
|
231 |
-
* @param $value (mixed) the value found in the database
|
232 |
-
* @param $post_id (mixed) the $post_id from which the value was loaded
|
233 |
-
* @param $field (array) the field array holding all the field options
|
234 |
-
* @return $value
|
235 |
-
*/
|
236 |
-
function load_value( $value, $post_id, $field ) {
|
237 |
-
|
238 |
-
$field = array_merge($this->defaults, $field);
|
239 |
-
|
240 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
|
241 |
-
if ( $field['show_date'] == 'true') {
|
242 |
-
$value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
243 |
-
} else {
|
244 |
-
$value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
|
245 |
-
}
|
246 |
-
}
|
247 |
-
return $value;
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
/*
|
252 |
-
* update_value()
|
253 |
-
*
|
254 |
-
* This filter is appied to the $value before it is updated in the db
|
255 |
-
*
|
256 |
-
* @type filter
|
257 |
-
* @since 3.6
|
258 |
-
* @date 23/01/13
|
259 |
-
*
|
260 |
-
* @param $value - the value which will be saved in the database
|
261 |
-
* @param $post_id - the $post_id of which the value will be saved
|
262 |
-
* @param $field - the field array holding all the field options
|
263 |
-
*
|
264 |
-
* @return $value - the modified value
|
265 |
-
*/
|
266 |
-
|
267 |
-
// function update_value( $value, $post_id, $field ) {
|
268 |
-
// $field = array_merge($this->defaults, $field);
|
269 |
-
// if ($value != '' && $field['save_as_timestamp'] == 'true') {
|
270 |
-
// $value = strtotime( $value );
|
271 |
-
// }
|
272 |
-
// return $value;
|
273 |
-
// }
|
274 |
-
|
275 |
-
function update_value( $value, $post_id, $field ) {
|
276 |
-
$field = array_merge($this->defaults, $field);
|
277 |
-
if ($value != '' && $field['save_as_timestamp'] == 'true') {
|
278 |
-
if (preg_match('/^dd?\//',$field['date_format'] )) { //if start with dd/ or d/ (not supported by strtotime())
|
279 |
-
$value = str_replace('/', '-', $value);
|
280 |
-
}
|
281 |
-
$value = strtotime( $value );
|
282 |
-
}
|
283 |
-
|
284 |
-
return $value;
|
285 |
-
}
|
286 |
-
|
287 |
-
/*
|
288 |
-
* input_admin_enqueue_scripts()
|
289 |
-
*
|
290 |
-
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
291 |
-
* Use this action to add css + javascript to assist your create_field() action.
|
292 |
-
*
|
293 |
-
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
294 |
-
* @type action
|
295 |
-
* @since 3.6
|
296 |
-
* @date 23/01/13
|
297 |
-
*/
|
298 |
-
|
299 |
-
function input_admin_enqueue_scripts() {
|
300 |
-
|
301 |
-
global $wp_locale;
|
302 |
-
|
303 |
-
|
304 |
-
$has_locale = false;
|
305 |
-
$js_locale = $this->get_js_locale(get_locale());
|
306 |
-
|
307 |
-
wp_enqueue_script( 'jquery-ui-timepicker', $this->dir . 'js/jquery-ui-timepicker-addon.js', array(
|
308 |
-
'acf-input',
|
309 |
-
'jquery-ui-slider'
|
310 |
-
), $this->version, true );
|
311 |
-
|
312 |
-
if ( file_exists( $this->path . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
313 |
-
wp_enqueue_script( 'timepicker-localization', $this->dir . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
314 |
-
'jquery-ui-timepicker'
|
315 |
-
), $this->version, true );
|
316 |
-
wp_enqueue_script( 'timepicker', $this->dir . 'js/timepicker.js', array(
|
317 |
-
'timepicker-localization'
|
318 |
-
), $this->version, true );
|
319 |
-
$has_locale = true;
|
320 |
-
} else {
|
321 |
-
wp_enqueue_script( 'timepicker', $this->dir . 'js/timepicker.js', array(
|
322 |
-
'jquery-ui-timepicker'
|
323 |
-
), $this->version, true );
|
324 |
-
}
|
325 |
-
|
326 |
-
if ( ! $has_locale && $js_locale != 'en' ) {
|
327 |
-
$timepicker_locale = array(
|
328 |
-
'closeText' => __( 'Done', $this->domain )
|
329 |
-
, 'currentText' => __( 'Today', $this->domain )
|
330 |
-
, 'prevText' => __( 'Prev', $this->domain )
|
331 |
-
, 'nextText' => __( 'Next', $this->domain )
|
332 |
-
, 'monthStatus' => __( 'Show a different month', $this->domain )
|
333 |
-
, 'weekHeader' => __( 'Wk', $this->domain )
|
334 |
-
, 'timeText' => __( "Time", $this->domain )
|
335 |
-
, 'hourText' => __( "Hour", $this->domain )
|
336 |
-
, 'minuteText' => __( "Minute", $this->domain )
|
337 |
-
, 'secondText' => __( "Second", $this->domain )
|
338 |
-
, 'millisecText' => __( "Millisecond", $this->domain )
|
339 |
-
, 'timezoneText' => __( "Time Zone", $this->domain )
|
340 |
-
, 'isRTL' => $wp_locale->is_rtl()
|
341 |
-
);
|
342 |
-
}
|
343 |
-
$timepicker_wp_locale = array(
|
344 |
-
'monthNames' => $this->strip_array_indices( $wp_locale->month )
|
345 |
-
, 'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev )
|
346 |
-
, 'dayNames' => $this->strip_array_indices( $wp_locale->weekday )
|
347 |
-
, 'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev )
|
348 |
-
, 'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial )
|
349 |
-
, 'showMonthAfterYear' => false
|
350 |
-
, 'showWeek' => false
|
351 |
-
, 'firstDay' => get_option( 'start_of_week' )
|
352 |
-
);
|
353 |
-
|
354 |
-
$l10n = ( isset( $timepicker_locale ) ) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
|
355 |
-
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
|
356 |
-
|
357 |
-
wp_enqueue_style('jquery-style', $this->dir . 'css/jquery-ui.css',array(
|
358 |
-
'acf-datepicker'
|
359 |
-
),$this->version);
|
360 |
-
wp_enqueue_style('timepicker', $this->dir . 'css/jquery-ui-timepicker-addon.css',array(
|
361 |
-
'jquery-style'
|
362 |
-
),$this->version);
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
|
367 |
-
* @param array $ArrayToStrip
|
368 |
-
* @return array
|
369 |
-
*/
|
370 |
-
function strip_array_indices( $ArrayToStrip ) {
|
371 |
-
foreach ( $ArrayToStrip as $objArrayItem ) {
|
372 |
-
$NewArray[] = $objArrayItem;
|
373 |
-
}
|
374 |
-
|
375 |
-
return $NewArray;
|
376 |
-
}
|
377 |
-
|
378 |
-
function get_js_locale($locale) {
|
379 |
-
$dir_path = $this->path . 'js/localization/';
|
380 |
-
$exclude_list = array(".", "..");
|
381 |
-
$languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
|
382 |
-
|
383 |
-
$locale = strtolower(str_replace("_", "-", $locale));
|
384 |
-
|
385 |
-
if (false !== strpos($locale,'-')) {
|
386 |
-
$l = explode("-",$locale);
|
387 |
-
$pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
|
388 |
-
} else {
|
389 |
-
$pattern = array('/' . $locale . '/');
|
390 |
-
}
|
391 |
-
$res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
|
392 |
-
|
393 |
-
return ($count) ? implode("", $res) : 'en';
|
394 |
-
}
|
395 |
-
|
396 |
-
|
397 |
-
function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
|
398 |
-
if (function_exists('preg_filter'))
|
399 |
-
return preg_filter($pattern, $replace, $subject,$limit,$count);
|
400 |
-
else
|
401 |
-
return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
|
402 |
-
}
|
403 |
-
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
|
408 |
-
// create field
|
409 |
-
new acf_field_date_time_picker();
|
410 |
-
|
411 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/localization/jquery-ui-timepicker-da.js
CHANGED
File without changes
|
js/localization/jquery-ui-timepicker-hr.js
CHANGED
File without changes
|
js/timepicker.js
CHANGED
@@ -1,153 +1,136 @@
|
|
1 |
/**
|
2 |
* Date and Time Picker
|
3 |
*/
|
4 |
-
(function($){
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
if($('body > #ui-datepicker-div').length > 0)
|
138 |
-
{
|
139 |
-
$('#ui-datepicker-div').wrap('<div class="ui-acf" />');
|
140 |
-
}
|
141 |
-
|
142 |
-
// allow null
|
143 |
-
input.blur(function(){
|
144 |
-
|
145 |
-
if( !input.val() )
|
146 |
-
{
|
147 |
-
input.val('');
|
148 |
-
}
|
149 |
-
});
|
150 |
-
});
|
151 |
-
});
|
152 |
-
}
|
153 |
})(jQuery);
|
1 |
/**
|
2 |
* Date and Time Picker
|
3 |
*/
|
|
|
4 |
|
5 |
+
acf = acf || {};
|
6 |
+
|
7 |
+
(function ($) {
|
8 |
+
|
9 |
+
function initialize_field($el) {
|
10 |
+
//$el.doStuff();
|
11 |
+
}
|
12 |
+
|
13 |
+
if (typeof acf.add_action !== 'undefined') {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* ready append (ACF5)
|
17 |
+
*
|
18 |
+
* These are 2 events which are fired during the page load
|
19 |
+
* ready = on page load similar to $(document).ready()
|
20 |
+
* append = on new DOM elements appended via repeater field
|
21 |
+
*
|
22 |
+
* @type event
|
23 |
+
* @date 20/07/13
|
24 |
+
*
|
25 |
+
* @param $el (jQuery selection) the jQuery element which contains the ACF fields
|
26 |
+
* @return n/a
|
27 |
+
*/
|
28 |
+
acf.add_action('ready append', function ($el) {
|
29 |
+
|
30 |
+
acf.get_fields({ type : 'date_time_picker'}, $el).each(function () {
|
31 |
+
// var input = $('input', $(this)),
|
32 |
+
var input = $(this).find('input'),
|
33 |
+
is_timeonly = (input.attr('data-date_format') == undefined),
|
34 |
+
date_format = (input.attr('data-date_format') != undefined) ? input.attr('data-date_format') : 'mm/dd/yy',
|
35 |
+
time_format = input.attr('data-time_format'),
|
36 |
+
has_ampm = (input.attr('data-date_format') != undefined) ? (input.attr('data-time_format').search(/t/i) != -1) : false;
|
37 |
+
|
38 |
+
//don't apply datepicker to clone field (check for different class names to enhance compatibility with older acf versions)
|
39 |
+
if (input.parents('.acf-row.acf-clone').length || input.parents('.acf-row.clone, .acf-clone').length) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
|
43 |
+
input
|
44 |
+
.addClass('active')
|
45 |
+
.attr("placeholder", (is_timeonly) ? time_format : date_format + ' ' + time_format)
|
46 |
+
.datetimepicker({
|
47 |
+
changeYear: true,
|
48 |
+
yearRange: "-100:+100",
|
49 |
+
changeMonth: true,
|
50 |
+
timeOnly: is_timeonly,
|
51 |
+
timeFormat: time_format,
|
52 |
+
dateFormat: date_format,
|
53 |
+
showWeek: (input.attr('data-show_week_number') != "true") ? 0 : 1,
|
54 |
+
ampm: has_ampm,
|
55 |
+
controlType: input.attr('data-picker'),
|
56 |
+
timeOnlyTitle: input.attr('title'),
|
57 |
+
monthNames: timepicker_objectL10n.monthNames,
|
58 |
+
monthNamesShort: timepicker_objectL10n.monthNamesShort,
|
59 |
+
dayNames: timepicker_objectL10n.dayNames,
|
60 |
+
dayNamesShort: timepicker_objectL10n.dayNamesShort,
|
61 |
+
dayNamesMin: timepicker_objectL10n.dayNamesMin,
|
62 |
+
firstDay: timepicker_objectL10n.firstDay
|
63 |
+
});
|
64 |
+
|
65 |
+
if ($('body > #ui-datepicker-div').length > 0) {
|
66 |
+
$('#ui-datepicker-div').wrap('<div class="ui-acf" />');
|
67 |
+
}
|
68 |
+
|
69 |
+
// allow null
|
70 |
+
input.blur(function () {
|
71 |
+
if (!input.val()) {
|
72 |
+
input.val('');
|
73 |
+
}
|
74 |
+
});
|
75 |
+
});
|
76 |
+
});
|
77 |
+
} else {
|
78 |
+
/**
|
79 |
+
* acf/setup_fields (ACF4)
|
80 |
+
*
|
81 |
+
* This event is triggered when ACF adds any new elements to the DOM.
|
82 |
+
*
|
83 |
+
* @type function
|
84 |
+
* @since 1.0.0
|
85 |
+
* @date 01/01/12
|
86 |
+
*
|
87 |
+
* @param event e: an event object. This can be ignored
|
88 |
+
* @param Element postbox: An element which contains the new HTML
|
89 |
+
*
|
90 |
+
* @return n/a
|
91 |
+
*/
|
92 |
+
$(document).live('acf/setup_fields', function (e, postbox) {
|
93 |
+
$(postbox).find('input.ps_timepicker').each(function () {
|
94 |
+
var input = $(this),
|
95 |
+
is_timeonly = (input.attr('data-date_format') == undefined),
|
96 |
+
date_format = (input.attr('data-date_format') != undefined) ? input.attr('data-date_format') : 'mm/dd/yy',
|
97 |
+
time_format = input.attr('data-time_format'),
|
98 |
+
has_ampm = (input.attr('data-time_format').search(/t/i) != -1);
|
99 |
+
|
100 |
+
if (acf.helpers.is_clone_field(input)) {
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
input.addClass('active').attr("placeholder", (is_timeonly) ? time_format : date_format + ' ' + time_format).datetimepicker({
|
105 |
+
changeYear: true,
|
106 |
+
yearRange: "-100:+100",
|
107 |
+
changeMonth: true,
|
108 |
+
timeOnly: is_timeonly,
|
109 |
+
timeFormat: time_format,
|
110 |
+
dateFormat: date_format,
|
111 |
+
showWeek: (input.attr('data-show_week_number') != "true") ? 0 : 1,
|
112 |
+
ampm: has_ampm,
|
113 |
+
controlType: input.attr('data-picker'),
|
114 |
+
timeOnlyTitle: input.attr('title'),
|
115 |
+
monthNames: timepicker_objectL10n.monthNames,
|
116 |
+
monthNamesShort: timepicker_objectL10n.monthNamesShort,
|
117 |
+
dayNames: timepicker_objectL10n.dayNames,
|
118 |
+
dayNamesShort: timepicker_objectL10n.dayNamesShort,
|
119 |
+
dayNamesMin: timepicker_objectL10n.dayNamesMin,
|
120 |
+
firstDay: timepicker_objectL10n.firstDay
|
121 |
+
});
|
122 |
+
|
123 |
+
if ($('body > #ui-datepicker-div').length > 0) {
|
124 |
+
$('#ui-datepicker-div').wrap('<div class="ui-acf" />');
|
125 |
+
}
|
126 |
+
|
127 |
+
// allow null
|
128 |
+
input.blur(function () {
|
129 |
+
if (!input.val()) {
|
130 |
+
input.val('');
|
131 |
+
}
|
132 |
+
});
|
133 |
+
});
|
134 |
+
});
|
135 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
})(jQuery);
|
lang/acf-date_time_picker.po
DELETED
@@ -1,159 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: \n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2013-04-05 14:13+0100\n"
|
6 |
-
"PO-Revision-Date: 2013-04-05 14:13+0100\n"
|
7 |
-
"Last-Translator: Per Søderlind <per@soderlind.no>\n"
|
8 |
-
"Language-Team: \n"
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-Poedit-KeywordsList: __;_e\n"
|
13 |
-
"X-Poedit-Basepath: .\n"
|
14 |
-
"X-Poedit-SearchPath-0: ..\n"
|
15 |
-
|
16 |
-
#: ../date_time_picker-v3.php:28
|
17 |
-
#: ../date_time_picker-v3.php:80
|
18 |
-
#: ../date_time_picker-v4.php:23
|
19 |
-
#: ../date_time_picker-v4.php:82
|
20 |
-
msgid "Date and Time Picker"
|
21 |
-
msgstr ""
|
22 |
-
|
23 |
-
#: ../date_time_picker-v3.php:32
|
24 |
-
#: ../date_time_picker-v4.php:28
|
25 |
-
msgid "Choose Time"
|
26 |
-
msgstr ""
|
27 |
-
|
28 |
-
#: ../date_time_picker-v3.php:70
|
29 |
-
#: ../date_time_picker-v4.php:72
|
30 |
-
msgid "Date and Time Picker?"
|
31 |
-
msgstr ""
|
32 |
-
|
33 |
-
#: ../date_time_picker-v3.php:81
|
34 |
-
#: ../date_time_picker-v4.php:83
|
35 |
-
msgid "Time Picker"
|
36 |
-
msgstr ""
|
37 |
-
|
38 |
-
#: ../date_time_picker-v3.php:89
|
39 |
-
#: ../date_time_picker-v4.php:91
|
40 |
-
msgid "Date format"
|
41 |
-
msgstr ""
|
42 |
-
|
43 |
-
#: ../date_time_picker-v3.php:90
|
44 |
-
msgid "eg. mm/dd/yy. read more about"
|
45 |
-
msgstr ""
|
46 |
-
|
47 |
-
#: ../date_time_picker-v3.php:104
|
48 |
-
#: ../date_time_picker-v4.php:106
|
49 |
-
msgid "Time Format"
|
50 |
-
msgstr ""
|
51 |
-
|
52 |
-
#: ../date_time_picker-v3.php:105
|
53 |
-
#: ../date_time_picker-v4.php:107
|
54 |
-
#, php-format
|
55 |
-
msgid "eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting time</a>"
|
56 |
-
msgstr ""
|
57 |
-
|
58 |
-
#: ../date_time_picker-v3.php:119
|
59 |
-
#: ../date_time_picker-v4.php:121
|
60 |
-
msgid "Display Week Number?"
|
61 |
-
msgstr ""
|
62 |
-
|
63 |
-
#: ../date_time_picker-v3.php:129
|
64 |
-
#: ../date_time_picker-v4.php:131
|
65 |
-
msgid "Yes"
|
66 |
-
msgstr ""
|
67 |
-
|
68 |
-
#: ../date_time_picker-v3.php:130
|
69 |
-
#: ../date_time_picker-v4.php:132
|
70 |
-
msgid "No"
|
71 |
-
msgstr ""
|
72 |
-
|
73 |
-
#: ../date_time_picker-v3.php:138
|
74 |
-
msgid "Time Picker Style?"
|
75 |
-
msgstr ""
|
76 |
-
|
77 |
-
#: ../date_time_picker-v3.php:148
|
78 |
-
#: ../date_time_picker-v4.php:150
|
79 |
-
msgid "Slider"
|
80 |
-
msgstr ""
|
81 |
-
|
82 |
-
#: ../date_time_picker-v3.php:149
|
83 |
-
#: ../date_time_picker-v4.php:151
|
84 |
-
msgid "Select"
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#: ../date_time_picker-v3.php:221
|
88 |
-
#: ../date_time_picker-v4.php:224
|
89 |
-
msgid "Done"
|
90 |
-
msgstr ""
|
91 |
-
|
92 |
-
#: ../date_time_picker-v3.php:222
|
93 |
-
#: ../date_time_picker-v4.php:225
|
94 |
-
msgid "Today"
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: ../date_time_picker-v3.php:223
|
98 |
-
#: ../date_time_picker-v4.php:226
|
99 |
-
msgid "Prev"
|
100 |
-
msgstr ""
|
101 |
-
|
102 |
-
#: ../date_time_picker-v3.php:224
|
103 |
-
#: ../date_time_picker-v4.php:227
|
104 |
-
msgid "Next"
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
#: ../date_time_picker-v3.php:225
|
108 |
-
#: ../date_time_picker-v4.php:228
|
109 |
-
msgid "Show a different month"
|
110 |
-
msgstr ""
|
111 |
-
|
112 |
-
#: ../date_time_picker-v3.php:226
|
113 |
-
#: ../date_time_picker-v4.php:229
|
114 |
-
msgid "Wk"
|
115 |
-
msgstr ""
|
116 |
-
|
117 |
-
#: ../date_time_picker-v3.php:227
|
118 |
-
#: ../date_time_picker-v4.php:230
|
119 |
-
msgid "Time"
|
120 |
-
msgstr ""
|
121 |
-
|
122 |
-
#: ../date_time_picker-v3.php:228
|
123 |
-
#: ../date_time_picker-v4.php:231
|
124 |
-
msgid "Hour"
|
125 |
-
msgstr ""
|
126 |
-
|
127 |
-
#: ../date_time_picker-v3.php:229
|
128 |
-
#: ../date_time_picker-v4.php:232
|
129 |
-
msgid "Minute"
|
130 |
-
msgstr ""
|
131 |
-
|
132 |
-
#: ../date_time_picker-v3.php:230
|
133 |
-
#: ../date_time_picker-v4.php:233
|
134 |
-
msgid "Second"
|
135 |
-
msgstr ""
|
136 |
-
|
137 |
-
#: ../date_time_picker-v3.php:231
|
138 |
-
#: ../date_time_picker-v4.php:234
|
139 |
-
msgid "Millisecond"
|
140 |
-
msgstr ""
|
141 |
-
|
142 |
-
#: ../date_time_picker-v3.php:232
|
143 |
-
#: ../date_time_picker-v4.php:235
|
144 |
-
msgid "Time Zone"
|
145 |
-
msgstr ""
|
146 |
-
|
147 |
-
#: ../date_time_picker-v4.php:24
|
148 |
-
msgid "jQuery"
|
149 |
-
msgstr ""
|
150 |
-
|
151 |
-
#: ../date_time_picker-v4.php:92
|
152 |
-
#, php-format
|
153 |
-
msgid "eg. mm/dd/yy. read more about <a href=\"%s\" target=\"_blank\">formatting date</a>"
|
154 |
-
msgstr ""
|
155 |
-
|
156 |
-
#: ../date_time_picker-v4.php:140
|
157 |
-
msgid "Time Picker style?"
|
158 |
-
msgstr ""
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: PerS
|
|
3 |
Donate link: http://soderlind.no/donate/
|
4 |
Tags: acf, custom field,datepicker,timepicker
|
5 |
Requires at least: 3.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -15,7 +15,7 @@ Date and Time Picker field for Advanced Custom Fields
|
|
15 |
|
16 |
This is an add-on for the [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) WordPress plugin, that allows you to add a Date and Time Picker field type.
|
17 |
|
18 |
-
|
19 |
|
20 |
[youtube http://www.youtube.com/watch?v=Mumx4HGOljQ]
|
21 |
|
@@ -23,7 +23,7 @@ Thanks to [yanknudtskov](https://github.com/yanknudtskov), the plugin now works
|
|
23 |
|
24 |
This add-on will work with:
|
25 |
|
26 |
-
* Advanced Custom Fields version 4
|
27 |
* Advanced Custom Fields version 3 and bellow
|
28 |
|
29 |
= More Information =
|
@@ -60,8 +60,23 @@ function my_register_fields()
|
|
60 |
|
61 |
== Frequently Asked Questions ==
|
62 |
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
To set the date and time format when you create the field, you have to create a string using the letters below.
|
67 |
|
@@ -111,7 +126,11 @@ TT AM or PM for AM/PM
|
|
111 |
|
112 |
The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your theme.
|
113 |
|
|
|
114 |
== Changelog ==
|
|
|
|
|
|
|
115 |
= 2.0.18 =
|
116 |
* Thanks to [kamilgrzegorczyk](https://github.com/kamilgrzegorczyk), Fixing clone field issue in repeater
|
117 |
= 2.0.17 =
|
@@ -122,8 +141,8 @@ The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date]
|
|
122 |
* Thanks to [yanknudtskov](https://github.com/yanknudtskov), the plugin now works with ACF 5.0
|
123 |
= 2.0.14 =
|
124 |
* Added new languages/acf-field-date-time-picker.po file (note, renamed the language file)
|
125 |
-
= 2.0.13 =
|
126 |
-
* Fixed compatibility bug with ACF 4.3.5
|
127 |
* NOTE: 2.0.13 requires ACF 4.3.5 or later
|
128 |
= 2.0.12 =
|
129 |
* Added support for date format dd/mm/yy
|
3 |
Donate link: http://soderlind.no/donate/
|
4 |
Tags: acf, custom field,datepicker,timepicker
|
5 |
Requires at least: 3.6
|
6 |
+
Tested up to: 4.5.3
|
7 |
+
Stable tag: 2.1.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
15 |
|
16 |
This is an add-on for the [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) WordPress plugin, that allows you to add a Date and Time Picker field type.
|
17 |
|
18 |
+
**ACF PRO 5.0+ is no longer supported, ACF PRO [has its own date and time picker](https://www.advancedcustomfields.com/resources/date-time-picker/)**
|
19 |
|
20 |
[youtube http://www.youtube.com/watch?v=Mumx4HGOljQ]
|
21 |
|
23 |
|
24 |
This add-on will work with:
|
25 |
|
26 |
+
* Advanced Custom Fields version 4.*.*
|
27 |
* Advanced Custom Fields version 3 and bellow
|
28 |
|
29 |
= More Information =
|
60 |
|
61 |
== Frequently Asked Questions ==
|
62 |
|
63 |
+
= Updating to ACF PRO =
|
64 |
|
65 |
+
I got this quetion over at [AWP on Facebook](https://www.facebook.com/groups/advancedwp/permalink/1198240376904841/?comment_id=1198432300218982¬if_t=group_comment¬if_id=1469033404164280):
|
66 |
+
|
67 |
+
`
|
68 |
+
How does upgrading work? If someone starts with ACF and your plugin,
|
69 |
+
then upgrades to ACF Pro, will their date/time custom field disappear?
|
70 |
+
I understand the data will be maintained but wondering if the field
|
71 |
+
will still be visible in WP admin.
|
72 |
+
`
|
73 |
+
|
74 |
+
Updating to ACF PRO should work fine, ACF PRO has a compatibility add-on for this plugin, but test it on a non production environment first.
|
75 |
+
|
76 |
+
Also, read the comments on this issue: [https://github.com/.../acf-field-date-time-picker/issues/103](https://github.com/.../acf-field-date-time-picker/issues/103)
|
77 |
+
|
78 |
+
|
79 |
+
= How do I set the date and time format? =
|
80 |
|
81 |
To set the date and time format when you create the field, you have to create a string using the letters below.
|
82 |
|
126 |
|
127 |
The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your theme.
|
128 |
|
129 |
+
|
130 |
== Changelog ==
|
131 |
+
= 2.1.0 =
|
132 |
+
* ACF PRO 5.0+ is no longer supported, ACF PRO [has its own date and time picker](https://www.advancedcustomfields.com/resources/date-time-picker/)
|
133 |
+
* Update plugin to WPCS standards.
|
134 |
= 2.0.18 =
|
135 |
* Thanks to [kamilgrzegorczyk](https://github.com/kamilgrzegorczyk), Fixing clone field issue in repeater
|
136 |
= 2.0.17 =
|
141 |
* Thanks to [yanknudtskov](https://github.com/yanknudtskov), the plugin now works with ACF 5.0
|
142 |
= 2.0.14 =
|
143 |
* Added new languages/acf-field-date-time-picker.po file (note, renamed the language file)
|
144 |
+
= 2.0.13 =
|
145 |
+
* Fixed compatibility bug with ACF 4.3.5
|
146 |
* NOTE: 2.0.13 requires ACF 4.3.5 or later
|
147 |
= 2.0.12 =
|
148 |
* Added support for date format dd/mm/yy
|