' . get_bloginfo( 'name' ) . ''; } /** * Shortcode to display a link to WordPress.org. * @since 0.6.0 */ function Easy_wp_link_shortcode() { return '' . __( 'WordPress', Easy_get_textdomain() ) . ''; } /** * Shortcode to display a link to the Easy theme page. * * @since 0.6.0 * @uses get_theme_data() Gets theme (parent theme) information. */ function Easy_theme_link_shortcode() { $data = get_theme_data( trailingslashit( TEMPLATEPATH ) . 'style.css' ); return '' . esc_attr( $data['Name'] ) . ''; } /** * Shortcode to display a link to the child theme's page. * * @since 0.6.0 * @uses get_theme_data() Gets theme (child theme) information. */ function Easy_child_link_shortcode() { $data = get_theme_data( trailingslashit( STYLESHEETPATH ) . 'style.css' ); return '' . esc_attr( $data['Name'] ) . ''; } /** * Shortcode to display a login link or logout link. * * @since 0.6.0 * @uses is_user_logged_in() Checks if the current user is logged into the site. * @uses wp_logout_url() Creates a logout URL. * @uses wp_login_url() Creates a login URL. */ function Easy_loginout_link_shortcode() { $domain = Easy_get_textdomain(); if ( is_user_logged_in() ) $out = '' . __( 'Log out', $domain ) . ''; else $out = '' . __( 'Log in', $domain ) . ''; return $out; } /** * Displays query count and load time if the current user can edit themes. * * @since 0.6.0 * @uses current_user_can() Checks if the current user can edit themes. */ function Easy_query_counter_shortcode() { if ( current_user_can( 'edit_themes' ) ) $out = sprintf( __( 'This page loaded in %1$s seconds with %2$s database queries.', Easy_get_textdomain() ), timer_stop( 0, 3 ), get_num_queries() ); return $out; } /** * Displays a nav menu that has been created from the Menus screen in the admin. * * @since 0.8.0 * @uses wp_nav_menu() Displays the nav menu. */ function Easy_nav_menu_shortcode( $attr ) { $attr = shortcode_atts( array( 'menu' => '', 'container' => 'div', 'container_id' => '', 'container_class' => 'nav-menu', 'menu_id' => '', 'menu_class' => '', 'link_before' => '', 'link_after' => '', 'before' => '', 'after' => '', 'fallback_cb' => 'wp_page_menu', 'walker' => '' ), $attr ); $attr['echo'] = false; return wp_nav_menu( $attr ); } /** * Displays the edit link for an individual post. * * @since 0.7.0 * @param array $attr */ function Easy_entry_edit_link_shortcode( $attr ) { global $post; $domain = Easy_get_textdomain(); $post_type = get_post_type_object( $post->post_type ); if ( !current_user_can( $post_type->cap->edit_post, $post->ID ) ) return ''; $attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr ); return $attr['before'] . '' . __( 'Edit', $domain ) . '' . $attr['after']; } /** * Displays the published date of an individual post. * * @since 0.7.0 * @param array $attr */ function Easy_entry_published_shortcode( $attr ) { $domain = Easy_get_textdomain(); $attr = shortcode_atts( array( 'before' => '', 'after' => '', 'format' => get_option( 'date_format' ) ), $attr ); $published = '' . sprintf( get_the_time( $attr['format'] ) ) . ''; return $attr['before'] . $published . $attr['after']; } /** * Displays a post's number of comments wrapped in a link to the comments area. * * @since 0.7.0 * @param array $attr */ function Easy_entry_comments_link_shortcode( $attr ) { $domain = Easy_get_textdomain(); $comments_link = ''; $number = get_comments_number(); $attr = shortcode_atts( array( 'zero' => __( 'Leave a response', $domain ), 'one' => __( '%1$s Response', $domain ), 'more' => __( '%1$s Responses', $domain ), 'css_class' => 'comments-link', 'none' => '', 'before' => '', 'after' => '' ), $attr ); if ( 0 == $number && !comments_open() && !pings_open() ) { if ( $attr['none'] ) $comments_link = '' . sprintf( $attr['none'], number_format_i18n( $number ) ) . ''; } elseif ( 0 == $number ) $comments_link = '' . sprintf( $attr['zero'], number_format_i18n( $number ) ) . ''; elseif ( 1 == $number ) $comments_link = '' . sprintf( $attr['one'], number_format_i18n( $number ) ) . ''; elseif ( 1 < $number ) $comments_link = '' . sprintf( $attr['more'], number_format_i18n( $number ) ) . ''; if ( $comments_link ) $comments_link = $attr['before'] . $comments_link . $attr['after']; return $comments_link; } /** * Displays an individual post's author with a link to his or her archive. * * @since 0.7.0 * @param array $attr */ function Easy_entry_author_shortcode( $attr ) { $attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr ); $author = '' . get_the_author_meta( 'display_name' ) . ''; return $attr['before'] . $author . $attr['after']; } /** * Displays a list of terms for a specific taxonomy. * * @since 0.7.0 * @param array $attr */ function Easy_entry_terms_shortcode( $attr ) { global $post; $attr = shortcode_atts( array( 'id' => $post->ID, 'taxonomy' => 'post_tag', 'separator' => ', ', 'before' => '', 'after' => '' ), $attr ); $attr['before'] = ( empty( $attr['before'] ) ? '' : '' . $attr['before'] . '' ); $attr['after'] = ( empty( $attr['after'] ) ? '' : '' . $attr['after'] . '' ); return get_the_term_list( $attr['id'], $attr['taxonomy'], $attr['before'], $attr['separator'], $attr['after'] ); } /** * Displays a post's title with a link to the post. * * @since 0.7.0 */ function Easy_entry_title_shortcode() { global $post; if ( is_front_page() && !is_home() ) $title = the_title( '

', '

', false ); elseif ( is_singular() ) $title = the_title( '

', '

', false ); elseif ( 'link_category' == get_query_var( 'taxonomy' ) ) $title = false; else $title = the_title( '

', '

', false ); /* If there's no post title, return a clickable '(No title)'. */ if ( empty( $title ) && 'link_category' !== get_query_var( 'taxonomy' ) ) { if ( is_singular() ) $title = '

' . __( '(Untitled)', Easy_get_textdomain() ) . '

'; else $title = '

' . __( '(Untitled)', Easy_get_textdomain() ) . '

'; } return $title; } /** * Displays the shortlinke of an individual entry. * * @since 0.8.0 */ function Easy_entry_shortlink_shortcode( $attr ) { global $post; $domain = Easy_get_textdomain(); $attr = shortcode_atts( array( 'text' => __( 'Shortlink', $domain ), 'title' => the_title_attribute( array( 'echo' => false ) ), 'before' => '', 'after' => '' ), $attr ); $shortlink = wp_get_shortlink( $post->ID ); return "{$attr['before']}{$attr['text']}{$attr['after']}"; } /** * Displays the published date and time of an individual comment. * * @since 0.7.0 */ function Easy_comment_published_shortcode() { $domain = Easy_get_textdomain(); $link = '' . sprintf( __( '%1$s at %2$s', $domain ), '' . get_comment_date() . '', '' . get_comment_time() . '' ) . ''; return $link; } /** * Displays the comment author of an individual comment. * * @since 0.8.0 * @global $comment The current comment's DB object. * @return string */ function Easy_comment_author_shortcode( $attr ) { global $comment; $attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr ); $author = esc_html( get_comment_author( $comment->comment_ID ) ); $url = esc_url( get_comment_author_url( $comment->comment_ID ) ); /* Display link and cite if URL is set. Also, properly cites trackbacks/pingbacks. */ if ( $url ) $output = '' . $author . ''; else $output = '' . $author . ''; $output = '
' . $attr['before'] . apply_filters( 'get_comment_author_link', $output ) . $attr['after'] . '
'; /* @deprecated 0.8. Create a custom shortcode instead of filtering Easy_comment_author. */ return apply_filters( Easy_get_prefix() . '_comment_author', $output ); } /** * Displays the permalink to an individual comment. * * @since 0.7.0 */ function Easy_comment_permalink_shortcode( $attr ) { global $comment; $attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr ); $domain = Easy_get_textdomain(); $link = ''; return $attr['before'] . $link . $attr['after']; } /** * Displays a comment's edit link to users that have the capability to edit the comment. * * @since 0.7.0 */ function Easy_comment_edit_link_shortcode( $attr ) { global $comment; $edit_link = get_edit_comment_link( $comment->comment_ID ); if ( !$edit_link ) return ''; $attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr ); $domain = Easy_get_textdomain(); $link = '' . __( 'Edit', $domain ) . ''; $link = apply_filters( 'edit_comment_link', $link, $comment->comment_ID ); return $attr['before'] . $link . $attr['after']; } /** * Displays a reply link for the 'comment' comment_type if threaded comments are enabled. * * @since 0.7.0 */ function Easy_comment_reply_link_shortcode( $attr ) { $domain = Easy_get_textdomain(); if ( !get_option( 'thread_comments' ) || 'comment' !== get_comment_type() ) return ''; $defaults = array( 'reply_text' => __( 'Reply', $domain ), 'login_text' => __( 'Log in to reply.', $domain ), 'depth' => $GLOBALS['comment_depth'], 'max_depth' => get_option( 'thread_comments_depth' ), 'before' => '', 'after' => '' ); $attr = shortcode_atts( $defaults, $attr ); return get_comment_reply_link( $attr ); } ?>