| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/././mahyarcake/./www/wp-content/plugins/gravityforms/includes/settings/ |
Upload File : |
<?php
namespace Gravity_Forms\Gravity_Forms\Settings;
use Gravity_Forms\Gravity_Forms\Settings\Fields\Base;
use WP_Error;
defined( 'ABSPATH' ) || die();
class Fields {
/**
* A collection of registered Settings field types.
*
* @since 2.5
*
* @var Fields\Base[]
*/
private static $types = array();
/**
* Initialize a new Settings field.
*
* @since 2.5
*
* @param array|Base $props
* @param \Gravity_Forms\Gravity_Forms\Settings\Settings $settings Settings instance.
*
* @return Fields\Base|WP_Error
*/
public static function create( $props, $settings ) {
// If field is already created, return.
if ( is_a( $props, 'Gravity_Forms\Gravity_Forms\Settings\Fields\Base' ) && ! self::exists( $props['type'] ) ) {
return $props;
}
// Ensure Settings instance was provided.
if ( ! is_a( $settings, 'Gravity_Forms\Gravity_Forms\Settings\Settings' ) && ! is_subclass_of( $settings, 'Gravity_Forms\Gravity_Forms\Settings\Settings' ) ) {
return new WP_Error( 'settings_not_found', 'Instance of Settings Framework must be provided.' );
}
// If no field type is defined, use Base field.
if ( ( ! rgar( $props, 'type' ) || ! self::exists( $props['type'] ) ) && rgar( $props, 'callback' ) ) {
return new Fields\Base( $props, $settings );
}
// If field type does not exist, exit.
if ( ! self::exists( $props['type'] ) ) {
return new WP_Error( 'type_not_found', 'Field type does not exist.' );
}
// Create field.
$field = new self::$types[ $props['type'] ]( $props, $settings );
return $field;
}
/**
* Determine if field type exists.
*
* @since 2.5
*
* @param string $type Field type.
*
* @return bool
*/
public static function exists( $type ) {
return isset( self::$types[ $type ] );
}
/**
* Register a new Settings field type.
*
* @since 2.5
*
* @param string $type Field type.
* @param string $class_name Class name.
*
* @return bool|WP_Error
*/
public static function register( $type, $class_name ) {
if ( self::exists( $type ) ) {
return new WP_Error( 'type_registered', 'Field type already registered.' );
}
self::$types[ $type ] = $class_name;
return true;
}
}
// Load all field files.
foreach ( glob( plugin_dir_path( __FILE__ ) . '/fields/class-*.php' ) as $filename ) {
require_once( $filename );
}