Advertisement
Guest User

Wordpress WP-Member wp-members-dialogs.php

a guest
Jan 9th, 2013
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.52 KB | None | 0 0
  1. <?php
  2. /**
  3.  * WP-Members Dialog Functions
  4.  *
  5.  * Handles functions that output front-end dialogs to
  6.  * end users.
  7.  *
  8.  * This file is part of the WP-Members plugin by Chad Butler
  9.  * You can find out more about this plugin at http://rocketgeek.com
  10.  * Copyright (c) 2006-2012  Chad Butler (email : plugins@butlerblog.com)
  11.  * WP-Members(tm) is a trademark of butlerblog.com
  12.  *
  13.  * @package WordPress
  14.  * @subpackage WP-Members
  15.  * @author Chad Butler
  16.  * @copyright 2006-2012
  17.  */
  18.  
  19.  
  20. if ( ! function_exists( 'wpmem_inc_login' ) ):
  21. /**
  22.  * Login Dialog
  23.  *
  24.  * Loads the login form for user login
  25.  *
  26.  * @since 1.8
  27.  *
  28.  * @uses apply_filters Calls wpmem_restricted_msg filters message content
  29.  * @uses wpmem_login_form()
  30.  *
  31.  * @param string $page
  32.  * @return string $str the generated html for the login form
  33.  */
  34. function wpmem_inc_login( $page="page" )
  35. {  
  36.     global $wpmem_regchk;
  37.  
  38.     $str = '';
  39.     $arr = get_option( 'wpmembers_dialogs' );
  40.  
  41.     if( $page == "page" ){
  42.          if( $wpmem_regchk!="success" ){
  43.        
  44.             // this shown above blocked content
  45.             $str = '<p>' . stripslashes($arr[0]) . '</p>';
  46.            
  47.             // filter blocked content message
  48.             $str = apply_filters( 'wpmem_restricted_msg', $str );
  49.  
  50.         }  
  51.     }
  52.  
  53.     $arr = array( __( 'Existing Users Login', 'wp-members' ), __( 'Username', 'wp-members' ), 'text', 'log', __( 'Password', 'wp-members' ), 'password', 'pwd', 'login', __( 'Login', 'wp-members' ), 'username', 'password' );
  54.    
  55.     $str = $str . wpmem_login_form( $page, $arr );
  56.     return $str;
  57. }
  58. endif;
  59.  
  60.  
  61. if ( ! function_exists( 'wpmem_inc_changepassword' ) ):
  62. /**
  63.  * Change Password Dialog
  64.  *
  65.  * Loads the form for changing password.
  66.  *
  67.  * @since 2.0
  68.  *
  69.  * @uses wpmem_login_form()
  70.  *
  71.  * @return string $str the generated html for the change password form
  72.  */
  73. function wpmem_inc_changepassword()
  74. {
  75.     $arr = array(__('Change Password', 'wp-members'), __('New Password', 'wp-members'), 'password', 'pass1', __('Repeat Password', 'wp-members'), 'password', 'pass2', 'pwdchange', __('Update Password', 'wp-members'), 'password', 'password');
  76.     $str = wpmem_login_form( 'page', $arr );
  77.     return $str;
  78. }
  79. endif;
  80.  
  81.  
  82. if ( ! function_exists( 'wpmem_inc_resetpassword' ) ):
  83. /**
  84.  * Reset Password Dialog
  85.  *
  86.  * Loads the form for resetting password.
  87.  *
  88.  * @since 2.1
  89.  *
  90.  * @uses wpmem_login_form()
  91.  *
  92.  * @return string $str the generated html fo the reset password form
  93.  */
  94. function wpmem_inc_resetpassword()
  95. {
  96.     $arr = array(__('Reset Forgotten Password', 'wp-members'), __('Username', 'wp-members'), 'text', 'user', __('Email', 'wp-members'), 'text', 'email', 'pwdreset', __('Reset Password', 'wp-members'), 'username', 'textbox');
  97.     $str = wpmem_login_form( 'page', $arr );
  98.     return $str;
  99. }
  100. endif;
  101.  
  102.  
  103. if ( ! function_exists( 'wpmem_inc_loginfailed' ) ):
  104. /**
  105.  * Login Failed Dialog
  106.  *
  107.  * Returns the login failed error message.
  108.  *
  109.  * @since 1.8
  110.  *
  111.  * @uses apply_filters Calls wpmem_login_failed which filters the failed login dialog
  112.  *
  113.  * @return string $str the generated html for the login failed message
  114.  */
  115. function wpmem_inc_loginfailed()
  116. {
  117.     $str = '<div align="center" id="wpmem_msg">
  118.         <h2>' . __('Login Failed!', 'wp-members') . '</h2>
  119.         <p>' . __('You entered an invalid username or password.', 'wp-members') . '</p>
  120.         <p><a href="' . $_SERVER['REQUEST_URI'] . '">' . __('Click here to continue.', 'wp-members') . '</a></p>
  121.     </div>';
  122.    
  123.     $str = apply_filters( 'wpmem_login_failed', $str );
  124.  
  125.     return $str;
  126. }
  127. endif;
  128.  
  129.  
  130. if( ! function_exists( 'wpmem_inc_memberlinks' ) ):
  131. /**
  132.  * Member Links Dialog
  133.  *
  134.  * Outputs the links used on the members area.
  135.  *
  136.  * @since 2.0
  137.  *
  138.  * @uses apply_filters Calls 'wpmem_member_links'
  139.  * @uses apply_filters Calls 'wpmem_register_links'
  140.  * @uses apply_filters Calls 'wpmem_login_links'
  141.  *
  142.  * @param string $page
  143.  * @return string $str
  144.  */
  145. function wpmem_inc_memberlinks( $page = 'members' )
  146. {
  147.     global $user_login;
  148.    
  149.     $link = wpmem_chk_qstr();
  150.    
  151.     switch( $page ) {
  152.    
  153.     case 'members':
  154.         $str  = '<ul><li><a href="'  .$link . 'a=edit">' . __( 'Edit My Information', 'wp-members' ) . '</a></li>
  155.                 <li><a href="' . $link . 'a=pwdchange">' . __( 'Change Password', 'wp-members' ) . '</a></li>';
  156.         if( WPMEM_USE_EXP == 1 ) { $str .= wpmem_user_page_detail(); }
  157.         $str.= '</ul>';
  158.         $str = apply_filters( 'wpmem_member_links', $str );
  159.         break;
  160.        
  161.     case 'register':   
  162.         $str = '<p>' . sprintf( __( 'You are logged in as %s', 'wp-members' ), $user_login ) . '</p>
  163.             <ul>
  164.                 <li><a href="' . $link . 'a=logout">' . __( 'Click here to logout.', 'wp-members' ) . '</a></li>
  165.                 <li><a href="' . get_option('siteurl') . '">' . __( 'Begin using the site.', 'wp-members' ) . '</a></li>
  166.             </ul>';
  167.         $str = apply_filters( 'wpmem_register_links', $str );
  168.         break; 
  169.    
  170.     case 'login':
  171.  
  172.         $str = '<p>
  173.             ' . sprintf( __( 'You are logged in as %s', 'wp-members' ), $user_login ) . '<br />
  174.             <a href="' . $link . 'a=logout">' . __( 'click here to logout', 'wp-members' ) . '</a>
  175.             </p>';
  176.         $str = apply_filters( 'wpmem_login_links', $str );
  177.         break; 
  178.            
  179.     case 'status':
  180.         $str ='<p>
  181.             ' . sprintf( __( 'You are logged in as %s', 'wp-members' ), $user_login ) . '  |
  182.             <a href="' . $link . 'a=logout">' . __( 'click here to logout', 'wp-members' ) . '</a>
  183.             </p>';
  184.         break;
  185.    
  186.     }
  187.    
  188.     return $str;
  189. }
  190. endif;
  191.  
  192.  
  193. if ( ! function_exists( 'wpmem_inc_regmessage' ) ):
  194. /**
  195.  * Message Dialog
  196.  *
  197.  * Returns various dialogs and error messages.
  198.  *
  199.  * @since 1.8
  200.  *
  201.  * @uses apply_filters Calls the wpmem_msg_dialog filter to filter the message dialog
  202.  *
  203.  * @param  string $toggle error message toggle to look for specific error messages
  204.  * @param  string $msg a message that has no toggle that is passed directly to the function
  205.  * @return string $str
  206.  */
  207. function wpmem_inc_regmessage( $toggle, $msg='' )
  208. {
  209.     $wpmem_dialogs = get_option('wpmembers_dialogs');
  210.     $arr = array( 'user', 'email', 'success', 'editsuccess', 'pwdchangerr', 'pwdchangesuccess', 'pwdreseterr', 'pwdresetsuccess' );
  211.  
  212.     $str = '<div class="wpmem_msg" align="center">
  213.         <p>&nbsp;</p>
  214.         <p><b>';
  215.  
  216.     for( $r = 0; $r < count( $arr ); $r++ ) {
  217.  
  218.         if( $toggle == $arr[$r] ) {
  219.  
  220.             $str = $str . stripslashes( $wpmem_dialogs[$r+1] ) . '</b></p>
  221.                 <p>&nbsp;</p>
  222.             </div>';
  223.            
  224.             $str = apply_filters( 'wpmem_msg_dialog', $str );
  225.  
  226.             return $str;
  227.         }
  228.     }
  229.  
  230.     $str = $str . stripslashes( $msg ) . '</b></p>
  231.         <p>&nbsp;</p>
  232.         </div>';
  233.  
  234.     $str = apply_filters( 'wpmem_msg_dialog', $str );
  235.  
  236.     return $str;
  237.  
  238. }
  239. endif;
  240.  
  241.  
  242. if ( ! function_exists( 'wpmem_inc_registration' ) ):
  243. /**
  244.  * Registration Form Include
  245.  *
  246.  * Calls the appropriate set of forms and passes back string containing the form
  247.  *
  248.  * @since 2.5.1
  249.  *
  250.  * @uses wpmem_inc_registration_NEW()
  251.  * @uses wpmem_inc_registration_OLD()
  252.  *
  253.  * @param var $toggle
  254.  * @param string $heading
  255.  * @return string
  256.  */
  257. function wpmem_inc_registration( $toggle = 'new', $heading = '' )
  258. {
  259.     if ( WPMEM_OLD_FORMS != 1 ) {
  260.         $str = wpmem_inc_registration_NEW( $toggle, $heading );
  261.     } else {
  262.         include_once( 'wp-members-deprecated.php' );
  263.         $str = wpmem_inc_registration_OLD( $toggle, $heading );
  264.     }
  265.    
  266.     return $str;
  267. }
  268. endif;
  269.  
  270.  
  271. if ( ! function_exists( 'wpmem_login_form' ) ):
  272. /**
  273.  * Login Form Include
  274.  *
  275.  * Calls the appropriate set of forms.
  276.  *
  277.  * @since 2.5.1
  278.  *
  279.  * @uses wpmem_login_form_NEW()
  280.  * @uses wpmem_login_form_OLD()
  281.  *
  282.  * @param string $page
  283.  * @param array $arr array of the login form pieces
  284.  * @var string the html of the form
  285.  * @return string the html of the form in $str
  286.  */
  287. function wpmem_login_form( $page, $arr )
  288. {
  289.     if ( WPMEM_OLD_FORMS != 1 ) {
  290.         $str = wpmem_login_form_NEW( $page, $arr );
  291.     } else {
  292.         include_once( 'wp-members-deprecated.php' );
  293.         $str = wpmem_login_form_OLD( $page, $arr );
  294.     }
  295.    
  296.     return $str;
  297. }
  298. endif;
  299.  
  300.  
  301. if( ! function_exists( 'wpmem_inc_registration_NEW' ) ):
  302. /**
  303.  * Registration Form Dialog
  304.  *
  305.  * Outputs the table-less form for new user
  306.  * registration and existing user edits.
  307.  *
  308.  * @since 2.5.1
  309.  *
  310.  * @uses apply_filters Calls 'wpmem_register_form_before'
  311.  * @uses apply_filters Calls 'wpmem_register_form'
  312.  * @uses apply_filters Calls 'wpmem_register_heading'
  313.  * @uses apply_filters Calls 'wpmem_tos_link_txt'
  314.  *
  315.  * @param  string $toggle
  316.  * @param  string $heading
  317.  * @return string $form
  318.  */
  319. function wpmem_inc_registration_NEW( $toggle = 'new', $heading = '' )
  320. {
  321.     // fix the wptexturize
  322.     remove_filter( 'the_content', 'wpautop' );
  323.     remove_filter( 'the_content', 'wptexturize' );
  324.     add_filter( 'the_content', 'wpmem_texturize', 99 );
  325.    
  326.     global $userdata, $wpmem_regchk, $username, $wpmem_fieldval_arr;
  327.  
  328.     if( !$heading ) { $heading = apply_filters( 'wpmem_register_heading', __( 'New Users Registration', 'wp-members' ) ); }
  329.  
  330.     $form = apply_filters( 'wpmem_register_form_before', '' );
  331.  
  332.     $form.= '[wpmem_txt]<div id="wpmem_reg">
  333.         <a name="register"></a>
  334.     <form name="form" method="post" action="' . get_permalink() . '" class="form">
  335.         <fieldset>
  336.             <legend>' . $heading . '</legend>';
  337.  
  338.     if( $toggle == 'edit' ) {
  339.  
  340.         $form = $form . '<div class="container_username_div"><div class="container_username"><label for="username" class="text username">' . __( 'Username', 'wp-members' ) . '</label></div>
  341.             <div class="div_text_username"><div class="div_text"><p class="noinput">' .
  342.                 $userdata->user_login .
  343.             '</p></div></div></div>';
  344.  
  345.     } else {
  346.  
  347.         $form = $form . '<div class="container_username_div"><div class="container_username"><label for="username" class="text username">' . __( 'Choose a Username', 'wp-members' ) . '<font class="req">*</font></label></div>
  348.             <div class="div_text_username"><div class="div_text">
  349.                 <input name="log" type="text" value="' . stripslashes( $username ) . '" class="username" id="username" />
  350.             </div></div></div>';
  351.  
  352.     }
  353.  
  354.     $wpmem_fields = get_option( 'wpmembers_fields' );
  355.     for( $row = 0; $row < count($wpmem_fields); $row++ )
  356.     {
  357.         $do_row = true;
  358.         if( $toggle == 'edit' && $wpmem_fields[$row][2] == 'password' ) { $do_row = false; }
  359.         if( $wpmem_fields[$row][2] == 'tos' && $toggle == 'edit' && ( get_user_meta($userdata->ID, 'tos', true ) ) ) {
  360.             // makes tos field hidden on user edit page, unless they haven't got a value for tos
  361.             $do_row = false;
  362.             $form = $form . wpmem_create_formfield( $wpmem_fields[$row][2], 'hidden', get_user_meta($userdata->ID, 'tos', true ) );
  363.         }
  364.  
  365.         if( $wpmem_fields[$row][4] == 'y' && $do_row == true ) {
  366.  
  367.             if( $wpmem_fields[$row][2] != 'tos' ) {
  368.  
  369.                 if( $wpmem_fields[$row][3] == 'password' ) {
  370.                     $class = 'text';
  371.                 } else {
  372.                     $class = $wpmem_fields[$row][3];
  373.                 }
  374.                
  375.                 $form = $form . '<div class="container_' . $wpmem_fields[$row][2] . '_div"><div class="container_' . $wpmem_fields[$row][2] . '"><label for="' . $wpmem_fields[$row][2] . '" class="' . $class . ' ' . $wpmem_fields[$row][2] . '">' . $wpmem_fields[$row][1];
  376.                 if( $wpmem_fields[$row][5] == 'y' ) { $form = $form . '<font class="req">*</font>'; }
  377.                 $form = $form . '</label></div>';
  378.  
  379.             }
  380.  
  381.             $form = $form . '<div class="div_' . $class . '_' . $wpmem_fields[$row][2] . '"><div class="div_' . $class . '">';
  382.  
  383.             if( ( $toggle == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) {
  384.  
  385.                 if( WPMEM_DEBUG == true ) { $form = $form . $wpmem_fields[$row][2] . "&nbsp;"; }
  386.  
  387.                 switch( $wpmem_fields[$row][2] ) {
  388.                     case( 'description' ):
  389.                         $val = get_user_meta( $userdata->ID, 'description', 'true' );
  390.                         break;
  391.  
  392.                     case( 'user_email' ):
  393.                         $val = $userdata->user_email;
  394.                         break;
  395.  
  396.                     case( 'user_url' ):
  397.                         $val = $userdata->user_url;
  398.                         break;
  399.  
  400.                     default:
  401.                         $val = get_user_meta( $userdata->ID, $wpmem_fields[$row][2], 'true' );
  402.                         break;
  403.                 }
  404.  
  405.             } else {
  406.  
  407.                 $val = $wpmem_fieldval_arr[$row];
  408.  
  409.             }
  410.  
  411.             if( $wpmem_fields[$row][2] == 'tos' ) {
  412.  
  413.                 if( ( $toggle == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) {
  414.                     $chk_tos;  // HUH?
  415.                 } else {
  416.                     $val = $wpmem_fieldval_arr[$row];
  417.                 }
  418.  
  419.                 // should be checked by default? and only if form hasn't been submitted
  420.                 if( ! $_POST && $wpmem_fields[$row][8] == 'y' ) { $val = $wpmem_fields[$row][7]; }
  421.  
  422.                 $form = $form . wpmem_create_formfield( $wpmem_fields[$row][2], $wpmem_fields[$row][3], $wpmem_fields[$row][7], $val );
  423.  
  424.                 if( $wpmem_fields[$row][5] == 'y' ) { $form = $form . '<font class="req">*</font>'; }
  425.  
  426.                 // determine if TOS is a WP page or not...
  427.                 $tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
  428.                 if( strstr( $tos_content, '[wp-members page="tos"' ) ) {
  429.                    
  430.                     $tos_content = " " . $tos_content;
  431.                     $ini = strpos( $tos_content, 'url="' );
  432.                     $ini += strlen( 'url="' );
  433.                     $len = strpos( $tos_content, '"]', $ini ) - $ini;
  434.                     $link = substr( $tos_content, $ini, $len );
  435.                     $tos_pop = '<a href="' . $link . '" target="_blank">';
  436.  
  437.                 } else {
  438.                     $tos_pop = "<a href=\"#\" onClick=\"window.open('" . WP_PLUGIN_URL . "/wp-members/wp-members-tos.php','mywindow');\">";
  439.                 }
  440.                 $form.= apply_filters( 'wpmem_tos_link_txt', sprintf( __( 'Please indicate that you agree to the %s TOS %s', 'wp-members' ), $tos_pop, '</a>' ) );
  441.  
  442.             } else {
  443.  
  444.                 // for checkboxes
  445.                 if( $wpmem_fields[$row][3] == 'checkbox' ) {
  446.                     $valtochk = $val;
  447.                     $val = $wpmem_fields[$row][7];
  448.                     // if it should it be checked by default (& only if form not submitted), then override above...
  449.                     if( $wpmem_fields[$row][8] == 'y' && ( ! $_POST && $toggle != 'edit' ) ) { $val = $valtochk = $wpmem_fields[$row][7]; }
  450.                 }
  451.  
  452.                 // for dropdown select
  453.                 if( $wpmem_fields[$row][3] == 'select' ) {
  454.                     $valtochk = $val;
  455.                     $val = $wpmem_fields[$row][7];
  456.                 }
  457.                
  458.                 if( ! isset( $valtochk ) ) { $valtochk = ''; }
  459.  
  460.                 $form = $form . wpmem_create_formfield($wpmem_fields[$row][2],$wpmem_fields[$row][3],$val,$valtochk);
  461.             }
  462.  
  463.             $form = $form . '</div></div></div>';
  464.         }
  465.     }
  466.  
  467.     if( WPMEM_CAPTCHA == 1 && $toggle != 'edit' ) { // don't show on edit page!
  468.  
  469.         $wpmem_captcha = get_option('wpmembers_captcha');
  470.         if( $wpmem_captcha[0] && $wpmem_captcha[1] ) {
  471.  
  472.             $form = $form . '<div class="clear"></div>
  473.                 <div align="right" class="captcha">';
  474.             $form = $form . wpmem_inc_recaptcha( $wpmem_captcha[0], $wpmem_captcha[2] );
  475.             $form = $form . '</div></div>';
  476.         }
  477.     }
  478.  
  479.     if( $toggle == 'edit' ) {
  480.         $form = $form . '<input name="a" type="hidden" value="update" />';
  481.     } else {
  482.         $form = $form . '<input name="a" type="hidden" value="register" />';
  483.     }
  484.  
  485.     $form = $form . '<input name="redirect_to" type="hidden" value="' . get_permalink() . '" />
  486.         <div class="button_div">
  487.             <input name="reset" type="reset" value="' . __( 'Clear Form', 'wp-members' ) . '" class="buttons" />
  488.             <input name="submit" type="submit" value="' . __( 'Submit', 'wp-members' ) . '" class="buttons" />
  489.         </div>';
  490.            
  491.     // @todo find a better place to put this
  492.     $form = $form . '<div class="container_text_req"><label class="text"><font class="req">*</font>' . __( 'Required field', 'wp-members' ) . '</label></div></fieldset></form>';
  493.     $form = $form . wpmem_inc_attribution();
  494.     $form = $form . '</div>[/wpmem_txt]';
  495.    
  496.     $form = apply_filters( 'wpmem_register_form', $form );
  497.  
  498.     return $form;
  499. }
  500. endif;
  501.  
  502.  
  503. if ( ! function_exists( 'wpmem_login_form_NEW' ) ):
  504. /**
  505.  * Login Form Dialog
  506.  *
  507.  * Builds the table-less form used for
  508.  * login, change password, and reset password.
  509.  *
  510.  * @since 2.5.1
  511.  *
  512.  * @uses apply_filters Calls 'wpmem_login_form_before'
  513.  * @uses apply_filters Calls 'wpmem_forgot_link'
  514.  * @uses apply_filters Calls 'wpmem_reg_link'
  515.  * @uses apply_filters Calls 'wpmem_login_form'
  516.  *
  517.  * @param string $page
  518.  * @param array $arr
  519.  * @return string $form
  520.  */
  521. function wpmem_login_form_NEW( $page, $arr )
  522. {
  523.     // are we redirecting somewhere?
  524.     if( isset( $_REQUEST['redirect_to'] ) ) {
  525.         $redirect_to = $_REQUEST['redirect_to'];
  526.     } else {
  527.         $redirect_to = get_permalink();
  528.     }
  529.  
  530.     // fix the wptexturize
  531.     remove_filter( 'the_content', 'wpautop' );
  532.     remove_filter( 'the_content', 'wptexturize' );
  533.     add_filter('the_content', 'wpmem_texturize', 99);
  534.    
  535.     $form = apply_filters( 'wpmem_login_form_before', '' );
  536.    
  537.     $form.= '[wpmem_txt]<div id="wpmem_login">
  538.         <a name="login"></a>
  539.         <form action="' . get_permalink() . '" method="POST" class="form">
  540.         <fieldset>
  541.             <legend>' . $arr[0] . '</legend>
  542.             <div class="container_username_div">
  543.             <div class="container_username">   
  544.             <label class="username" for="username">' . $arr[1] . '</label>
  545.             </div>
  546.             <div class="div_text_username"><div class="div_text">
  547.                 ' . wpmem_create_formfield( $arr[3], $arr[2], '', '', $arr[9] ) . '
  548.             </div></div></div>
  549.             <div class="container_password_div">
  550.             <div class="container_password">
  551.             <label class="password" for="password">' . $arr[4] . '</label>
  552.             </div>
  553.             <div class="div_text_password"><div class="div_text">
  554.                 ' . wpmem_create_formfield( $arr[6], $arr[5], '', '', $arr[10] ) . '
  555.             </div></div></div>
  556.                
  557.             <input type="hidden" name="redirect_to" value="' . $redirect_to . '" />';
  558.     if ( $arr[7] != 'login' ) { $form = $form . wpmem_create_formfield( 'formsubmit', 'hidden', '1' ); }
  559.    
  560.     $form = $form . wpmem_create_formfield( 'a', 'hidden', $arr[7] );
  561.                
  562.     $form = $form . '<div class="button_div">';
  563.    
  564.     if ( $arr[7] == 'login' ) {
  565.         $form = $form . '<input name="rememberme" type="checkbox" id="rememberme" value="forever" />&nbsp;' . __('Remember me', 'wp-members') . '&nbsp;&nbsp;<input type="submit" name="Submit" value="' . $arr[8] . '" class="buttons" />';
  566.     } else {
  567.         $form = $form . '<input type="submit" name="Submit" value="' . $arr[8] . '" class="buttons" />';
  568.     }
  569.    
  570.     $form = $form . '</div>
  571.  
  572.             <div class="clear"></div>
  573.             <div align="right">';
  574.                
  575.     if ( ( WPMEM_MSURL != null || $page == 'members' ) && $arr[7] == 'login' ) {
  576.        
  577.         $link = apply_filters( 'wpmem_forgot_link', wpmem_chk_qstr( WPMEM_MSURL ) . 'a=pwdreset' );
  578.         $form = $form . __('Forgot password?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to reset', 'wp-members') . '</a>';
  579.  
  580.     }
  581.    
  582.     $form = $form . '</div>
  583.             <div align="right">';
  584.            
  585.     if ( ( WPMEM_REGURL != null ) && $arr[7] == 'login' ) {
  586.  
  587.         $link = apply_filters( 'wpmem_reg_link', WPMEM_REGURL );
  588.         $form = $form . __('New User?', 'wp-members') . '&nbsp;<a href="' . $link . '">' . __('Click here to register', 'wp-members') . '</a>';
  589.  
  590.     }          
  591.    
  592.     $form = $form. '</div> 
  593.             <div class="clear"></div>
  594.         </fieldset></form>
  595.     </div>[/wpmem_txt]';
  596.    
  597.     $form = apply_filters( 'wpmem_login_form', $form );
  598.    
  599.     return $form;
  600. }
  601. endif;
  602.  
  603. if ( ! function_exists( 'wpmem_inc_recaptcha' ) ):
  604. /**
  605.  * Create reCAPTCHA form
  606.  *
  607.  * @since  2.6.0
  608.  *
  609.  * @uses apply_filters Calls wpmem_recaptcha
  610.  *
  611.  * @param  string $key
  612.  * @param  string $theme
  613.  * @return string $str
  614.  */
  615. function wpmem_inc_recaptcha( $key, $theme )
  616. {
  617.     $str = '<script type="text/javascript">
  618.             var RecaptchaOptions = { theme : \''. $theme . '\' };
  619.         </script>
  620.         <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=' . $key . '"></script>
  621.         <noscript>
  622.             <iframe src="http://www.google.com/recaptcha/api/noscript?k=' . $key . '" height="300" width="500" frameborder="0"></iframe><br/>
  623.             <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
  624.             <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
  625.         </noscript>';
  626.        
  627.     $str = apply_filters( 'wpmem_recaptcha', $str );
  628.    
  629.     return $str;
  630. }
  631. endif;
  632.  
  633.  
  634. /**
  635.  * Create an attribution link in the form
  636.  *
  637.  * @since 2.6.0
  638.  * @return $str string
  639.  */
  640. function wpmem_inc_attribution()
  641. {
  642.     /*
  643.         Taking this out?  That's ok.  But please consider making a donation
  644.         to support the further development of this plugin.  Many hours of
  645.         work have gone into its development and ongoing support.
  646.        
  647.         If you are a developer using this for a client site, you see
  648.         value in not having to do this from scratch.
  649.         Please consider a larger amount.
  650.        
  651.         If you are a donor, I thank you for your support!  
  652.     */
  653.    
  654.     $show_attribution = true;
  655.     if( defined( 'WPMEM_REMOVE_ATTR' ) ) { $show_attribution = false; }
  656.  
  657.     if( WPMEM_OLD_FORMS != 1 && $show_attribution == true ) { // NEW FORMS
  658.    
  659.         $str = '
  660.         <!-- Attribution keeps this plugin free!! -->
  661.         <div align="center">
  662.             <small>Powered by <a href="http://rocketgeek.com" target="_blank">WP-Members</a></small>
  663.         </div>';
  664.        
  665.         return $str;
  666.  
  667.     } elseif( $show_attribution == true ) {  // LEGACY FORMS
  668.  
  669.         $str = '
  670.             <tr>
  671.               <td>&nbsp;</td>
  672.               <td align="center"><!-- Attribution keeps this plugin free!! -->
  673.                 <small>Powered by <a href="http://rocketgeek.com" target="_blank">WP-Members</a></small>
  674.               </td>
  675.             </tr>';
  676.            
  677.         return $str;
  678.            
  679.     }
  680.    
  681.     return;
  682.    
  683. }
  684.  
  685.  
  686. if ( ! function_exists( 'wpmem_page_pwd_reset' ) ):
  687. /**
  688.  * Password reset forms
  689.  *
  690.  * This function creates both password reset and forgotten
  691.  * password forms for page=password shortcode.
  692.  *
  693.  * @since 2.7.6
  694.  *
  695.  * @param $wpmem_regchk
  696.  * @param $content
  697.  * @return $content
  698.  */
  699. function wpmem_page_pwd_reset( $wpmem_regchk, $content )
  700. {
  701.     if( is_user_logged_in() ) {
  702.    
  703.         switch( $wpmem_regchk ) {
  704.                
  705.         case "pwdchangempty":
  706.             $content = wpmem_inc_regmessage( $wpmem_regchk, __( 'Password fields cannot be empty', 'wp-members' ) );
  707.             $content = $content . wpmem_inc_changepassword();
  708.             break;
  709.  
  710.         case "pwdchangerr":
  711.             $content = wpmem_inc_regmessage( $wpmem_regchk );
  712.             $content = $content . wpmem_inc_changepassword();
  713.             break;
  714.  
  715.         case "pwdchangesuccess":
  716.             $content = $content . wpmem_inc_regmessage( $wpmem_regchk );
  717.             break;
  718.  
  719.         default:
  720.             $content = $content . wpmem_inc_changepassword();
  721.             break;             
  722.         }
  723.    
  724.     } else {
  725.    
  726.         switch( $wpmem_regchk ) {
  727.  
  728.         case "pwdreseterr":
  729.             $content = $content
  730.                 . wpmem_inc_regmessage( $wpmem_regchk )
  731.                 . wpmem_inc_resetpassword();
  732.             $wpmem_regchk = ''; // clear regchk
  733.             break;
  734.  
  735.         case "pwdresetsuccess":
  736.             $content = $content . wpmem_inc_regmessage( $wpmem_regchk );
  737.             $wpmem_regchk = ''; // clear regchk
  738.             break;
  739.  
  740.         default:
  741.             $content = $content . wpmem_inc_resetpassword();
  742.             break;
  743.         }
  744.        
  745.     }
  746.    
  747.     return $content;
  748.  
  749. }
  750. endif;
  751.  
  752.  
  753. if ( ! function_exists( 'wpmem_page_user_edit' ) ):
  754. /**
  755.  * Creates a user edit page
  756.  *
  757.  * @since 2.7.6
  758.  *
  759.  * @param $wpmem_regchk
  760.  * @param $content
  761.  * @return $content
  762.  */
  763. function wpmem_page_user_edit( $wpmem_regchk, $content )
  764. {
  765.     global $wpmem_a, $wpmem_themsg;
  766.    
  767.     $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) );
  768.    
  769.     if( $wpmem_a == "update") { $content.= wpmem_inc_regmessage( $wpmem_regchk, $wpmem_themsg ); }
  770.     $content = $content . wpmem_inc_registration( 'edit', $heading );
  771.    
  772.     return $content;
  773. }
  774. endif;
  775. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement