Emulate core function for draft or post title

This commit is contained in:
Brian Miyaji
2014-04-29 11:08:12 +10:00
parent 98cab7f307
commit a5ea708b60

View File

@@ -674,12 +674,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
<?php echo str_repeat( '<ul><li>', sizeof( $parents ) ); ?> <?php echo str_repeat( '<ul><li>', sizeof( $parents ) ); ?>
<label class="selectit"> <label class="selectit">
<input type="checkbox" value="<?php echo $post->ID; ?>" name="<?php echo $meta; ?><?php if ( isset( $index ) ) echo '[' . $index . ']'; ?>[]"<?php if ( in_array( $post->ID, $selected ) ) echo ' checked="checked"'; ?>> <input type="checkbox" value="<?php echo $post->ID; ?>" name="<?php echo $meta; ?><?php if ( isset( $index ) ) echo '[' . $index . ']'; ?>[]"<?php if ( in_array( $post->ID, $selected ) ) echo ' checked="checked"'; ?>>
<?php <?php echo sp_draft_or_post_title( $post ); ?>
$title = $post->post_title;
if ( empty( $title ) )
$title = __( '(no title)', 'sportspress' );
echo $title;
?>
</label> </label>
<?php echo str_repeat( '</li></ul>', sizeof( $parents ) ); ?> <?php echo str_repeat( '</li></ul>', sizeof( $parents ) ); ?>
</li> </li>
@@ -693,6 +688,26 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
} }
} }
/**
* Get the post title.
*
* The post title is fetched and if it is blank then a default string is
* returned.
*
* @since 2.7.0
* @param mixed $post Post id or object. If not supplied the global $post is used.
* @return string The post title if set
*/
if ( !function_exists( 'sp_draft_or_post_title' ) ) {
function sp_draft_or_post_title( $post = 0 ) {
$title = get_the_title( $post );
if ( empty( $title ) )
$title = __( '(no title)', 'sportspress' );
return $title;
}
}
if ( !function_exists( 'sp_get_var_labels' ) ) { if ( !function_exists( 'sp_get_var_labels' ) ) {
function sp_get_var_labels( $post_type ) { function sp_get_var_labels( $post_type ) {
$args = array( $args = array(