Source Code Documentation


s2member-pro\includes\classes\login-widget.inc.php


  1. <?php
  2. /**
  3. * Pro Login Widget.
  4. *
  5. * Copyright: © 2009-2011
  6. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  7. * ( coded in the USA )
  8. *
  9. * This WordPress® plugin ( s2Member Pro ) is comprised of two parts:
  10. *
  11. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  12. * You should have received a copy of the GNU General Public License,
  13. * along with this software. In the main directory, see: /licensing/
  14. * If not, see: {@link http://www.gnu.org/licenses/}.
  15. *
  16. * o (2) All other parts of ( s2Member Pro ); including, but not limited to:
  17. * the CSS code, some JavaScript code, images, and design;
  18. * are licensed according to the license purchased.
  19. * See: {@link http://www.s2member.com/prices/}
  20. *
  21. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  22. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  23. * or make an offer to do any of these things. All of these things are strictly
  24. * prohibited with part (2) of the s2Member Pro Module.
  25. *
  26. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  27. * ( i.e. new features, bug fixes, updates, improvements ); along with full access
  28. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  29. *
  30. * @package s2Member\Widgets
  31. * @since 1.5
  32. */
  33. if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
  34. exit("Do not access this file directly.");
  35. /**/
  36. if (!class_exists ("c_ws_plugin__s2member_pro_login_widget"))
  37. {
  38. /**
  39. * Pro Login Widget.
  40. *
  41. * @package s2Member\Widgets
  42. * @since 1.5
  43. *
  44. * @todo Optimize these methods with ``empty()`` and ``isset()``.
  45. */
  46. class c_ws_plugin__s2member_pro_login_widget /* << Register widget class. */
  47. extends WP_Widget /* See: /wp-includes/widgets.php for further details. */
  48. {
  49. /**
  50. * Constructor.
  51. *
  52. * @package s2Member\Widgets
  53. * @since 1.5
  54. *
  55. * @return null
  56. */
  57. public function c_ws_plugin__s2member_pro_login_widget () /* Builds the classname, id_base, description, etc. */
  58. {
  59. $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.");
  60. $control_ops = array ("width" => 400, "id_base" => "ws_plugin__s2member_pro_login_widget");
  61. /**/
  62. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  63. do_action ("ws_plugin__s2member_pro_login_widget_before_construction", get_defined_vars (), $this);
  64. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  65. /**/
  66. $this->WP_Widget ($control_ops["id_base"], "s2Member Pro ( Login Widget )", $widget_ops, $control_ops);
  67. /**/
  68. do_action ("ws_plugin__s2member_pro_login_widget_after_construction", get_defined_vars (), $this);
  69. /**/
  70. return; /* Return for uniformity. */
  71. }
  72. /**
  73. * Widget display.
  74. *
  75. * @package s2Member\Widgets
  76. * @since 1.5
  77. *
  78. * @param array $args Optional. An array of basic settings.
  79. * @param array $instance Optional. An array of options for this instance.
  80. * @return null
  81. */
  82. public function widget ($args = FALSE, $instance = FALSE)
  83. {
  84. $options = c_ws_plugin__s2member_pro_login_widget::configure_options_and_their_defaults ((array)$instance);
  85. /**/
  86. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  87. do_action ("ws_plugin__s2member_pro_login_widget_before_display", get_defined_vars (), $this);
  88. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  89. /**/
  90. echo $args["before_widget"]; /* OK, here we go into this widget. */
  91. /**/
  92. if ((is_user_logged_in () && strlen ($options["profile_title"])) || (!is_user_logged_in () && strlen ($options["title"])))
  93. echo $args["before_title"] . apply_filters ("widget_title", $options[((is_user_logged_in ()) ? "profile_title" : "title")]) . $args["after_title"];
  94. /**/
  95. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  96. do_action ("ws_plugin__s2member_pro_login_widget_during_display_before", get_defined_vars (), $this);
  97. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  98. /**/
  99. if (!is_user_logged_in ()) /* The User/Member is NOT logged in. */
  100. {
  101. $links = c_ws_plugin__s2member_cache::cached_page_links ();
  102. /**/
  103. $ops_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
  104. /**/
  105. if ($ops_page && is_page ($ops_page) && /* Seeking something specific? */ !empty ($_GET["_s2member_seeking"]["_uri"]))
  106. $seeking = trim (base64_decode (trim (stripslashes ((string)$_GET["_s2member_seeking"]["_uri"]))));
  107. /**/
  108. $options["login_redirect"] = ($options["login_redirect"] === "%%previous%%" && $ops_page && is_page ($ops_page) && empty ($seeking)) ? "" : $options["login_redirect"];
  109. /**/
  110. $redirect_to = preg_replace ("/%%previous%%/i", ((!empty ($seeking)) ? $seeking : $_SERVER["REQUEST_URI"]), ($redirect_to = $options["login_redirect"]));
  111. $redirect_to = preg_replace ("/%%home%%/i", home_url ("/"), $redirect_to);
  112. /**/
  113. echo '<div class="ws-plugin--s2member-pro-login-widget">' . "\n";
  114. /**/
  115. echo '<form method="post" action="' . esc_attr (wp_login_url ()) . '" class="ws-plugin--s2member-pro-login-widget-form">' . "\n";
  116. /**/
  117. echo '<div class="ws-plugin--s2member-pro-login-widget-username">' . "\n";
  118. echo '<label for="ws-plugin--s2member-pro-login-widget-username">' . _x ("Username", "s2member-front", "s2member") . ':</label><br />' . "\n";
  119. echo '<input type="text" name="log" id="ws-plugin--s2member-pro-login-widget-username" title="Username" />' . "\n";
  120. echo '</div>' . "\n";
  121. /**/
  122. echo '<div class="ws-plugin--s2member-pro-login-widget-password">' . "\n";
  123. echo '<label for="ws-plugin--s2member-pro-login-widget-password">' . _x ("Password", "s2member-front", "s2member") . ':</label><br />' . "\n";
  124. echo '<input type="password" name="pwd" id="ws-plugin--s2member-pro-login-widget-password" title="Password" />' . "\n";
  125. echo '</div>' . "\n";
  126. /**/
  127. echo '<div class="ws-plugin--s2member-pro-login-widget-lost-password">' . "\n";
  128. $reg_cookies_ok_url = (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site ()) ? c_ws_plugin__s2member_utils_urls::wp_signup_url () : c_ws_plugin__s2member_utils_urls::wp_register_url ();
  129. echo ($options["signup_url"]) ? '<a href="' . esc_attr (($options["signup_url"] !== "%%automatic%%") ? $options["signup_url"] : ((c_ws_plugin__s2member_register_access::reg_cookies_ok ()) ? $reg_cookies_ok_url : $links["membership_options_page"])) . '" tabindex="-1">' . _x ("signup now", "s2member-front", "s2member") . '</a> | ' : '';
  130. echo '<a href="' . esc_attr (wp_lostpassword_url ()) . '" tabindex="-1">' . _x ("forgot password?", "s2member-front", "s2member") . '</a>' . "\n";
  131. echo '</div>' . "\n";
  132. /**/
  133. echo '<div class="ws-plugin--s2member-pro-login-widget-remember-me">' . "\n";
  134. echo '<label><input type="checkbox" name="rememberme" value="forever" />' . _x ("Remember Me", "s2member-front", "s2member") . '</label>' . "\n";
  135. echo '</div>' . "\n";
  136. /**/
  137. echo '<div class="ws-plugin--s2member-pro-login-widget-submit">' . "\n";
  138. echo ($redirect_to) ? '<input type="hidden" name="redirect_to" value="' . esc_attr ($redirect_to) . '" />' . "\n" : '';
  139. echo '<input type="submit" value="' . esc_attr (_x ("Log Me In", "s2member-front", "s2member")) . '" />' . "\n";
  140. echo '</div>' . "\n";
  141. /**/
  142. echo '</form>' . "\n";
  143. /**/
  144. echo '<div class="ws-plugin--s2member-pro-login-widget-code">' . "\n";
  145. /**/
  146. if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
  147. echo do_shortcode (trim ($options["logged_out_code"])); /* No PHP code. */
  148. /**/
  149. else /* Otherwise, it's OK to execute PHP code. */
  150. echo do_shortcode (c_ws_plugin__s2member_utilities::evl (trim ($options["logged_out_code"])));
  151. /**/
  152. echo '</div>' . "\n";
  153. /**/
  154. echo '<div style="clear:both;"></div>' . "\n";
  155. /**/
  156. echo '</div>' . "\n";
  157. }
  158. /**/
  159. else if (is_user_logged_in () && is_object ($user = wp_get_current_user ()) && !empty ($user->ID) && ($user_id = $user->ID))
  160. {
  161. $links = c_ws_plugin__s2member_cache::cached_page_links ();
  162. /**/
  163. $ops_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
  164. $welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
  165. /**/
  166. $options["logout_redirect"] = ($options["logout_redirect"] === "%%previous%%" && $ops_page && is_page ($ops_page)) ? "" : $options["logout_redirect"];
  167. $options["logout_redirect"] = ($options["logout_redirect"] === "%%previous%%" && $welcome_page && is_page ($welcome_page)) ? "" : $options["logout_redirect"];
  168. /**/
  169. $redirect_to = preg_replace ("/%%previous%%/i", $_SERVER["REQUEST_URI"], ($redirect_to = $options["logout_redirect"]));
  170. $redirect_to = preg_replace ("/%%home%%/i", home_url ("/"), $redirect_to);
  171. /**/
  172. echo '<div id="ws-plugin--s2member-pro-login-widget" class="ws-plugin--s2member-pro-login-widget">' . "\n";
  173. /**/
  174. echo '<div class="ws-plugin--s2member-pro-login-widget-profile-summary">' . "\n";
  175. /**/
  176. 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" : '';
  177. /**/
  178. echo ($options["display_name"]) ? '<div class="ws-plugin--s2member-pro-login-widget-profile-summary-name">' . esc_html ($user->display_name) . '</div>' . "\n" : '';
  179. /**/
  180. echo '<div class="ws-plugin--s2member-pro-login-widget-profile-summary-code">' . "\n";
  181. /**/
  182. if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
  183. echo do_shortcode (trim ($options["logged_in_code"])); /* No PHP code. */
  184. /**/
  185. else /* Otherwise, it's OK to execute PHP code. */
  186. echo do_shortcode (c_ws_plugin__s2member_utilities::evl (trim ($options["logged_in_code"])));
  187. /**/
  188. echo '</div>' . "\n";
  189. /**/
  190. 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"])) . '">' . _x ("My Account", "s2member-front", "s2member") . '</a></div>' . "\n" : '';
  191. 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")) . '" onclick="if(!window.open(\'' . c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (site_url ("/?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(\'' . c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please disable popup blockers and try again!", "s2member-front", "s2member")) . '\'); return false;') . '">' . _x ("Edit My Profile", "s2member-front", "s2member") . '</a></div>' . "\n" : '';
  192. echo '<div class="ws-plugin--s2member-pro-login-widget-profile-summary-logout"><a href="' . esc_attr (wp_logout_url ($redirect_to)) . '">' . _x ("Logout", "s2member-front", "s2member") . '</a></div>' . "\n";
  193. /**/
  194. echo '<div style="clear:both;"></div>' . "\n";
  195. /**/
  196. echo '</div>' . "\n";
  197. /**/
  198. echo '</div>' . "\n";
  199. }
  200. /**/
  201. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  202. do_action ("ws_plugin__s2member_pro_login_widget_during_display_after", get_defined_vars (), $this);
  203. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  204. /**/
  205. echo $args["after_widget"];
  206. /**/
  207. do_action ("ws_plugin__s2member_pro_login_widget_after_display", get_defined_vars (), $this);
  208. /**/
  209. return; /* Return for uniformity. */
  210. }
  211. /**
  212. * Widget form control.
  213. *
  214. * @package s2Member\Widgets
  215. * @since 1.5
  216. *
  217. * @param array $instance Optional. An array of options for this instance.
  218. * @return null
  219. */
  220. public function form ($instance = FALSE)
  221. {
  222. $options = c_ws_plugin__s2member_pro_login_widget::configure_options_and_their_defaults ((array)$instance);
  223. /**/
  224. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  225. do_action ("ws_plugin__s2member_pro_login_widget_before_form", get_defined_vars (), $this);
  226. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  227. /*
  228. Ok, here is where we need to handle the widget control form. This allows a user to further customize the widget.
  229. */
  230. echo '<label for="' . esc_attr ($this->get_field_id ("title")) . '"><strong>Public Title</strong> ( when NOT logged in )</label><br />' . "\n";
  231. echo '<input type="text" autocomplete="off" id="' . esc_attr ($this->get_field_id ("title")) . '" name="' . esc_attr ($this->get_field_name ("title")) . '" value="' . format_to_edit ($options["title"]) . '" class="widefat" /><br /><br />' . "\n";
  232. /**/
  233. echo '<label for="' . esc_attr ($this->get_field_id ("login_redirect")) . '">Redirection After Login</label><br />' . "\n";
  234. echo '<select id="' . esc_attr ($this->get_field_id ("login_redirect")) . '" name="' . esc_attr ($this->get_field_name ("login_redirect")) . '" class="widefat"><option value=""' . ((!$options["login_redirect"]) ? ' selected="selected"' : '') . '>Login Welcome Page</option><option value="%%previous%%"' . (($options["login_redirect"] === "%%previous%%") ? ' selected="selected"' : '') . '>Previous page</option><option value="%%home%%"' . (($options["login_redirect"] === "%%home%%") ? ' selected="selected"' : '') . '>Home Page</option></select><br /><br />' . "\n";
  235. /**/
  236. echo '<label for="' . esc_attr ($this->get_field_id ("signup_url")) . '">Signup Now ( enter URL, or just use <code>%%automatic%%</code> )</label><br />' . "\n";
  237. echo '<input type="text" autocomplete="off" id="' . esc_attr ($this->get_field_id ("signup_url")) . '" name="' . esc_attr ($this->get_field_name ("signup_url")) . '" value="' . format_to_edit ($options["signup_url"]) . '" class="widefat" /><br />' . "\n";
  238. echo '<small>( leave blank to exclude this link )</small><br /><br />' . "\n";
  239. /**/
  240. 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?</label><br />' . "\n";
  241. echo '<textarea id="' . esc_attr ($this->get_field_id ("logged_out_code")) . '" name="' . esc_attr ($this->get_field_name ("logged_out_code")) . '" rows="1" cols="1" class="widefat" style="height:50px;">' . format_to_edit ($options["logged_out_code"]) . '</textarea>' . "\n";
  242. /**/
  243. echo '<div style="margin:15px 0 15px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>' . "\n";
  244. /**/
  245. echo '<label for="' . esc_attr ($this->get_field_id ("profile_title")) . '"><strong>Profile Title</strong> ( when logged-in )</label><br />' . "\n";
  246. echo '<input type="text" autocomplete="off" id="' . esc_attr ($this->get_field_id ("profile_title")) . '" name="' . esc_attr ($this->get_field_name ("profile_title")) . '" value="' . format_to_edit ($options["profile_title"]) . '" class="widefat" /><br /><br />' . "\n";
  247. /**/
  248. echo '<label for="' . esc_attr ($this->get_field_id ("display_gravatar")) . '">Display Gravatar Image?</label><br />' . "\n";
  249. echo '<select id="' . esc_attr ($this->get_field_id ("display_gravatar")) . '" name="' . esc_attr ($this->get_field_name ("display_gravatar")) . '" class="widefat"><option value="1"' . (($options["display_gravatar"]) ? ' selected="selected"' : '') . '>Yes, display Gravatar</option><option value="0"' . ((!$options["display_gravatar"]) ? ' selected="selected"' : '') . '>No, do NOT display</option></select><br /><br />' . "\n";
  250. /**/
  251. echo '<label for="' . esc_attr ($this->get_field_id ("link_gravatar")) . '">Link To Gravatar.com?</label><br />' . "\n";
  252. echo '<select id="' . esc_attr ($this->get_field_id ("link_gravatar")) . '" name="' . esc_attr ($this->get_field_name ("link_gravatar")) . '" class="widefat"><option value="1"' . (($options["link_gravatar"]) ? ' selected="selected"' : '') . '>Yes, apply link</option><option value="0"' . ((!$options["link_gravatar"]) ? ' selected="selected"' : '') . '>No, do NOT apply</option></select><br /><br />' . "\n";
  253. /**/
  254. echo '<label for="' . esc_attr ($this->get_field_id ("display_name")) . '">Display User\'s Name?</label><br />' . "\n";
  255. echo '<select id="' . esc_attr ($this->get_field_id ("display_name")) . '" name="' . esc_attr ($this->get_field_name ("display_name")) . '" class="widefat"><option value="1"' . (($options["display_name"]) ? ' selected="selected"' : '') . '>Yes, display User\'s name</option><option value="0"' . ((!$options["display_name"]) ? ' selected="selected"' : '') . '>No, do NOT display</option></select><br /><br />' . "\n";
  256. /**/
  257. echo '<label for="' . esc_attr ($this->get_field_id ("my_account_url")) . '">My Account ( enter URL, or just use <code>%%automatic%%</code> )</label><br />' . "\n";
  258. echo '<input type="text" autocomplete="off" id="' . esc_attr ($this->get_field_id ("my_account_url")) . '" name="' . esc_attr ($this->get_field_name ("my_account_url")) . '" value="' . format_to_edit ($options["my_account_url"]) . '" class="widefat" /><br />' . "\n";
  259. echo '<small>( leave blank to exclude this link )</small><br /><br />' . "\n";
  260. /**/
  261. echo '<label for="' . esc_attr ($this->get_field_id ("my_profile_url")) . '">Edit Profile ( enter URL, or use <code>%%automatic%%</code> )</label><br />' . "\n";
  262. echo '<input type="text" autocomplete="off" id="' . esc_attr ($this->get_field_id ("my_profile_url")) . '" name="' . esc_attr ($this->get_field_name ("my_profile_url")) . '" value="' . format_to_edit ($options["my_profile_url"]) . '" class="widefat" /><br />' . "\n";
  263. echo '<small>( leave blank to exclude this link )</small><br /><br />' . "\n";
  264. /**/
  265. echo '<label for="' . esc_attr ($this->get_field_id ("logout_redirect")) . '">Redirection After Logout</label><br />' . "\n";
  266. echo '<select id="' . esc_attr ($this->get_field_id ("logout_redirect")) . '" name="' . esc_attr ($this->get_field_name ("logout_redirect")) . '" class="widefat"><option value="%%home%%"' . (($options["logout_redirect"] === "%%home%%") ? ' selected="selected"' : '') . '>Home Page</option><option value="%%previous%%"' . (($options["logout_redirect"] === "%%previous%%") ? ' selected="selected"' : '') . '>Previous page</option><option value=""' . ((!$options["logout_redirect"]) ? ' selected="selected"' : '') . '>Login screen</option></select><br /><br />' . "\n";
  267. /**/
  268. 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?</label><br />' . "\n";
  269. echo '<textarea id="' . esc_attr ($this->get_field_id ("logged_in_code")) . '" name="' . esc_attr ($this->get_field_name ("logged_in_code")) . '" rows="1" cols="1" class="widefat" style="height:50px;">' . format_to_edit ($options["logged_in_code"]) . '</textarea>' . "\n";
  270. /**/
  271. 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" : '';
  272. echo (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) ? '<em>Or include this widget dynamically via PHP:<br />' . c_ws_plugin__s2member_utils_strings::highlight_php ('<?php echo s2member_pro_login_widget(); ?>') . '<br /><small>See: <code>s2Member -> API Scripting -> Pro Login Widget</code></small></em>' . "\n" : '';
  273. /**/
  274. do_action ("ws_plugin__s2member_pro_login_widget_after_form", get_defined_vars (), $this);
  275. /**/
  276. echo '<br />' . "\n";
  277. /**/
  278. return; /* Return for uniformity. */
  279. }
  280. /**
  281. * Widget updates.
  282. *
  283. * @package s2Member\Widgets
  284. * @since 1.5
  285. *
  286. * @param array $instance Optional. An array of options for this instance.
  287. * @param array $old Optional. An old array of options for this instance.
  288. * @return array New array of options for this instance.
  289. */
  290. public function update ($instance = FALSE, $old = FALSE)
  291. {
  292. eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
  293. do_action ("ws_plugin__s2member_pro_login_widget_before_update", get_defined_vars (), $this);
  294. unset ($__refs, $__v); /* Unset defined __refs, __v. */
  295. /**/
  296. $instance = (array)c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($instance));
  297. /**/
  298. return c_ws_plugin__s2member_pro_login_widget::configure_options_and_their_defaults ($instance);
  299. }
  300. /**
  301. * Configure/validate all widget options; and set their defaults.
  302. *
  303. * @package s2Member\Widgets
  304. * @since 1.5
  305. *
  306. * @param array $options Optional. An array of options for a particular instance.
  307. * @return array Array of options, after having been validated and merged with defaults.
  308. */
  309. public function configure_options_and_their_defaults ($options = FALSE)
  310. {
  311. $default_options = apply_filters ("ws_plugin__s2member_pro_login_widget_default_options", array ("title" => _x ("Membership Login", "s2member-front", "s2member"), "profile_title" => _x ("My Profile Summary", "s2member-front", "s2member"), "signup_url" => "%%automatic%%", "my_account_url" => "%%automatic%%", "my_profile_url" => "%%automatic%%", "login_redirect" => "", "logout_redirect" => "%%home%%", "logged_in_code" => "", "logged_out_code" => "", "display_gravatar" => "1", "link_gravatar" => "1", "display_name" => "1"));
  312. /**/
  313. $options = array_merge ($default_options, (array)$options); /* Merge options with defaults. */
  314. /**/
  315. foreach ($options as $key => /* By reference. */ &$value)
  316. {
  317. if (!isset ($default_options[$key]))
  318. unset($options[$key]);
  319. /**/
  320. else if (($key === "title" || $key === "profile_title") && !is_string ($value))
  321. $value = $default_options[$key];
  322. /**/
  323. else if (preg_match ("/^(signup|my_account|my_profile)_url$/", $key) && !is_string ($value))
  324. $value = $default_options[$key];
  325. /**/
  326. else if (preg_match ("/^(login|logout)_redirect$/", $key) && !is_string ($value))
  327. $value = $default_options[$key];
  328. /**/
  329. else if (preg_match ("/^logged_(in|out)_code$/", $key) && !is_string ($value))
  330. $value = $default_options[$key];
  331. /**/
  332. else if (preg_match ("/^(display|link)_(name|gravatar)$/", $key) && (!is_string ($value) || !is_numeric ($value)))
  333. $value = $default_options[$key];
  334. }
  335. /**/
  336. return apply_filters ("ws_plugin__s2member_pro_login_widget_options", $options);
  337. }
  338. }
  339. }
  340. ?>

s2member-pro\includes\classes\login-widget.inc.php

Source Code Documentation