Description
Create an Add new link for a selected post_type using a dashiconWe may already have the right values from bw_page() or bw_post() or the user could have passed in overrides
Usage
$string = bw_dash_link( $atts, $content, $tag );Parameters
- $atts
- ( array ) required – shortcode parameters
- $content
- ( string ) optional – not expected – but it could be "Add new" or something
- $tag
- ( string ) optional –
Returns
string the generated HTMLSource
File name: oik-bob-bing-wide/shortcodes/oik-post-page.phpLines:
1 to 36 of 36
function bw_dash_link( $atts, $content=null, $tag=null ) { $post_type = bw_array_get_from( $atts, "post_type,0", "post" ); bw_trace2( $post_type, 'post_type', false, BW_TRACE_VERBOSE ); $icon = bw_array_get( $atts, "icon", null ); $text = bw_array_get( $atts, "text", null ); $post_object = get_post_type_object( $post_type ); if ( $post_object ) { //bw_trace2( $post_object ); if ( !$text ) { $text = $post_object->labels->add_new_item; } if ( !$icon ) { if ( $post_type === "page" ) { $icon = "admin-page"; } elseif ( 'post' === $post_type ) { $icon = "admin-post"; } elseif ( $post_object->menu_icon ) { // Why is there a blank prefix? $icon = " " . $post_object->menu_icon; //$icon = $post_object->menu_icon; } } } else { bw_trace2( $post_type, "Invalid post_type", true, BW_TRACE_WARNING ); } $dash_atts = array( $icon ); bw_trace2( $dash_atts, "dash_atts", false, BW_TRACE_VERBOSE ); oik_require( "shortcodes/oik-dash.php", "oik-bob-bing-wide" ); $dash = bw_dash( $dash_atts ); $url = admin_url( "post-new.php" ); if ( $post_type !== "post" ) { $url .= "?post_type=$post_type"; } alink( null, $url, $dash , $text ); return( bw_ret() ); }View on GitHub
Invoked by
Calls
1 to 4 of 4
Call hooks
API Letters:
