/** * 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 * * @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') { // set all default attributes to false $defaults = array('page' => false, 'url' => false, 'status' => false, 'msg' => false, 'field' => false, 'id' => false); // merge defaults with $attr and extract extract(shortcode_atts($defaults, $attr, $tag)); // handles the 'page' attribute if ($page) { if ($page == 'user-list') { //return ( function_exists( 'wpmem_list_users' ) ) ? do_shortcode( wpmem_list_users( $attr, $content ) ) : ''; if (function_exists('wpmem_list_users')) { $content = do_shortcode(wpmem_list_users($attr, $content)); } } elseif ($page == 'tos') { return $url; } else { //return do_shortcode( wpmem_do_sc_pages( $page ) ); $content = do_shortcode(wpmem_do_sc_pages($page)); } // resolve any texturize issues... if (strstr($content, '[wpmem_txt]')) { // fix the wptexturize remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'wptexturize'); add_filter('the_content', 'wpmem_texturize', 99); } return $content; } // handles the 'status' attribute if ($status || $tag == 'wpmem_logged_in') { $do_return = false; // if using the wpmem_logged_in tag with no attributes & the user is logged in if ($tag == 'wpmem_logged_in' && !$attr && is_user_logged_in()) { $do_return = true; } // if there is a status attribute of "in" and the user is logged in if ($status == 'in' && is_user_logged_in()) { $do_return = true; } // if there is a status attribute of "out" and the user is not logged in if ($status == 'out' && !is_user_logged_in()) { $do_return = true; } // if there is a status attribute of "sub" and the user is logged in if ($status == 'sub' && is_user_logged_in()) { if (WPMEM_USE_EXP == 1) { if (!wpmem_chk_exp()) { $do_return = true; } elseif ($msg == true) { $do_return = true; $content = wpmem_sc_expmessage(); } } } // return content (or empty content) depending on the result of the above logic return $do_return ? do_shortcode($content) : ''; } // 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 ($field || $tag == 'wpmem_field') { if ($id) { // we are getting some other user if ($id == 'get') { $the_user_ID = isset($_GET['uid']) ? $_GET['uid'] : ''; } else { $the_user_ID = $id; } } else { // get the current user $the_user_ID = get_current_user_id(); } $user_info = get_userdata($the_user_ID); // @todo - check this change return $user_info ? htmlspecialchars($user_info->{$field}) . do_shortcode($content) : do_shortcode($content); // return ( $user_info ) ? htmlspecialchars( $user_info->$field ) . do_shortcode( $content ) : ''; } // logout link shortcode if (is_user_logged_in() && $tag == 'wpmem_logout') { $link = $url ? wpmem_chk_qstr($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>"); } }
/** * 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>"); } }
/** * Executes shortcode for settings, register, and login pages * * @since 2.4 * * @param array $attr page|status|field * @param string $content * @return string returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content */ function wpmem_shortcode($attr, $content = null) { // handles the 'page' attribute if (isset($attr['page'])) { if ($attr['page'] == 'user-list') { return do_shortcode(wpmem_list_users($attr, $content)); } else { return do_shortcode(wpmem_do_sc_pages($attr['page'])); } } // handles the 'status' attribute if (isset($attr['status'])) { if ($attr['status'] == 'in' && is_user_logged_in()) { return do_shortcode($content); } elseif ($attr['status'] == 'out' && !is_user_logged_in()) { return do_shortcode($content); } elseif ($attr['status'] == 'sub' && is_user_logged_in()) { if (WPMEM_USE_EXP == 1) { if (!wpmem_chk_exp()) { return do_shortcode($content); } elseif ($attr['msg'] == true) { return do_shortcode(wpmem_sc_expmessage()); } } } } // handles the 'field' attribute if (isset($attr['field'])) { global $user_ID; $user_info = get_userdata($user_ID); return htmlspecialchars($user_info->{$attr}['field']) . do_shortcode($content); } }
/** * 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); } }