示例#1
0
 /**
  * Finishes clone operation
  *
  * @subcommand finish-restore-site
  *
  * @when before_wp_load
  *
  */
 public function finishRestore($args, $assoc_args)
 {
     define('SHORTINIT', true);
     $wpConfigPath = \WP_CLI\Utils\locate_wp_config();
     require_once $wpConfigPath;
     require ABSPATH . WPINC . '/formatting.php';
     require ABSPATH . WPINC . '/link-template.php';
     require ABSPATH . WPINC . '/shortcodes.php';
     require ABSPATH . WPINC . '/taxonomy.php';
     wp_plugin_directory_constants();
     require_once WP_PLUGIN_DIR . '/versionpress/bootstrap.php';
     $versionPressContainer = DIContainer::getConfiguredInstance();
     /** @var ActionsDefinitionRepository $actionsDefinitionRepository */
     $actionsDefinitionRepository = $versionPressContainer->resolve(VersionPressServices::ACTIONS_DEFINITION_REPOSITORY);
     $actionsDefinitionRepository->restoreAllDefinitionFilesFromHistory();
     // Truncate tables
     /** @var Database $database */
     $database = $versionPressContainer->resolve(VersionPressServices::DATABASE);
     /** @var DbSchemaInfo $dbSchema */
     $dbSchema = $versionPressContainer->resolve(VersionPressServices::DB_SCHEMA);
     $tables = array_map(function ($entityName) use($dbSchema) {
         return $dbSchema->getPrefixedTableName($entityName);
     }, array_merge($dbSchema->getAllEntityNames(), array_map(function ($referenceDetails) {
         return $referenceDetails['junction-table'];
     }, $dbSchema->getAllMnReferences())));
     $tables = array_filter($tables, function ($table) use($database) {
         return $table !== $database->options;
     });
     foreach ($tables as $table) {
         $truncateCmd = "TRUNCATE TABLE `{$table}`";
         @$database->query($truncateCmd);
         // Intentional @ - not existing table is ok for us but TRUNCATE ends with error
     }
     // Create VersionPress tables
     /** @var \VersionPress\Initialization\Initializer $initializer */
     $initializer = $versionPressContainer->resolve(VersionPressServices::INITIALIZER);
     $initializer->createVersionPressTables();
     WP_CLI::success("VersionPress tables created");
     // Install Custom merge driver
     MergeDriverInstaller::installMergeDriver(VP_PROJECT_ROOT, VERSIONPRESS_PLUGIN_DIR, VP_VPDB_DIR);
     WP_CLI::success("Git merge driver added");
     // Run synchronization
     /** @var SynchronizationProcess $syncProcess */
     $syncProcess = $versionPressContainer->resolve(VersionPressServices::SYNCHRONIZATION_PROCESS);
     $syncProcess->synchronizeAll();
     WP_CLI::success("Database synchronized");
     VPCommandUtils::runWpCliCommand('vp-internal', 'flush-regenerable-values', ['require' => __FILE__]);
 }
