Esempio n. 1
0
 /**
  * Executes various shortcodes.
  *
  * This function executes shortcodes for pages (settings, register, login, user-list,
  * and tos pages), as well as login status and field attributes when the wp-members tag
  * is used.  Also executes shortcodes for login status with the wpmem_logged_in tags
  * and fields when the wpmem_field tags are used.
  *
  * @since 2.4.0
  *
  * @global object $wpmem The WP_Members object.
  *
  * @param  array  $attr page|url|status|msg|field|id
  * @param  string $content
  * @param  string $tag
  * @return string Returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content.
  */
 function wpmem_shortcode($attr, $content = null, $tag = 'wp-members')
 {
     global $wpmem;
     // Set all default attributes to false.
     $defaults = array('page' => false, 'redirect_to' => null, 'url' => false, 'status' => false, 'msg' => false, 'field' => false, 'id' => false, 'underscores' => 'off');
     // Merge defaults with $attr.
     $atts = shortcode_atts($defaults, $attr, $tag);
     // Handles the 'page' attribute.
     if ($atts['page']) {
         if ($atts['page'] == 'user-list') {
             if (function_exists('wpmem_list_users')) {
                 $content = do_shortcode(wpmem_list_users($attr, $content));
             }
         } elseif ($atts['page'] == 'tos') {
             return $atts['url'];
         } else {
             $content = do_shortcode(wpmem_do_sc_pages($atts['page'], $atts['redirect_to']));
         }
         // Resolve any texturize issues.
         if (strstr($content, '[wpmem_txt]')) {
             // Fixes the wptexturize.
             remove_filter('the_content', 'wpautop');
             remove_filter('the_content', 'wptexturize');
             add_filter('the_content', 'wpmem_texturize', 999);
         }
         return $content;
     }
     // Handles the 'status' attribute.
     if ($atts['status'] || $tag == 'wpmem_logged_in') {
         return do_shortcode(wpmem_sc_logged_in($atts, $content, $tag));
     }
     // @deprecated 3.0.0
     // Handles the wpmem_logged_out tag with no attributes & the user is not logged in.
     /*
     if ( $tag == 'wpmem_logged_out' && ( ! $attr ) && ! is_user_logged_in() ) {
     	return do_shortcode( $content );
     }
     */
     // Handles the 'field' attribute.
     if ($atts['field'] || $tag == 'wpmem_field') {
         if ($atts['id']) {
             // We are getting some other user.
             if ($atts['id'] == 'get') {
                 $the_user_ID = isset($_GET['uid']) ? $_GET['uid'] : '';
             } else {
                 $the_user_ID = $atts['id'];
             }
         } else {
             // Get the current user.
             $the_user_ID = get_current_user_id();
         }
         $user_info = get_userdata($the_user_ID);
         if ($atts['underscores'] == 'off' && $user_info) {
             $user_info->{$atts}['field'] = str_replace('_', ' ', $user_info->{$atts}['field']);
         }
         return $user_info ? htmlspecialchars($user_info->{$atts}['field']) . do_shortcode($content) : do_shortcode($content);
     }
     // Logout link shortcode.
     if (is_user_logged_in() && $tag == 'wpmem_logout') {
         $link = $atts['url'] ? wpmem_chk_qstr($atts['url']) . 'a=logout' : wpmem_chk_qstr(get_permalink()) . 'a=logout';
         $text = $content ? $content : __('Click here to log out.', 'wp-members');
         return do_shortcode("<a href=\"{$link}\">{$text}</a>");
     }
 }
Esempio n. 2
0
 /**
  * Executes various shortcodes.
  *
  * This function executes shortcodes for pages (settings, register, login, user-list,
  * and tos pages), as well as login status and field attributes when the wp-members tag
  * is used.  Also executes shortcodes for login status with the wpmem_logged_in tags
  * and fields when the wpmem_field tags are used.
  *
  * @since 2.4.0
  * @deprecated 3.1.2 
  *
  * @global object $wpmem The WP_Members object.
  *
  * @param  array  $attr page|url|status|msg|field|id
  * @param  string $content
  * @param  string $tag
  * @return string Returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content.
  */
 function wpmem_shortcode($attr, $content = null, $tag = 'wp-members')
 {
     $error = "wpmem_shortcode() is deprecated as of WP-Members 3.1.2. The [wp-members] shortcode tag should be replaced. ";
     $error .= 'See replacement shortcodes: http://rkt.bz/logsc ';
     $error .= "post ID: " . get_the_ID() . " ";
     $error .= "page url: " . wpmem_current_url();
     wpmem_write_log($error);
     global $wpmem;
     // Set all default attributes to false.
     $defaults = array('page' => false, 'redirect_to' => null, 'url' => false, 'status' => false, 'msg' => false, 'field' => false, 'id' => false, 'underscores' => 'off');
     // Merge defaults with $attr.
     $atts = shortcode_atts($defaults, $attr, $tag);
     // Handles the 'page' attribute.
     if ($atts['page']) {
         if ($atts['page'] == 'user-list') {
             if (function_exists('wpmem_list_users')) {
                 $content = do_shortcode(wpmem_list_users($attr, $content));
             }
         } elseif ($atts['page'] == 'tos') {
             return $atts['url'];
         } else {
             $content = do_shortcode(wpmem_do_sc_pages($atts, $content, $tag));
         }
         // Resolve any texturize issues.
         if (strstr($content, '[wpmem_txt]')) {
             // Fixes the wptexturize.
             remove_filter('the_content', 'wpautop');
             remove_filter('the_content', 'wptexturize');
             add_filter('the_content', 'wpmem_texturize', 999);
         }
         return $content;
     }
     // Handles the 'status' attribute.
     if ($atts['status'] || $tag == 'wpmem_logged_in') {
         return wpmem_sc_logged_in($atts, $content, $tag);
     }
     // Handles the 'field' attribute.
     if ($atts['field'] || $tag == 'wpmem_field') {
         return wpmem_sc_fields($atts, $content, $tag);
     }
 }