Exemple #1
0
 public static function init($pluginbuddy_settings, $pluginbuddy_init = 'init.php')
 {
     self::$start_time = microtime(true);
     self::$_settings = array_merge((array) self::$_settings, (array) $pluginbuddy_settings);
     // Merge settings over framework defaults.
     // Set up various path variables.
     self::$_plugin_path = dirname(dirname(__FILE__));
     $relative_path = ltrim(str_replace('\\', '/', str_replace(rtrim(ABSPATH, '\\\\/'), '', self::$_plugin_path)), '\\\\/');
     self::$_plugin_url = site_url() . '/' . ltrim($relative_path, '/');
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         self::$_plugin_url = str_replace('http://', 'https://', self::$_plugin_url);
     }
     // Handle https URLs properly.
     if (isset($_GET['page'])) {
         // If in an admin page then append page querystring.
         self::$_self_link = array_shift(explode('?', $_SERVER['REQUEST_URI'])) . '?page=' . htmlentities($_GET['page']);
     }
     // Set the init file.
     self::$_settings['init'] = $pluginbuddy_init;
     // Removed. see add_page(). Now using create_function() to bypass need for this. self::$_callbacks = new pluginbuddy_callbacks();
     // Load thumbnail live downsizer if needed.
     if (isset(self::$_settings['modules']['downsizer']) && self::$_settings['modules']['downsizer'] === true) {
         require_once self::$_plugin_path . '/pluginbuddy/_image_downsize.php';
     }
     // filesystem class controller.
     if (isset(self::$_settings['modules']['filesystem']) && self::$_settings['modules']['filesystem'] === true) {
         self::init_class_controller('filesystem');
     }
     // format class controller.
     if (isset(self::$_settings['modules']['format']) && self::$_settings['modules']['format'] === true) {
         self::init_class_controller('format');
     }
     if (is_admin()) {
         // Load automatic upgrades system if needed.
         if (isset(self::$_settings['modules']['updater']) && self::$_settings['modules']['updater'] === true) {
             require_once self::$_plugin_path . '/pluginbuddy/lib/updater/updater.php';
             $preloader_class = 'pb_' . self::settings('slug') . '_updaterpreloader';
             $updater_preloader = new $preloader_class(self::settings('slug'));
         }
         // Load UI system.
         self::init_class_controller('ui');
         // Load media library system if needed.
         if (isset(self::$_settings['modules']['media_library']) && self::$_settings['modules']['media_library'] === true) {
             self::add_ajax('media_library');
         }
         // Add troubleshooting sending system.
         self::add_ajax('pbframework_troubleshooting');
         // Load activation hook if in admin and activation file exists.
         if (file_exists(self::$_plugin_path . '/controllers/activation.php')) {
             register_activation_hook(self::$_plugin_path . '/' . pb_backupbuddy::settings('init'), create_function('', "require_once('" . self::$_plugin_path . "/controllers/activation.php');"));
             // Run some code when plugin is activated in dashboard.
         }
     } else {
         // Public side.
         // Do nothing.
     }
 }
 public static function init($pluginbuddy_settings, $pluginbuddy_init = 'init.php')
 {
     self::$start_time = microtime(true);
     self::$_settings = array_merge((array) self::$_settings, (array) $pluginbuddy_settings);
     // Merge settings over framework defaults.
     if (function_exists('plugin_dir_url')) {
         // URL and path functions available (not in ImportBuddy but inside WordPress).
         self::$_plugin_path = rtrim(plugin_dir_path(dirname(__FILE__)), '/\\');
         self::$_plugin_url = rtrim(plugin_dir_url(dirname(__FILE__)), '/\\');
     } else {
         // Generate URL and paths old way (old WordPress versions or inside ImportBuddy).
         self::$_plugin_path = dirname(dirname(__FILE__));
         $relative_path = ltrim(str_replace('\\', '/', str_replace(rtrim(ABSPATH, '\\\\/'), '', self::$_plugin_path)), '\\\\/');
         if (defined('PB_STANDALONE') && PB_STANDALONE === true) {
             self::$_plugin_url = 'importbuddy';
             // Relative importbuddy path.
         } else {
             // Normal full path.
             self::$_plugin_url = site_url() . '/' . ltrim($relative_path, '/');
             if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
                 // Handle https URLs properly.
                 self::$_plugin_url = str_replace('http://', 'https://', self::$_plugin_url);
             }
         }
     }
     if (isset($_GET['page'])) {
         // If in an admin page then append page querystring.
         $arr = explode('?', $_SERVER['REQUEST_URI']);
         // avoid reference error by setting here.
         self::$_self_link = array_shift($arr) . '?page=' . htmlentities($_GET['page']);
         unset($arr);
     }
     // Set the init file.
     self::$_settings['init'] = $pluginbuddy_init;
     // filesystem class controller.
     if (isset(self::$_settings['modules']['filesystem']) && self::$_settings['modules']['filesystem'] === true) {
         self::init_class_controller('filesystem');
     }
     // format class controller.
     if (isset(self::$_settings['modules']['format']) && self::$_settings['modules']['format'] === true) {
         self::init_class_controller('format');
     }
     if (is_admin()) {
         // Load UI system.
         self::init_class_controller('ui');
         // Load activation hook if in admin and activation file exists.
         if (file_exists(self::$_plugin_path . '/controllers/activation.php')) {
             $escaped_plugin_path = preg_replace('#^\\\\\\\\#', '\\\\\\\\\\\\\\\\', self::$_plugin_path);
             // Replace a path starting with \\ to be \\\\ so that when create_function parses the backslash it will return back to \\.
             register_activation_hook(self::$_plugin_path . '/' . pb_backupbuddy::settings('init'), create_function('', "require_once('" . $escaped_plugin_path . "/controllers/activation.php');"));
             // Run some code when plugin is activated in dashboard.
         }
     } else {
         // Public side.
         // Do nothing.
     }
 }