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
3885e9ad
Commit
3885e9ad
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Missing phpdoc and minor cleanup
parent
8f7b4f92
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth-timeline.php
+34
-7
34 additions, 7 deletions
eth-timeline.php
with
34 additions
and
7 deletions
eth-timeline.php
+
34
−
7
View file @
3885e9ad
...
@@ -56,7 +56,11 @@ class ETH_Timeline {
...
@@ -56,7 +56,11 @@ class ETH_Timeline {
}
}
/**
/**
* Register actions and filters
*
*
* @uses add_action
* @uses add_filter
* @return null
*/
*/
private
function
setup
()
{
private
function
setup
()
{
add_action
(
'init'
,
array
(
$this
,
'action_init'
)
);
add_action
(
'init'
,
array
(
$this
,
'action_init'
)
);
...
@@ -74,7 +78,12 @@ class ETH_Timeline {
...
@@ -74,7 +78,12 @@ class ETH_Timeline {
}
}
/**
/**
* Register post type and shortcode
*
*
* @uses register_post_type
* @uses add_shortcode
* @action init
* @return null
*/
*/
public
function
action_init
()
{
public
function
action_init
()
{
register_post_type
(
$this
->
post_type
,
array
(
register_post_type
(
$this
->
post_type
,
array
(
...
@@ -285,17 +294,30 @@ class ETH_Timeline {
...
@@ -285,17 +294,30 @@ class ETH_Timeline {
*/
*/
/**
/**
* Render list of timeline entries
*
*
* @global $post
* @param mixed $atts
* @uses shortcode_atts
* @uses WP_Query
* @uses this::get_times
* @uses the_ID
* @uses this::format_date
* @uses the_title
* @uses get_the_content
* @uses remove_filter
* @uses the_content
* @uses add_filter
* @uses wp_reset_query
* @return string or null
*/
*/
public
function
do_shortcode
(
$atts
)
{
public
function
do_shortcode
(
$atts
)
{
// Parse and sanitize atts
// Parse and sanitize atts
$
defaults
=
array
(
$
atts
=
shortcode_atts
(
array
(
'posts_per_page'
=>
100
,
'posts_per_page'
=>
100
,
'order'
=>
'DESC'
,
'order'
=>
'DESC'
,
'year'
=>
null
,
'year'
=>
null
,
);
),
$atts
);
$atts
=
shortcode_atts
(
$defaults
,
$atts
);
$atts
[
'posts_per_page'
]
=
min
(
200
,
max
(
(
int
)
$atts
[
'posts_per_page'
],
1
)
);
$atts
[
'posts_per_page'
]
=
min
(
200
,
max
(
(
int
)
$atts
[
'posts_per_page'
],
1
)
);
$atts
[
'order'
]
=
'ASC'
==
$atts
[
'order'
]
?
'ASC'
:
'DESC'
;
$atts
[
'order'
]
=
'ASC'
==
$atts
[
'order'
]
?
'ASC'
:
'DESC'
;
...
@@ -374,7 +396,7 @@ class ETH_Timeline {
...
@@ -374,7 +396,7 @@ class ETH_Timeline {
if
(
!
empty
(
$content
)
)
{
if
(
!
empty
(
$content
)
)
{
$removed
=
remove_filter
(
'the_content'
,
'wpautop'
);
$removed
=
remove_filter
(
'the_content'
,
'wpautop'
);
echo
' <span class="sep">
for
</span> '
;
echo
' <span class="sep">
—
</span> '
;
the_content
();
the_content
();
if
(
$removed
)
if
(
$removed
)
...
@@ -383,8 +405,6 @@ class ETH_Timeline {
...
@@ -383,8 +405,6 @@ class ETH_Timeline {
?>
?>
</li>
</li>
<?php
<?php
}
}
// Ensure our tags are balanced!
// Ensure our tags are balanced!
...
@@ -420,7 +440,14 @@ class ETH_Timeline {
...
@@ -420,7 +440,14 @@ class ETH_Timeline {
}
}
/**
/**
* Determine appropriate date format for display start and end dates together.
* Prevents duplication of month or year.
*
*
* @param int $timestamp
* @param int $loop_year
* @param int $loop_month
* @param bool $start
* @return string
*/
*/
private
function
format_date
(
$timestamp
,
$loop_year
,
$loop_month
,
$start
=
true
)
{
private
function
format_date
(
$timestamp
,
$loop_year
,
$loop_month
,
$start
=
true
)
{
$ts_year
=
date
(
'Y'
,
$timestamp
);
$ts_year
=
date
(
'Y'
,
$timestamp
);
...
...
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