Plugin Directory

Changeset 3371018


Ignore:
Timestamp:
10/01/2025 09:50:41 AM (2 months ago)
Author:
nintechnet
Message:

Adding v1.8

Location:
code-profiler/trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • code-profiler/trunk/index.php

    r3316061 r3371018  
    66Author: Jerome Bruandet ~ NinTechNet Ltd.
    77Author URI: https://nintechnet.com/
    8 Version: 1.7.7
     8Version: 1.8
    99Network: true
    1010License: GPLv3 or later
     
    1313*/
    1414
    15 define('CODE_PROFILER_VERSION', '1.7.7');
     15define('CODE_PROFILER_VERSION', '1.8');
    1616/**
    1717 +=====================================================================+
     
    3030}
    3131
    32 // ===================================================================== 2023-08-20
     32// =====================================================================
    3333// Menu functions
    3434require __DIR__ .'/lib/menu.php';
     
    3737// AJAX calls
    3838require __DIR__ .'/lib/ajax.php';
    39 // ===================================================================== 2023-06-17
     39// Scheduled tasks
     40require_once __DIR__ .'/lib/class-wp-cron.php';
     41// =====================================================================
    4042// Activation: make sure the blog meets the requirements.
    4143
     
    7981        code_profiler_default_options();
    8082    }
     83
     84    /**
     85     * Install scheduled tasks on the main site only.
     86     */
     87    if ( is_main_site() ) {
     88        CodeProfiler_WPCron::install();
     89    }
    8190}
    8291
     
    96105        unlink( WPMU_PLUGIN_DIR .'/'. CODE_PROFILER_MUPLUGIN );
    97106    }
     107
     108    /**
     109     * Uninstall scheduled tasks.
     110     */
     111    CodeProfiler_WPCron::uninstall();
    98112}
    99113
  • code-profiler/trunk/lib/ajax.php

    r3314519 r3371018  
    2828
    2929    $cp_options = get_option('code-profiler');
     30    if (! empty( $cp_options['mem'] ) ) {
     31        $mem = $cp_options['mem'];
     32    } else {
     33        $mem = [];
     34    }
    3035
    3136    code_profiler_log_debug(
     
    7883
    7984    // Frontend or backend
    80     if ( empty( $_POST['where'] ) ||
    81         ! in_array( $_POST['where'], ['frontend', 'backend', 'custom'] ) ) {
     85    if ( empty( $_POST['x_end'] ) ||
     86        ! in_array( $_POST['x_end'], ['frontend', 'backend', 'custom'] ) ) {
    8287
    8388        $msg = sprintf(
    84             esc_html__('Missing or incorrect parameter (%s)', 'code-profiler'), 'where'
     89            esc_html__('Missing or incorrect parameter (%s)', 'code-profiler'), 'x_end'
    8590        );
    8691        $response['message'] = $msg;
     
    8893        code_profiler_wp_send_json( $response );
    8994    }
    90     $cp_options['mem_where'] = $_POST['where'];
     95    $mem['x_end'] = $_POST['x_end'];
    9196
    9297    code_profiler_log_debug(
     
    100105        code_profiler_wp_send_json( $response );
    101106    }
    102     $cp_options['mem_post'] = $_POST['post'];
     107    $mem['post'] = $_POST['post'];
    103108
    104109    // Make sure we have no more that 4 decimals, because when returning
     
    111116
    112117    // Authentication
    113     if ( empty( $_POST['user'] ) || $_POST['user'] != 'authenticated' ) {
    114         $_POST['user'] = 'unauthenticated';
    115     }
    116     $cp_options['mem_user'] = $_POST['user'];
     118    if ( empty( $_POST['x_auth'] ) || $_POST['x_auth'] != 'authenticated' ) {
     119        $_POST['x_auth'] = 'unauthenticated';
     120    }
     121    $mem['x_auth'] = $_POST['x_auth'];
    117122
    118123    code_profiler_log_debug(
     
    143148
    144149    // User-agent
    145     if ( empty( $_POST['ua'] ) ) {
    146         $ua = 'Firefox';
     150    if ( empty( $_POST['user_agent'] ) ) {
     151        $user_agent = 'Firefox';
    147152    } else {
    148         $ua = sanitize_text_field( $_POST['ua'] );
     153        $user_agent = sanitize_text_field( $_POST['user_agent'] );
    149154    }
    150155    foreach( CODE_PROFILER_UA as $types => $types_array ) {
    151156        foreach( $types_array as $name => $value ) {
    152             if ( $ua == $name ) {
     157            if ( $user_agent == $name ) {
    153158                $ua_signature = $value;
    154159                break;
     
    159164        $ua_signature = CODE_PROFILER_UA['Desktop']['Firefox'];
    160165    }
    161     $cp_options['ua'] = $ua;
     166    $mem['user_agent'] = $user_agent;
    162167
    163168    // Theme
     
    165170    if ( empty( $_POST['theme'] ) || empty( $themes[ $_POST['theme'] ] ) ) {
    166171        $theme = '';
    167         unset( $cp_options['mem_theme'] );
     172        unset( $mem['theme'] );
    168173    } else {
    169174        code_profiler_log_debug(
     
    171176        );
    172177        $theme = $_POST['theme'];
    173         $cp_options['mem_theme'] = $theme;
     178        $mem['theme'] = $theme;
    174179        // Append the template to the stylesheet
    175180        if (! empty( $themes[ $theme ]['t'] ) ) {
     
    246251    }
    247252    if (! empty( $is_custom_headers ) ) {
    248         $cp_options['custom_headers']   = json_encode( $is_custom_headers );
     253        $mem['custom_headers']  = json_encode( $is_custom_headers );
    249254    } else {
    250         unset( $cp_options['custom_headers'] );
     255        unset( $mem['custom_headers'] );
    251256    }
    252257
     
    266271    }
    267272
    268     if ( $_POST['user'] == 'authenticated') {
     273    if ( $_POST['x_auth'] == 'authenticated') {
    269274
    270275        code_profiler_log_debug(
     
    297302                code_profiler_wp_send_json( $response );
    298303            }
    299             $cp_options['mem_username'] = strtolower( $username );
     304            $mem['username'] = strtolower( $username );
    300305            $headers['cookies'][ $cookie_auth ] = wp_generate_auth_cookie(
    301306                $user_object->ID,
     
    363368    if (! empty( $_POST['method'] ) && $_POST['method'] == 'post') {
    364369        $safe_method = 'wp_safe_remote_post';
    365         $cp_options['mem_method'] = 'post';
     370        $mem['method'] = 'post';
    366371
    367372        // Content-type
     
    374379            ! in_array( $_POST['content_type'], [ 1, 2, 3 ] ) ) {
    375380
    376             $cp_options['mem_content_type'] = 1;
     381            $mem['content_type'] = 1;
    377382        } else {
    378             $cp_options['mem_content_type'] = (int) $_POST['content_type'];
    379         }
    380         $headers['headers']['content-type'] = $content_type[ $cp_options['mem_content_type'] ];
     383            $mem['content_type'] = (int) $_POST['content_type'];
     384        }
     385        $headers['headers']['content-type'] = $content_type[ $mem['content_type'] ];
    381386
    382387        // Optional POST payload
     
    390395             * application/x-www-form-urlencoded (formatted)
    391396             */
    392             if ( $cp_options['mem_content_type'] == 1 ) {
     397            if ( $mem['content_type'] == 1 ) {
    393398                $payload_array = explode( PHP_EOL, $_payload );
    394399                foreach( $payload_array as $item ) {
     
    403408             * application/x-www-form-urlencoded (raw)
    404409             */
    405             } elseif ( $cp_options['mem_content_type'] == 3 ) {
     410            } elseif ( $mem['content_type'] == 3 ) {
    406411                parse_str( $_payload , $payload_array );
    407412                foreach( $payload_array as $key => $item ) {
     
    414419                $headers['body'] = $_payload;
    415420            }
    416             $cp_options['payload'] = json_encode( $_payload );
     421            $mem['payload'] = json_encode( $_payload );
    417422
    418423        } else {
    419424            // POST request without a payload
    420             unset( $cp_options['payload'] );
     425            unset( $mem['payload'] );
    421426        }
    422427
    423428    } else {
    424429        $safe_method = 'wp_safe_remote_get';
    425         $cp_options['mem_method'] = 'get';
     430        $mem['method'] = 'get';
    426431    }
    427432
     
    442447            }
    443448        }
    444         $cp_options['cookies'] = json_encode( $_POST['cookies'] );
     449        $mem['cookies'] = json_encode( $_POST['cookies'] );
    445450    } else {
    446         unset( $cp_options['cookies'] );
     451        unset( $mem['cookies'] );
    447452    }
    448453
     
    466471
    467472    if ( $exclusions) {
    468         $cp_options['exclusions'] = json_encode( $exclusions );
     473        $mem['exclusions'] = json_encode( $exclusions );
    469474    } else {
    470         unset( $cp_options['exclusions'] );
    471     }
    472 
     475        unset( $mem['exclusions'] );
     476    }
     477
     478    $cp_options['mem'] = $mem;
    473479    update_option('code-profiler', $cp_options );
     480
     481    /**
     482     * Save the profile configuration into a temporary file (used by the re-run feature).
     483     */
     484    file_put_contents(
     485        CODE_PROFILER_UPLOAD_DIR ."/$microtime.". CODE_PROFILER_TMP_RERUN_LOG,
     486        json_encode( $mem )
     487    );
    474488
    475489    code_profiler_log_debug(
     
    548562
    549563            $contents .= __('Post payload:', 'code-profiler') ."\n\n";
    550             if ( $cp_options['mem_content_type'] == 2 ) {
     564            if ( $mem['content_type'] == 2 ) {
    551565                /**
    552566                 * application/json: must be decoded.
     
    812826    }
    813827
     828    /**
     829     * Rename the profile in the summary file,
     830     * so that it can be used by the re-run feature.
     831     */
     832    if (! empty( $match[1] ) &&
     833        is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile" ) ) {
     834
     835        $data = json_decode(
     836            file_get_contents( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile" ),
     837            true
     838        );
     839        if (! empty( $data['rerun']['profile'] ) ) {
     840            $data['rerun']['profile'] = $new_name;
     841            file_put_contents(
     842                CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile", json_encode( $data )
     843            );
     844        }
     845    }
     846
    814847    $response['status']  = 'success';
    815848    $response['newname']    = $new_name;
  • code-profiler/trunk/lib/class-cli.php

    r3316061 r3371018  
    3838        }
    3939
    40         $_POST['where'] = 'frontend';
     40        $_POST['x_end'] = 'frontend';
    4141        // Detect if we're authenticated or not
    4242        if ( is_user_logged_in() === true ) {
    43             $_POST['user']      = 'authenticated';
     43            $_POST['x_auth']        = 'authenticated';
    4444        } else {
    45             $_POST['user']      = 'unauthenticated';
    46         }
    47         $_POST['profile']  = 'WP-CLI_' . time();
    48         $_POST['ua']       = 'Firefox';
     45            $_POST['x_auth']        = 'unauthenticated';
     46        }
     47        $_POST['profile']       = 'WP-CLI_' . time();
     48        $_POST['user_agent']    = 'Firefox';
    4949
    5050        if (! empty( $assoc_args['dest'] ) ) {
     
    172172
    173173            // Display name, time and %
    174             if ( $cp_options['display_name'] == 'slug' ) {
     174            if ( isset( $cp_options['display_name'] ) && $cp_options['display_name'] == 'slug' ) {
    175175                $name = $v[0];
    176176            } else {
  • code-profiler/trunk/lib/class-profiler.php

    r3288391 r3371018  
    3030    private $tmp_calls;
    3131    private $tmp_connections;
     32    private $tmp_rerun;
    3233
    3334    /**
     
    4849        $this->tmp_connections  = CODE_PROFILER_UPLOAD_DIR ."/$microtime." .
    4950                                            CODE_PROFILER_TMP_CONNECTIONS_LOG;
     51        $this->tmp_rerun            = CODE_PROFILER_UPLOAD_DIR ."/$microtime." .
     52                                            CODE_PROFILER_TMP_RERUN_LOG;
    5053
    5154        if ( function_exists('hrtime') ) {
     
    150153        fclose( self::$fh );
    151154
     155        // Summary file (metadata)
     156        $summary = [];
     157        if ( is_file( $this->tmp_rerun ) ) {
     158            $summary['rerun'] = json_decode( file_get_contents( $this->tmp_rerun ), true );
     159            unlink( $this->tmp_rerun );
     160        }
    152161        $summary['memory']      = memory_get_peak_usage();
    153162        $summary['queries']     = get_num_queries() - 2;
  • code-profiler/trunk/lib/class-report.php

    r3158496 r3371018  
    212212        $this->summary_list['time']     = number_format( $this->summary_list['time'], 4 );
    213213
     214        // Re-run options
     215        if (! empty( $s['rerun'] ) ) {
     216            $this->summary_list['rerun'] = $s['rerun'];
     217            $this->summary_list['rerun']['profile'] = $this->profile_name;
     218        }
     219
    214220        // Save Code Profiler, PHP and WordPress' versions
    215221        global $wp_version;
     
    221227
    222228        file_put_contents( $summary_json, json_encode( $this->summary_list ) );
    223 
    224229    }
    225230
  • code-profiler/trunk/lib/class-table-profiles.php

    r3314519 r3371018  
    158158        $order  = (! empty( $_GET['order'] ) ) ? sanitize_key( $_GET['order'] ) : 'asc';
    159159
     160        /**
     161         * The option to re-run a profile is only available with profiles created with v1.8.
     162         */
     163        if (! empty( $item['rerun'] ) ) {
     164            $rerun = sprintf(
     165                '<a href="?page=code-profiler&cptab=profiler&action=rerun&profiles[]=%1$s" title="'.
     166                esc_attr__('Re-run the profile with the same options and parameters.', 'code-profiler') .
     167                '">%2$s</a>',
     168                esc_attr( $item['ID'] ),
     169                esc_html__('Re-run', 'code-profiler')
     170            );
     171        } else {
     172            $rerun = '<font style="cursor:not-allowed" title="'.
     173                esc_attr__('This feature is only available with profiles created with Code Profiler v1.8+',
     174                'code-profiler') .'">'. esc_html__('Re-run', 'code-profiler') .'</font>';
     175        }
     176
    160177        $actions = array(
    161178            'view'   => sprintf(
     
    170187                esc_html__('Quick Edit')
    171188            ),
     189            'rerun' => $rerun,
    172190            'delete' => sprintf(
    173191                '<a href="?page=code-profiler&cptab=profiles_list&action=%s&profiles[]=%s'.
     
    278296                        // Ignore these ones, there aren't mandatory
    279297                        if ( in_array( $pname, [ 'composer', 'summary' ] ) ) { continue; }
    280                         if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
     298                        if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
    281299                            $fsize += filesize( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" );
    282300                        } else {
     
    288306                    if ( $error ) {
    289307                        foreach( $this->default_files as $pname ) {
    290                             if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
     308                            if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
    291309                                unlink( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" );
    292310                            }
     
    326344                    if ( empty( $summary['io'] ) )      { $summary['io']            = '-'; }
    327345
     346                    /**
     347                     * Check if we can re-run the profile (v1.8+).
     348                     */
     349                    if (! empty( $summary['rerun'] ) ) {
     350                        $profiles[$count]['rerun'] = true;
     351                    }
    328352                    $fsize                              += filesize( $path );
    329353                    $profiles[$count]['ID']         = $match[1];
     
    385409            }
    386410            foreach( $this->default_files as $pname ) {
    387                 if ( file_exists( "$profile_name.$pname.profile" ) ) {
    388                     unlink( "$profile_name.$pname.profile" );
     411                if ( is_file( "$profile_name.$pname.profile") ) {
     412                    unlink( "$profile_name.$pname.profile");
    389413                }
    390414            }
  • code-profiler/trunk/lib/helper.php

    r3314519 r3371018  
    3434define('CODE_PROFILER_TMP_IOSTATS_LOG', 'iostats.tmp');
    3535define('CODE_PROFILER_TMP_SUMMARY_LOG', 'summary.tmp');
     36define('CODE_PROFILER_TMP_RERUN_LOG', 'rerun.tmp');
    3637define('CODE_PROFILER_TMP_CALLS_LOG', 'calls.tmp');
    3738define('CODE_PROFILER_TMP_DISKIO_LOG', 'diskio.tmp');
     
    129130function code_profiler_init_update() {
    130131
    131     $cp_options = get_option('code-profiler');
     132    if ( ( $cp_options = get_option('code-profiler') ) == false ) {
     133        /**
     134         * "Automatic conversion of false to array is deprecated" since PHP 8.1
     135         */
     136        $cp_options = [];
     137    }
     138
    132139    if ( empty( $cp_options['version'] ) ||
    133140        version_compare( $cp_options['version'], CODE_PROFILER_VERSION, '<') ) {
     
    158165        if (! isset( $cp_options['php_error'] ) ) {
    159166            $cp_options['php_error'] = 1;
     167        }
     168
     169        // Version 1.8
     170        if ( isset( $cp_options['mem_where'] ) ) {
     171            $cp_options['mem']['x_end'] = $cp_options['mem_where'];
     172            unset( $cp_options['mem_where'] );
     173        }
     174        if ( isset( $cp_options['mem_post'] ) ) {
     175            $cp_options['mem']['post'] = $cp_options['mem_post'];
     176            unset( $cp_options['mem_post'] );
     177        }
     178        if ( isset( $cp_options['mem_user'] ) ) {
     179            $cp_options['mem']['x_auth'] = $cp_options['mem_user'];
     180            unset( $cp_options['mem_user'] );
     181        }
     182        if ( isset( $cp_options['mem_username'] ) ) {
     183            $cp_options['mem']['username'] = $cp_options['mem_username'];
     184            unset( $cp_options['mem_username'] );
     185        }
     186        if ( isset( $cp_options['mem_method'] ) ) {
     187            $cp_options['mem']['method'] = $cp_options['mem_method'];
     188            unset( $cp_options['mem_method'] );
     189        }
     190        if ( isset( $cp_options['mem_theme'] ) ) {
     191            $cp_options['mem']['theme'] = $cp_options['mem_theme'];
     192            unset( $cp_options['mem_theme'] );
     193        }
     194        if ( isset( $cp_options['ua'] ) ) {
     195            $cp_options['mem']['user_agent'] = $cp_options['ua'];
     196            unset( $cp_options['ua'] );
     197        }
     198        if ( isset( $cp_options['cookies'] ) ) {
     199            $cp_options['mem']['cookies'] = $cp_options['cookies'];
     200            unset( $cp_options['cookies'] );
     201        }
     202        if ( isset( $cp_options['mem_content_type'] ) ) {
     203            $cp_options['mem']['content_type'] = $cp_options['mem_content_type'];
     204            unset( $cp_options['mem_content_type'] );
     205        }
     206        if ( isset( $cp_options['payload'] ) ) {
     207            $cp_options['mem']['payload'] = $cp_options['payload'];
     208            unset( $cp_options['payload'] );
     209        }
     210        if ( isset( $cp_options['custom_headers'] ) ) {
     211            $cp_options['mem']['custom_headers'] = $cp_options['custom_headers'];
     212            unset( $cp_options['custom_headers'] );
     213        }
     214        if ( isset( $cp_options['exclusions'] ) ) {
     215            $cp_options['mem']['exclusions'] = $cp_options['exclusions'];
     216            unset( $cp_options['exclusions'] );
    160217        }
    161218
  • code-profiler/trunk/lib/i18n-extra.php

    r3240958 r3371018  
    152152__('Run the profiler', 'code-profiler');
    153153__('Enter your license', 'code-profiler');
    154 __('Profile your blog with Code Profiler Pro.', 'code-profiler');
    155154__('The MU plugin isn\'t loaded, please check the log', 'code-profiler');
    156155__('Initializing Code Profiler Pro v%s on %s. Profile:  %s - %s', 'code-profiler');
  • code-profiler/trunk/lib/menu_profiler.php

    r3314519 r3371018  
    4949$home = home_url('/'); // Frontend
    5050$site = site_url('/'); // Backend
     51
    5152// Get user login name
    5253$current_user = wp_get_current_user();
     54
     55$cp_options = get_option('code-profiler');
     56/**
     57 * Check if we've been asked to re-run a profile.
     58 */
     59if (! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'rerun' &&
     60    ! empty( $_REQUEST['profiles'][0] ) ) {
     61    /**
     62     * Make sure the profile exists and get its full path.
     63     */
     64    $profile_path = code_profiler_get_profile_path( $_REQUEST['profiles'][0] );
     65    if ( $profile_path !== false ) {
     66
     67        $cp_data    = json_decode( file_get_contents("$profile_path.summary.profile"), true );
     68        if (! empty( $cp_data['rerun'] ) ) {
     69            $cp_options['mem'] = $cp_data['rerun'];
     70            $rerun = true;
     71        }
     72    }
     73}
    5374// Profile's name
    54 $profile = code_profiler_profile_name();
    55 
    56 $cp_options = get_option('code-profiler');
    57 // Memorized options
    58 if ( empty( $cp_options['mem_where'] ) ) {
    59     $cp_options['mem_where'] = 'frontend';
    60 }
    61 if ( empty( $cp_options['mem_post'] ) ) {
    62     $cp_options['mem_post'] = '';
    63 }
    64 if ( empty( $cp_options['mem_user'] ) ) {
    65     $cp_options['mem_user'] = 'unauthenticated';
    66 }
    67 if ( $cp_options['mem_where'] == 'backend') {
    68     $cp_options['mem_user'] = 'authenticated';
    69 }
    70 if ( empty( $cp_options['mem_method'] ) ) {
    71     $cp_options['mem_method'] = 'get';
     75if (! empty( $cp_options['mem']['profile'] ) ) {
     76    $profile = $cp_options['mem']['profile'];
     77} else {
     78    $profile = code_profiler_profile_name();
     79}
     80/**
     81 * Memorized options from last run.
     82 */
     83if ( empty( $cp_options['mem']['x_end'] ) ) {
     84    $cp_options['mem']['x_end'] = 'frontend';
     85}
     86if ( empty( $cp_options['mem']['post'] ) ) {
     87    $cp_options['mem']['post'] = '';
     88}
     89if ( empty( $cp_options['mem']['x_auth'] ) ) {
     90    $cp_options['mem']['x_auth'] = 'unauthenticated';
     91}
     92if ( $cp_options['mem']['x_end'] == 'backend') {
     93    $cp_options['mem']['x_auth'] = 'authenticated';
     94}
     95if ( empty( $cp_options['mem']['method'] ) ) {
     96    $cp_options['mem']['method'] = 'get';
    7297}
    7398$default_theme = get_option('stylesheet');
    74 if ( empty( $cp_options['mem_theme'] ) ) {
    75     $cp_options['mem_theme'] = $default_theme;
    76 }
    77 if ( empty( $cp_options['ua'] ) ) {
    78     $cp_options['ua'] = 'Firefox';
    79 }
    80 $cookies                = '';
    81 $payload                = '';
    82 $custom_headers = '';
    83 $exclusions         = [];
    84 
    85 if ( isset( $cp_options['cookies'] ) ) {
     99if ( empty( $cp_options['mem']['theme'] ) ) {
     100    $cp_options['mem']['theme'] = $default_theme;
     101}
     102if ( empty( $cp_options['mem']['user_agent'] ) ) {
     103    $cp_options['mem']['user_agent'] = 'Firefox';
     104}
     105if ( isset( $cp_options['mem']['cookies'] ) ) {
    86106    // stripslashes is only needed for cookies
    87     $cookies = trim( stripslashes( json_decode( $cp_options['cookies'] ) ) );
    88 }
    89 if ( empty( $cp_options['mem_content_type'] ) ||
    90     ! in_array( $cp_options['mem_content_type'], [ 1, 2, 3 ] ) ) {
    91 
    92     $cp_options['mem_content_type'] = 1;
    93 }
    94 if ( isset( $cp_options['payload'] ) ) {
    95     $payload    =  trim( json_decode( $cp_options['payload'] ) );
    96 }
    97 if ( isset( $cp_options['custom_headers'] ) ) {
    98     $custom_headers = trim( json_decode( $cp_options['custom_headers'] ) );
    99 }
    100 if ( isset( $cp_options['exclusions'] ) ) {
    101     $exclusions = json_decode( $cp_options['exclusions'] );
    102 }
     107    $cookies = trim( stripslashes( json_decode( $cp_options['mem']['cookies'] ) ) );
     108} else {
     109    $cookies = '';
     110}
     111if ( empty( $cp_options['mem']['content_type'] ) ||
     112    ! in_array( $cp_options['mem']['content_type'], [ 1, 2, 3 ] ) ) {
     113
     114    $cp_options['mem']['content_type'] = 1;
     115}
     116if ( isset( $cp_options['mem']['payload'] ) ) {
     117    $payload    =  trim( json_decode( $cp_options['mem']['payload'] ) );
     118} else {
     119    $payload = '';
     120}
     121if ( isset( $cp_options['mem']['custom_headers'] ) ) {
     122    $custom_headers = trim( json_decode( $cp_options['mem']['custom_headers'] ) );
     123} else {
     124    $custom_headers = '';
     125}
     126if ( isset( $cp_options['mem']['exclusions'] ) ) {
     127    $exclusions = json_decode( $cp_options['mem']['exclusions'] );
     128} else {
     129    $exclusions = [];
     130}
     131
    103132?>
    104 <table class="form-table">
     133
     134<table style="width:100%">
    105135    <tr>
    106         <th scope="row"><?php esc_html_e('Page to profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Select the page you want the profiler to analyze. It can be in the frontend of the site, in the admin backend or a custom URL.', 'code-profiler') ?>"></span></th>
    107136        <td>
    108             <p><label><input type="radio" name="where" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem_where'], 'frontend') ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label>
    109             &nbsp;&nbsp;&nbsp;&nbsp;
    110             <label><input type="radio" name="where" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem_where'], 'custom') ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label>
    111             &nbsp;&nbsp;&nbsp;&nbsp;
    112             <label><input type="radio" name="where" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem_where'], 'backend') ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label>
    113             </p>
    114             <br />
    115             <?php
    116             if ( $cp_options['mem_where'] == 'frontend') {
    117                 echo '<p id="p-frontend">';
    118             } else {
    119                 echo '<p id="p-frontend" style="display:none">';
    120             }
    121             ?>
    122                 <?php esc_html_e('Select a page:', 'code-profiler') ?>
    123                 <select name="frontend" id="id-frontend">
    124                     <?php echo code_profiler_fetch_pages( $home, $cp_options ); ?>
    125                 </select>
    126             </p>
    127             <?php
    128             if ( $cp_options['mem_where'] == 'custom') {
    129                 $value = $cp_options['mem_post'];
    130                 echo '<p id="p-custom">';
    131             } else {
    132                 $value = '';
    133                 echo '<p id="p-custom" style="display:none">';
    134             }
    135             ?>
    136                 <input name="custom" id="id-custom" type="text" value="<?php echo esc_attr( $value ) ?>" size="70" placeholder="<?php
    137                 echo esc_attr(
    138                     sprintf(
    139                         __('e.g., %s', 'code-profiler'),
    140                         "{$home}foo/bar/"
    141                     )
    142                 ) ?>" />
    143             </p>
    144             <?php
    145             if ( $cp_options['mem_where'] == 'backend') {
    146                 echo '<p id="p-backend">';
    147             } else {
    148                 echo '<p id="p-backend" style="display:none">';
    149             }
    150             if (! empty( $cp_options['mem_username'] ) ) {
    151                 $username = $cp_options['mem_username'];
    152             } else {
    153                 $username = $current_user->user_login;
    154             }
    155             ?>
    156                 <?php esc_html_e('Select a page:', 'code-profiler') ?>
    157                 <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $site, $cp_options ) ?></select>
    158             </p>
     137            <table class="form-table">
     138                <tr>
     139                    <th scope="row"><?php esc_html_e('Page to profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Select the page you want the profiler to analyze. It can be in the frontend of the site, in the admin backend or a custom URL.', 'code-profiler') ?>"></span></th>
     140                    <td>
     141                        <p><label><input type="radio" name="x_end" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem']['x_end'], 'frontend') ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label>
     142                        &nbsp;&nbsp;&nbsp;&nbsp;
     143                        <label><input type="radio" name="x_end" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem']['x_end'], 'custom') ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label>
     144                        &nbsp;&nbsp;&nbsp;&nbsp;
     145                        <label><input type="radio" name="x_end" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem']['x_end'], 'backend') ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label>
     146                        </p>
     147                        <br />
     148                        <?php
     149                        if ( $cp_options['mem']['x_end'] == 'frontend') {
     150                            echo '<p id="p-frontend">';
     151                        } else {
     152                            echo '<p id="p-frontend" style="display:none">';
     153                        }
     154                        ?>
     155                            <?php esc_html_e('Select a page:', 'code-profiler') ?>
     156                            <select name="frontend" id="id-frontend">
     157                                <?php echo code_profiler_fetch_pages( $home, $cp_options ); ?>
     158                            </select>
     159                        </p>
     160                        <?php
     161                        if ( $cp_options['mem']['x_end'] == 'custom') {
     162                            $value = $cp_options['mem']['post'];
     163                            echo '<p id="p-custom">';
     164                        } else {
     165                            $value = '';
     166                            echo '<p id="p-custom" style="display:none">';
     167                        }
     168                        ?>
     169                            <input name="custom" id="id-custom" type="text" value="<?php echo esc_attr( $value ) ?>" size="70" placeholder="<?php
     170                            echo esc_attr(
     171                                sprintf(
     172                                    __('e.g., %s', 'code-profiler'),
     173                                    "{$home}foo/bar/"
     174                                )
     175                            ) ?>" />
     176                        </p>
     177                        <?php
     178                        if ( $cp_options['mem']['x_end'] == 'backend') {
     179                            echo '<p id="p-backend">';
     180                        } else {
     181                            echo '<p id="p-backend" style="display:none">';
     182                        }
     183                        if (! empty( $cp_options['mem']['username'] ) ) {
     184                            $username = $cp_options['mem']['username'];
     185                        } else {
     186                            $username = $current_user->user_login;
     187                        }
     188                        ?>
     189                            <?php esc_html_e('Select a page:', 'code-profiler') ?>
     190                            <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $site, $cp_options ) ?></select>
     191                        </p>
     192                    </td>
     193                </tr>
     194                <tr>
     195                    <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile, otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler') ?>"></span></th>
     196                    <td>
     197                        <p><label><input type="radio" onclick="cpjs_authenticated(0);" name="x_auth" value="unauthenticated" id="user-unauthenticated"<?php checked( $cp_options['mem']['x_auth'], 'unauthenticated'); disabled( $cp_options['mem']['x_end'], 'backend'); ?> /> <?php esc_html_e('Unauthenticated user', 'code-profiler') ?></label></p>
     198                        <p><label><input type="radio" onclick="cpjs_authenticated(1);" name="x_auth" value="authenticated" id="user-authenticated"<?php checked( $cp_options['mem']['x_auth'], 'authenticated') ?> /> <?php esc_html_e('Authenticated user', 'code-profiler') ?></label></p>
     199                        <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem']['x_auth'], 'unauthenticated') ?> /></label></p>
     200                    </td>
     201                </tr>
     202                <tr>
     203                    <th scope="row"><?php esc_html_e('Theme', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('If you want to profile different themes, you can use this option so that you don\'t need to modify your WordPress settings. The change will not affect your visitors, but only the profiler when it is running.', 'code-profiler') ?>"></span></th>
     204                    <td>
     205                        <select name="theme" id="id-theme">
     206                        <?php
     207                        $themes = code_profiler_get_themes();
     208                        foreach( $themes as $slug => $name ) {
     209                            if ( $slug == $default_theme ) {
     210                                echo '<option value=""'. selected( $cp_options['mem']['theme'], $slug, false ) .'>'.
     211                                    esc_html( $name['n'] ) .' '. __('(active theme)', 'code-profiler') .'</option>';
     212                            } else {
     213                                echo '<option value="'. esc_attr( $slug ) .'"'. selected( $cp_options['mem']['theme'], $slug, false ) .'>'.
     214                                    esc_html( $name['n'] ) .'</option>';
     215                            }
     216                        }
     217                        ?>
     218                        </select>
     219                    </td>
     220                </tr>
     221                <tr>
     222                    <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler') ?>"></span></th>
     223                    <td>
     224                        <select name="user_agent" id="ua-id">
     225                        <?php
     226                        foreach( CODE_PROFILER_UA as $types => $types_array ) {
     227                            echo '<optgroup label="'. esc_attr( $types ) .'">';
     228                            foreach( $types_array as $name => $value ) {
     229                                echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['mem']['user_agent'], $name, false ) .'>'. esc_html( $name ) .'</option>';
     230                            }
     231                            echo '</optgroup>';
     232                        }
     233                        ?>
     234                        </select>
     235                    </td>
     236                </tr>
     237                <tr>
     238                    <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler') ?>"></span></th>
     239                    <td>
     240                        <p><label><input type="text" class="regular-text" name="profile" maxlength="100" value="<?php echo esc_attr( $profile ) ?>" id="profile-name" /></label></p>
     241                        <p class="description"><?php esc_html_e('Max 100 characters', 'code-profiler') ?></p>
     242                    </td>
     243                </tr>
     244            </table>
    159245        </td>
    160     </tr>
    161     <tr>
    162         <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile, otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler') ?>"></span></th>
    163         <td>
    164             <p><label><input type="radio" onclick="cpjs_authenticated(0);" name="user" value="unauthenticated" id="user-unauthenticated"<?php checked( $cp_options['mem_user'], 'unauthenticated'); disabled( $cp_options['mem_where'], 'backend'); ?> /> <?php esc_html_e('Unauthenticated user', 'code-profiler') ?></label></p>
    165             <p><label><input type="radio" onclick="cpjs_authenticated(1);" name="user" value="authenticated" id="user-authenticated"<?php checked( $cp_options['mem_user'], 'authenticated') ?> /> <?php esc_html_e('Authenticated user', 'code-profiler') ?></label></p>
    166             <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem_user'], 'unauthenticated') ?> /></label></p>
    167         </td>
    168     </tr>
    169     <tr>
    170         <th scope="row"><?php esc_html_e('Theme', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('If you want to profile different themes, you can use this option so that you don\'t need to modify your WordPress settings. The change will not affect your visitors, but only the profiler when it is running.', 'code-profiler') ?>"></span></th>
    171         <td>
    172             <select name="theme" id="id-theme">
    173             <?php
    174             $themes = code_profiler_get_themes();
    175             foreach( $themes as $slug => $name ) {
    176                 if ( $slug == $default_theme ) {
    177                     echo '<option value=""'. selected( $cp_options['mem_theme'], $slug, false ) .'>'.
    178                         esc_html( $name['n'] ) .' '. __('(active theme)', 'code-profiler') .'</option>';
    179                 } else {
    180                     echo '<option value="'. esc_attr( $slug ) .'"'. selected( $cp_options['mem_theme'], $slug, false ) .'>'.
    181                         esc_html( $name['n'] ) .'</option>';
    182                 }
    183             }
    184             ?>
    185             </select>
    186         </td>
    187     </tr>
    188     <tr>
    189         <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler') ?>"></span></th>
    190         <td>
    191             <select name="ua" id="ua-id">
    192             <?php
    193             foreach( CODE_PROFILER_UA as $types => $types_array ) {
    194                 echo '<optgroup label="'. esc_attr( $types ) .'">';
    195                 foreach( $types_array as $name => $value ) {
    196                     echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['ua'], $name, false ) .'>'. esc_html( $name ) .'</option>';
    197                 }
    198                 echo '</optgroup>';
    199             }
    200             ?>
    201             </select>
    202         </td>
    203     </tr>
    204     <tr>
    205         <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler') ?>"></span></th>
    206         <td>
    207             <p><label><input type="text" class="regular-text" name="profile" maxlength="100" value="<?php echo esc_attr( $profile ) ?>" id="profile-name" /></label></p>
    208             <p class="description"><?php esc_html_e('Max 100 characters', 'code-profiler') ?></p>
     246        <td style="vertical-align:top;text-align: center">
     247        <?php
     248        /**
     249         * Display any available discount coupon.
     250         */
     251        CodeProfiler_WPCron::display_coupon();
     252        ?>
    209253        </td>
    210254    </tr>
    211255</table>
    212256<?php
    213 if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem_method'] == 'post' || ! empty( $exclusions ) ) {
     257
     258if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem']['method'] == 'post' || ! empty( $exclusions ) ) {
    214259    echo '<div id="cp-advanced-settings">';
    215260    $disabled_button = ' disabled';
     
    225270                <p>
    226271                    <label>
    227                         <input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem_method'], 'get') ?> /> GET(<?php esc_html_e('default', 'code-profiler') ?>)
     272                        <input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem']['method'], 'get') ?> /> GET(<?php esc_html_e('default', 'code-profiler') ?>)
    228273                    </label>
    229274                </p>
    230275                <p>
    231276                    <label>
    232                         <input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem_method'], 'post') ?> /> POST
     277                        <input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem']['method'], 'post') ?> /> POST
    233278                    </label>
    234279                </p>
    235280                <p>
    236281                    <?php esc_html_e('Content-type:', 'code-profiler') ?>
    237                     <select name="cp-content-type" id="id-content-type"<?php disabled( $cp_options['mem_method'], 'get') ?> onChange="cpjs_content_type(this.value);">
    238                         <option value="1"<?php selected( $cp_options['mem_content_type'], 1 )?>>application/x-www-form-urlencoded (<?php esc_html_e('formatted', 'code-profiler') ?>)</option>
    239                         <option value="3"<?php selected( $cp_options['mem_content_type'], 3 )?>>application/x-www-form-urlencoded (<?php esc_html_e('raw', 'code-profiler') ?>)</option>
    240                         <option value="2"<?php selected( $cp_options['mem_content_type'], 2 )?>>application/json</option>
     282                    <select name="cp-content-type" id="id-content-type"<?php disabled( $cp_options['mem']['method'], 'get') ?> onChange="cpjs_content_type(this.value);">
     283                        <option value="1"<?php selected( $cp_options['mem']['content_type'], 1 )?>>application/x-www-form-urlencoded (<?php esc_html_e('formatted', 'code-profiler') ?>)</option>
     284                        <option value="3"<?php selected( $cp_options['mem']['content_type'], 3 )?>>application/x-www-form-urlencoded (<?php esc_html_e('raw', 'code-profiler') ?>)</option>
     285                        <option value="2"<?php selected( $cp_options['mem']['content_type'], 2 )?>>application/json</option>
    241286                    </select>
    242287                </p>
    243288                <p>
    244                     <textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem_method'], 'get') ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea>
    245                 </p>
    246                 <p class="description" id="ct-1"<?php echo code_profiler_showhide( $cp_options['mem_content_type'], 1 ) ?>>
     289                    <textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem']['method'], 'get') ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea>
     290                </p>
     291                <p class="description" id="ct-1"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 1 ) ?>>
    247292                    <?php printf( esc_html__('Optional POST payload in %s format, one item per line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-1.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?>
    248293                </p>
    249                 <p class="description" id="ct-3"<?php echo code_profiler_showhide( $cp_options['mem_content_type'], 3 ) ?>>
     294                <p class="description" id="ct-3"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 3 ) ?>>
    250295                    <?php printf( esc_html__('Optional raw POST payload, on a single line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-3.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?>
    251296                </p>
    252                 <p class="description" id="ct-2"<?php echo code_profiler_showhide( $cp_options['mem_content_type'], 2 ) ?>>
     297                <p class="description" id="ct-2"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 2 ) ?>>
    253298                    <?php printf( esc_html__('Optional JSON-encoded payload, on a single line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-2.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?>
    254299                </p>
     
    294339    <img style="vertical-align:middle;display:none" id="progress-gif" src="<?php echo plugins_url('/static/progress.gif', dirname (__FILE__ ) ) ?>" />&nbsp;&nbsp;<font id="progress-text" style="display:none"><?php esc_html_e('Starting the profiler...', 'code-profiler') ?></font>
    295340</div>
    296 
    297341<?php
     342
     343/**
     344 * Re-run a profile.
     345 */
     346if (! empty( $rerun ) ) {
     347    echo '<script>window.addEventListener("load", cpjs_start_profiler);</script>';
     348}
    298349
    299350// =====================================================================
     
    304355    $posts = '';
    305356
    306     if ( empty( $cp_options['mem_post'] ) ) {
    307         $cp_options['mem_post'] = $home;
    308     }
    309 
    310     if ( $cp_options['mem_post'] == $home ) {
     357    if ( empty( $cp_options['mem']['post'] ) ) {
     358        $cp_options['mem']['post'] = $home;
     359    }
     360
     361    if ( $cp_options['mem']['post'] == $home ) {
    311362        $pages = sprintf(
    312363            '<option value="%1$s" title="%1$s" selected>%2$s</option>',
     
    338389            $permalink = get_permalink( $item->ID );
    339390
    340             if ( $cp_options['mem_post'] == $permalink ) {
     391            if ( $cp_options['mem']['post'] == $permalink ) {
    341392                $pages .= sprintf(
    342393                    '<option value="%1$s" title="%1$s" selected>%2$s</option>',
     
    367418    $backend = '';
    368419
    369     if ( empty( $cp_options['mem_post'] ) ) {
    370         $cp_options['mem_post'] = $home;
     420    if ( empty( $cp_options['mem']['post'] ) ) {
     421        $cp_options['mem']['post'] = $home;
    371422    }
    372423
     
    377428                $value[0] = trim( preg_replace('/\s*<.+$/', '', $value[0] ) );
    378429
    379                 if ( $cp_options['mem_post'] == "{$home}wp-admin/{$value[2]}" ) {
     430                if ( $cp_options['mem']['post'] == "{$home}wp-admin/{$value[2]}" ) {
    380431                    $backend .= sprintf(
    381432                        '<option value="%1$s" title="%1$s" selected>%2$s</option>',
  • code-profiler/trunk/readme.txt

    r3316061 r3371018  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.7.7
     6Stable tag: 1.8
    77License: GPLv3 or later
    88Requires PHP: 7.1
     
    9494== Changelog ==
    9595
     96= 1.8 (1st October, 2025) =
     97
     98* This version introduces a new feature requested by many users: the possibility to re-run an existing profile. In the "Profiles List" table, click on the "Re-run" row action link and Code Profiler will run again the profile with the same options and parameters.
     99* Fixed an "Automatic conversion of false to array is deprecated" message in PHP 8.1+.
     100* Small fixes and adjustments.
     101
    96102= 1.7.7 (23 June, 2025) =
    97103
  • code-profiler/trunk/static/code-profiler.js

    r3314519 r3371018  
    197197
    198198function cpjs_start_profiler() {
    199     'use strict';
     199
     200    'use strict';
     201
     202    jQuery('html, body').animate( {
     203        scrollTop: jQuery('#button-adv-settings').offset().top
     204    }, 1000 );
     205
    200206    // Get the nonce
    201207    var cp_nonce = jQuery('#cp_nonce').val();
     
    207213    // Get the scan type (frontend/backend)
    208214    var post;
    209     var where = jQuery('input[name="where"]:checked').val();
    210     if ( where == 'frontend') {
     215    var x_end = jQuery('input[name="x_end"]:checked').val();
     216    if ( x_end == 'frontend') {
    211217        post = jQuery('#id-frontend').val();
    212218
    213     } else if ( where == 'backend') {
     219    } else if ( x_end == 'backend') {
    214220        post = jQuery('#id-backend').val();
    215221
    216     } else if ( where == 'custom') {
     222    } else if ( x_end == 'custom') {
    217223        post = jQuery('#id-custom').val().trim(); // Trim user input
    218224
     
    234240    }
    235241
    236     var user = jQuery('input[name="user"]:checked').val();
    237     if ( user == '') {
     242    var x_auth = jQuery('input[name="x_auth"]:checked').val();
     243    if ( x_auth == '') {
    238244        alert( cpi18n.missing_userauth );
    239245        return;
     
    241247
    242248    var username = jQuery('#user-name').val().trim(); // Trim user input
    243     if ( user == 'authenticated') {
     249    if ( x_auth == 'authenticated') {
    244250        if ( username == '') {
    245251            alert( cpi18n.missing_username );
     
    249255    }
    250256
    251     var ua = jQuery('#ua-id').val();
    252     if ( ua == 'undefined') {
    253         ua = 'FireFox';
     257    var user_agent = jQuery('#ua-id').val();
     258    if ( user_agent == 'undefined') {
     259        user_agent = 'FireFox';
    254260    }
    255261
     
    299305        'action': 'codeprofiler_start_profiler',
    300306        'cp_nonce': cp_nonce,
    301         'where': where,
     307        'x_end': x_end,
    302308        'post': post,
    303309        'content_type': ct,
    304310        'profile': profile,
    305         'user': user,
     311        'x_auth': x_auth,
    306312        'username': username,
    307313        'cookies': cookies,
     
    310316        'method': method,
    311317        'payload': payload,
    312         'ua': ua,
     318        'user_agent': user_agent,
    313319        'theme': theme
    314320    };
Note: See TracChangeset for help on using the changeset viewer.