3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySettingsPage { /** * Holds the values to be used in the fields callbacks */ private $options; /** * Start up */ public function __construct() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); } /** * Add options page */ public function add_plugin_page() { // This page will be under "Settings" add_options_page( 'Settings Admin', 'My Settings', 'manage_options', 'my-setting-admin', array( $this, 'create_admin_page' ) ); } /** * Options page callback */ public function create_admin_page() { // Set class property $this->options = get_option( 'my_option_name' ); ?> <div class="wrap"> <?php screen_icon(); ?> <h2>My Settings</h2> <form method="post" action="options.php"> <?php // This prints out all hidden setting fields settings_fields( 'my_option_group' ); do_settings_sections( 'my-setting-admin' ); submit_button(); ?> </form> </div> <?php } /** * Register and add settings */ public function page_init() { register_setting( 'my_option_group', // Option group 'my_option_name', // Option name array( $this, 'sanitize' ) // Sanitize ); add_settings_section( 'setting_section_id', // ID 'My Custom Settings', // Title array( $this, 'print_section_info' ), // Callback 'my-setting-admin' // Page ); add_settings_field( 'id_number', // ID 'ID Number', // Title array( $this, 'id_number_callback' ), // Callback 'my-setting-admin', // Page 'setting_section_id' // Section ); add_settings_field( 'title', 'Title', array( $this, 'title_callback' ), 'my-setting-admin', 'setting_section_id' ); } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys */ public function sanitize( $input ) { $new_input = array(); if( isset( $input['id_number'] ) ) $new_input['id_number'] = absint( $input['id_number'] ); if( isset( $input['title'] ) ) $new_input['title'] = sanitize_text_field( $input['title'] ); return $new_input; } /** * Print the Section text */ public function print_section_info() { print 'Enter your settings below:'; } /** * Get the settings option array and print one of its values */ public function id_number_callback() { printf( '<input type="text" id="id_number" name="my_option_name[id_number]" value="%s" />', isset( $this->options['id_number'] ) ? esc_attr( $this->options['id_number']) : '' ); } /** * Get the settings option array and print one of its values */ public function title_callback() { printf( '<input type="text" id="title" name="my_option_name[title]" value="%s" />', isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : '' ); } } if( is_admin() ) $my_settings_page = new MySettingsPage();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/HoUT1
function name:  (null)
number of ops:  7
compiled vars:  !0 = $my_settings_page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  139     0  E >   INIT_FCALL_BY_NAME                                       'is_admin'
          1        DO_FCALL                                      0  $1      
          2      > JMPZ                                                     $1, ->6
  140     3    >   NEW                                              $2      'MySettingsPage'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
          6    > > RETURN                                                   1

Class MySettingsPage:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  __construct
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL_BY_NAME                                       'add_action'
          1        SEND_VAL_EX                                              'admin_menu'
          2        FETCH_THIS                                       ~0      
          3        INIT_ARRAY                                       ~1      ~0
          4        ADD_ARRAY_ELEMENT                                ~1      'add_plugin_page'
          5        SEND_VAL_EX                                              ~1
          6        DO_FCALL                                      0          
   15     7        INIT_FCALL_BY_NAME                                       'add_action'
          8        SEND_VAL_EX                                              'admin_init'
          9        FETCH_THIS                                       ~3      
         10        INIT_ARRAY                                       ~4      ~3
         11        ADD_ARRAY_ELEMENT                                ~4      'page_init'
         12        SEND_VAL_EX                                              ~4
         13        DO_FCALL                                      0          
   16    14      > RETURN                                                   null

End of function __construct

Function add_plugin_page:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  add_plugin_page
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL_BY_NAME                                       'add_options_page'
   25     1        SEND_VAL_EX                                              'Settings+Admin'
   26     2        SEND_VAL_EX                                              'My+Settings'
   27     3        SEND_VAL_EX                                              'manage_options'
   28     4        SEND_VAL_EX                                              'my-setting-admin'
   29     5        FETCH_THIS                                       ~0      
          6        INIT_ARRAY                                       ~1      ~0
          7        ADD_ARRAY_ELEMENT                                ~1      'create_admin_page'
          8        SEND_VAL_EX                                              ~1
          9        DO_FCALL                                      0          
   31    10      > RETURN                                                   null

End of function add_plugin_page

Function create_admin_page:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  create_admin_page
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL_BY_NAME                                       'get_option'
          1        SEND_VAL_EX                                              'my_option_name'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN_OBJ                                               'options'
          4        OP_DATA                                                  $1
   41     5        ECHO                                                     '++++++++%3Cdiv+class%3D%22wrap%22%3E%0A++++++++++++'
   42     6        INIT_FCALL_BY_NAME                                       'screen_icon'
          7        DO_FCALL                                      0          
   43     8        ECHO                                                     '++++++++++++%3Ch2%3EMy+Settings%3C%2Fh2%3E+++++++++++%0A++++++++++++%3Cform+method%3D%22post%22+action%3D%22options.php%22%3E%0A++++++++++++'
   47     9        INIT_FCALL_BY_NAME                                       'settings_fields'
         10        SEND_VAL_EX                                              'my_option_group'
         11        DO_FCALL                                      0          
   48    12        INIT_FCALL_BY_NAME                                       'do_settings_sections'
         13        SEND_VAL_EX                                              'my-setting-admin'
         14        DO_FCALL                                      0          
   49    15        INIT_FCALL_BY_NAME                                       'submit_button'
         16        DO_FCALL                                      0          
   51    17        ECHO                                                     '++++++++++++%3C%2Fform%3E%0A++++++++%3C%2Fdiv%3E%0A++++++++'
   54    18      > RETURN                                                   null

End of function create_admin_page

Function page_init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  page_init
number of ops:  38
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   INIT_FCALL_BY_NAME                                       'register_setting'
   62     1        SEND_VAL_EX                                              'my_option_group'
   63     2        SEND_VAL_EX                                              'my_option_name'
   64     3        FETCH_THIS                                       ~0      
          4        INIT_ARRAY                                       ~1      ~0
          5        ADD_ARRAY_ELEMENT                                ~1      'sanitize'
          6        SEND_VAL_EX                                              ~1
          7        DO_FCALL                                      0          
   67     8        INIT_FCALL_BY_NAME                                       'add_settings_section'
   68     9        SEND_VAL_EX                                              'setting_section_id'
   69    10        SEND_VAL_EX                                              'My+Custom+Settings'
   70    11        FETCH_THIS                                       ~3      
         12        INIT_ARRAY                                       ~4      ~3
         13        ADD_ARRAY_ELEMENT                                ~4      'print_section_info'
         14        SEND_VAL_EX                                              ~4
   71    15        SEND_VAL_EX                                              'my-setting-admin'
         16        DO_FCALL                                      0          
   74    17        INIT_FCALL_BY_NAME                                       'add_settings_field'
   75    18        SEND_VAL_EX                                              'id_number'
   76    19        SEND_VAL_EX                                              'ID+Number'
   77    20        FETCH_THIS                                       ~6      
         21        INIT_ARRAY                                       ~7      ~6
         22        ADD_ARRAY_ELEMENT                                ~7      'id_number_callback'
         23        SEND_VAL_EX                                              ~7
   78    24        SEND_VAL_EX                                              'my-setting-admin'
   79    25        SEND_VAL_EX                                              'setting_section_id'
         26        DO_FCALL                                      0          
   82    27        INIT_FCALL_BY_NAME                                       'add_settings_field'
   83    28        SEND_VAL_EX                                              'title'
   84    29        SEND_VAL_EX                                              'Title'
   85    30        FETCH_THIS                                       ~9      
         31        INIT_ARRAY                                       ~10     ~9
         32        ADD_ARRAY_ELEMENT                                ~10     'title_callback'
         33        SEND_VAL_EX                                              ~10
   86    34        SEND_VAL_EX                                              'my-setting-admin'
   87    35        SEND_VAL_EX                                              'setting_section_id'
         36        DO_FCALL                                      0          
   89    37      > RETURN                                                   null

End of function page_init

Function sanitize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 11
filename:       /in/HoUT1
function name:  sanitize
number of ops:  22
compiled vars:  !0 = $input, !1 = $new_input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   RECV                                             !0      
   98     1        ASSIGN                                                   !1, <array>
   99     2        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'id_number'
          3      > JMPZ                                                     ~3, ->11
  100     4    >   INIT_FCALL_BY_NAME                                       'absint'
          5        CHECK_FUNC_ARG                                           
          6        FETCH_DIM_FUNC_ARG                               $5      !0, 'id_number'
          7        SEND_FUNC_ARG                                            $5
          8        DO_FCALL                                      0  $6      
          9        ASSIGN_DIM                                               !1, 'id_number'
         10        OP_DATA                                                  $6
  102    11    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'title'
         12      > JMPZ                                                     ~7, ->20
  103    13    >   INIT_FCALL_BY_NAME                                       'sanitize_text_field'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $9      !0, 'title'
         16        SEND_FUNC_ARG                                            $9
         17        DO_FCALL                                      0  $10     
         18        ASSIGN_DIM                                               !1, 'title'
         19        OP_DATA                                                  $10
  105    20    > > RETURN                                                   !1
  106    21*     > RETURN                                                   null

End of function sanitize

Function print_section_info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  print_section_info
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  113     0  E >   ECHO                                                     'Enter+your+settings+below%3A'
  114     1      > RETURN                                                   null

End of function print_section_info

Function id_number_callback:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  id_number_callback
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  121     0  E >   INIT_FCALL                                               'printf'
  122     1        SEND_VAL                                                 '%3Cinput+type%3D%22text%22+id%3D%22id_number%22+name%3D%22my_option_name%5Bid_number%5D%22+value%3D%22%25s%22+%2F%3E'
  123     2        FETCH_OBJ_IS                                     ~0      'options'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~0, 'id_number'
          4      > JMPZ                                                     ~1, ->13
          5    >   INIT_FCALL_BY_NAME                                       'esc_attr'
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $2      'options'
          8        FETCH_DIM_FUNC_ARG                               $3      $2, 'id_number'
          9        SEND_FUNC_ARG                                            $3
         10        DO_FCALL                                      0  $4      
         11        QM_ASSIGN                                        ~5      $4
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~5      ''
         14    >   SEND_VAL                                                 ~5
         15        DO_ICALL                                                 
  125    16      > RETURN                                                   null

End of function id_number_callback

Function title_callback:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HoUT1
function name:  title_callback
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  132     0  E >   INIT_FCALL                                               'printf'
  133     1        SEND_VAL                                                 '%3Cinput+type%3D%22text%22+id%3D%22title%22+name%3D%22my_option_name%5Btitle%5D%22+value%3D%22%25s%22+%2F%3E'
  134     2        FETCH_OBJ_IS                                     ~0      'options'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~0, 'title'
          4      > JMPZ                                                     ~1, ->13
          5    >   INIT_FCALL_BY_NAME                                       'esc_attr'
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $2      'options'
          8        FETCH_DIM_FUNC_ARG                               $3      $2, 'title'
          9        SEND_FUNC_ARG                                            $3
         10        DO_FCALL                                      0  $4      
         11        QM_ASSIGN                                        ~5      $4
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~5      ''
         14    >   SEND_VAL                                                 ~5
         15        DO_ICALL                                                 
  136    16      > RETURN                                                   null

End of function title_callback

End of class MySettingsPage.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.5 ms | 1412 KiB | 15 Q