Add endtime field to wpt_events #136

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@jbrandligt
Contributor

No description provided.

@slimndap

Thank you!

However, it looks like you copied the entire time() method, which ws designed to handle both start and end times.

It would be better to add two new methods: endtime() and enddate(). Both methods would just call their generic equivalents, but with the right $args:

$endtime = $this->time(
  array( 
    'start' => false,
    'html' => $html,
    'filters' => $filters,
  )
);
Owner

Indeed that is what I did. I think you are right, I'll see if I can solve it that way. Thanks.

And perhaps we add two more methods:

starttime() and startdate().

And to make it event more user friendly, we could turn it into 8 new methods:

starttime()
starttime_html()
startdate()
startdate_html()
endtime()
endtime_html()
enddate()
enddate_html()

Where all '_html' method return the HTML equivalent of the corresponding field.

Jeroen

Owner

We will probably have to tweak the original time and date methods a little to make sure it generates the right html output when called from another method.
For instance this line: $html = '<div class="'.self::post_type_name.'_time">';

Maybe:

$html = '<div class="'.self::post_type_name.'_time '.self::post_type_name.'_endtime">';

We can also do it the other way around. Make the date() and time() methods much simpler. All they do is call one of the 8 new methods, based on $args.

Owner

Yes, I think that might be a better approach, more logical that way. I'll see what I can come up with.

@jbrandligt
Owner

please ignore commit...

@slimndap slimndap added this to the v0.12 milestone Jun 25, 2015
@jbrandligt
Contributor

Hey, I did a partial commit of my work so far. Could you have a look and tell me if this is what you had in mind?

@slimndap

[$field] is no longer needed here.
$this->endtime_html is enough.

@slimndap

You should replace $args['start'] with false.

@slimndap

You can use $this->endtime() over here.

Owner

This one gives me trouble: "Fatal error: Can't use method return value in write context"
It seems I have to specify a place where apply_filters can store its output. Can be [$anyfield]. If I omit [$field] entirely the result output is 1.

I think you can just leave this whole part out (lines 920 - 930).
And on line 941, you can replace $this->endtime_html[ $field ] with $this->endtime().

Owner

Indeed! Works fine now.

@slimndap

You can skip the WPT_Filters here. They are already applied in endtime().

@slimndap
Owner

And yes: this is what I had in mind.

@jbrandligt
Contributor

Ok cool, I'll clean up the code and implement the date methods too then.

@slimndap slimndap added a commit that referenced this pull request Jun 26, 2015
@slimndap Added tests that confirm the lack of support for {{starttime}}, {{sta…
…rtdate}}, {{endtime}} and {{enddate}} placeholders.

See #60 and #136.
ef1ea5a
@jbrandligt jbrandligt Startdate and enddate methods implemented too and some code cleanup. …
…Date and and time methods are in fact identical to startdate_html and starttime_html methods but left for backward compatibility.
184e3f2
@slimndap
Owner

I just merged your code back into mine.

@jbrandligt
Contributor

Sweet!

@slimndap slimndap added a commit that referenced this pull request Jun 28, 2015
@slimndap Merge branch 'issue-60' into v0.12
* issue-60:
  wpt_event.php is now PHP CodeSniffer approved.
  Improved the code of @jbrandligt: - Removed all PHP notices. - Fully deprecated WPT_Event::date() and WPT_Event::time(). - Complete the PHPDocs for the new methods.
  Startdate and enddate methods implemented too and some code cleanup. Date and and time methods are in fact identical to startdate_html and starttime_html methods but left for backward compatibility.
  Added tests that confirm the lack of support for {{starttime}}, {{startdate}}, {{endtime}} and {{enddate}} placeholders. See #60 and #136.
  Partial commit, starttime and endtime methods implemented, both text and html. startdate and enddate still to come.
  New approach on endtime method, work in progress...
  Add endtime field to wpt_events

Conflicts:
	functions/wpt_event.php
bc1552e
@slimndap slimndap closed this Jul 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment