3v4l.org

run code in 300+ 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 = 10
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 63
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 62
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 62
Branch analysis from position: 23
10 jumps found. (Code = 188) Position 1 = 41, Position 2 = 43, Position 3 = 45, Position 4 = 47, Position 5 = 55, Position 6 = 57, Position 7 = 59, Position 8 = 59, Position 9 = 61, Position 10 = 24
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 59
Branch analysis from position: 61
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 43
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 45
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 47
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 55
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 57
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 59
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 59
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 59
Branch analysis from position: 59
Branch analysis from position: 57
Branch analysis from position: 55
Branch analysis from position: 47
Branch analysis from position: 45
Branch analysis from position: 43
Branch analysis from position: 41
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 63
filename:       /in/bf6Ji
function name:  form_render_login
number of ops:  113
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, ->10
    9     3    >   INIT_FCALL                                               'sprintf'
          4        SEND_VAL                                                 '%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%25s%27%3E%D0%92%D1%8B%D0%B9%D1%82%D0%B8%3C%2Fa%3E.'
          5        INIT_FCALL_BY_NAME                                       'wp_logout_url'
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9      > RETURN                                                   $7
   13    10    >   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    11        FETCH_IS                                         ~9      '_REQUEST'
         12        ISSET_ISEMPTY_DIM_OBJ                         0          ~9, 'errno'
         13      > JMPZ                                                     ~10, ->63
   17    14    >   INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '%2C'
         16        FETCH_R                      global              ~11     '_REQUEST'
         17        FETCH_DIM_R                                      ~12     ~11, 'errno'
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !1, $13
   19    21      > FE_RESET_R                                       $15     !1, ->62
         22    > > FE_FETCH_R                                               $15, !2, ->62
   20    23    > > SWITCH_STRING                                            !2, [ 'empty_username':->41, 'empty_password':->43, 'invalid_username':->45, 'incorrect_password':->47, 'confirm':->55, 'changed':->57, 'expiredkey':->59, 'invalidkey':->59, ], ->61
   21    24    >   IS_EQUAL                                                 !2, 'empty_username'
         25      > JMPNZ                                                    ~16, ->41
   24    26    >   IS_EQUAL                                                 !2, 'empty_password'
         27      > JMPNZ                                                    ~16, ->43
   27    28    >   IS_EQUAL                                                 !2, 'invalid_username'
         29      > JMPNZ                                                    ~16, ->45
   30    30    >   IS_EQUAL                                                 !2, 'incorrect_password'
         31      > JMPNZ                                                    ~16, ->47
   33    32    >   IS_EQUAL                                                 !2, 'confirm'
         33      > JMPNZ                                                    ~16, ->55
   36    34    >   IS_EQUAL                                                 !2, 'changed'
         35      > JMPNZ                                                    ~16, ->57
   39    36    >   IS_EQUAL                                                 !2, 'expiredkey'
         37      > JMPNZ                                                    ~16, ->59
   40    38    >   IS_EQUAL                                                 !2, 'invalidkey'
         39      > JMPNZ                                                    ~16, ->59
         40    > > JMP                                                      ->61
   22    41    >   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    42      > JMP                                                      ->61
   25    43    >   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    44      > JMP                                                      ->61
   28    45    >   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    46      > JMP                                                      ->61
   31    47    >   INIT_FCALL                                               'sprintf'
         48        SEND_VAL                                                 '%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%25s%27%3E%D0%97%D0%B0%D0%B1%D1%8B%D0%BB%D0%B8%3C%2Fa%3E%3F%3C%2Fp%3E'
         49        INIT_FCALL_BY_NAME                                       'wp_lostpassword_url'
         50        DO_FCALL                                      0  $20     
         51        SEND_VAR                                                 $20
         52        DO_ICALL                                         $21     
         53        ASSIGN_OP                                     8          !0, $21
   32    54      > JMP                                                      ->61
   34    55    >   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    56      > JMP                                                      ->61
   37    57    >   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    58      > JMP                                                      ->61
   41    59    >   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    60      > JMP                                                      ->61
   19    61    > > JMP                                                      ->22
         62    >   FE_FREE                                                  $15
   50    63    >   INIT_ARRAY                                       ~26     <false>, 'echo'
   51    64        INIT_FCALL_BY_NAME                                       'site_url'
         65        CHECK_FUNC_ARG                                           
         66        FETCH_FUNC_ARG               global              $27     '_SERVER'
         67        FETCH_DIM_FUNC_ARG                               $28     $27, 'REQUEST_URI'
         68        SEND_FUNC_ARG                                            $28
         69        DO_FCALL                                      0  $29     
         70        ADD_ARRAY_ELEMENT                                ~26     $29, 'redirect'
   52    71        ADD_ARRAY_ELEMENT                                ~26     'loginform', 'form_id'
   53    72        INIT_FCALL_BY_NAME                                       '__'
         73        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'
         74        DO_FCALL                                      0  $30     
         75        ADD_ARRAY_ELEMENT                                ~26     $30, 'label_username'
   54    76        INIT_FCALL_BY_NAME                                       '__'
         77        SEND_VAL_EX                                              '%D0%9F%D0%B0%D1%80%D0%BE%D0%BB%D1%8C'
         78        DO_FCALL                                      0  $31     
         79        ADD_ARRAY_ELEMENT                                ~26     $31, 'label_password'
   55    80        INIT_FCALL_BY_NAME                                       '__'
         81        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'
         82        DO_FCALL                                      0  $32     
         83        ADD_ARRAY_ELEMENT                                ~26     $32, 'label_remember'
   56    84        INIT_FCALL_BY_NAME                                       '__'
         85        SEND_VAL_EX                                              '%D0%92%D0%BE%D0%B9%D1%82%D0%B8'
         86        DO_FCALL                                      0  $33     
         87        ADD_ARRAY_ELEMENT                                ~26     $33, 'label_log_in'
   57    88        ADD_ARRAY_ELEMENT                                ~26     'user_login', 'id_username'
   58    89        ADD_ARRAY_ELEMENT                                ~26     'user_pass', 'id_password'
   59    90        ADD_ARRAY_ELEMENT                                ~26     'rememberme', 'id_remember'
   60    91        ADD_ARRAY_ELEMENT                                ~26     'wp-submit', 'id_submit'
   50    92        ADD_ARRAY_ELEMENT                                ~26     <true>, 'remember'
         93        ADD_ARRAY_ELEMENT                                ~26     null, 'value_username'
         94        ADD_ARRAY_ELEMENT                                ~26     <true>, 'value_remember'
   49    95        ASSIGN                                                   !3, ~26
   67    96        INIT_FCALL                                               'str_replace'
         97        SEND_VAL                                                 'wp-login.php'
         98        SEND_VAL                                                 'wp-login.php%3Fpass%3D1'
         99        INIT_FCALL_BY_NAME                                       'wp_login_form'
        100        SEND_VAR_EX                                              !3
        101        DO_FCALL                                      0  $35     
        102        SEND_VAR                                                 $35
        103        DO_ICALL                                         $36     
        104        ASSIGN                                                   !4, $36
   69   105        ASSIGN_OP                                     8          !0, !4
   71   106        INIT_FCALL_BY_NAME                                       'wp_lostpassword_url'
        107        DO_FCALL                                      0  $39     
        108        CONCAT                                           ~40     '%3Ca+class%3D%22forgot-password-page%22+href%3D%22', $39
        109        CONCAT                                           ~41     ~40, '%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'
        110        ASSIGN_OP                                     8          !0, ~41
   74   111      > RETURN                                                   !0
   76   112*     > 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 = 32
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/bf6Ji
function name:  pageform_redirect_at_authenticate
number of ops:  34
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, ->32
   86     7    >   INIT_FCALL_BY_NAME                                       'is_wp_error'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10      > JMPZ                                                     $8, ->32
   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      > EXIT                                                     
   97    32    > > RETURN                                                   !0
   98    33*     > 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 = 79) Position 1 = -2
filename:       /in/bf6Ji
function name:  pageform_logout_redirect
number of ops:  8
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      > EXIT                                                     
  108     7*     > RETURN                                                   null

End of function pageform_logout_redirect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
246.94 ms | 1416 KiB | 22 Q