Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Timeline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
Timeline
Commits
215fe9b4
Commit
215fe9b4
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Hook up datepicker and confirm dates are saved to, and retrieved from, the database.
parent
41d267f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eth-timeline.php
+29
-11
29 additions, 11 deletions
eth-timeline.php
js/admin.js
+14
-0
14 additions, 0 deletions
js/admin.js
with
43 additions
and
11 deletions
eth-timeline.php
+
29
−
11
View file @
215fe9b4
...
...
@@ -34,8 +34,8 @@ class ETH_Timeline {
private
$post_type
=
'eth_timeline'
;
// private $taxonomy = 'eth_timeline_event';
private
$meta_start
=
'_timeline_start'
;
private
$meta_end
=
'_timeline_end'
;
private
$meta_start
=
'_
eth_
timeline_start'
;
private
$meta_end
=
'_
eth_
timeline_end'
;
/**
* Silence is golden!
...
...
@@ -140,7 +140,9 @@ class ETH_Timeline {
$screen
=
get_current_screen
();
if
(
is_object
(
$screen
)
&&
!
is_wp_error
(
$screen
)
&&
$this
->
post_type
=
$screen
->
post_type
)
{
wp_enqueue_script
(
'eth-timeline-admin'
,
plugins_url
(
'js/admin.js'
,
__FILE__
),
array
(
'jquery'
,
'jquery-ui-datepicker'
),
20130721
,
false
);
wp_enqueue_script
(
'eth-timeline-admin'
,
plugins_url
(
'js/admin.js'
,
__FILE__
),
array
(
'jquery'
,
'jquery-ui-datepicker'
),
time
(),
false
);
wp_enqueue_style
(
'eth-timeline-admin'
,
plugins_url
(
'css/smoothness.min.css'
,
__FILE__
),
array
(),
20130721
,
'screen'
);
}
}
...
...
@@ -159,8 +161,20 @@ class ETH_Timeline {
$end
=
(
int
)
get_post_meta
(
$post
->
ID
,
$this
->
meta_end
,
true
);
?>
Date pickers go here.
<p
id=
"eth-timeline-startbox"
>
<label
for=
"eth-timeline-start"
>
<?php
_e
(
'Start:'
,
'eth-timeline'
);
?>
</label>
<input
type=
"text"
name=
"eth-timeline-form[start]"
id=
"eth-timeline-start"
class=
"regular-text"
value=
"
<?php
echo
date
(
'F j, Y'
,
$start
);
?>
"
/>
<input
type=
"hidden"
name=
"eth-timeline[start]"
value=
"
<?php
echo
$start
*
1000
;
?>
"
/>
</p>
<p
id=
"eth-timeline-endbox"
>
<label
for=
"eth-timeline-end"
>
<?php
_e
(
'End:'
,
'eth-timeline'
);
?>
</label>
<input
type=
"text"
name=
"eth-timeline-form[end]"
id=
"eth-timeline-end"
class=
"regular-text"
value=
"
<?php
echo
date
(
'F j, Y'
,
$end
);
?>
"
/>
<input
type=
"hidden"
name=
"eth-timeline[end]"
value=
"
<?php
echo
$end
*
1000
;
?>
"
/>
</p>
<?php
wp_nonce_field
(
$this
->
get_field_name
(
'date'
),
$this
->
get_nonce_name
(
'date'
),
false
);
}
/**
...
...
@@ -170,14 +184,18 @@ class ETH_Timeline {
if
(
$this
->
post_type
!=
get_post_type
(
$post_id
)
)
return
;
// Location
if
(
isset
(
$_POST
[
$this
->
get_nonce_name
(
'location'
)
]
)
&&
wp_verify_nonce
(
$_POST
[
$this
->
get_nonce_name
(
'location'
)
],
$this
->
meta_key_location
)
)
{
$location
=
sanitize_text_field
(
$_POST
[
$this
->
get_field_name
(
'location'
)
]
);
if
(
isset
(
$_POST
[
$this
->
get_nonce_name
(
'date'
)
]
)
&&
wp_verify_nonce
(
$_POST
[
$this
->
get_nonce_name
(
'date'
)
],
$this
->
get_field_name
(
'date'
)
)
)
{
$dates
=
isset
(
$_POST
[
'eth-timeline'
]
)
?
array_map
(
'intval'
,
$_POST
[
'eth-timeline'
]
)
:
array
();
foreach
(
$dates
as
$key
=>
$timestamp
)
{
// Timestamp comes from JS
$timestamp
=
$timestamp
/
1000
;
if
(
$location
)
update_post_meta
(
$post_id
,
$this
->
meta_key_location
,
$location
);
else
delete_post_meta
(
$post_id
,
$this
->
meta_key_location
);
if
(
$timestamp
)
update_post_meta
(
$post_id
,
$this
->
{
'meta_'
.
$key
},
$timestamp
);
else
delete_post_meta
(
$post_id
,
$this
->
{
'meta_'
.
$key
}
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
js/admin.js
+
14
−
0
View file @
215fe9b4
(
function
(
$
)
{
$
(
document
).
ready
(
function
()
{
var
datepicker_args
=
{
altField
:
'
input[name="eth-timeline[start]"]
'
,
altFormat
:
'
@
'
,
dateFormat
:
'
M dd, yy
'
,
};
$
(
'
#eth-timeline-start
'
).
datepicker
(
datepicker_args
);
$
.
extend
(
datepicker_args
,
{
altField
:
'
input[name="eth-timeline[end]"]
'
,
}
);
$
(
'
#eth-timeline-end
'
).
datepicker
(
datepicker_args
);
}
);
}
)(
jQuery
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment