PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/web/wp-includes/pluggable-deprecated.php

https://bitbucket.org/abreuleonel64/comoprogramarphp
PHP | 170 lines | 57 code | 11 blank | 102 comment | 12 complexity | 7bf93f85e769fa546e6e3a89f194ddc0 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Deprecated pluggable functions from past WordPress versions. You shouldn't use these
  4. * functions and look for the alternatives instead. The functions will be removed in a
  5. * later version.
  6. *
  7. * Deprecated warnings are also thrown if one of these functions is being defined by a plugin.
  8. *
  9. * @package WordPress
  10. * @subpackage Deprecated
  11. * @see pluggable.php
  12. */
  13. /*
  14. * Deprecated functions come here to die.
  15. */
  16. if ( !function_exists('set_current_user') ) :
  17. /**
  18. * Changes the current user by ID or name.
  19. *
  20. * Set $id to null and specify a name if you do not know a user's ID.
  21. *
  22. * @since 2.0.1
  23. * @see wp_set_current_user() An alias of wp_set_current_user()
  24. * @deprecated 3.0.0
  25. * @deprecated Use wp_set_current_user()
  26. *
  27. * @param int|null $id User ID.
  28. * @param string $name Optional. The user's username
  29. * @return object returns wp_set_current_user()
  30. */
  31. function set_current_user($id, $name = '') {
  32. _deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' );
  33. return wp_set_current_user($id, $name);
  34. }
  35. endif;
  36. if ( !function_exists('get_userdatabylogin') ) :
  37. /**
  38. * Retrieve user info by login name.
  39. *
  40. * @since 0.71
  41. * @deprecated 3.3.0
  42. * @deprecated Use get_user_by('login')
  43. *
  44. * @param string $user_login User's username
  45. * @return bool|object False on failure, User DB row object
  46. */
  47. function get_userdatabylogin($user_login) {
  48. _deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" );
  49. return get_user_by('login', $user_login);
  50. }
  51. endif;
  52. if ( !function_exists('get_user_by_email') ) :
  53. /**
  54. * Retrieve user info by email.
  55. *
  56. * @since 2.5
  57. * @deprecated 3.3.0
  58. * @deprecated Use get_user_by('email')
  59. *
  60. * @param string $email User's email address
  61. * @return bool|object False on failure, User DB row object
  62. */
  63. function get_user_by_email($email) {
  64. _deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" );
  65. return get_user_by('email', $email);
  66. }
  67. endif;
  68. if ( !function_exists('wp_setcookie') ) :
  69. /**
  70. * Sets a cookie for a user who just logged in. This function is deprecated.
  71. *
  72. * @since 1.5
  73. * @deprecated 2.5
  74. * @deprecated Use wp_set_auth_cookie()
  75. * @see wp_set_auth_cookie()
  76. *
  77. * @param string $username The user's username
  78. * @param string $password Optional. The user's password
  79. * @param bool $already_md5 Optional. Whether the password has already been through MD5
  80. * @param string $home Optional. Will be used instead of COOKIEPATH if set
  81. * @param string $siteurl Optional. Will be used instead of SITECOOKIEPATH if set
  82. * @param bool $remember Optional. Remember that the user is logged in
  83. */
  84. function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
  85. _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
  86. $user = get_user_by('login', $username);
  87. wp_set_auth_cookie($user->ID, $remember);
  88. }
  89. else :
  90. _deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' );
  91. endif;
  92. if ( !function_exists('wp_clearcookie') ) :
  93. /**
  94. * Clears the authentication cookie, logging the user out. This function is deprecated.
  95. *
  96. * @since 1.5
  97. * @deprecated 2.5
  98. * @deprecated Use wp_clear_auth_cookie()
  99. * @see wp_clear_auth_cookie()
  100. */
  101. function wp_clearcookie() {
  102. _deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' );
  103. wp_clear_auth_cookie();
  104. }
  105. else :
  106. _deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' );
  107. endif;
  108. if ( !function_exists('wp_get_cookie_login') ):
  109. /**
  110. * Gets the user cookie login. This function is deprecated.
  111. *
  112. * This function is deprecated and should no longer be extended as it won't be
  113. * used anywhere in WordPress. Also, plugins shouldn't use it either.
  114. *
  115. * @since 2.0.3
  116. * @deprecated 2.5
  117. * @deprecated No alternative
  118. *
  119. * @return bool Always returns false
  120. */
  121. function wp_get_cookie_login() {
  122. _deprecated_function( __FUNCTION__, '2.5' );
  123. return false;
  124. }
  125. else :
  126. _deprecated_function( 'wp_get_cookie_login', '2.5' );
  127. endif;
  128. if ( !function_exists('wp_login') ) :
  129. /**
  130. * Checks a users login information and logs them in if it checks out. This function is deprecated.
  131. *
  132. * Use the global $error to get the reason why the login failed. If the username
  133. * is blank, no error will be set, so assume blank username on that case.
  134. *
  135. * Plugins extending this function should also provide the global $error and set
  136. * what the error is, so that those checking the global for why there was a
  137. * failure can utilize it later.
  138. *
  139. * @since 1.2.2
  140. * @deprecated Use wp_signon()
  141. * @global string $error Error when false is returned
  142. *
  143. * @param string $username User's username
  144. * @param string $password User's password
  145. * @param bool $deprecated Not used
  146. * @return bool False on login failure, true on successful check
  147. */
  148. function wp_login($username, $password, $deprecated = '') {
  149. _deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' );
  150. global $error;
  151. $user = wp_authenticate($username, $password);
  152. if ( ! is_wp_error($user) )
  153. return true;
  154. $error = $user->get_error_message();
  155. return false;
  156. }
  157. else :
  158. _deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
  159. endif;