Localize - Pass data from PHP to JS
@param  $var - Define variable name used in JS file
@param  $handle - Specify script handle (optional)
@return boolean
513514
public function localize($var, $handle = null)
    {
        if(! isset($this->data) || ! $this->data || is_string($var) == false) {
            return false;
        }

        if($handle !== null) {
            $this->handle = $handle;
        }

        $this->var = $var;

        add_action( 'wp_enqueue_scripts', array($this, '_localize') );

        return true;
    }
667755
function pparse_plainHTML($handle){
    	if (!$this->loadfile($handle)) {
    		die("Template->pparse(): Impossible de charger le fichier template pour le modèle $handle");
    	}
    	
    	// actually compile the template now.
    	if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) {
    		// Actually compile the code now.
    		$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle],true);
    	}
    	return $this->compiled_code[$handle];
    	//return true;
    }
1131007
public function maybe_enqueue( $handle ) {
		if ( $this->is_registered( $handle ) ) {
			$enqueue = $this->get_enqueue_function();
			$enqueue( $handle );
			return true;
		}
		return false;
	}
524065
public function translate($params, &$smarty)
    {
        // All parameters other than 'l' and 'd' and 'js' are supposed to be variables. Build an array of var => value pairs
        // and pass it to the translator
        $vars = array();

        foreach ($params as $name => $value) {
            if (!in_array($name, $this->protectedParams)) {
                $vars["%$name"] = $value;
            }
        }

        $str = $this->translator->trans(
            $this->getParam($params, 'l'),
            $vars,
            $this->getParam($params, 'd', $this->defaultTranslationDomain),
            $this->getParam($params, 'locale', $this->defaultLocale),
            $this->getBoolean($this->getParam($params, 'default', true), true),
            $this->getBoolean($this->getParam($params, 'fallback', true), true)
        );

        if ($this->getParam($params, 'js', 0)) {
            $str = preg_replace("/(['\"])/", "\\\\$1", $str);
        }

        return $str;
    }
538233
public function _builded( $tag, $handle, $src ) {
		$handles = apply_filters( 'inc2734_wp_page_speed_optimization_builded_scripts', [] );

		if ( ! in_array( $handle, $handles ) ) {
			return $tag;
		}

		return sprintf(
			'<script>
			document.addEventListener("DOMContentLoaded", function(event) {
				var s=document.createElement("script");
				s.src="%s";
				s.async=true;document.body.appendChild(s);
			});
			</script>',
			$src
		);
	}
1202434
public static function fetchIDFromHandle($handle)
    {
        return Symphony::Database()->fetchVar('id', 0, sprintf(
            "SELECT `id`
            FROM `tbl_pages`
            WHERE `handle` = '%s'
            LIMIT 1",
            Symphony::Database()->cleanValue($handle)
        ));
    }
1272984
protected function hook($handle = NULL) {
        return \nb\Hook::pos(empty($handle) ? get_class($this) : $handle);
    }
1198291
public static function sendInteger($handle, $integer) {
        $buffer = self::_parseInteger($integer);
        return self::_writeToServer($handle, $buffer);
    }
1058618
public static function do($key, $vars=NULL) {
		
		$self = static::getInstance();
		$app  = Application::getInstance();
		
		// load translation strings
		$self->loadStrings();
		
		// search into strings
		if (array_key_exists($key, $self->strings) and $self->strings[$key]) {
			
			$string = $self->strings[$key];
			
		// search into strings of default language
		} else if (is_array($self->defaultStrings) and array_key_exists($key, $self->defaultStrings) and $self->defaultStrings[$key]) {
			
			$app->logWarning('Language string ' . $key . ' is untranslated for current language [' . $self->currentLocale->code . ']');
			$string = $self->defaultStrings[$key];
			
		// return the string constant, as debug info
		} else {
			
			$app->logWarning('Language string ' . $key . ' is untranslated');
			$string = '[' . $key . ']';
			
		}
		
		// vars is optional
		if (!is_null($vars)) {
			
			// force a single string to be the expected array
			if (!is_array($vars)) {
				$vars = array((string)$vars);
			}
			
			// binds of parameters on %s placeholders
			$string = vsprintf($string, $vars);
			
		}
		
		return $string;
		
	}
