| 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/ |
Upload File : |
<?php
namespace Gravity_Forms\Gravity_Forms;
use Gravity_Forms\Gravity_Forms\Config\GF_App_Config;
use Gravity_Forms\Gravity_Forms\Config\GF_Config_Service_Provider;
/**
* Class GF_Service_Provider
*
* An abstraction which provides a contract for defining Service Providers. Service Providers facilitate
* organizing Services into discreet modules, as opposed to having to register each service in a single location.
*
* @since 2.5
*
* @package Gravity_Forms\Gravity_Forms
*/
abstract class GF_Service_Provider {
/**
* @var GF_Service_Container $container
*/
protected $container;
public function set_container( GF_Service_Container $container ) {
$this->container = $container;
}
/**
* Register new services to the Service Container.
*
* @param GF_Service_Container $container
*
* @return void
*/
abstract public function register( GF_Service_Container $container );
/**
* Noop by default - used to initialize hooks and filters for the given module.
*/
public function init( GF_Service_Container $container ) {}
//----------------------------------------
//---------- App Registration ------------
//----------------------------------------
/**
* Register a JS app with the given arguments.
*
* @since 2.7.1
*
* @param array $args
*/
public function register_app( $args ) {
$config = new GF_App_Config( $this->container->get( GF_Config_Service_Provider::DATA_PARSER ) );
$config->set_data( $args );
$this->container->get( GF_Config_Service_Provider::CONFIG_COLLECTION )->add_config( $config );
$should_display = is_callable( $args['enqueue'] ) ? call_user_func( $args['enqueue'] ) : $args['enqueue'];
if ( ! $should_display ) {
return;
}
if ( ! empty( $args['css'] ) ) {
$this->enqueue_app_css( $args );
}
if ( ! empty( $args['root_element'] ) ) {
$this->add_root_element( $args['root_element'] );
}
}
/**
* Enqueue the CSS assets for the app.
*
* @since 2.7.1
*
* @param $args
*/
protected function enqueue_app_css( $args ) {
$css_asset = $args['css'];
add_action( 'wp_enqueue_scripts', function () use ( $css_asset ) {
call_user_func_array( 'wp_enqueue_style', $css_asset );
} );
add_action( 'admin_enqueue_scripts', function () use ( $css_asset ) {
call_user_func_array( 'wp_enqueue_style', $css_asset );
} );
}
/**
* Add the root element to the footer output for bootstrapping.
*
* @since 2.7.1
*
* @param string $root
*/
protected function add_root_element( $root ) {
add_action( 'admin_footer', function() use ( $root ) {
echo '<div data-js="' . $root . '"></div>';
}, 10, 0 );
}
}