示例#2
0
require ABSPATH . WPINC . '/cron.php';
require ABSPATH . WPINC . '/deprecated.php';
require ABSPATH . WPINC . '/script-loader.php';
require ABSPATH . WPINC . '/taxonomy.php';
require ABSPATH . WPINC . '/update.php';
require ABSPATH . WPINC . '/canonical.php';
require ABSPATH . WPINC . '/shortcodes.php';
require ABSPATH . WPINC . '/class-wp-embed.php';
require ABSPATH . WPINC . '/media.php';
//require( ABSPATH . WPINC . '/http.php' );
//require( ABSPATH . WPINC . '/class-http.php' );
require ABSPATH . WPINC . '/widgets.php';
//require( ABSPATH . WPINC . '/nav-menu.php' );
//require( ABSPATH . WPINC . '/nav-menu-template.php' );
//require( ABSPATH . WPINC . '/admin-bar.php' );
wp_plugin_directory_constants();
require 'calendarize-it.php';
// Load pluggable functions.
require ABSPATH . WPINC . '/pluggable.php';
require ABSPATH . WPINC . '/pluggable-deprecated.php';
do_action('plugins_loaded');
$GLOBALS['wp_the_query'] = new WP_Query();
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
$GLOBALS['wp'] = new WP();
$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
$GLOBALS['wp_roles'] = new WP_Roles();
do_action('setup_theme');
do_action('after_setup_theme');
//$GLOBALS['wp']->init();
do_action('init');
示例#3
0
 /**
  * Returns path to the plugin's directory. If `$file` is provided
  * than is appended to the end of the path.
  *
  * @since 0.1.3
  * @param string $file (Optional).
  * @return string
  */
 public function get_path($file = '')
 {
     if (!defined('WP_PLUGIN_DIR')) {
         wp_plugin_directory_constants();
     }
     // TODO There is probably better constant than WP_CONTENT_DIR!
     $path = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $this->id;
     if (!empty($file)) {
         $path .= DIRECTORY_SEPARATOR . $file;
     }
     return $path;
 }
 /**
  * Include only the WP files needed
  *
  * This brilliant piece of code (cough) is from the dsIDXpress plugin.
  *
  * @since 1.3
  */
 function bootstrap_wp_for_direct_access()
 {
     /** @define "$bootstrap_dir" "/srv/www/wordpress-default" */
     $bootstrap_dir = dirname($_SERVER['SCRIPT_FILENAME']);
     /** @define "$bootstrap_dir" "/srv/www" */
     $document_root = dirname(isset($_SERVER['APPL_PHYSICAL_PATH']) ? $_SERVER['APPL_PHYSICAL_PATH'] : $_SERVER['DOCUMENT_ROOT']);
     // Loop through folders and keep looking up the directories until you find a directory that has wp-load.php
     while (!file_exists($bootstrap_dir . '/wp-load.php')) {
         $bootstrap_dir = dirname($bootstrap_dir);
         // The base is no longer part of the path. We're in the weeds.
         // Let's fall back to default relative path to this file from wordpress
         // (wp-content/plugins/gravityview-datatables/includes/)
         if (false === strpos($bootstrap_dir, $document_root)) {
             $bootstrap_dir = "../../../../..";
             break;
         }
     }
     require $bootstrap_dir . '/wp-load.php';
     // Only load what we need.
     if (!function_exists('get_locale')) {
         require_once ABSPATH . WPINC . '/locale.php';
         // is_rtl()
         require_once ABSPATH . WPINC . '/class-wp-walker.php';
         // Needed for GF
         require_once ABSPATH . WPINC . '/plugin.php';
         require_once ABSPATH . WPINC . '/load.php';
         require_once ABSPATH . WPINC . '/l10n.php';
         require_once ABSPATH . WPINC . '/general-template.php';
         require_once ABSPATH . WPINC . '/link-template.php';
         require_once ABSPATH . WPINC . '/formatting.php';
         require_once ABSPATH . WPINC . '/kses.php';
         require_once ABSPATH . WPINC . '/pluggable.php';
         require_once ABSPATH . WPINC . '/capabilities.php';
         require_once ABSPATH . WPINC . '/user.php';
         require_once ABSPATH . WPINC . '/meta.php';
         require_once ABSPATH . WPINC . '/session.php';
         require_once ABSPATH . WPINC . '/shortcodes.php';
         require_once ABSPATH . WPINC . '/theme.php';
         require_once ABSPATH . WPINC . '/template.php';
         require_once ABSPATH . WPINC . '/widgets.php';
         require_once ABSPATH . WPINC . '/rewrite.php';
         require_once ABSPATH . WPINC . '/query.php';
     }
     // Setup WP_PLUGIN_URL, WP_PLUGIN_DIR, etc.
     if (function_exists('wp_plugin_directory_constants')) {
         wp_plugin_directory_constants();
     }
     // USER_COOKIE, AUTH_COOKIE, etc.
     if (function_exists('wp_cookie_constants')) {
         wp_cookie_constants();
     }
     // TEMPLATEPATH, STYLESHEETPATH, etc.
     if (function_exists('wp_templating_constants')) {
         wp_templating_constants();
     }
 }