/** * Settings object constructor * * If no settings are available (the table doesn't exist), * the unavailable flag is set. * * @since 1.0 * @version 1.1 **/ private function __construct() { $this->_table = $this->tablename(self::$table); $this->bootup = ShoppLoader::is_activating(); if ($this->bootup) { add_action('shopp_init', array($this, 'booted')); } }
/** * Setup path related constants * * @author Jonathan Davis * @since 1.3 * * @return void **/ public function paths() { // This should only run once if (defined('SHOPP_PATH')) { return; } $filepath = dirname(ShoppLoader::basepath()) . "/Shopp.php"; $path = sanitize_path(dirname($filepath)); $file = basename($filepath); $directory = basename($path); // Paths define('SHOPP_PATH', $path); define('SHOPP_DIR', $directory); define('SHOPP_PLUGINFILE', "{$directory}/{$file}"); define('SHOPP_PLUGINURI', set_url_scheme(plugins_url() . "/{$directory}")); define('SHOPP_ADMIN_DIR', '/core/ui'); define('SHOPP_ADMIN_PATH', SHOPP_PATH . SHOPP_ADMIN_DIR); define('SHOPP_ADMIN_URI', SHOPP_PLUGINURI . SHOPP_ADMIN_DIR); define('SHOPP_ICONS_URI', SHOPP_ADMIN_URI . '/icons'); define('SHOPP_FLOW_PATH', SHOPP_PATH . '/core/flow'); define('SHOPP_MODEL_PATH', SHOPP_PATH . '/core/model'); define('SHOPP_GATEWAYS', SHOPP_PATH . '/gateways'); define('SHOPP_SHIPPING', SHOPP_PATH . '/shipping'); define('SHOPP_STORAGE', SHOPP_PATH . '/storage'); define('SHOPP_THEME_APIS', SHOPP_PATH . '/api/theme'); // @deprecated define('SHOPP_DBSCHEMA', SHOPP_PATH . '/core/schema/schema.sql'); }
public function add($handle, $src, $deps = array(), $ver = false, $args = null) { $debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG; // Determine if we are debugging the scripts if (isset($_GET['debug']) && 1 == $_GET['debug']) { $debug = true; } $extension = '.js'; // Use .js extension for script files $suffix = '.min'; // Use .min for suffix $minsrc = str_replace($extension, $suffix . $extension, $src); // Add the suffix when not debugging and the suffix isn't already used (the file is not available unminified) if (!$debug && false === strpos($src, $suffix . $extension) && file_exists(ShoppLoader::basepath() . $minsrc)) { $src = $minsrc; } return parent::add($handle, $src, $deps, $ver, $args); }
if (!defined('WPINC')) { define('WPINC', 'wp-includes'); } date_default_timezone_set('UTC'); } $ShoppScripts = new ShoppScripts(); shopp_default_scripts($ShoppScripts); $compress = isset($_GET['c']) && $_GET['c']; $force_gzip = $compress && 'gzip' == $_GET['c']; $expires_offset = 31536000; $out = ''; foreach ($load as $handle) { if (!isset($ShoppScripts->registered[$handle])) { continue; } $path = ShoppLoader::basepath() . $ShoppScripts->registered[$handle]->src; $out .= get_file($path) . "\n"; } header('Content-Type: application/x-javascript; charset=UTF-8'); header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $expires_offset) . ' GMT'); header("Cache-Control: public, max-age={$expires_offset}"); if ($compress && !ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler')) { header('Vary: Accept-Encoding'); // Handle proxies if (false !== strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && !$force_gzip) { header('Content-Encoding: deflate'); $out = gzdeflate($out, 3); } elseif (false !== strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode')) { header('Content-Encoding: gzip'); $out = gzencode($out, 3); }
/** * Activates a specified module * * @author Jonathan Davis * @since 1.3 * * @param string $module The module file class/package name * @return Object The activated module object or false if it failed to load **/ public function activate($module) { $ModuleFile = $this->module($module); if (false === $ModuleFile) { return false; } if ($ModuleFile->modified()) { unset($this->modules[$module], $this->active[$module]); $this->recache(); $ModuleFile = new ModuleFile($ModuleFile->file); if (false === $ModuleFile) { return false; } $module = $ModuleFile->classname; $this->modules[$module] = $ModuleFile; } ShoppLoader::add($module, $ModuleFile->file); $Module = $ModuleFile->load(); if (false === $Module) { return false; } $this->active[$module] = $Module; return $this->active[$module]; }
require "{$path}/core/library/Loader.php"; } // Barebones bootstrap (say that 5x fast) for WordPress if (!defined('ABSPATH') && ($loadfile = ShoppLoader::find_wpload())) { require $loadfile; global $table_prefix; } // Stub i18n for compatibility if (!function_exists('__')) { // Localization API is not available at this point function __($string, $domain = false) { return $string; } } ShoppDeveloperAPI::load(dirname(ShoppLoader::basepath()), array('core', 'settings')); // Start the server new ImageServer(); exit; /** * ImageServer class * * @author Jonathan Davis * @since 1.1 * @package image **/ class ImageServer { static $prettyurls = '{^/.+?/images/(\\d+)/.*$}'; private $caching = true; // Set to false to force off image caching
/** * Recursively scan files in the base path to add to the classmap * * @author Jonathan Davis * @since 1.3 * * @param string $class The name of the class to load * @param string $path (optional) The path to scan. Uses the basepath of the loader by default. * @return boolean True if succesful, false otherwise **/ protected function scanner($class, $path = '') { if (empty($path)) { $path = self::$basepath; } $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($objects as $name => $object) { $this->scanfile($name, $path); } self::$scanned = true; // Flag file system scan done (so it only ever runs once) if ($this->classmap($class)) { return true; } return false; }
/** * Adds a maintenance mode notice to every admin screen * * @since 1.3 * * @return void **/ public function maintenance() { if (ShoppLoader::is_activating() || Shopp::upgradedb()) { return; } $setting = isset($_POST['settings']['maintenance']) ? $_POST['settings']['maintenance'] : false; $nonce = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : false; if (false !== $setting && wp_verify_nonce($nonce, 'shopp-setup')) { shopp_set_setting('maintenance', $setting); } if (!Shopp::maintenance()) { return; } if (wp_verify_nonce($this->request('_wpnonce'), 'shopp_disable_maintenance')) { shopp_set_setting('maintenance', 'off'); } else { $url = wp_nonce_url(add_query_arg('page', ShoppAdmin::pagename('settings'), admin_url('admin.php')), 'shopp_disable_maintenance'); $this->Screen->notice(Shopp::__('Shopp is currently in maintenance mode. %sDisable Maintenance Mode%s', '<a href="' . $url . '" class="button">', '</a>'), 'error', 1); } }
/** * Handles maintenance mode messages **/ private function maintenance() { if (ShoppLoader::is_activating() || Shopp::upgradedb()) { return; } if (isset($_POST['settings']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'shopp-setup')) { if (isset($_POST['settings']['maintenance'])) { shopp_set_setting('maintenance', $_POST['settings']['maintenance']); } } if (Shopp::maintenance()) { if (isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'shopp_disable_maintenance')) { shopp_set_setting('maintenance', 'off'); } else { $url = wp_nonce_url(add_query_arg('page', $this->Admin->pagename('setup'), admin_url('admin.php')), 'shopp_disable_maintenance'); $this->notice(Shopp::__('Shopp is currently in maintenance mode. %sDisable Maintenance Mode%s', '<a href="' . $url . '" class="button">', '</a>'), 'error', 1); } } }