Automator_Load::automator_closure_scripts()

Enqueue script


Source Source

File: src/class-automator-load.php

	public function automator_closure_scripts() {
		if ( ! is_user_logged_in() ) {
			return;
		}
		// check if there is a recipe and closure with publish status
		$check_closure = Automator()->db->closure->get_all();
		if ( empty( $check_closure ) ) {
			return;
		}
		$user_id   = wp_get_current_user()->ID;
		$api_setup = array(
			'root'              => esc_url_raw( rest_url() . AUTOMATOR_REST_API_END_POINT . '/uoa_redirect/' ),
			'nonce'             => wp_create_nonce( 'wp_rest' ),
			'user_id'           => $user_id,
			'client_secret_key' => md5( 'l6fsX3vAAiJbSXticLBd' . $user_id ),
		);
		wp_register_script( 'uoapp-client', Utilities::automator_get_js( 'uo-sseclient.js' ), array(), '2.1.0' ); //phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter
		wp_localize_script( 'uoapp-client', 'uoAppRestApiSetup', $api_setup );
		wp_enqueue_script( 'uoapp-client' );
	}