' : '') . '
'; foreach ($stati as $id => $labels) { $return .= '
'; $return .= '
'; if ($edit) { $return .= '

'; } $return .= '

' . $labels['label']; $return .= ($edit) ? '' : ''; $return .= '

'; $return .= '
'; if ($meta) { $args = array('post_type' => 'ml_usage', 'post_status' => $id, 'include' => $meta); $usages = get_posts($args); if (!empty($usages)) { foreach ($usages as $use) { $product = get_post($use->post_parent); $return .= ml_product_thumbnail($product, $use, $edit, false); } } } elseif (!$edit) { $return .= '

' . __('There are no products listed on this shelf.', 'media-libraries') . '

'; } $return .= '
'; $return .= '
'; $return .= '
'; $return .= '
'; } $return .= '
'; $return .= '
'; if (!$echo) { return $return; } echo $return; } function ml_product_thumbnail ($prod, $use=false, $edit=false, $echo=true) { static $i = 0; $i++; $image = get_post_meta($prod->ID, 'ml_image', true); $link = get_post_meta($prod->ID, 'ml_link', true); $stati = ml_get_usage_stati(); $query_arg = array('editproduct' => $prod->ID, 'addnew' => 1); $people = get_the_term_list($prod->ID, 'ml_person', '', ', ', '
'); $add_html = ''; $add_html = apply_filters('ml-product-thumbnail', $add_html, $prod, $use); $use_id = (!$use) ? '__i__' : $use->ID; $id_string = 'product-'.esc_attr($prod->ID).'-'.esc_attr($use_id); $id_arr_string = 'product-'.esc_attr($prod->ID).'['.esc_attr($use_id).']'; $status = (!$use) ? false : $use->post_status; $return = '
'; $return .= '
'; if ($edit) { $return .= '
'; $return .= ''; $return .= '' . __('Edit') . '' . __('Add') . ''; $return .= '
'; } $return .= '

' . $prod->post_title . '

'; $return .= '
'; $return .= '
'; $return .= '
'; if ($edit) { $return .= '
'; $return .= ''; $return .= ''; $return .= ml_time_box($use, $id_string, $id_arr_string, true, false); $return .= ''; $return .= '
'; $return .= '
'; $return .= '' . __('Delete') . ' |'; $return .= '' . __('Close') . ''; $return .= '
'; $return .= '
'; $return .= ''; $return .= submit_button(__( 'Save' ), 'button-primary product-control-save', 'saveproduct', false, array('id' => 'product-' . esc_attr($prod->ID) . '-saveproduct')); $return .= '
'; $return .= '
'; $return .= '
'; $return .= '
'; } else { ml_time_box($use, $id_string, $id_arr_string, false, false); } $return .= '
'; $return .= '
'; $return .= '
'; $return .= '
'; $return .= $people . $add_html; $return .= '
'; $return .= '
'; if (!$echo) { return $return; } echo $return; } // testing function ml_time_box ($usage, $id_string, $id_array, $edit=false, $echo=true) { $added = (!$usage) ? 0 : get_post_meta($usage->ID, 'ml_added', true); $start = (!$usage) ? 0 : get_post_meta($usage->ID, 'ml_started', true); $ended = (!$usage) ? 0 : get_post_meta($usage->ID, 'ml_finished', true); $function = ($edit) ? 'ml_show_date' : 'ml_show_times'; $return = $function($added, 'added', $id_string, $id_array, $echo); $return .= $function($start, 'started', $id_string, $id_array, $echo); $return .= $function($ended, 'finished', $id_string, $id_array, $echo); if (!$echo) { return $return; } echo $return; } function ml_show_date ($time=0, $which='added', $id_string='', $id_array='', $echo=true) { global $post, $action; $time = ($time == 0) ? current_time('mysql') : $time; $datef = __('M j, Y @ G:i'); $stamp = __('%1$s'); $date = date_i18n($datef, strtotime($time)); $stati = ml_get_usage_stati(); $string = (isset($stati[$which]['single'])) ? $stati[$which]['single'] : ''; $return = '
'; $return .= __($string, 'media-libraries') . ': ' . sprintf($stamp, $date) . '?>'; $return .= '' . __('Edit') . ''; $return .= '
' . ml_touch_time($time, $which, $id_string, $id_array, $echo) . '
'; $return .= '
'; if (!$echo) { return $return; } echo $return; } function ml_show_times ($time=0, $which='added', $id_string='', $id_array='', $echo=true) { global $post, $action; $time = ($time == 0) ? current_time('mysql') : $time; $datef = __('M j, Y @ G:i'); $stamp = __('%1$s'); $date = date_i18n($datef, strtotime($time)); $stati = ml_get_usage_stati(); $string = (isset($stati[$which]['single'])) ? $stati[$which]['single'] : ''; $return = '
'; $return .= $string . ': ' . sprintf($stamp, $date) . ''; $return .= '
'; if (!$echo) { return $return; } echo $return; } /** * Generate a timestamp field in html * Adapted from WP's touch_time() * * @param string $which which timestamp to produce * @param bool $edit true for edit mode (default) * @param int $tab_index tab index for input fields (default is none) * @param bool $echo false to return a string, true to echo (default is true) * @return mixed html string if $echo is false, null otherwise */ function ml_touch_time($time, $which, $id_string, $id_array, $echo=true ) { global $wp_locale, $post, $comment; $time_adj = current_time('timestamp'); $jj = mysql2date( 'd', $time, false ); $mm = mysql2date( 'm', $time, false ); $aa = mysql2date( 'Y', $time, false ); $hh = mysql2date( 'H', $time, false ); $mn = mysql2date( 'i', $time, false ); $ss = mysql2date( 's', $time, false ); $cur_jj = gmdate( 'd', $time_adj ); $cur_mm = gmdate( 'm', $time_adj ); $cur_aa = gmdate( 'Y', $time_adj ); $cur_hh = gmdate( 'H', $time_adj ); $cur_mn = gmdate( 'i', $time_adj ); $cur_ss = gmdate( 's', $time_adj ); $month = ''; $day = ''; $year = ''; $hour = ''; $minute = ''; $ret = '
'; $ret .= sprintf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute); $ret .= '
'; $ret .= "\n\n"; foreach ( array('mm', 'jj', 'aa', 'hh', 'mn', 'ss') as $timeunit ) { $ret .= '' . "\n"; $cur_timeunit = 'cur_' . $timeunit; $ret .= '' . "\n"; } $ret .= '

'; $ret .= '' . __('OK') . ''; $ret .= '' . __('Cancel') . ''; $ret .= '

'; if (!$echo) { return $ret; } echo $ret; }