public function testFieldsCanBeUpdated() { $mockBuilder = m::mock('Illuminate\\Database\\Query\\Builder'); $mockBuilder->shouldReceive('update')->with(array('field1' => 'blah', 'field2' => 'blah'))->once(); $mockBuilder->shouldReceive('select', 'where')->atLeast()->once()->withAnyArgs()->andReturn($mockBuilder); $mockDb = $this->mock($mockBuilder, true); $obj = new Scaffold($mockDb, self::TEST_TABLE); $obj->addElements(array('field1' => array(), 'field2' => array())); $obj->update(array('field1' => 'blah', 'field2' => 'blah', 'column1' => '1', 'column2' => '2')); }
/** * Imports css via @import statements * @param $source Scaffold_Source * @param $scaffold Scaffold * @return void */ public function replace_rules($source, Scaffold $scaffold) { if ($rules = $this->find_rules($source->contents)) { foreach ($rules[1] as $key => $file) { if ($file = $source->find($file)) { $this->loaded[] = $file; # Use Scaffold to compile the inner CSS file $inner = $scaffold->compile(new Scaffold_Source_File($file)); # Replace the rule $source->contents = str_replace($rules[0][$key], $inner->contents, $source->contents); } } } }
public static function create_gradient($direction, $size, $from, $to, $stops = false) { if (!class_exists('GradientGD')) { include dirname(__FILE__) . '/libraries/gradientgd.php'; } $file = "{$direction}_{$size}_" . str_replace('#', '', $from) . "_" . str_replace('#', '', $to) . ".png"; if ($direction == 'horizontal') { $height = 50; $width = $size; $repeat = 'y'; } else { $height = $size; $width = 50; $repeat = 'x'; } if (!Scaffold_Cache::exists('gradients/' . $file)) { Scaffold_Cache::create('gradients'); $file = Scaffold_Cache::find('gradients') . '/' . $file; $gradient = new GradientGD($width, $height, $direction, $from, $to, $stops); $gradient->save($file); } $file = Scaffold_Cache::find('gradients') . '/' . $file; self::$gradients[] = array($direction, $size, $from, $to, $file); $properties = "\n\t\t\tbackground-position: top left;\n\t\t background-repeat: repeat-{$repeat};\n\t\t background-image: url(" . Scaffold::url_path($file) . ");\n\t\t"; return $properties; }
/** * Takes a CSS string, rewrites all URL's using Scaffold's built-in find_file method * * @author Anthony Short * @param $css * @return $css string */ public static function formatting_process() { # The absolute url to the directory of the current CSS file $dirPath = SCAFFOLD_DOCROOT . Scaffold::url_path(Scaffold::$css->path); $dir = rtrim(SCAFFOLD_URLPATH, '\\/') . '/' . str_replace(rtrim(SCAFFOLD_DOCROOT, '\\/') . DIRECTORY_SEPARATOR, '', Scaffold::$css->path); //$dir = str_replace('\\', '/', SCAFFOLD_URLPATH . str_replace(SCAFFOLD_DOCROOT, '', Scaffold::$css->path)); # @imports - Thanks to the guys from Minify for the regex :) if (preg_match_all('/ @import\\s+ (?:url\\(\\s*)? # maybe url( [\'"]? # maybe quote (.*?) # 1 = URI [\'"]? # maybe end quote (?:\\s*\\))? # maybe ) ([a-zA-Z,\\s]*)? # 2 = media list ; # end token /x', Scaffold::$css->string, $found)) { foreach ($found[1] as $key => $value) { # Should we skip it if (self::skip($value)) { continue; } $media = $found[2][$key] == "" ? '' : ' ' . preg_replace('/\\s+/', '', $found[2][$key]); # Absolute path $absolute = self::up_directory($dir, substr_count($url, '..' . DIRECTORY_SEPARATOR, 0)) . str_replace('..' . DIRECTORY_SEPARATOR, '', $url); $absolute = str_replace('\\', '/', $absolute); # Rewrite it # Webligo - PHP5.1 compat Scaffold::$css->string = str_replace($found[0][$key], '@import \'' . $absolute . '\'' . $media . ';', Scaffold::$css->string); } } # Convert all url()'s to absolute paths if required if (preg_match_all('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', Scaffold::$css->__toString(), $found)) { foreach ($found[1] as $key => $value) { // START - Webligo Developments $original = $found[0][$key]; $url = Scaffold_Utils::unquote($value); # Absolute Path if (self::skip($url)) { continue; } # home path if ($url[0] == '~' && $url[1] == '/') { $absolute = str_replace('\\', '/', rtrim(SCAFFOLD_URLPATH, '/\\') . '/' . ltrim($url, '~/')); $absolutePath = rtrim(SCAFFOLD_DOCROOT, '/\\') . DIRECTORY_SEPARATOR . ltrim($url, '~/'); } else { $absolute = str_replace('\\', '/', self::up_directory($dir, substr_count($url, '..' . DIRECTORY_SEPARATOR, 0)) . str_replace('..' . DIRECTORY_SEPARATOR, '', $url)); $absolutePath = self::up_directory($dirPath, substr_count($url, '..' . DIRECTORY_SEPARATOR, 0)) . str_replace('..' . DIRECTORY_SEPARATOR, '', $url); } # If the file doesn't exist if (!Scaffold::find_file($absolutePath)) { Scaffold::log("Missing image - {$absolute} / {$absolutePath}", 1); } # Rewrite it Scaffold::$css->string = str_replace($original, 'url(' . $absolute . ')', Scaffold::$css->string); # Webligo - PHP5.1 compat // END - Webligo Developments } } }
function Scaffold_image_replace_matrix($params) { if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) { foreach ($matches as $key => $original) { $new = str_replace(',', '#COMMA#', $original); $params = str_replace($original, $new, $params); } } $params = explode(',', $params); foreach (array('url', 'width', 'height', 'x', 'y') as $key => $name) { ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params))); } $url = preg_replace('/\\s+/', '', $url); $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url); if (!$x) { $x = 0; } if (!$y) { $y = 0; } $path = Scaffold::find_file($url); if ($path === false) { return false; } // Make sure theres a value so it doesn't break the css if (!$width && !$height) { $width = $height = 0; } // Build the selector $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat {$x}px {$y}px;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;"; return $properties; }
/** * Post Process. Needs to come after the nested selectors. * * @author Anthony Short * @param $css object * @return $css string */ public static function replace_flags($css) { if ($found = $css->find_at_group('flag', false)) { foreach ($found['groups'] as $group_key => $group) { $flags = explode(',', $found['flag'][$group_key]); # See if any of the flags are set foreach ($flags as $flag_key => $flag) { if (Scaffold::flag($flag)) { $parse = true; break; } else { $parse = false; } } if ($parse) { # Just remove the flag name, and it should just work. $css->string = str_replace($found['groups'][$group_key], $found['content'][$group_key], $css->string); } else { # Get it out of there, that flag isn't set! $css->string = str_replace($found['groups'][$group_key], '', $css->string); } } # Loop through the newly parsed CSS to look for more flags $css = self::replace_flags($css); } return $css; }
/** * Imports css via @import statements * * @author Anthony Short * @param $css */ public static function server_import($css, $base) { if (preg_match_all('/\\@include\\s+(?:\'|\\")([^\'\\"]+)(?:\'|\\")\\;/', $css, $matches)) { $unique = array_unique($matches[1]); $include = str_replace("\\", "/", Scaffold_Utils::unquote($unique[0])); # If they haven't supplied an extension, we'll assume its a css file if (pathinfo($include, PATHINFO_EXTENSION) == "") { $include .= '.css'; } # Make sure it's a CSS file if (pathinfo($include, PATHINFO_EXTENSION) != 'css') { $css = str_replace($matches[0][0], '', $css); Scaffold::log('Invalid @include file - ' . $include); self::server_import($css, $base); } # Find the file if ($path = Scaffold::find_file($include, $base)) { # Make sure it hasn't already been included if (!in_array($path, self::$loaded)) { self::$loaded[] = $path; $contents = file_get_contents($path); # Check the file again for more imports $contents = self::server_import($contents, realpath(dirname($path)) . '/'); $css = str_replace($matches[0][0], $contents, $css); } else { $css = str_replace($matches[0][0], '', $css); } } else { Scaffold::error('Can\'t find the @include file - <strong>' . $unique[0] . '</strong>'); } $css = self::server_import($css, $base); } return $css; }
public static function LoadConfig($config) { if (is_array($config) and !empty($config)) { self::$config = $config; return true; } return false; }
public function init() { $this->table_name = 'yaf_admin'; $this->primary = 'user_id'; $this->columns = array('user_name', 'remark'); $this->Scaffold = TRUE; parent::init(); }
/** * Constructor * * @author peshkov@UD */ public function __construct() { parent::__construct(); /** Handle screen option 'per page' */ add_filter('set-screen-option', array($this, 'set_per_page_option'), 10, 3); /** Init Administration Menu */ add_action('admin_menu', array($this, 'admin_menu'), 20); }
public function init() { $this->table_name = 'yaf_scaffold_config'; $this->primary = 'cid'; $this->columns = array('model_name', 'remark', 'table_primary', 'table_name', 'columns'); $this->Scaffold = TRUE; parent::init(); }
/** * Embeds a file in the CSS using Base64 * * @param $file * @return string */ function Scaffold_embed($file) { $path = Scaffold::find_file(Scaffold_Utils::unquote($file)); # Couldn't find it if ($path === false) { return false; } $data = 'data:image/' . pathinfo($path, PATHINFO_EXTENSION) . ';base64,' . base64_encode(file_get_contents($path)); return "url(" . $data . ")"; }
function test_Import() { $this->dir('Import'); $original = file_get_contents($this->dir() . 'in.css'); $expected = file_get_contents($this->dir() . 'out.css'); Scaffold::$current['file'] = $this->dir() . 'in.css'; Scaffold::add_include_path($this->dir()); $css = Import::import_process($original); $this->assertEqual($expected, $css); }
public static function display() { if (Scaffold::option('typography')) { # Make sure we're sending HTML header('Content-Type: text/html'); # Load the test suite markup Scaffold::view('scaffold_typography', true); exit; } }
public function __construct($itemCount, $page = 1) { $itemsPerPage = Scaffold::Config('items_per_page'); $this->itemsPerPage = $itemsPerPage !== null ? (int) max(1, $itemsPerPage) : 20; $this->itemCount = (int) max(0, $itemCount); $this->pageCount = ceil($this->itemCount / $this->itemsPerPage); $this->page = (int) min(max(1, $page), $this->pageCount); $this->previous = $this->page > 1 ? $this->page - 1 : false; $this->next = $this->page < $this->pageCount ? $this->page + 1 : false; $this->offset = ($this->page - 1) * $this->itemsPerPage; }
/** * Sets up the cache path * * @return return type */ public function setup($path, $lifetime) { if (!is_dir($path)) { Scaffold::log("Cache path does not exist. {$path}", 0); } if (!is_writable($path)) { Scaffold::log("Cache path is not writable. {$path}", 0); } self::$cache_path = $path; self::lifetime($lifetime); }
/** * */ public function __construct($args = array()) { parent::__construct($args); //echo "<pre>"; print_r( $args ); echo "</pre>"; die(); //** Set UD API URL. Can be defined custom one in wp-config.php */ $this->api_url = defined('UD_API_URL') ? trailingslashit(UD_API_URL) : 'https://www.usabilitydynamics.com/'; //** Don't ever change this, as it will mess with the data stored of which products are activated, etc. */ $this->token = 'udl_' . $this->slug; //** API */ $this->api = new API(array_merge($args, array('api_url' => $this->api_url, 'token' => $this->token))); //** Set available screens */ $screens = array(); if ($this->type == 'theme') { $screens = array_filter(array('licenses' => __('License', $this->domain), 'more_products' => false)); } elseif ($this->type == 'plugin') { $screens = array_filter(array('licenses' => __('Licenses', $this->domain), 'more_products' => __('More Products', $this->domain))); } //** UI */ $this->ui = new UI(array_merge($args, array('token' => $this->token, 'screens' => $screens))); $path = wp_normalize_path(dirname(dirname(__DIR__))); $this->screens_path = trailingslashit($path . '/static/templates'); if ($this->type == 'theme' && strpos($path, wp_normalize_path(WP_PLUGIN_DIR)) === false) { $root_path = wp_normalize_path(get_template_directory()); $this->assets_url = trailingslashit(get_template_directory_uri() . str_replace($root_path, '', $path) . '/static'); } else { $this->assets_url = trailingslashit(plugin_dir_url(dirname(dirname(__DIR__)) . '/readme.md') . 'static'); } //** Load the updaters. */ add_action('admin_init', array($this, 'load_updater_instances')); //** Ensure keys are actually active on specific screens */ add_action('current_screen', array($this, 'current_screen')); if ($this->type == 'plugin') { //** Check Activation Statuses */ add_action('plugins_loaded', array($this, 'check_activation_status'), 11); } elseif ($this->type == 'theme') { $this->check_activation_status(); } //** Add Licenses page */ add_action('admin_menu', array($this, 'register_licenses_screen'), 999); //** Admin Notices Filter */ add_filter('ud:errors:admin_notices', array($this, 'maybe_remove_notices')); add_filter('ud:messages:admin_notices', array($this, 'maybe_remove_notices')); add_filter('ud:warnings:admin_notices', array($this, 'maybe_remove_notices')); /** * May be add additional information about available add-ons * for legacy users ( who purchased any deprecated premium feature ) */ add_action('ud::bootstrap::upgrade_notice::additional_info', array($this, 'maybe_add_info_to_upgrade_notice'), 10, 2); }
function testHeaders() { $files = array('/unit_tests/_files/HTTP/standard.css'); $options = array(); $this->loadConfig(); $result = Scaffold::parse($files, $this->config, $options, true); $this->assertNotNull($result['headers']['Expires']); $this->assertNotNull($result['headers']['Cache-Control']); $this->assertNotNull($result['headers']['Content-Type']); $this->assertNotNull($result['headers']['Last-Modified']); $this->assertNotNull($result['headers']['Content-Length']); $this->assertNotNull($result['headers']['ETag']); // Make sure the content length is set $this->assertNotEqual(strlen($result['headers']['Content-Length']), 0); }
public static function generate(array $variables, $connection, $destination) { self::$variables = $variables; self::$connection = $connection; self::$destination = $destination; if (!self::controller()) { return false; } if (!self::model()) { return false; } if (!self::views()) { return false; } return true; }
/** * Takes a CSS string, rewrites all URL's using Scaffold's built-in find_file method * * @author Anthony Short * @param $css * @return $css string */ public static function formatting_process() { # The absolute url to the directory of the current CSS file $dir = Scaffold::url_path(Scaffold::$css->path); # @imports - Thanks to the guys from Minify for the regex :) if (preg_match_all('/ @import\\s+ (?:url\\(\\s*)? # maybe url( [\'"]? # maybe quote (.*?) # 1 = URI [\'"]? # maybe end quote (?:\\s*\\))? # maybe ) ([a-zA-Z,\\s]*)? # 2 = media list ; # end token /x', Scaffold::$css, $found)) { foreach ($found[1] as $key => $value) { # Should we skip it if (self::skip($value)) { continue; } $media = $found[2][$key] == "" ? '' : ' ' . preg_replace('/\\s+/', '', $found[2][$key]); # Absolute path $absolute = self::up_directory($dir, substr_count($value, '..' . DIRECTORY_SEPARATOR, 0)) . str_replace('..' . DIRECTORY_SEPARATOR, '', $value); # Rewrite it Scaffold::$css->string = str_replace($found[0][$key], '@import \'' . $absolute . '\'' . $media . ';', Scaffold::$css); } } # Convert all url()'s to absolute paths if required if (preg_match_all('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', Scaffold::$css, $found)) { foreach ($found[1] as $key => $value) { $url = Scaffold_Utils::unquote($value); # Absolute Path if (self::skip($url)) { continue; } # Absolute path $absolute = self::up_directory($dir, substr_count($url, '..' . DIRECTORY_SEPARATOR, 0)) . str_replace('..' . DIRECTORY_SEPARATOR, '', $url); # If the file doesn't exist if (!Scaffold::find_file($absolute)) { Scaffold::log("Missing image - {$absolute}", 1); } # Rewrite it Scaffold::$css->string = str_replace($found[0][$key], 'url(' . $absolute . ')', Scaffold::$css); } } }
public static function create_rgba($r, $g, $b, $a) { if (!class_exists('RgbaGd')) { include dirname(__FILE__) . '/libraries/rgbagd.php'; } $file = "color_r{$r}_g{$g}_b{$b}_a{$a}.png"; $alpha = intval(127 - 127 * $a); if (!Scaffold_Cache::exists('rgba/' . $file)) { Scaffold_Cache::create('rgba'); $file = Scaffold_Cache::find('rgba') . '/' . $file; $rgba = new RgbaGd($r, $g, $b, $alpha); $rgba->save($file); } $file = Scaffold_Cache::find('rgba') . '/' . $file; self::$rgba[] = array($r, $g, $b, $alpha); $properties = "\n\t\t\tbackground-position: top left;\n\t\t background-repeat: repeat;\n\t\t background-image: url(" . Scaffold::url_path($file) . ") !important;\n\t\t background-image:none;\n\t\t background: rgba({$r},{$g},{$b},{$a});\n\t\t filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" . Scaffold::url_path($file) . ", sizingMethod=scale);\n\t\t"; return $properties; }
/** * Adds the image-replace property that allows you to automatically * replace text with an image on your server. * * Because functions can't have - in their name, it is replaced * with an underscore. The property name is still image-replace * * @author Anthony Short * @param $url * @return string */ function Scaffold_image_replace($url) { $url = preg_replace('/\\s+/', '', $url); $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url); $path = Scaffold::find_file($url); if ($path === false) { return false; } // Get the size of the image file $size = GetImageSize($path); $width = $size[0]; $height = $size[1]; // Make sure theres a value so it doesn't break the css if (!$width && !$height) { $width = $height = 0; } // Build the selector $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat 0 0;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;"; return $properties; }
/** * Adds the image-width property that allows you to automatically * obtain the width of a image * * Because functions can't have - in their name, it is replaced * with an underscore. The property name is still image-width * * @author Kirk Bentley * @param $url * @return string */ function Scaffold_image_width($url, $w = false) { $url = preg_replace('/\\s+/', '', $url); $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url); $path = Scaffold::find_file($url); if ($path === false) { return false; } // Get the width of the image file $size = GetImageSize($path); $width = $size[0]; if ($w == '50%') { $width = $width * 0.5; } // Make sure theres a value so it doesn't break the css if (!$width) { $width = 0; } return $width; }
/** * Constructor * Attention: MUST NOT BE CALLED DIRECTLY! USE get_instance() INSTEAD! * * @author peshkov@UD */ protected function __construct($args) { parent::__construct($args); //** Define our Admin Notices handler object */ $this->errors = new Errors($args); //** Determine if Composer autoloader is included and modules classes are up to date */ $this->composer_dependencies(); //** Determine if plugin/theme requires or recommends another plugin(s) */ $this->plugins_dependencies(); // Maybe run install or upgrade processes. $this->maybe_run_upgrade_process(); //** Set install/upgrade pages if needed */ $this->define_splash_pages(); //** Maybe need to show UD splash page. Used static functions intentionaly. */ if (!has_action('admin_init', array(Dashboard::get_instance(), 'maybe_ud_splash_page'))) { add_action('admin_init', array(Dashboard::get_instance(), 'maybe_ud_splash_page')); } if (!has_action('admin_menu', array(Dashboard::get_instance(), 'add_ud_splash_page'))) { add_action('admin_menu', array(Dashboard::get_instance(), 'add_ud_splash_page')); } }
/** * Adds the image-width property that allows you to automatically * obtain the height of a image * * Because functions can't have - in their name, it is replaced * with an underscore. The property name is still image-height * * @author Kirk Bentley * @param $url * @return string */ function Scaffold_image_height($url, $h = false) { $url = preg_replace('/\\s+/', '', $url); $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url); $h = trim($h); $path = Scaffold::find_file($url); if ($path === false) { return false; } // Get the width of the image file $size = GetImageSize($path); $height = $size[1]; if ($h == '50%') { $height = $height * 0.5; } // Make sure theres a value so it doesn't break the css if (!$height) { $height = 0; } return $height; }
public static function display() { if (Scaffold::option('validate')) { # Get the validator options from the config $validator_options = Scaffold::$config['Validate']['options']; # Add our options $validator_options['text'] = Scaffold::$output; $validator_options['output'] = 'soap12'; # Encode them $validator_options = http_build_query($validator_options); $url = "http://jigsaw.w3.org/css-validator/validator?{$validator_options}"; # The Curl options $options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1); # Start CURL $handle = curl_init(); curl_setopt_array($handle, $options); $buffer = curl_exec($handle); curl_close($handle); # If something was returned if (!empty($buffer)) { # Simplexml doesn't like colons $buffer = preg_replace("/(<\\/?)(\\w+):([^>]*>)/", "\$1\$2\$3", $buffer); # Let it be xml! $results = simplexml_load_string($buffer); $is_valid = (string) $results->envBody->mcssvalidationresponse->mvalidity; # Oh noes! Display the errors if ($is_valid == "false") { $errors = $results->envBody->mcssvalidationresponse->mresult->merrors; foreach ($errors->merrorlist->merror as $key => $error) { $line = (string) $error->mline; $message = trim((string) $error->mmessage); $near = (string) $error->mcontext; self::$errors[] = array('line' => $line, 'near' => $near, 'message' => $message); Scaffold::log("Validation Error on line {$line} near {$near} => {$message}", 1); } } } } }
/** * Adds the image-replace property that allows you to automatically * replace text with an image on your server. * * Because functions can't have - in their name, it is replaced * with an underscore. The property name is still image-holder-position * * @author Kirk Bentley * @param $url * @param $x - x position * @param $y - y position * @return string */ function Scaffold_image_holder_position($params) { if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) { foreach ($matches as $key => $original) { $new = str_replace(',', '#COMMA#', $original); $params = str_replace($original, $new, $params); } } $params = explode(',', $params); foreach (array('url', 'x', 'y') as $key => $name) { ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params))); } $url = preg_replace('/\\s+/', '', $url); $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url); $path = Scaffold::find_file($url); if ($path === false) { return false; } // Get the size of the image file $size = GetImageSize($path); $width = $size[0]; $height = $size[1]; // Make sure theres a value so it doesn't break the css if (!$width && !$height) { $width = $height = 0; } $left = $x; if ($x == '50%') { $left = -$width * 0.5; } $top = $y; if ($y == '50%') { $top = -$height * 0.5; } // Build the selector $properties = "top:{$top}px;\n\t\tleft:{$left}px;"; return $properties; }
/** * */ public function __construct($args = array()) { global $_ud_license_updater; parent::__construct($args); //** Maybe get queued theme update */ if ($this->type == 'theme') { $this->maybe_get_queued_theme_update(); } elseif ($this->type == 'plugin') { add_action('plugins_loaded', array($this, 'load_queued_updates'), 10); } $_ud_license_updater = !is_array($_ud_license_updater) ? array() : $_ud_license_updater; $_ud_license_updater[$this->slug] = $this; //** Load the admin. */ if (is_admin()) { $this->admin = new Admin($args); } /** * HACK. * Filter the whitelist of hosts to redirect to. * It adds Admin URL ( in case it's different with home or site urls ) * to allowed list. * * @param array $hosts An array of allowed hosts. * @param bool|string $host The parsed host; empty if not isset. */ add_filter('allowed_redirect_hosts', function ($hosts, $host) { if (!is_array($hosts)) { $hosts = array(); } $schema = parse_url(admin_url()); if (isset($schema['host'])) { array_push($hosts, $schema['host']); $hosts = array_unique($hosts); } return $hosts; }, 99, 2); }
/** * Sets flags for different times of the day * * @author Anthony Short * @return void */ public static function flag() { $now = time() + 60 * 60 * Scaffold::$config['Time']['offset']; self::set_current_time($now); $condition_types = array_keys(self::$types); foreach (Scaffold::$config['Time']['flags'] as $flag_name => $conditions) { foreach ($condition_types as $check) { if (!isset($conditions[$check])) { continue; } if (is_array($conditions[$check])) { $result[] = self::is_between($conditions[$check]['from'], $conditions[$check]['to'], $check, $now); } else { $result[] = $conditions[$check] == self::$current[$check] ? true : false; } } # It met all the conditions! Set the flag me hearties! if (array_search(false, $result) === false) { Scaffold::flag_set($flag_name); } # Reset the results array $result = array(); } }
/** * */ public function __construct($args) { parent::__construct($args); add_action('admin_notices', array($this, 'admin_notices')); add_action('admin_head', array($this, 'dismiss')); }