3v4l.org

run code in 500+ PHP versions simultaneously
<?php add_shortcode( 'form_custom_login', 'form_render_login' ); function form_render_login() { // проверяем, если пользователь уже авторизован, то выводим соответствующее сообщение и ссылку "Выйти" if ( is_user_logged_in() ) { return sprintf( "Вы уже авторизованы на сайте. <a href='%s'>Выйти</a>.", wp_logout_url() ); } // присваиваем содержимое формы переменной и затем возвращаем её, выводить через echo() мы не можем, так как это шорткод $return = '<div class="login-form-container-page"><h2>Войти на сайт</h2>'; // если возникли какие-либо ошибки, отображаем их if ( isset( $_REQUEST['errno'] ) ) { $error_codes = explode( ',', $_REQUEST['errno'] ); foreach ( $error_codes as $error_code ) { switch ( $error_code ) { case 'empty_username': $return .= '<p class="errno">Вы не забыли указать свой email/имя пользователя?</p>'; break; case 'empty_password': $return .= '<p class="errno">Пожалуйста, введите пароль.</p>'; break; case 'invalid_username': $return .= '<p class="errno">На сайте не найдено указанного пользователя.</p>'; break; case 'incorrect_password': $return .= sprintf( "<p class='errno'>Неверный пароль. <a href='%s'>Забыли</a>?</p>", wp_lostpassword_url() ); break; case 'confirm': $return .= '<p class="errno success">Инструкции по сбросу пароля отправлены на ваш email.</p>'; break; case 'changed': $return .= '<p class="errno success">Пароль успешно изменён.</p>'; break; case 'expiredkey': case 'invalidkey': $return .= '<p class="errno">Недействительный ключ.</p>'; break; } } } // используем wp_login_form() для вывода формы (но можете сделать это и на чистом HTML) $args = array( 'echo' => false, 'redirect' => site_url($_SERVER['REQUEST_URI']), //перенаправление на ту же страницу 'form_id' => 'loginform', 'label_username' => __('Имя пользователя'), 'label_password' => __('Пароль'), 'label_remember' => __('Запомнить меня'), 'label_log_in' => __('Войти'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => true ); $form = str_replace('wp-login.php', 'wp-login.php?pass=1', wp_login_form($args)); $return .= $form; $return .= '<a class="forgot-password-page" href="' . wp_lostpassword_url() . '">Забыли пароль</a></div>'; // и наконец возвращаем всё, что получилось return $return; } /* * Редиректы обратно на кастомную форму входа в случае ошибки */ add_filter( 'authenticate', 'pageform_redirect_at_authenticate', 101, 3 ); function pageform_redirect_at_authenticate( $user, $username, $password ) { if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { if ( is_wp_error( $user ) ) { $error_codes = join( ',', $user->get_error_codes() ); $login_url = home_url( '/page-login/' ); $login_url = add_query_arg( 'errno', $error_codes, $login_url ); wp_redirect( $login_url ); exit; } } return $user; } /* * Редиректы после выхода с сайта */ add_action( 'wp_logout', 'pageform_logout_redirect', 5 ); function pageform_logout_redirect(){ wp_safe_redirect( site_url( '/page-login/?logged_out=true' ) ); exit; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bf6Ji
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                           'add_shortcode'
          1        SEND_VAL_EX                                                  'form_custom_login'
          2        SEND_VAL_EX                                                  'form_render_login'
          3        DO_FCALL                                          0          
   81     4        INIT_FCALL_BY_NAME                                           'add_filter'
          5        SEND_VAL_EX                                                  'authenticate'
          6        SEND_VAL_EX                                                  'pageform_redirect_at_authenticate'
          7        SEND_VAL_EX                                                  101
          8        SEND_VAL_EX                                                  3
          9        DO_FCALL                                          0          
  103    10        INIT_FCALL_BY_NAME                                           'add_action'
         11        SEND_VAL_EX                                                  'wp_logout'
         12        SEND_VAL_EX                                                  'pageform_logout_redirect'
         13        SEND_VAL_EX                                                  5
         14        DO_FCALL                                          0          
  108    15      > RETURN                                                       1

Function form_render_login:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 61
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 60
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 60
Branch analysis from position: 22
10 jumps found. (Code = 188) Position 1 = 40, Position 2 = 42, Position 3 = 44, Position 4 = 46, Position 5 = 53, Position 6 = 55, Position 7 = 57, Position 8 = 57, Position 9 = 59, Position 10 = 23
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 57
Branch analysis from position: 59
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 40
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 42
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 44
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 46
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 53
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 55
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 57
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 57
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 57
Branch analysis from position: 57
Branch analysis from position: 55
Branch analysis from position: 53
Branch analysis from position: 46
Branch analysis from position: 44
Branch analysis from position: 42
Branch analysis from position: 40
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 61
filename:       /in/bf6Ji
function name:  form_render_login
number of ops:  108
compiled vars:  !0 = $return, !1 = $error_codes, !2 = $error_code, !3 = $args, !4 = $form
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL_BY_NAME                                           'is_user_logged_in'
          1        DO_FCALL                                          0  $5      
          2      > JMPZ                                                         $5, ->9
    9     3    >   INIT_FCALL_BY_NAME                                           'wp_logout_url'
          4        DO_FCALL                                          0  $6      
          5        ROPE_INIT                                         3  ~8      '%D0%92%D1%8B+%D1%83%D0%B6%D0%B5+%D0%B0%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D1%8B+%D0%BD%D0%B0+%D1%81%D0%B0%D0%B9%D1%82%D0%B5.+%3Ca+href%3D%27'
          6        ROPE_ADD                                          1  ~8      ~8, $6
          7        ROPE_END                                          2  ~7      ~8, '%27%3E%D0%92%D1%8B%D0%B9%D1%82%D0%B8%3C%2Fa%3E.'
          8      > RETURN                                                       ~7
   13     9    >   ASSIGN                                                       !0, '%3Cdiv+class%3D%22login-form-container-page%22%3E%3Ch2%3E%D0%92%D0%BE%D0%B9%D1%82%D0%B8+%D0%BD%D0%B0+%D1%81%D0%B0%D0%B9%D1%82%3C%2Fh2%3E'
   16    10        FETCH_IS                                             ~11     '_REQUEST'
         11        ISSET_ISEMPTY_DIM_OBJ                             0          ~11, 'errno'
         12      > JMPZ                                                         ~12, ->61
   17    13    >   INIT_FCALL                                                   'explode'
         14        SEND_VAL                                                     '%2C'
         15        FETCH_R                          global              ~13     '_REQUEST'
         16        FETCH_DIM_R                                          ~14     ~13, 'errno'
         17        SEND_VAL                                                     ~14
         18        DO_ICALL                                             $15     
         19        ASSIGN                                                       !1, $15
   19    20      > FE_RESET_R                                           $17     !1, ->60
         21    > > FE_FETCH_R                                                   $17, !2, ->60
   20    22    > > SWITCH_STRING                                                !2, [ 'empty_username':->40, 'empty_password':->42, 'invalid_username':->44, 'incorrect_password':->46, 'confirm':->53, 'changed':->55, 'expiredkey':->57, 'invalidkey':->57, ], ->59
   21    23    >   IS_EQUAL                                                     !2, 'empty_username'
         24      > JMPNZ                                                        ~18, ->40
   24    25    >   IS_EQUAL                                                     !2, 'empty_password'
         26      > JMPNZ                                                        ~18, ->42
   27    27    >   IS_EQUAL                                                     !2, 'invalid_username'
         28      > JMPNZ                                                        ~18, ->44
   30    29    >   IS_EQUAL                                                     !2, 'incorrect_password'
         30      > JMPNZ                                                        ~18, ->46
   33    31    >   IS_EQUAL                                                     !2, 'confirm'
         32      > JMPNZ                                                        ~18, ->53
   36    33    >   IS_EQUAL                                                     !2, 'changed'
         34      > JMPNZ                                                        ~18, ->55
   39    35    >   IS_EQUAL                                                     !2, 'expiredkey'
         36      > JMPNZ                                                        ~18, ->57
   40    37    >   IS_EQUAL                                                     !2, 'invalidkey'
         38      > JMPNZ                                                        ~18, ->57
         39    > > JMP                                                          ->59
   22    40    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno%22%3E%D0%92%D1%8B+%D0%BD%D0%B5+%D0%B7%D0%B0%D0%B1%D1%8B%D0%BB%D0%B8+%D1%83%D0%BA%D0%B0%D0%B7%D0%B0%D1%82%D1%8C+%D1%81%D0%B2%D0%BE%D0%B9+email%2F%D0%B8%D0%BC%D1%8F+%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F%3F%3C%2Fp%3E'
   23    41      > JMP                                                          ->59
   25    42    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno%22%3E%D0%9F%D0%BE%D0%B6%D0%B0%D0%BB%D1%83%D0%B9%D1%81%D1%82%D0%B0%2C+%D0%B2%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C.%3C%2Fp%3E'
   26    43      > JMP                                                          ->59
   28    44    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno%22%3E%D0%9D%D0%B0+%D1%81%D0%B0%D0%B9%D1%82%D0%B5+%D0%BD%D0%B5+%D0%BD%D0%B0%D0%B9%D0%B4%D0%B5%D0%BD%D0%BE+%D1%83%D0%BA%D0%B0%D0%B7%D0%B0%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE+%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F.%3C%2Fp%3E'
   29    45      > JMP                                                          ->59
   31    46    >   INIT_FCALL_BY_NAME                                           'wp_lostpassword_url'
         47        DO_FCALL                                          0  $22     
         48        ROPE_INIT                                         3  ~24     '%3Cp+class%3D%27errno%27%3E%D0%9D%D0%B5%D0%B2%D0%B5%D1%80%D0%BD%D1%8B%D0%B9+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C.+%3Ca+href%3D%27'
         49        ROPE_ADD                                          1  ~24     ~24, $22
         50        ROPE_END                                          2  ~23     ~24, '%27%3E%D0%97%D0%B0%D0%B1%D1%8B%D0%BB%D0%B8%3C%2Fa%3E%3F%3C%2Fp%3E'
         51        ASSIGN_OP                                         8          !0, ~23
   32    52      > JMP                                                          ->59
   34    53    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno+success%22%3E%D0%98%D0%BD%D1%81%D1%82%D1%80%D1%83%D0%BA%D1%86%D0%B8%D0%B8+%D0%BF%D0%BE+%D1%81%D0%B1%D1%80%D0%BE%D1%81%D1%83+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8F+%D0%BE%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D1%8B+%D0%BD%D0%B0+%D0%B2%D0%B0%D1%88+email.%3C%2Fp%3E'
   35    54      > JMP                                                          ->59
   37    55    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno+success%22%3E%D0%9F%D0%B0%D1%80%D0%BE%D0%BB%D1%8C+%D1%83%D1%81%D0%BF%D0%B5%D1%88%D0%BD%D0%BE+%D0%B8%D0%B7%D0%BC%D0%B5%D0%BD%D1%91%D0%BD.%3C%2Fp%3E'
   38    56      > JMP                                                          ->59
   41    57    >   ASSIGN_OP                                         8          !0, '%3Cp+class%3D%22errno%22%3E%D0%9D%D0%B5%D0%B4%D0%B5%D0%B9%D1%81%D1%82%D0%B2%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D0%BA%D0%BB%D1%8E%D1%87.%3C%2Fp%3E'
   42    58      > JMP                                                          ->59
   19    59    > > JMP                                                          ->21
         60    >   FE_FREE                                                      $17
   50    61    >   INIT_ARRAY                                           ~30     <false>, 'echo'
   51    62        INIT_FCALL_BY_NAME                                           'site_url'
         63        CHECK_FUNC_ARG                                               
         64        FETCH_FUNC_ARG                   global              $31     '_SERVER'
         65        FETCH_DIM_FUNC_ARG                                   $32     $31, 'REQUEST_URI'
         66        SEND_FUNC_ARG                                                $32
         67        DO_FCALL                                          0  $33     
         68        ADD_ARRAY_ELEMENT                                    ~30     $33, 'redirect'
   52    69        ADD_ARRAY_ELEMENT                                    ~30     'loginform', 'form_id'
   53    70        INIT_FCALL_BY_NAME                                           '__'
         71        SEND_VAL_EX                                                  '%D0%98%D0%BC%D1%8F+%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F'
         72        DO_FCALL                                          0  $34     
         73        ADD_ARRAY_ELEMENT                                    ~30     $34, 'label_username'
   54    74        INIT_FCALL_BY_NAME                                           '__'
         75        SEND_VAL_EX                                                  '%D0%9F%D0%B0%D1%80%D0%BE%D0%BB%D1%8C'
         76        DO_FCALL                                          0  $35     
         77        ADD_ARRAY_ELEMENT                                    ~30     $35, 'label_password'
   55    78        INIT_FCALL_BY_NAME                                           '__'
         79        SEND_VAL_EX                                                  '%D0%97%D0%B0%D0%BF%D0%BE%D0%BC%D0%BD%D0%B8%D1%82%D1%8C+%D0%BC%D0%B5%D0%BD%D1%8F'
         80        DO_FCALL                                          0  $36     
         81        ADD_ARRAY_ELEMENT                                    ~30     $36, 'label_remember'
   56    82        INIT_FCALL_BY_NAME                                           '__'
         83        SEND_VAL_EX                                                  '%D0%92%D0%BE%D0%B9%D1%82%D0%B8'
         84        DO_FCALL                                          0  $37     
         85        ADD_ARRAY_ELEMENT                                    ~30     $37, 'label_log_in'
   57    86        ADD_ARRAY_ELEMENT                                    ~30     'user_login', 'id_username'
   58    87        ADD_ARRAY_ELEMENT                                    ~30     'user_pass', 'id_password'
   59    88        ADD_ARRAY_ELEMENT                                    ~30     'rememberme', 'id_remember'
   60    89        ADD_ARRAY_ELEMENT                                    ~30     'wp-submit', 'id_submit'
   50    90        ADD_ARRAY_ELEMENT                                    ~30     <true>, 'remember'
         91        ADD_ARRAY_ELEMENT                                    ~30     null, 'value_username'
         92        ADD_ARRAY_ELEMENT                                    ~30     <true>, 'value_remember'
   49    93        ASSIGN                                                       !3, ~30
   67    94        INIT_FCALL_BY_NAME                                           'wp_login_form'
         95        SEND_VAR_EX                                                  !3
         96        DO_FCALL                                          0  $39     
         97        FRAMELESS_ICALL_3                str_replace         ~40     'wp-login.php', 'wp-login.php%3Fpass%3D1'
         98        OP_DATA                                                      $39
         99        ASSIGN                                                       !4, ~40
   69   100        ASSIGN_OP                                         8          !0, !4
   71   101        INIT_FCALL_BY_NAME                                           'wp_lostpassword_url'
        102        DO_FCALL                                          0  $43     
        103        CONCAT                                               ~44     '%3Ca+class%3D%22forgot-password-page%22+href%3D%22', $43
        104        CONCAT                                               ~45     ~44, '%22%3E%D0%97%D0%B0%D0%B1%D1%8B%D0%BB%D0%B8+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C%3C%2Fa%3E%3C%2Fdiv%3E'
        105        ASSIGN_OP                                         8          !0, ~45
   74   106      > RETURN                                                       !0
   76   107*     > RETURN                                                       null

End of function form_render_login

Function pageform_redirect_at_authenticate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 33
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 33
Branch analysis from position: 11
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/bf6Ji
function name:  pageform_redirect_at_authenticate
number of ops:  35
compiled vars:  !0 = $user, !1 = $username, !2 = $password, !3 = $error_codes, !4 = $login_url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   83     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   85     3        FETCH_R                          global              ~5      '_SERVER'
          4        FETCH_DIM_R                                          ~6      ~5, 'REQUEST_METHOD'
          5        IS_IDENTICAL                                                 ~6, 'POST'
          6      > JMPZ                                                         ~7, ->33
   86     7    >   INIT_FCALL_BY_NAME                                           'is_wp_error'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0  $8      
         10      > JMPZ                                                         $8, ->33
   87    11    >   INIT_FCALL                                                   'join'
         12        SEND_VAL                                                     '%2C'
         13        INIT_METHOD_CALL                                             !0, 'get_error_codes'
         14        DO_FCALL                                          0  $9      
         15        SEND_VAR                                                     $9
         16        DO_ICALL                                             $10     
         17        ASSIGN                                                       !3, $10
   89    18        INIT_FCALL_BY_NAME                                           'home_url'
         19        SEND_VAL_EX                                                  '%2Fpage-login%2F'
         20        DO_FCALL                                          0  $12     
         21        ASSIGN                                                       !4, $12
   90    22        INIT_FCALL_BY_NAME                                           'add_query_arg'
         23        SEND_VAL_EX                                                  'errno'
         24        SEND_VAR_EX                                                  !3
         25        SEND_VAR_EX                                                  !4
         26        DO_FCALL                                          0  $14     
         27        ASSIGN                                                       !4, $14
   92    28        INIT_FCALL_BY_NAME                                           'wp_redirect'
         29        SEND_VAR_EX                                                  !4
         30        DO_FCALL                                          0          
   93    31      > INIT_FCALL                                                   'exit'
         32*       DO_ICALL                                                     
   97    33    > > RETURN                                                       !0
   98    34*     > RETURN                                                       null

End of function pageform_redirect_at_authenticate

Function pageform_logout_redirect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 61) Position 1 = -2
filename:       /in/bf6Ji
function name:  pageform_logout_redirect
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  106     0  E >   INIT_FCALL_BY_NAME                                           'wp_safe_redirect'
          1        INIT_FCALL_BY_NAME                                           'site_url'
          2        SEND_VAL_EX                                                  '%2Fpage-login%2F%3Flogged_out%3Dtrue'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR_NO_REF_EX                                           $0
          5        DO_FCALL                                          0          
  107     6      > INIT_FCALL                                                   'exit'
          7*       DO_ICALL                                                     
  108     8*     > RETURN                                                       null

End of function pageform_logout_redirect

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.3 ms | 2182 KiB | 16 Q