/** * Generate CSS markup for this style's dynamic rules * * @return string */ public function export() { // the markup that will be returned $markup = parent::export(); // render rules if ($this->rules->count()) { // get markup for each rule foreach ($this->rules->to_array() as $rule) { // append output of rule export $markup .= '/*+++ generating style ***/' . PHP_EOL; $markup .= $rule->export(); $markup .= '/*--- style generation complete! */' . PHP_EOL . PHP_EOL; } } // all done return $markup; }
/** * Inject internal scripts into script directives * * @internal * @param ICE_Map $script_defs */ private function setup_internal_scripts(ICE_Map $script_defs) { // map of scripts and script depends $script = new ICE_Map(); // get export $export_script = $this->scheme->exports()->get('scripts'); // build up array of exports if (is_admin()) { $exports['dynamic-admin'] = $export_script->child('admin'); } else { $exports['dynamic'] = $export_script; } // add internal script for every export foreach ($exports as $handle => $export) { $script->add($handle, $export->url); } // any scripts to add? if ($script->count()) { // add directive $directive = new ICE_Init_Directive('@', 'script', $script); $script_defs->add('@', $directive, true); } // hook up scripts internal handler add_action('ice_enqueue_scripts', array($this, 'handle_script_internal')); }
/** * One time initialization helper * * @param string $base_theme * @return ICE_Scheme */ public function init($base_theme) { // do not init same scheme twice if ($this->base_theme) { return; } // set base theme $this->base_theme = $base_theme; // is there at least one compiled themes? if ($this->themes_compiled->count() >= 1) { // copy all compiled themes $compiled = $this->themes_compiled->to_array(); // use highest ancestor $this->root_theme = key($compiled); } else { // no compiled theme, root is template $this->root_theme = get_template(); } // load it $this->load(); // add filters $this->add_filters(); // run theme feature support helper $this->feature_support(); // some scheme initializations must occur after WP theme setup add_action('after_setup_theme', array($this, 'init_enqueueing')); add_action('after_setup_theme', array($this, 'load_functions')); add_action('ice_enqueue_styles', array($this, 'exports_refresh'), 0); add_action('ice_enqueue_scripts', array($this, 'exports_refresh'), 0); return $this; }
/** * Returns true if this asset has any sections * * @return boolean */ public final function has_sections() { return $this->sections->count(); }
/** * Export all variables * * @param boolen $object Set to true to return as an object */ public function export_variables($object = false) { // skip if no variables if (!$this->variables->count()) { return null; } // formatted variable statements $vars = array(); // add each variable foreach ($this->variables->to_array() as $name => $value) { // format the var switch (true) { case is_numeric($value): $vars[$name] = $value; break; case is_bool($value): $vars[$name] = $value ? 'true' : 'false'; break; case is_null($value): $vars[$name] = 'null'; break; case is_string($value): $vars[$name] = sprintf("'%s'", $value); break; case is_array($value): $vars[$name] = sprintf("['%s']", implode("','", $value)); break; } } // assignment operator $operator = $object ? ':' : '='; // formatted var expressions $vars_f = array(); // loop all vars and format them foreach ($vars as $var_name => $var_val) { // object properties must be quoted if ($object) { $var_name = sprintf("'%s'", $var_name); } // push onto array array_push($vars_f, $var_name . $operator . $var_val); } // return complete expression if ($object) { return sprintf('{%s}', implode(',', $vars_f)); } else { return sprintf('var %s;', implode(',', $vars_f)); } }
/** * Update the export file * * @return boolean */ public function update() { // result is null by default $data = null; // have a callback if ($this->callback) { // have a callback, make sure its callable if (is_callable($this->callback)) { // execute it $data .= call_user_func($this->callback); } } else { // loop stack and append result of export method of each foreach ($this->stack as $exportable) { /* @var $exportable ICE_Exportable */ $data .= $exportable->export(); } } // any result? if (empty($data)) { // no content to write, empty it $this->write(); } else { // write it! $this->write($data); } // now try to update my children if ($this->children->count()) { // loop all and call update foreach ($this->children as $child) { $child->update(); } } }