525156
protected function varExport($var, $indent = '')
    {
        switch (gettype($var)) {

            case 'string':
                return '"'.addcslashes($var, "\\\$\"\r\n\t\v\f").'"';

            case 'array':
                $indexed = array_keys($var) === range(0, count($var) - 1);

                $r = [];

                foreach ($var as $key => $value) {
                    $r[] = "$indent    "
                        .($indexed ? '' : $this->varExport($key).' => ')
                        .$this->varExport($value, "{$indent}    ");
                }

                return "[\n".implode(",\n", $r)."\n".$indent.']';

            case 'boolean':
                return $var ? 'true' : 'false';

            case 'integer':
            case 'double':
                return $var;

            default:
                return var_export($var, true);
        }
    }
351637
public static function setVar($name,$value){
		self::init();
		self::$variables[$name]=$value;
		return true;
		}
182218
public function value($handle = null, $default = '')
    {
        if ($handle && ! $this->get($handle)) {
            return $default;
        }

        if ($handle) {
            return $this->get($handle)->value ?: $this->defaultValue($handle);
        }

        return $this->setting->value ?: $this->setting->default;
    }
615927
protected function set_js_vars() {
		if ( ! is_array( $this->js_vars ) ) {
			$this->js_vars = [];
		}

		// Check if transport is set to auto.
		// If not, then skip the auto-calculations and exit early.
		if ( 'auto' !== $this->transport ) {
			return;
		}

		// Set transport to refresh initially.
		// Serves as a fallback in case we failt to auto-calculate js_vars.
		$this->transport = 'refresh';

		$js_vars = [];

		// Try to auto-generate js_vars.
		// First we need to check if js_vars are empty, and that output is not empty.
		if ( empty( $this->js_vars ) && ! empty( $this->output ) ) {

			// Start going through each item in the $output array.
			foreach ( $this->output as $output ) {
				$output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style';

				// If 'element' is not defined, skip this.
				if ( ! isset( $output['element'] ) ) {
					continue;
				}
				if ( is_array( $output['element'] ) ) {
					$output['element'] = implode( ',', $output['element'] );
				}

				// If there's a sanitize_callback defined skip this, unless we also have a js_callback defined.
				if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) {
					continue;
				}

				// If we got this far, it's safe to add this.
				$js_vars[] = $output;
			}

			// Did we manage to get all the items from 'output'?
			// If not, then we're missing something so don't add this.
			if ( count( $js_vars ) !== count( $this->output ) ) {
				return;
			}
			$this->js_vars   = $js_vars;
			$this->transport = 'postMessage';
		}
	}
436438
public function setGlobalVariable($variable = NULL, $value = NULL)
	{
		try {

			$result = FALSE;

			if (is_null($variable))
				throw new Exception("Global variable name not provided or is null", 503);

			if (is_null($value))
				throw new Exception("Global variable value not provided or is null", 503);

			$uri = "/asterisk/variable";
			$postData = array("variable" => $variable, "value" => $value);

			$this->ariEndpointOptions['json'] = $postData;
			$result = json_decode($this->ariEndpointClient->post($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents());

			return $result;

		} catch (\GuzzleHttp\Exception\RequestException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (\GuzzleHttp\Exception\ClientException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (\GuzzleHttp\Exception\ServerException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (Exception $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();

			return FALSE;
		}
	}
1066168
public function bind($variable, $callback = null)
    {
        $name = 'bind.'.$variable;

        // If callback pass, so put in a queue.
        if (! empty($callback)) {
            // Preparing callback in to queues.
            $this->events->listen($name, function() use ($callback, $variable) {
                return ($callback instanceof Closure) ? $callback() : $callback;
            });
        }

        // Passing variable to closure.
        $_events   =& $this->events;
        $_bindings =& $this->bindings;

        // Buffer processes to save request.
        return array_get($this->bindings, $name, function() use (&$_events, &$_bindings, $name) {
            $response = current($_events->fire($name));
            array_set($_bindings, $name, $response);
            return $response;
        });
    }
575765
public function wpEnqueueScript($handle, $src = '', $deps = [], $ver = false, $inFooter = false)
    {
        return $this->callGlobalFunction('wp_enqueue_script', [$handle, $src, $deps, $ver, $inFooter]);
    }
1364838
protected function maybe_localize( $dependency, $context ) {
		if ( ! array_key_exists( 'localize', $dependency ) ) {
			return;
		}

		$localize = $dependency['localize'];
		$data     = $localize['data'];
		if ( is_callable( $data ) ) {
			$data = $data( $context );
		}

		wp_localize_script( $dependency['handle'], $localize['name'], $data );
	}