aiwoo_shortcode_loginout

The WooCommerce Menu Extension aiwoo shortcode loginout function.

Description

aiwoo_shortcode_loginout( $atts, (null) $content = null ); 

Parameters (2)

0. $atts
The atts.
1. $content — Optional. (null) => null
The content.

Usage

  1. if ( !function_exists( 'aiwoo_shortcode_loginout' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-menu-extension/include/frontend.inc.php'; 
  3.  
  4. // The atts. 
  5. $atts = null; 
  6.  
  7. // The content. 
  8. $content = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = aiwoo_shortcode_loginout($atts, $content); 
  12.  

Defined (1)

The function is defined in the following location(s).

/include/frontend.inc.php  
  1. function aiwoo_shortcode_loginout( $atts, $content = null ) { 
  2. global $woocommerce; 
  3. extract(shortcode_atts(array( 
  4. "edit_tag" => "",  
  5. "redirect" => get_permalink( woocommerce_get_page_id( 'myaccount' ) ) 
  6. ), $atts ) ); 
  7. $edit_tag = strip_tags( $edit_tag ); 
  8. $href = is_user_logged_in() ? wp_logout_url( $redirect ) : get_permalink( woocommerce_get_page_id( 'myaccount' ) ); 
  9. if( $content && strstr( $content, '|' ) != '' ) { // the "|" char is used to split titles 
  10. $content = explode( '|', $content ); 
  11. $content = is_user_logged_in() ? $content[1] : $content[0]; 
  12. }else{ 
  13. $current_user = wp_get_current_user(); 
  14. $message = is_user_logged_in() ? __( 'Hello ' ) . $current_user->user_login . ', ' : ''; 
  15. $content = is_user_logged_in() ? __( 'Logout' ) : __( 'Log In' ); 
  16. return $message . '<a href="' . esc_url( $href ) . '"' .$edit_tag . '>' . $content . '</a>';