/home/altere25/infinet.finance/wp-content/plugins/weforms/includes
Edit: /home/altere25/infinet.finance/wp-content/plugins/weforms/includes/class-scripts-styles.php (17525B)
base == 'toplevel_page_weforms' ) {
$registered_scripts = array_keys( $wp_scripts->registered );
foreach ( $registered_scripts as $r_script ) {
if ( !in_array( $r_script, $required_objects ) ) {
$reg_arr[] = $r_script;
wp_deregister_script( $r_script );
}
}
// $this->enqueue_scripts( $this->get_admin_scripts() );
// foreach ( $reg_arr as $reg_obj ) {
// if ( !in_array( $reg_obj, $wp_scripts->queue ) ) {
// wp_enqueue_script( $reg_obj );
// }
// }
}
}
/**
* Register frontend scripts and styles
*
* @return void
*/
public function register_frontend() {
$this->register_styles( $this->get_frontend_styles() );
$this->register_scripts( $this->get_frontend_scripts() );
$this->get_frontend_localized();
}
/**
* Register frontend scripts and styles
*
* @return void
*/
public function register_backend() {
// bail out if not weforms screen
$screen = get_current_screen();
if ( $screen->base != 'toplevel_page_weforms' ) {
return;
}
$this->register_styles( $this->get_admin_styles() );
$this->register_scripts( $this->get_admin_scripts() );
$this->get_frontend_localized();
}
/**
* Enqueue all the scripts and styles for frontend
*
* @return void
*/
public function enqueue_frontend() {
$this->enqueue_scripts( $this->get_frontend_scripts() );
$this->enqueue_styles( $this->get_frontend_styles() );
}
/**
* Enqueue all the scripts and styles for backend
*
* @return void
*/
public function enqueue_backend() {
$this->enqueue_scripts( $this->get_admin_scripts() );
$this->enqueue_styles( $this->get_admin_styles() );
}
/**
* Get file prefix
*
* @return string
*/
public function get_prefix() {
$prefix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
return $prefix;
}
/**
* Get all registered admin scripts
*
* @return array
*/
public function get_admin_scripts() {
$prefix = $this->get_prefix();
$form_builder_js_deps = apply_filters( 'weforms-form-builder-js-deps', [
'jquery',
'jquery-ui-sortable',
'jquery-ui-draggable',
'jquery-ui-droppable',
'jquery-ui-resizable',
'jquery-ui-datepicker',
'weforms-tiny-mce',
'underscore',
] );
$builder_scripts = apply_filters( 'weforms_builder_scripts', [
'weforms-tiny-mce' => [
'src' => site_url( '/wp-includes/js/tinymce/tinymce.min.js' ),
'deps' => [],
'in_footer' => true,
],
'weforms-vendor' => [
'src' => WEFORMS_ASSET_URI . '/js/vendor' . $prefix . '.js',
'deps' => $form_builder_js_deps,
'in_footer' => true,
],
'weforms-form-builder-mixins' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/js/wpuf-form-builder-mixins.js',
'deps' => ['weforms-vendor'],
'in_footer' => true,
],
'weforms-form-builder-mixins-form' => [
'src' => WEFORMS_ASSET_URI . '/js/wpuf-form-builder-contact-forms' . $prefix . '.js',
'deps' => ['weforms-vendor'],
'in_footer' => true,
],
'weforms-form-builder-components' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/js/wpuf-form-builder-components' . $prefix . '.js',
'deps' => [ 'weforms-form-builder-mixins', 'weforms-form-builder-mixins-form' ],
'in_footer' => true,
],
] );
$spa_scripts = [
'weforms-mixins' => [
'src' => WEFORMS_ASSET_URI . '/js/spa-mixins' . $prefix . '.js',
'deps' => [ 'weforms-vendor', 'wp-util' ],
'in_footer' => true,
],
'weforms-components' => [
'src' => WEFORMS_ASSET_URI . '/js/form-builder-components' . $prefix . '.js',
'deps' => [ 'weforms-vendor', 'wp-util' ],
'in_footer' => true,
],
'weforms-app' => [
'src' => WEFORMS_ASSET_URI . '/js/spa-app' . $prefix . '.js',
'deps' => [ 'weforms-vendor', 'wp-util', 'weforms-form-builder-components' ],
'in_footer' => true,
],
];
$scripts = array_merge( $builder_scripts, $spa_scripts );
return apply_filters( 'weforms_admin_scripts', $scripts );
}
/**
* Get admin styles
*
* @return array
*/
public function get_admin_styles() {
$frontend_styles = $this->get_frontend_styles();
$backend_styles = [
'weforms-font-awesome' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/font-awesome/css/font-awesome.min.css',
],
'weforms-sweetalert2' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/sweetalert2/dist/sweetalert2.css',
],
'weforms-selectize' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/selectize/css/selectize.default.css',
],
'weforms-toastr' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/toastr/toastr.min.css',
],
'weforms-tooltip' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/tooltip/tooltip.css',
],
'weforms-form-builder' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/css/wpuf-form-builder.css',
'deps' => [
'weforms-css',
'weforms-font-awesome',
'weforms-sweetalert2',
'weforms-selectize',
'weforms-toastr',
'weforms-tooltip',
],
],
'weforms-style' => [
'src' => WEFORMS_ASSET_URI . '/css/admin.css',
],
'weforms-tiny-mce-css' => [
'src' => site_url( '/wp-includes/css/editor.css' ),
'deps' => [ 'wp-color-picker' ],
],
];
$styles = array_merge( $frontend_styles, $backend_styles );
return apply_filters( 'weforms_admin_styles', $styles );
}
/**
* Get all registered frontend scripts
*
* @return array
*/
public function get_frontend_scripts() {
$prefix = $this->get_prefix();
$scripts = [
'wpuf-form' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/js/frontend-form' . $prefix . '.js',
'deps' => [ 'jquery', 'jquery-ui-datepicker', 'jquery-ui-slider' ],
'in_footer' => true,
],
'wpuf-sweetalert2' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/sweetalert2/dist/sweetalert2' . $prefix . '.js',
'in_footer' => true,
],
'jquery-ui-timepicker' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/js/jquery-ui-timepicker-addon' . $prefix . '.js',
'deps' => [ 'jquery-ui-datepicker' ],
'in_footer' => true,
],
'wpuf-upload' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/js/upload' . $prefix . '.js',
'deps' => [ 'jquery', 'plupload-handlers', 'jquery-ui-sortable' ],
'in_footer' => true,
],
];
// load single min file of above scripts including chart js when script debug disabled
// weforms.min.js/weforms.js file generate by grunt release command
// check concat:frontendScripts in Gruntfile.js
if ( !SCRIPT_DEBUG ) {
$scripts = [
'wpuf-form' => [
'src' => WEFORMS_ASSET_URI . '/js/weforms.min.js',
'deps' => [ 'jquery', 'jquery-ui-datepicker', 'jquery-ui-slider', 'plupload-handlers', 'jquery-ui-sortable' ],
'in_footer' => true,
],
];
}
return apply_filters( 'weforms_frontend_scripts', $scripts );
}
/**
* Get all registered frontend styles
*
* @return array
*/
public function get_frontend_styles() {
$styles = [
'weforms-css' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/css/frontend-forms.css',
],
'wpuf-sweetalert2' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/vendor/sweetalert2/dist/sweetalert2.css',
],
'jquery-ui' => [
'src' => WEFORMS_ASSET_URI . '/wpuf/css/jquery-ui-1.9.1.custom.css',
],
];
return apply_filters( 'weforms_frontend_styles', $styles );
}
/**
* Frontend localized scripts
*
* @return void
*/
public function get_frontend_localized() {
wp_localize_script( 'wpuf-form', 'wpuf_frontend', apply_filters( 'wpuf_frontend_js_data', [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'error_message' => __( 'Please fix the errors to proceed', 'weforms' ),
'nonce' => wp_create_nonce( 'wpuf_nonce' ),
'word_limit' => __( 'Word limit reached', 'weforms' ),
] ) );
wp_localize_script( 'wpuf-form', 'error_str_obj', [
'required' => __( 'is required', 'weforms' ),
'mismatch' => __( 'does not match', 'weforms' ),
'validation' => __( 'is not valid', 'weforms' ),
'duplicate' => __( 'requires a unique entry and this value has already been used', 'weforms' ),
] );
wp_localize_script( 'wpuf-form', 'wpuf_frontend_upload', [
'confirmMsg' => __( 'Are you sure?', 'weforms' ),
'delete_it' => __( 'Yes, delete it', 'weforms' ),
'cancel_it' => __( 'No, cancel it', 'weforms' ),
'nonce' => wp_create_nonce( 'wpuf_nonce' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'plupload' => [
'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'wpuf-upload-nonce' ),
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
'filters' => [
[
'title' => __( 'Allowed Files', 'weforms' ),
'extensions' => '*',
],
],
'multipart' => true,
'urlstream_upload' => true,
'warning' => __( 'Maximum number of files reached!', 'weforms' ),
'size_error' => __( 'The file you have uploaded exceeds the file size limit. Please try again.', 'weforms' ),
'type_error' => __( 'You have uploaded an incorrect file type. Please try again.', 'weforms' ),
],
] );
}
/**
* Register scripts
*
* @param array $scripts
*
* @return void
*/
public function register_scripts( $scripts ) {
foreach ( $scripts as $handle => $script ) {
$deps = isset( $script['deps'] ) ? $script['deps'] : false;
$in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
wp_register_script( $handle, $script['src'], $deps, WEFORMS_VERSION, $in_footer );
}
}
/**
* Register styles
*
* @param array $styles
*
* @return void
*/
public function register_styles( $styles ) {
foreach ( $styles as $handle => $style ) {
$deps = isset( $style['deps'] ) ? $style['deps'] : false;
wp_register_style( $handle, $style['src'], $deps, WEFORMS_VERSION );
}
}
/**
* Enqueue the scripts
*
* @param array $scripts
*
* @return void
*/
public function enqueue_scripts( $scripts ) {
foreach ( $scripts as $handle => $script ) {
wp_enqueue_script( $handle );
}
}
/**
* Enqueue styles
*
* @param array $styles
*
* @return void
*/
public function enqueue_styles( $styles ) {
foreach ( $styles as $handle => $script ) {
wp_enqueue_style( $handle );
}
}
}