contention/wp-setup 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

contention/wp-setup

最新稳定版本:v0.5

Composer 安装命令:

composer require contention/wp-setup

包简介

README 文档

README

Deploying WP via composer.json, together with a set of simple utilities.

Originally created to enable fast and hassle-free setup of WordPress sites on ephemeral filesystems such as Heroku, where the filesystem (and therefore any uploaded content and/or changes to the codebase) is wiped on every deployment or restart. It should also work on any install of WP where core and plugin updates are managed locally and production code is then pushed to remote production environments.

Utilities

  • File editor remover - mu-plugin that removes links to the WP file editor to prevent changes to production environment theme or plugin source via the WP production backend.
  • File cacher - mu-plugin that acts as a basic file/feed/data cacher (useful for pulling and caching social media feeds, etc).
  • Upload to S3 - mu-plugin to 'bypass' local storage in order to host/serve images and other uploaded documents directly from Amazon S3. Requires an Amazon AWS account. Runs if constants are defined in wp-config.php
  • XML sitemap - root directory drop-in that generates an XML sitemap on the fly at /sitemap.xml
  • Auth - fires simple HTTP AUTH if CONTENTION_AUTH_USER and CONTENTION_AUTH_PW are defined in wp-config

Dependencies

  • aws/aws-sdk-php - to allow S3 uploads.

Usage

Should be required by a project with a folder structure that looks like the following as a minimum:

root
 - .gitignore
 - composer.json
 - src
    - plugins
    - theme
    - wp-config.php

.gitignore

Here, we ignore any WP (or other files) that are dropped into the root on deployment. It should look like this:

# Ignore everything
/*

# But not these files...
!.gitignore
!composer.json
!composer.lock
!gulpfile.js
!package.json
!circle.yml
!circledeploy.sh
!src/

circle.yml

Theis file contains project-specific CircleCI test and deployment commands.

composer.json

The project composer.json should look like this:

{
    "name": "contention/[PROJECT NAME]",
    "require": {
        "contention/wp-setup": "dev-master"
    },
      "scripts": {
         "post-install-cmd": "bash vendor/contention/wp-setup/installer.sh",
         "post-update-cmd": "bash vendor/contention/wp-setup/installer.sh"
     }
}

/src

This should contain any plugins inside /plugins, and all theme files inside /theme

wp-config.php

Here's a sample:

<?php
/**
 *  Begin session
 */
session_start();


/**
 * Require vendor
 */
require_once(ABSPATH.'vendor/autoload.php');


/**
 * Define site constants
 */
$host = $_SERVER['HTTP_HOST'];

if ($host == '' || $host == 'www.') {
  define('DB_NAME', '');
  define('DB_USER', '');
  define('DB_PASSWORD', '');
  define('DB_HOST', '');
  define('ENVIRONMENT','production');
  define('WP_HOME','');
  define('WP_SITEURL','');
  define('AWS_ACCESS_KEY_ID','');
  define('AWS_SECRET_ACCESS_KEY','');
  define('AWS_BUCKETNAME','');
  define('AWS_BUCKETLOCATION','');     
  
} elseif ($host == 'localhost') {
  define('DB_NAME', '');
  define('DB_USER', '');
  define('DB_PASSWORD', '');
  define('DB_HOST', '');
  define('ENVIRONMENT','development');
  define('WP_HOME','');
  define('WP_SITEURL','');
  define('AWS_ACCESS_KEY_ID','');
  define('AWS_SECRET_ACCESS_KEY','');
  define('AWS_BUCKETNAME','');
  define('AWS_REGION','');
  
} else {
  echo 'Error';
  exit;
}



/**
 * Other DB constants
 */
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
$table_prefix  = 'wp_';



/**
 * Environment auth
 */
define('ENVIRONMENT_AUTH_USER','');
define('ENVIRONMENT_AUTH_PW','');


/**
 * WordPress debugging mode.
 */
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);



/**
 * Safety mode!
 */
define('DISALLOW_FILE_MODS', true);
define('AUTOMATIC_UPDATER_DISABLED', true);
define('WP_AUTO_UPDATE_CORE', false);  



/**
 * Authentication Unique Keys and Salts.
 */
define('AUTH_KEY',         'j~)-W7_-#_hxjZmNhf}kg+5)yXBYr`qV,|++Ui1wFl(vR;5x)Y<.Ko6;[:IMXUKM');
define('SECURE_AUTH_KEY',  'p>{a(N,8*W<BIC<c|;G-6G7t!e3|htE&zE~g@{3s+e%>r>Fmy+LmzVSk`qLP:1-s');
define('LOGGED_IN_KEY',    'fMXA4p-gu~Eg(a.)@=lL[hp3uHCwCJN$:,0uy7FN>-nS&*KIR5u~(&h=Q`Xgb2m~');
define('NONCE_KEY',        'RPq?:--qJ2@za}FIQQqLq%L/-M`3]-b*)LZ`f$:44A#*TWBL9F*h^>)nP=.;,@=5');
define('AUTH_SALT',        'V{Tt;y;B+5m3mI,k=|-``BxWl0U d-`hH#NNZ8(3[t!cygDa--7q1W(;HeNQ7pj-');
define('SECURE_AUTH_SALT', 'Im+q$Lrq`(/Lsm^5@cJhVCj|Er!YR+t1|G*oF:~a_O (ugOeJ4I3*LUrBr|J9-j~');
define('LOGGED_IN_SALT',   'KO{c5gLNxRqKD4?av8OXq,n2`+fKV-lo-3}lvD2@AuTdL*/zno9ah;PMeoVKE|4Y');
define('NONCE_SALT',       'C*t(wuyj7ZFMqq7j_[8KfR{>/|Nig%_ZI-v[Gt&!?`eNGCoI)[-~lx1)Yp@WQdzz');



/**
 * WordPress Localized Language, defaults to English.
 */
define('WPLANG', '');



/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Build and edit your WP theme as normal inside src/theme.

Include any third party plugins inside src/plugins.

Create and edit your wp-config.php as normal inside src/.

Both the theme and wp-config.php are symlinked to the correct locations within WP, so the project repo can be safely managed and deployed by git.

Upgrading WP

Simply change references to the WP version and do a composer update, push and deploy.

统计信息

  • 总下载量: 598
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-09-19