s2Member v110815
Source Code: s2member-pro\includes\classes\login-widget.inc.php
Docs updated: August 15, 2011, 4:18 pm
Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code jQuery(window).load(function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli'+location.hash).addClass('hilite'); }); jQuery(window).bind('hashchange', function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli').removeClass('hilite'); jQuery('olli'+location.hash).addClass('hilite'); }); [ full view ]s2member-pro\includes\classes\login-widget.inc.php ?php /** * Pro Login Widget. * * Copyright: © 2009-2011 * {@link http://www.websharks-inc.com/ WebSharks, Inc.} * ( coded in the USA ) * * This WordPress® plugin ( s2Member Pro ) is comprised of two parts: * * o (1) Its PHP code is licensed under the GPL license, as is WordPress®. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * o (2) All other parts of ( s2Member Pro ); including, but not limited to: * the CSS code, some JavaScript code, images, and design; * are licensed according to the license purchased. * See: {@link http://www.s2member.com/prices/} * * Unless you have our prior written consent, you must NOT directly or indirectly license, * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module; * or make an offer to do any of these things. All of these things are strictly * prohibited with part (2) of the s2Member Pro Module. * * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com * ( i.e. new features, bug fixes, updates, improvements ); along with full access * to our video tutorial library: {@link http://www.s2member.com/videos/} * * @package s2Member\Widgets * @since 1.5 */ if ( realpath ( __FILE__ ) === realpath ( $_SERVER [ "SCRIPT_FILENAME" ] ) ) exit ( "Do not access this file directly." ) ; /**/ if ( ! class_exists ( "c_ws_plugin__s2member_pro_login_widget" ) ) { /** * Pro Login Widget. * * @package s2Member\Widgets * @since 1.5 * * @todo Optimize these methods with ``empty()`` and ``isset()``. */ class c_ws_plugin__s2member_pro_login_widget /* Register widget class. */ extends WP_Widget /* See: /wp-includes/widgets.php for further details. */ { /** * Constructor. * * @package s2Member\Widgets * @since 1.5 * * @return null */ public function c_ws_plugin__s2member_pro_login_widget ( ) /* Builds the classname, id_base, description, etc. */ { $widget_ops = array ( "classname" = "colors" , "description" = "Displays a Login Form if NOT logged in. Or a Profile Summary when a User/Member is logged in." ) ; $control_ops = array ( "width" = 400 , "id_base" = "ws_plugin__s2member_pro_login_widget" ) ; /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_before_construction" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $this - WP_Widget ( $control_ops [ "id_base" ] , "s2Member Pro ( Login Widget )" , $widget_ops , $control_ops ) ; /**/ do_action ( "ws_plugin__s2member_pro_login_widget_after_construction" , get_defined_vars ( ) , $this ) ; /**/ return ; /* Return for uniformity. */ } /** * Widget display. * * @package s2Member\Widgets * @since 1.5 * * @param array $args Optional. An array of basic settings. * @param array $instance Optional. An array of options for this instance. * @return null */ public function widget ( $args = FALSE , $instance = FALSE ) { $options = c_ws_plugin__s2member_pro_login_widget:: configure_options_and_their_defaults ( ( array ) $instance ) ; /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_before_display" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ echo $args [ "before_widget" ] ; /* OK, here we go into this widget. */ /**/ if ( ( is_user_logged_in ( ) && strlen ( $options [ "profile_title" ] ) ) || ( ! is_user_logged_in ( ) && strlen ( $options [ "title" ] ) ) ) echo $args [ "before_title" ] . apply_filters ( "widget_title" , $options [ ( ( is_user_logged_in ( ) ) ? "profile_title" : "title" ) ] ) . $args [ "after_title" ] ; /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_during_display_before" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( ! is_user_logged_in ( ) ) /* If the User/Member is NOT logged in. We show the login form. */ { $links = c_ws_plugin__s2member_cache:: cached_page_links ( ) ; /* Cached links. */ /**/ $ops_page = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "membership_options_page" ] ; /**/ $options [ "login_redirect" ] = ( $options [ "login_redirect" ] === "%%previous%%" && $ops_page && is_page ( $ops_page ) ) ? "" : $options [ "login_redirect" ] ; /**/ $redirect_to = preg_replace ( "/%%previous%%/i" , $_SERVER [ "REQUEST_URI" ] , ( $redirect_to = $options [ "login_redirect" ] ) ) ; $redirect_to = preg_replace ( "/%%home%%/i" , home_url ( "/" ) , $redirect_to ) ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget"' . "\n" ; /**/ echo 'form method="post" action="' . esc_attr ( wp_login_url ( ) ) . '" class="ws-plugin--s2member-pro-login-widget-form"' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-username"' . "\n" ; echo 'label for="ws-plugin--s2member-pro-login-widget-username"Username:/labelbr /' . "\n" ; echo 'input type="text" name="log" id="ws-plugin--s2member-pro-login-widget-username" title="Username" /' . "\n" ; echo '/div' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-password"' . "\n" ; echo 'label for="ws-plugin--s2member-pro-login-widget-password"Password:/labelbr /' . "\n" ; echo 'input type="password" name="pwd" id="ws-plugin--s2member-pro-login-widget-password" title="Password" /' . "\n" ; echo '/div' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-lost-password"' . "\n" ; echo ( $options [ "signup_url" ] ) ? 'a href="' . esc_attr ( ( $options [ "signup_url" ] !== "%%automatic%%" ) ? $options [ "signup_url" ] : $links [ "membership_options_page" ] ) . '" tabindex="-1"signup now/a | ' : '' ; echo 'a href="' . esc_attr ( wp_lostpassword_url ( ) ) . '" tabindex="-1"forgot password?/a' . "\n" ; echo '/div' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-remember-me"' . "\n" ; echo 'labelinput type="checkbox" name="rememberme" value="forever" /Remember Me/label' . "\n" ; echo '/div' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-submit"' . "\n" ; echo ( $redirect_to ) ? 'input type="hidden" name="redirect_to" value="' . esc_attr ( $redirect_to ) . '" /' . "\n" : '' ; echo 'input type="submit" value="Log Me In" /' . "\n" ; echo '/div' . "\n" ; /**/ echo '/form' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-code"' . "\n" ; /**/ if ( is_multisite ( ) && c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) && ! is_main_site ( ) ) echo do_shortcode ( trim ( $options [ "logged_out_code" ] ) ) ; /* No PHP code. */ /**/ else /* Otherwise, it's OK to execute PHP code. */ echo do_shortcode (c_ws_plugin__s2member_utilities:: evl ( trim ( $options [ "logged_out_code" ] ) ) ) ; /**/ echo '/div' . "\n" ; /**/ echo 'div style="clear:both;"/div' . "\n" ; /**/ echo '/div' . "\n" ; } /**/ else if ( is_user_logged_in ( ) ) /* We display a brief Profile Summary here. */ { $user = wp_get_current_user ( ) ; /* Get current User object. */ /**/ $links = c_ws_plugin__s2member_cache:: cached_page_links ( ) ; /* Cached links. */ /**/ $ops_page = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "membership_options_page" ] ; $welcome_page = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "login_welcome_page" ] ; /**/ $options [ "logout_redirect" ] = ( $options [ "logout_redirect" ] === "%%previous%%" && $ops_page && is_page ( $ops_page ) ) ? "" : $options [ "logout_redirect" ] ; $options [ "logout_redirect" ] = ( $options [ "logout_redirect" ] === "%%previous%%" && $welcome_page && is_page ( $welcome_page ) ) ? "" : $options [ "logout_redirect" ] ; /**/ $redirect_to = preg_replace ( "/%%previous%%/i" , $_SERVER [ "REQUEST_URI" ] , ( $redirect_to = $options [ "logout_redirect" ] ) ) ; $redirect_to = preg_replace ( "/%%home%%/i" , home_url ( "/" ) , $redirect_to ) ; /**/ echo 'div id="ws-plugin--s2member-pro-login-widget" class="ws-plugin--s2member-pro-login-widget"' . "\n" ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-profile-summary"' . "\n" ; /**/ echo ( $options [ "display_gravatar" ] ) ? ( ( $options [ "link_gravatar" ] ) ? 'a href="http://www.gravatar.com/" target="_blank"' : '' ) . get_avatar ( $user - ID , 48 ) . ( ( $options [ "link_gravatar" ] ) ? '/a' : '' ) . "\n" : '' ; /* Display avatar. */ /**/ echo ( $options [ "display_name" ] ) ? 'div class="ws-plugin--s2member-pro-login-widget-profile-summary-name"' . esc_html ( $user - display_name ) . '/div' . "\n" : '' ; /**/ echo 'div class="ws-plugin--s2member-pro-login-widget-profile-summary-code"' . "\n" ; /**/ if ( is_multisite ( ) && c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) && ! is_main_site ( ) ) echo do_shortcode ( trim ( $options [ "logged_in_code" ] ) ) ; /* No PHP code. */ /**/ else /* Otherwise, it's OK to execute PHP code. */ echo do_shortcode (c_ws_plugin__s2member_utilities:: evl ( trim ( $options [ "logged_in_code" ] ) ) ) ; /**/ echo '/div' . "\n" ; /**/ echo ( $options [ "my_account_url" ] ) ? 'div class="ws-plugin--s2member-pro-login-widget-profile-summary-my-account"a href="' . esc_attr ( ( $options [ "my_account_url" ] !== "%%automatic%%" ) ? c_ws_plugin__s2member_login_redirects:: fill_login_redirect_rc_vars ( $options [ "my_account_url" ] ) : ( ( $login_redirection_url = c_ws_plugin__s2member_login_redirects:: login_redirection_url ( $user ) ) ? $login_redirection_url : $links [ "login_welcome_page" ] ) ) . '"My Account/a/div' . "\n" : '' ; echo ( $options [ "my_profile_url" ] ) ? 'div class="ws-plugin--s2member-pro-login-widget-profile-summary-edit-profile"a href="' . ( ( $options [ "my_profile_url" ] !== "%%automatic%%" ) ? esc_attr (c_ws_plugin__s2member_login_redirects:: fill_login_redirect_rc_vars ( $options [ "my_profile_url" ] ) ) : esc_attr ( site_url ( "/?s2member_profile=1" ) ) . '" /?s2member_profile=1" ) ) ) . '\',\'_profile\', \'width=600,height=400,left=\'+((screen.width/2)-(600/2))+\',screenX=\'+((screen.width/2)-(600/2))+\',top=\'+((screen.height/2)-(400/2))+\',screenY=\'+((screen.height/2)-(400/2))+\',location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1\')) alert(\'Please disable popup blockers and try again!\'); return false;' ) . '"Edit My Profile/a/div' . "\n" : '' ; echo 'div class="ws-plugin--s2member-pro-login-widget-profile-summary-logout"a href="' . esc_attr ( wp_logout_url ( $redirect_to ) ) . '"Logout/a/div' . "\n" ; /**/ echo 'div style="clear:both;"/div' . "\n" ; /**/ echo '/div' . "\n" ; /**/ echo '/div' . "\n" ; } /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_during_display_after" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ echo $args [ "after_widget" ] ; /**/ do_action ( "ws_plugin__s2member_pro_login_widget_after_display" , get_defined_vars ( ) , $this ) ; /**/ return ; /* Return for uniformity. */ } /** * Widget form control. * * @package s2Member\Widgets * @since 1.5 * * @param array $instance Optional. An array of options for this instance. * @return null */ public function form ( $instance = FALSE ) { $options = c_ws_plugin__s2member_pro_login_widget:: configure_options_and_their_defaults ( ( array ) $instance ) ; /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_before_form" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /* Ok, here is where we need to handle the widget control form. This allows a user to further customize the widget. */ echo 'label for="' . esc_attr ( $this - get_field_id ( "title" ) ) . '"strongPublic Title/strong ( when NOT logged in )/labelbr /' . "\n" ; echo 'input class="widefat" id="' . esc_attr ( $this - get_field_id ( "title" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "title" ) ) . '" type="text" value="' . format_to_edit ( $options [ "title" ] ) . '" /br /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "login_redirect" ) ) . '"Redirection After Login/labelbr /' . "\n" ; echo 'select class="widefat" id="' . esc_attr ( $this - get_field_id ( "login_redirect" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "login_redirect" ) ) . '"option value=""' . ( ( ! $options [ "login_redirect" ] ) ? ' selected="selected"' : '' ) . 'Login Welcome Page/optionoption value="%%previous%%"' . ( ( $options [ "login_redirect" ] === "%%previous%%" ) ? ' selected="selected"' : '' ) . 'Previous page/optionoption value="%%home%%"' . ( ( $options [ "login_redirect" ] === "%%home%%" ) ? ' selected="selected"' : '' ) . 'Home Page/option/selectbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "signup_url" ) ) . '"Signup Now ( enter URL, or just use code%%automatic%%/code )/labelbr /' . "\n" ; echo 'input class="widefat" id="' . esc_attr ( $this - get_field_id ( "signup_url" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "signup_url" ) ) . '" type="text" value="' . format_to_edit ( $options [ "signup_url" ] ) . '" /br /' . "\n" ; echo 'small( leave blank to exclude this link )/smallbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "code" ) ) . '"Additional XHTML' . ( ( ! is_multisite ( ) || !c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) || is_main_site ( ) ) ? '/PHP' : '' ) . ' Code?/labelbr /' . "\n" ; echo 'textarea class="widefat" style="height:50px;" rows="1" cols="1" id="' . esc_attr ( $this - get_field_id ( "logged_out_code" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "logged_out_code" ) ) . '"' . format_to_edit ( $options [ "logged_out_code" ] ) . '/textarea' . "\n" ; /**/ echo 'div style="margin:15px 0 15px 0; height:1px; line-height:1px; background:#CCCCCC;"/div' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "profile_title" ) ) . '"strongProfile Title/strong ( when logged-in )/labelbr /' . "\n" ; echo 'input class="widefat" id="' . esc_attr ( $this - get_field_id ( "profile_title" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "profile_title" ) ) . '" type="text" value="' . format_to_edit ( $options [ "profile_title" ] ) . '" /br /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "display_gravatar" ) ) . '"Display Gravatar Image?/labelbr /' . "\n" ; echo 'select class="widefat" id="' . esc_attr ( $this - get_field_id ( "display_gravatar" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "display_gravatar" ) ) . '"option value="1"' . ( ( $options [ "display_gravatar" ] ) ? ' selected="selected"' : '' ) . 'Yes, display Gravatar/optionoption value="0"' . ( ( ! $options [ "display_gravatar" ] ) ? ' selected="selected"' : '' ) . 'No, do NOT display/option/selectbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "link_gravatar" ) ) . '"Link To Gravatar.com?/labelbr /' . "\n" ; echo 'select class="widefat" id="' . esc_attr ( $this - get_field_id ( "link_gravatar" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "link_gravatar" ) ) . '"option value="1"' . ( ( $options [ "link_gravatar" ] ) ? ' selected="selected"' : '' ) . 'Yes, apply link/optionoption value="0"' . ( ( ! $options [ "link_gravatar" ] ) ? ' selected="selected"' : '' ) . 'No, do NOT apply/option/selectbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "display_name" ) ) . '"Display User\'s Name?/labelbr /' . "\n" ; echo 'select class="widefat" id="' . esc_attr ( $this - get_field_id ( "display_name" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "display_name" ) ) . '"option value="1"' . ( ( $options [ "display_name" ] ) ? ' selected="selected"' : '' ) . 'Yes, display User\'s name/optionoption value="0"' . ( ( ! $options [ "display_name" ] ) ? ' selected="selected"' : '' ) . 'No, do NOT display/option/selectbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "my_account_url" ) ) . '"My Account ( enter URL, or just use code%%automatic%%/code )/labelbr /' . "\n" ; echo 'input class="widefat" id="' . esc_attr ( $this - get_field_id ( "my_account_url" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "my_account_url" ) ) . '" type="text" value="' . format_to_edit ( $options [ "my_account_url" ] ) . '" /br /' . "\n" ; echo 'small( leave blank to exclude this link )/smallbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "my_profile_url" ) ) . '"Edit Profile ( enter URL, or use code%%automatic%%/code )/labelbr /' . "\n" ; echo 'input class="widefat" id="' . esc_attr ( $this - get_field_id ( "my_profile_url" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "my_profile_url" ) ) . '" type="text" value="' . format_to_edit ( $options [ "my_profile_url" ] ) . '" /br /' . "\n" ; echo 'small( leave blank to exclude this link )/smallbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "logout_redirect" ) ) . '"Redirection After Logout/labelbr /' . "\n" ; echo 'select class="widefat" id="' . esc_attr ( $this - get_field_id ( "logout_redirect" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "logout_redirect" ) ) . '"option value="%%home%%"' . ( ( $options [ "logout_redirect" ] === "%%home%%" ) ? ' selected="selected"' : '' ) . 'Home Page/optionoption value="%%previous%%"' . ( ( $options [ "logout_redirect" ] === "%%previous%%" ) ? ' selected="selected"' : '' ) . 'Previous page/optionoption value=""' . ( ( ! $options [ "logout_redirect" ] ) ? ' selected="selected"' : '' ) . 'Login screen/option/selectbr /br /' . "\n" ; /**/ echo 'label for="' . esc_attr ( $this - get_field_id ( "code" ) ) . '"Additional XHTML' . ( ( ! is_multisite ( ) || !c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) || is_main_site ( ) ) ? '/PHP' : '' ) . ' Code?/labelbr /' . "\n" ; echo 'textarea class="widefat" style="height:50px;" rows="1" cols="1" id="' . esc_attr ( $this - get_field_id ( "logged_in_code" ) ) . '" name="' . esc_attr ( $this - get_field_name ( "logged_in_code" ) ) . '"' . format_to_edit ( $options [ "logged_in_code" ] ) . '/textarea' . "\n" ; /**/ echo ( ! is_multisite ( ) || !c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) || is_main_site ( ) ) ? 'div style="margin:15px 0 15px 0; height:1px; line-height:1px; background:#CCCCCC;"/div' . "\n" : '' ; echo ( ! is_multisite ( ) || !c_ws_plugin__s2member_utils_conds:: is_multisite_farm ( ) || is_main_site ( ) ) ? 'emOr include this widget dynamically via PHP:br /' . c_ws_plugin__s2member_utils_strings:: highlight_php ( '?php echo s2member_pro_login_widget(); ?' ) . 'br /smallSee: codes2Member - API Scripting - Pro Login Widget/code/small/em' . "\n" : '' ; /**/ do_action ( "ws_plugin__s2member_pro_login_widget_after_form" , get_defined_vars ( ) , $this ) ; /**/ echo 'br /' . "\n" ; /**/ return ; /* Return for uniformity. */ } /** * Widget updates. * * @package s2Member\Widgets * @since 1.5 * * @param array $instance Optional. An array of options for this instance. * @param array $old Optional. An old array of options for this instance. * @return array New array of options for this instance. */ public function update ( $instance = FALSE , $old = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_pro_login_widget_before_update" , get_defined_vars ( ) , $this ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $instance = ( array )c_ws_plugin__s2member_utils_strings:: trim_deep ( stripslashes_deep ( $instance ) ) ; /**/ return c_ws_plugin__s2member_pro_login_widget:: configure_options_and_their_defaults ( $instance ) ; } /** * Configure & validate all of the widget options; and set their defaults. * * @package s2Member\Widgets * @since 1.5 * * @param array $options Optional. An array of options for a particular instance. * @return array Array of options, after having been validated and merged with defaults. */ public function configure_options_and_their_defaults ( $options = FALSE ) { /* Here we build the default widget options array, these get merged on a per-widget basis. It is important to note that sometimes default options may not or should not be pre-filled on an options form. These defaults are for the system to use in various ways, we may choose not to pre-fill certain fields. In other words, some defaults may be used internally, but to the user, the option will be empty. */ $default_options = apply_filters ( "ws_plugin__s2member_pro_login_widget_default_options" , array ( /**/ "title" = "Membership Login" , /**/ "signup_url" = "%%automatic%%" , /**/ "login_redirect" = "" , /* redirect_to? */ "logged_out_code" = "" , /* 100% custom. */ "profile_title" = "My Profile Summary" , /**/ "display_gravatar" = "1" , /* Yes, display avatar. */ "link_gravatar" = "1" , /* Targer link. */ "display_name" = "1" , /* Yes, display name. */ "logged_in_code" = "" , /* 100% custom. */ "logout_redirect" = "%%home%%" , /**/ "my_account_url" = "%%automatic%%" , /**/ "my_profile_url" = "%%automatic%%" ) ) ; /* Here they are merged. User options will overwrite some or all defaults. */ $options = array_merge ( $default_options , ( array ) $options ) ; /* Validate each option, possibly reverting back to default if invalid. */ foreach ( $options as $key = & $value ) { if ( ! isset ( $default_options [ $key ] ) ) unset ( $options [ $key ] ) ; /**/ else if ( $key === "title" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "signup_url" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "login_redirect" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "logged_out_code" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "profile_title" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "display_gravatar" && ( ! is_string ( $value ) || ! is_numeric ( $value ) ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "link_gravatar" && ( ! is_string ( $value ) || ! is_numeric ( $value ) ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "display_name" && ( ! is_string ( $value ) || ! is_numeric ( $value ) ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "logged_in_code" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "logout_redirect" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "my_account_url" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; /**/ else if ( $key === "my_profile_url" && ! is_string ( $value ) ) $value = $default_options [ $key ] ; } /**/ return apply_filters ( "ws_plugin__s2member_pro_login_widget_options" , $options ) ; } } } ? [ full view ]s2member-pro\includes\classes\login-widget.inc.php Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code(!-- :: s-words --)Statistics: Posted by System Robot — August 15th, 2011, 3:17 pm
]]>