Edit Flow
[resolved] Text/Date metadata perform differently? (3 posts)

  1. davisshaver
    Posted 3 years ago #

    I am trying to expose certain EditFlow metadata on the frontend of a website. I have been able to repurpose code shared earlier in this forum to achieve the majority of what I want, but ran into trouble with dates. Maybe someone here could advise? I get no return for the final date option here and I've already confirmed that I have slug/type correct...

    I have also posted this code on Gist.

    function upcoming_info() {
    	global $post, $edit_flow;
    	$view = get_metadata( 'post', $post->ID, '', true );
    	$upcoming_assignment = $view[_ef_editorial_meta_paragraph_assignment][0];
    		if ($upcoming_assignment != null) :
    			echo '<h4>Assignment</h4><p>' . $upcoming_assignment . '</p>';
    	$upcoming_editor_id = $view[_ef_editorial_meta_user_editor][0];
    		if ($upcoming_editor_id != null) :
    			$upcoming_editor = get_userdata($upcoming_editor_id);
    			echo '<h4>Assigning Editor</h4> <p>' . $upcoming_editor->user_nicename . '</p>';
    	$upcoming_available_date = $view[_ef_editorial_meta_date_planned-availability][0];
    		if ($upcoming_available_date != null) :
    		$upcoming_available_date_human_format = date("F j, Y", $upcoming_available_date);
    		echo '<h4>Planned Availability</h4> <p>' . $upcoming_available_date_human_format . '</p>';


  2. Connor Jennings
    Posted 3 years ago #

    If I were to take a stab at it, no quotes around _ef_editorial_meta_date_planned-availability, _ef_editorial_meta_user_editor and _ef_editorial_meta_paragraph_assignment might cause some issues. PHP is fine with the last two I listed because they're composed of only underscores (_) as separators. PHP will just assume a few things to make it work. When it hits the last one [_ef_editorial_meta_date_planned-availability], PHP has a problem with dashes (-) so it'll break (probably silently, and it might not tell you because it's happy to assume things).
    To fix, add some quotes around those words like so:


    If you have any more issues, feel free to post back here.

  3. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 3 years ago #

    Also, remember to prefix all the things!

    @cojennin I think we need a helper function for getting editorial meta for a given post...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Edit Flow
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic