dvadf
File manager - Edit - /home/theblueo/tv/wp-includes/pomo/lib/Providers.tar
Back
Provider/Status.php 0000666 00000005442 15214236575 0010355 0 ustar 00 <?php namespace WPForms\Providers\Provider; /** * Class Status gives ability to check/work with provider statuses. * Might be used later to track Provider errors on data-delivery. * * @since 1.4.8 */ class Status { /** * Provider identifier, its slug. * * @since 1.4.8 * * @var string */ private $provider; /** * Form data and settings. * * @since 1.4.8 * * @var array */ protected $form_data = array(); /** * Status constructor. * * @param string $provider Provider slug. */ public function __construct( $provider ) { $this->provider = sanitize_key( (string) $provider ); } /** * Provide ability to statically init the object. * Useful for inline-invocations. * * @example: Status::init( 'drip' )->is_ready(); * * @since 1.4.8 * @since 1.5.9 Added a check on provider. * * @param string $provider Provider slug. * * @return \WPForms\Providers\Provider\Status */ public static function init( $provider ) { static $instance; if ( ! $instance || $provider !== $instance->provider ) { $instance = new self( $provider ); } return $instance; } /** * Check whether the defined provider is configured or not. * "Configured" means has an account, that might be checked/updated on Settings > Integrations. * * @since 1.4.8 * * @return bool */ public function is_configured() { $options = \wpforms_get_providers_options(); // We meed to leave this filter for BC. $is_configured = \apply_filters( 'wpforms_providers_' . $this->provider . '_configured', ! empty( $options[ $this->provider ] ) ? true : false ); // Use this filter to change the configuration status of the provider. return apply_filters( 'wpforms_providers_status_is_configured', $is_configured, $this->provider ); } /** * Check whether the defined provider is connected to some form. * "Connected" means it has a Connection in Form Builder > Providers > Provider tab. * * @since 1.4.8 * * @param int $form_id Form ID to check the status against. * * @return bool */ public function is_connected( $form_id ) { $is_connected = false; $this->form_data = \wpforms()->form->get( (int) $form_id, array( 'content_only' => true, ) ); if ( ! empty( $this->form_data['providers'][ $this->provider ] ) || ! empty( $this->form_data['payments'][ $this->provider ] ) ) { $is_connected = true; } return apply_filters( 'wpforms_providers_status_is_connected', $is_connected, $this->provider ); } /** * Is the current provider ready to be used? * It means both configured and connected. * * @since 1.4.8 * * @param int $form_id Form ID to check the status against. * * @return bool */ public function is_ready( $form_id ) { return $this->is_configured() && $this->is_connected( $form_id ); } } Provider/Process.php 0000666 00000004300 15214236575 0010500 0 ustar 00 <?php namespace WPForms\Providers\Provider; /** * Class Process handles entries processing using the provider settings and configuration. * * @since 1.4.7 */ abstract class Process { /** * Get the Core loader class of a provider. * * @since 1.4.7 * * @var Core */ protected $core; /** * Array of form fields. * * @since 1.4.7 * * @var array */ protected $fields = array(); /** * Submitted form content. * * @since 1.4.7 * * @var array */ protected $entry = array(); /** * Form data and settings. * * @since 1.4.7 * * @var array */ protected $form_data = array(); /** * ID of a saved entry. * * @since 1.4.7 * * @var int */ protected $entry_id; /** * Process constructor. * * @since 1.4.7 * * @param Core $core Provider core class. */ public function __construct( Core $core ) { $this->core = $core; } /** * Receive all wpforms_process_complete params and do the actual processing. * * @since 1.4.7 * * @param array $fields Array of form fields. * @param array $entry Submitted form content. * @param array $form_data Form data and settings. * @param int $entry_id ID of a saved entry. */ abstract public function process( $fields, $entry, $form_data, $entry_id ); /** * Process conditional logic for a connection. * * @since 1.4.7 * * @param array $fields Array of form fields. * @param array $form_data Form data and settings. * @param array $connection All connection data. * * @return bool */ protected function process_conditionals( $fields, $form_data, $connection ) { if ( empty( $connection['conditional_logic'] ) || empty( $connection['conditionals'] ) ) { return true; } $process = wpforms_conditional_logic()->process( $fields, $form_data, $connection['conditionals'] ); if ( ! empty( $connection['conditional_type'] ) && 'stop' === $connection['conditional_type'] ) { $process = ! $process; } return $process; } /** * Get provider options, saved on Settings > Integrations page. * * @since 1.4.7 * * @return array */ protected function get_options() { return \wpforms_get_providers_options( $this->core->slug ); } } Provider/Settings/FormBuilderInterface.php 0000666 00000001265 15214236575 0014724 0 ustar 00 <?php namespace WPForms\Providers\Provider\Settings; /** * Interface FormBuilderInterface defines required method for builder to work properly. * * @since 1.4.7 */ interface FormBuilderInterface { /** * Every provider should display a title in a Builder. * * @since 1.4.7 */ public function display_sidebar(); /** * Every provider should display a content of its settings in a Builder. * * @since 1.4.7 */ public function display_content(); /** * Use this method to register own templates for form builder. * Make sure, that you have `tmpl-` in template name in `<script id="tmpl-*">`. * * @since 1.4.7 */ public function builder_custom_templates(); } Provider/Settings/PageIntegrationsInterface.php 0000666 00000001103 15214236575 0015744 0 ustar 00 <?php namespace WPForms\Providers\Provider\Settings; /** * Interface PageIntegrationsInterface defines methods that are common among all Integration page providers content. * * @since 1.4.7 */ interface PageIntegrationsInterface { /** * Display the data for integrations tab. * This is a default one, that can be easily overwritten inside the child class of a specific provider. * * @since 1.4.7 * * @param array $active Array of activated providers addons. * @param array $settings Providers options. */ public function display( $active, $settings ); } Provider/Settings/FormBuilder.php 0000666 00000031312 15214236575 0013077 0 ustar 00 <?php namespace WPForms\Providers\Provider\Settings; use WPForms\Providers\Provider\Core; use WPForms\Providers\Provider\Status; /** * Class FormBuilder handles functionality inside the form builder. * * @since 1.4.7 */ abstract class FormBuilder implements FormBuilderInterface { /** * Get the Core loader class of a provider. * * @since 1.4.7 * * @var Core */ protected $core; /** * Most of Marketing providers will have 'connection' type. * Payment providers may have (or not) something different. * * @since 1.4.7 * * @var string */ protected $type = 'connection'; /** * Form data and settings. * * @since 1.4.7 * * @var array */ protected $form_data = array(); /** * Integrations constructor. * * @since 1.4.7 * * @param Core $core Core provider class. */ public function __construct( Core $core ) { $this->core = $core; if ( ! empty( $_GET['form_id'] ) ) { // phpcs:ignore $this->form_data = \wpforms()->form->get( \absint( $_GET['form_id'] ), // phpcs:ignore array( 'content_only' => true, ) ); } $this->init_hooks(); } /** * Register all hooks (actions and filters) here. * * @since 1.4.7 */ protected function init_hooks() { // Register builder HTML template(s). \add_action( 'wpforms_builder_print_footer_scripts', array( $this, 'builder_templates' ), 10 ); \add_action( 'wpforms_builder_print_footer_scripts', array( $this, 'builder_custom_templates' ), 11 ); // Process builder AJAX requests. \add_action( "wp_ajax_wpforms_builder_provider_ajax_{$this->core->slug}", array( $this, 'process_ajax' ) ); /* * Enqueue assets. */ if ( ( ! empty( $_GET['page'] ) && $_GET['page'] === 'wpforms-builder' ) && // phpcs:ignore ! empty( $_GET['form_id'] ) && // phpcs:ignore \is_admin() ) { \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } } /** * Used to register generic templates for all providers inside form builder. * * @since 1.4.7 */ public function builder_templates() { ?> <!-- Single connection block sub-template: FIELDS --> <script type="text/html" id="tmpl-wpforms-providers-builder-content-connection-fields"> <div class="wpforms-builder-provider-connection-block wpforms-builder-provider-connection-fields"> <table class="wpforms-builder-provider-connection-fields-table"> <thead> <tr> <th><?php \esc_html_e( 'Custom Field Name', 'wpforms-lite' ); ?></th> <th colspan="3"><?php \esc_html_e( 'Form Field Value', 'wpforms-lite' ); ?></th> </tr> </thead> <tbody> <# if ( ! _.isEmpty( data.connection.fields_meta ) ) { #> <# _.each( data.connection.fields_meta, function( item, meta_id ) { #> <tr class="wpforms-builder-provider-connection-fields-table-row"> <td> <# if ( ! _.isEmpty( data.provider.fields ) ) { #> <select class="wpforms-builder-provider-connection-field-name" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][{{ meta_id }}][name]"> <option value="" selected disabled><?php \esc_attr_e( '--- Select Field ---', 'wpforms-lite' ); ?></option> <# _.each( data.provider.fields, function( field_name, field_id ) { #> <option value="{{ field_id }}" <# if ( field_id === item.name ) { #>selected="selected"<# } #> > {{ field_name }} </option> <# } ); #> </select> <# } else { #> <input type="text" value="{{ item.name }}" class="wpforms-builder-provider-connection-field-name" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][{{ meta_id }}][name]" placeholder="<?php \esc_attr_e( 'Field Name', 'wpforms-lite' ); ?>" /> <# } #> </td> <td> <select class="wpforms-builder-provider-connection-field-value" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][{{ meta_id }}][field_id]"> <option value="" selected disabled><?php \esc_html_e( '--- Select Field ---', 'wpforms-lite' ); ?></option> <# _.each( data.fields, function( field, key ) { #> <option value="{{ field.id }}" <# if ( field.id === item.field_id ) { #>selected="selected"<# } #> > {{ field.label }} </option> <# } ); #> </select> </td> <td class="add"> <button class="button-secondary js-wpforms-builder-provider-connection-fields-add" title="<?php \esc_attr_e( 'Add Another', 'wpforms-lite' ); ?>"> <i class="fa fa-plus-circle"></i> </button> </td> <td class="delete"> <button class="button js-wpforms-builder-provider-connection-fields-delete <# if ( meta_id === 0 ) { #>hidden<# } #>" title="<?php \esc_attr_e( 'Remove', 'wpforms-lite' ); ?>"> <i class="fa fa-minus-circle"></i> </button> </td> </tr> <# } ); #> <# } else { #> <tr class="wpforms-builder-provider-connection-fields-table-row"> <td> <# if ( ! _.isEmpty( data.provider.fields ) ) { #> <select class="wpforms-builder-provider-connection-field-name" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][0][name]"> <option value="" selected disabled><?php \esc_attr_e( '--- Select Field ---', 'wpforms-lite' ); ?></option> <# _.each( data.provider.fields, function( field_name, field_id ) { #> <option value="{{ field_id }}"> {{ field_name }} </option> <# } ); #> </select> <# } else { #> <input type="text" value="" class="wpforms-builder-provider-connection-field-name" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][0][name]" placeholder="<?php \esc_attr_e( 'Field Name', 'wpforms-lite' ); ?>" /> <# } #> </td> <td> <select class="wpforms-builder-provider-connection-field-value" name="providers[{{ data.provider.slug }}][{{ data.connection.id }}][fields_meta][0][field_id]"> <option value="" selected disabled><?php \esc_html_e( '--- Select Field ---', 'wpforms-lite' ); ?></option> <# _.each( data.fields, function( field, key ) { #> <option value="{{ field.id }}"> {{ field.label }} </option> <# } ); #> </select> </td> <td class="add"> <button class="button-secondary js-wpforms-builder-provider-connection-fields-add" title="<?php \esc_attr_e( 'Add Another', 'wpforms-lite' ); ?>"> <i class="fa fa-plus-circle"></i> </button> </td> <td class="delete"> <button class="button js-wpforms-builder-provider-connection-fields-delete hidden" title="<?php \esc_attr_e( 'Delete', 'wpforms-lite' ); ?>"> <i class="fa fa-minus-circle"></i> </button> </td> </tr> <# } #> </tbody> </table><!-- /.wpforms-builder-provider-connection-fields-table --> <p class="description"> <?php \esc_html_e( 'Map custom fields (or properties) to form fields values.', 'wpforms-lite' ); ?> </p> </div><!-- /.wpforms-builder-provider-connection-fields --> </script> <!-- Single connection block sub-template: CONDITIONAL LOGIC --> <script type="text/html" id="tmpl-wpforms-providers-builder-content-connection-conditionals"> <?php echo wpforms_conditional_logic()->builder_block( // phpcs:ignore array( 'form' => $this->form_data, 'type' => 'panel', 'parent' => 'providers', 'panel' => esc_attr( $this->core->slug ), 'subsection' => '%connection_id%', 'reference' => esc_html__( 'Marketing provider connection', 'wpforms-lite' ), ), false ); ?> </script> <?php } /** * Enqueue JavaScript and CSS files if needed. * When extending - include the `parent::enqueue_assets();` not to break things! * * @since 1.4.7 */ public function enqueue_assets() { $min = \wpforms_get_min_suffix(); \wp_enqueue_script( 'wpforms-admin-builder-templates', WPFORMS_PLUGIN_URL . "assets/js/components/admin/builder/templates{$min}.js", array( 'wp-util' ), WPFORMS_VERSION, true ); \wp_enqueue_script( 'wpforms-admin-builder-providers', WPFORMS_PLUGIN_URL . "assets/js/components/admin/builder/providers{$min}.js", array( 'wpforms-utils', 'wpforms-builder', 'wpforms-admin-builder-templates' ), WPFORMS_VERSION, true ); } /** * Process the Builder AJAX requests. * * @since 1.4.7 */ public function process_ajax() { // Run a security check. \check_ajax_referer( 'wpforms-builder', 'nonce' ); // Check for permissions. if ( ! \wpforms_current_user_can( 'edit_forms' ) ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ), ) ); } // Process required values. $error = array( 'error' => \esc_html__( 'Something went wrong while performing an AJAX request.', 'wpforms-lite' ) ); if ( empty( $_POST['id'] ) || empty( $_POST['task'] ) ) { \wp_send_json_error( $error ); } $form_id = (int) $_POST['id']; $task = \sanitize_key( $_POST['task'] ); $data = null; // Setup form data based on the ID, that we got from AJAX request. $this->form_data = \wpforms()->form->get( $form_id, array( 'content_only' => true, ) ); // Do not allow to proceed further, as form_id may be incorrect. if ( empty( $this->form_data ) ) { \wp_send_json_error( $error ); } $data = \apply_filters( 'wpforms_providers_settings_builder_ajax_' . $task . '_' . $this->core->slug, null ); if ( null !== $data ) { \wp_send_json_success( $data ); } \wp_send_json_error( $error ); } /** * Display content inside the panel sidebar area. * * @since 1.4.7 */ public function display_sidebar() { $configured = ''; if ( ! empty( $this->form_data['id'] ) && Status::init( $this->core->slug )->is_ready( $this->form_data['id'] ) ) { $configured = 'configured'; } $classes = array( 'wpforms-panel-sidebar-section', 'icon', $configured, 'wpforms-panel-sidebar-section-' . $this->core->slug, ); ?> <a href="#" class="<?php echo \esc_attr( \implode( ' ', $classes ) ); ?>" data-section="<?php echo \esc_attr( $this->core->slug ); ?>"> <img src="<?php echo \esc_url( $this->core->icon ); ?>"> <?php echo \esc_html( $this->core->name ); ?> <i class="fa fa-angle-right wpforms-toggle-arrow"></i> <?php if ( ! empty( $configured ) ) : ?> <i class="fa fa-check-circle-o"></i> <?php endif; ?> </a> <?php } /** * Wrap the builder section content with the required (for tabs switching) markup. * * @since 1.4.7 */ public function display_content() { ?> <div class="wpforms-panel-content-section wpforms-builder-provider wpforms-panel-content-section-<?php echo \esc_attr( $this->core->slug ); ?>" id="<?php echo \esc_attr( $this->core->slug ); ?>-provider" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>"> <!-- Provider content goes here. --> <?php $this->display_content_header(); ?> <div class="wpforms-builder-provider-body"> <div class="wpforms-provider-connections-wrap wpforms-clear"> <div class="wpforms-builder-provider-connections"></div> </div> </div> </div> <?php } /** * Section content header. * * @since 1.4.7 */ protected function display_content_header() { $is_configured = Status::init( $this->core->slug )->is_configured(); ?> <div class="wpforms-builder-provider-title"> <?php echo \esc_html( $this->core->name ); ?> <span class="wpforms-builder-provider-title-spinner"> <i class="fa fa-refresh fa-spin"></i> </span> <button class="wpforms-builder-provider-title-add js-wpforms-builder-provider-connection-add <?php echo $is_configured ? '' : 'hidden'; ?>" data-form_id="<?php echo \absint( $_GET['form_id'] ); ?>" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>"> <?php \esc_html_e( 'Add New Connection', 'wpforms-lite' ); ?> </button> <button class="wpforms-builder-provider-title-add js-wpforms-builder-provider-account-add <?php echo ! $is_configured ? '' : 'hidden'; ?>" data-form_id="<?php echo \absint( $_GET['form_id'] ); ?>" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>"> <?php \esc_html_e( 'Add New Account', 'wpforms-lite' ); ?> </button> </div> <?php } } Provider/Settings/PageIntegrations.php 0000666 00000015074 15214236575 0014137 0 ustar 00 <?php namespace WPForms\Providers\Provider\Settings; use WPForms\Providers\Provider\Core; /** * Class PageIntegrations handles the WPForms -> Settings -> Integrations page. * * @since 1.4.7 */ abstract class PageIntegrations implements PageIntegrationsInterface { /** * Get the Core loader class of a provider. * * @since 1.4.7 * * @var Core */ protected $core; /** * Integrations constructor. * * @since 1.4.7 * * @param Core $core Core provider object. */ public function __construct( Core $core ) { $this->core = $core; $this->ajax(); } /** * Process the default ajax functionality. * * @since 1.4.7 */ protected function ajax() { // Remove provider from Settings Integrations tab. \add_action( "wp_ajax_wpforms_settings_provider_disconnect_{$this->core->slug}", array( $this, 'ajax_disconnect' ) ); // Add new provider from Settings Integrations tab. \add_action( "wp_ajax_wpforms_settings_provider_add_{$this->core->slug}", array( $this, 'ajax_connect' ) ); } /** * @inheritdoc */ public function display( $active, $settings ) { $connected = ! empty( $active[ $this->core->slug ] ); $accounts = ! empty( $settings[ $this->core->slug ] ) ? $settings[ $this->core->slug ] : array(); $class = $connected && $accounts ? 'connected' : ''; $arrow = 'right'; // This lets us highlight a specific service by a special link. if ( ! empty( $_GET['wpforms-integration'] ) ) { //phpcs:ignore if ( $this->core->slug === $_GET['wpforms-integration'] ) { //phpcs:ignore $class .= ' focus-in'; $arrow = 'down'; } else { $class .= ' focus-out'; } } ?> <div id="wpforms-integration-<?php echo \esc_attr( $this->core->slug ); ?>" class="wpforms-settings-provider wpforms-clear <?php echo \esc_attr( $this->core->slug ); ?> <?php echo \esc_attr( $class ); ?>"> <div class="wpforms-settings-provider-header wpforms-clear" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>"> <div class="wpforms-settings-provider-logo"> <i title="<?php \esc_attr_e( 'Show Accounts', 'wpforms-lite' ); ?>" class="fa fa-chevron-<?php echo \esc_attr( $arrow ); ?>"></i> <img src="<?php echo \esc_url( $this->core->icon ); ?>"> </div> <div class="wpforms-settings-provider-info"> <h3><?php echo \esc_html( $this->core->name ); ?></h3> <p> <?php /* translators: %s - provider name. */ \printf( \esc_html__( 'Integrate %s with WPForms', 'wpforms-lite' ), \esc_html( $this->core->name ) ); ?> </p> <span class="connected-indicator green"><i class="fa fa-check-circle-o"></i> <?php \esc_html_e( 'Connected', 'wpforms-lite' ); ?></span> </div> </div> <div class="wpforms-settings-provider-accounts" id="provider-<?php echo \esc_attr( $this->core->slug ); ?>"> <div class="wpforms-settings-provider-accounts-list"> <ul> <?php if ( ! empty( $accounts ) ) { foreach ( $accounts as $key => $account ) { echo '<li class="wpforms-clear">'; echo '<span class="label">' . \esc_html( $account['label'] ) . '</span>'; /* translators: %s - Connection date. */ echo '<span class="date">' . \sprintf( \esc_html__( 'Connected on: %s', 'wpforms-lite' ), \date_i18n( \get_option( 'date_format' ), $account['date'] ) ) . '</span>'; echo '<span class="remove"><a href="#" data-provider="' . \esc_attr( $this->core->slug ) . '" data-key="' . $key . '">' . \esc_html__( 'Disconnect', 'wpforms-lite' ) . '</a></span>'; echo '</li>'; } } ?> </ul> </div> <?php $this->display_add_new(); ?> </div> </div> <?php } /** * Any new connection should be added. * So display the content of that. * * @since 1.4.7 */ protected function display_add_new() { /* translators: %s - provider name. */ $title = \sprintf( \esc_html__( 'Connect to %s', 'wpforms-lite' ), $this->core->name ); ?> <p class="wpforms-settings-provider-accounts-toggle"> <a class="wpforms-btn wpforms-btn-md wpforms-btn-light-grey" href="#" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>"> <i class="fa fa-plus"></i> <?php \esc_html_e( 'Add New Account', 'wpforms-lite' ); ?> </a> </p> <div class="wpforms-settings-provider-accounts-connect"> <form> <p><?php \esc_html_e( 'Please fill out all of the fields below to add your new provider account.', 'wpforms-lite' ); ?></span></p> <p class="wpforms-settings-provider-accounts-connect-fields"> <?php $this->display_add_new_connection_fields(); ?> </p> <button type="submit" class="wpforms-btn wpforms-btn-md wpforms-btn-orange wpforms-settings-provider-connect" data-provider="<?php echo \esc_attr( $this->core->slug ); ?>" title="<?php echo \esc_attr( $title ); ?>"> <?php echo \esc_html( $title ); ?> </button> </form> </div> <?php } /** * Some providers may or may not have fields. * * @since 1.4.7 */ protected function display_add_new_connection_fields() { } /** * AJAX to disconnect a provider from the settings integrations tab. * * @since 1.4.7 */ public function ajax_disconnect() { // Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' ); // Check for permissions. if ( ! \wpforms_current_user_can() ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permission', 'wpforms-lite' ), ) ); } if ( empty( $_POST['provider'] ) || empty( $_POST['key'] ) ) { \wp_send_json_error( array( 'error' => \esc_html__( 'Missing data', 'wpforms-lite' ), ) ); } $providers = \wpforms_get_providers_options(); if ( ! empty( $providers[ $_POST['provider'] ][ $_POST['key'] ] ) ) { unset( $providers[ $_POST['provider'] ][ $_POST['key'] ] ); \update_option( 'wpforms_providers', $providers ); \wp_send_json_success(); } else { \wp_send_json_error( array( 'error' => \esc_html__( 'Connection missing', 'wpforms-lite' ), ) ); } } /** * AJAX to add a provider from the settings integrations tab. * * @since 1.4.7 * * @return bool False when not own provider is processed. */ public function ajax_connect() { // Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' ); // Check for permissions. if ( ! \wpforms_current_user_can() ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permissions.', 'wpforms-lite' ), ) ); } if ( empty( $_POST['data'] ) ) { \wp_send_json_error( array( 'error' => \esc_html__( 'Missing required data in payload.', 'wpforms-lite' ), ) ); } } } Provider/Core.php 0000666 00000006336 15214236575 0007765 0 ustar 00 <?php namespace WPForms\Providers\Provider; /** * Class Core stores the basic information about the provider. * It's also a Container to load single instances of requires classes. * * @since 1.4.7 */ abstract class Core { /** * Unique provider slug. * * @since 1.4.7 * * @var string */ public $slug; /** * Translatable provider name. * * @since 1.4.7 * * @var string */ public $name; /** * Custom provider icon (logo). * * @since 1.4.7 * * @var string */ public $icon; /** * Custom priority for a provider, that will affect loading/placement order. * * @since 1.4.8 * * @var int */ const PRIORITY = 10; /** * Get the instance of the class. * * @since 1.4.7 * * @return Core */ public static function get_instance() { static $instance; if ( ! $instance ) { // Same as new static(), but allows to avoid "abstract class init" error. $core = \get_called_class(); $instance = new $core(); } return $instance; } /** * Core constructor. * * @since 1.4.7 * * @param array $params Possible keys: slug*, name*, icon. * are required. * * @throws \UnexpectedValueException Provider class should define provider's "slug"/"name" params. */ public function __construct( array $params ) { // Define required provider properties. if ( ! empty( $params['slug'] ) ) { $this->slug = \sanitize_key( $params['slug'] ); } else { throw new \UnexpectedValueException( 'Provider class should define a provider "slug" param in its constructor.' ); } if ( ! empty( $params['name'] ) ) { $this->name = \sanitize_text_field( $params['name'] ); } else { throw new \UnexpectedValueException( 'Provider class should define a provider "name" param in its constructor.' ); } $this->icon = WPFORMS_PLUGIN_URL . 'assets/images/sullie.png'; if ( ! empty( $params['icon'] ) ) { $this->icon = \esc_url_raw( $params['icon'] ); } } /** * Add to list of registered providers. * * @since 1.4.7 * * @param array $providers Array of all active providers. * * @return array */ public function register_provider( array $providers ) { $providers[ $this->slug ] = $this->name; return $providers; } /** * Provide an instance of the object, that should process the submitted entry. * It will use data from an already saved entry to pass it further to a Provider. * * @since 1.4.7 * * @return null|\WPForms\Providers\Provider\Process */ abstract public function get_process(); /** * Provide an instance of the object, that should display provider settings * on Settings > Integrations page in admin area. * If you don't want to display it (i.e. you don't need it), you can pass null here in your Core provider class. * * @since 1.4.7 * * @return null|\WPForms\Providers\Provider\Settings\PageIntegrations */ abstract public function get_page_integrations(); /** * Provide an instance of the object, that should display provider settings in the Form Builder. * If you don't want to display it (i.e. you don't need it), you can pass null here in your Core provider class. * * @since 1.4.7 * * @return null|\WPForms\Providers\Provider\Settings\FormBuilder */ abstract public function get_form_builder(); } Loader.php 0000666 00000003201 15214236575 0006475 0 ustar 00 <?php namespace WPForms\Providers; /** * Class Loader gives ability to track/load all providers. * * @since 1.4.7 */ class Loader { /** * Get the instance of a class and store it in itself. * Later we will be able to use this class as $providers_loader = \WPForms\Providers\Loader::get_instance(); * * @since 1.4.7 */ public static function get_instance() { static $instance; if ( ! $instance ) { $instance = new Loader(); } return $instance; } /** * Loader constructor. * * @since 1.4.7 */ public function __construct() { } /** * Register a provider. * * @since 1.4.7 * * @param \WPForms\Providers\Provider\Core $provider The core class of a single provider. */ public function register( Provider\Core $provider ) { \add_filter( 'wpforms_providers_available', array( $provider, 'register_provider' ) ); // WPForms > Settings > Integrations page. $integration = $provider->get_page_integrations(); if ( null !== $integration ) { \add_action( 'wpforms_settings_providers', array( $integration, 'display' ), $provider::PRIORITY, 2 ); } // Editing Single Form > Form Builder. $form_builder = $provider->get_form_builder(); if ( null !== $form_builder ) { \add_action( 'wpforms_providers_panel_sidebar', array( $form_builder, 'display_sidebar' ), $provider::PRIORITY ); \add_action( 'wpforms_providers_panel_content', array( $form_builder, 'display_content' ), $provider::PRIORITY ); } // Process entry submission. $process = $provider->get_process(); if ( null !== $process ) { \add_action( 'wpforms_process_complete', array( $process, 'process' ), 5, 4 ); } } }
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings