Skip to content

Commit

Permalink
Merge branch 'release/2.0.0' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
JDGrimes committed Jun 30, 2015
2 parents 9d3ede1 + e27b61c commit c29a6ac
Show file tree
Hide file tree
Showing 216 changed files with 18,491 additions and 5,646 deletions.
10 changes: 0 additions & 10 deletions .ci-env.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .jshintignore

This file was deleted.

1 change: 1 addition & 0 deletions .jshintignore
2 changes: 1 addition & 1 deletion .jshintrc
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ php:

env:
- TRAVISCI_RUN=codesniff
- TRAVISCI_RUN=phpunit WP_VERSION=nightly
- TRAVISCI_RUN=phpunit WP_VERSION=latest
- TRAVISCI_RUN=phpunit WP_VERSION=4.0
- TRAVISCI_RUN=phpunit WP_VERSION=3.9
- TRAVISCI_RUN=phpunit WP_VERSION=master
- TRAVISCI_RUN=phpunit WP_VERSION=4.2

sudo: false

matrix:
include:
# Only run HHVM against the latest for now.
# Only run HHVM against trunk for now.
- php: hhvm
env: TRAVISCI_RUN=phpunit WP_VERSION=latest
env: TRAVISCI_RUN=phpunit WP_VERSION=master
# Only run nightly against trunk.
- php: nightly
env: TRAVISCI_RUN=phpunit WP_VERSION=master
exclude:
# The codesniff pass only needs to be run once, I chose PHP 5.3, since WPCS requires it.
- php: 5.2
Expand All @@ -36,11 +37,13 @@ matrix:
env: TRAVISCI_RUN=codesniff
allow_failures:
- php: hhvm
- php: nightly
fast_finish: true

before_script:
- export WORDPOINTS_PROJECT_TYPE=wordpoints
- export DEV_LIB_PATH=dev-lib-wordpoints
- export DEV_LIB_PATH=dev-lib
- if [ -e .wordpoints-dev-lib-config.sh ]; then source .wordpoints-dev-lib-config.sh; fi
- source $DEV_LIB_PATH/travis/before_script.sh

script:
Expand All @@ -50,6 +53,7 @@ script:
- codesniff-l10n
- codesniff-xmllint
- codesniff-bash
- codesniff-symlinks
- phpunit-basic
- phpunit-ms
- phpunit-ms-network
Expand Down
29 changes: 29 additions & 0 deletions .wordpoints-dev-lib-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# This project is a plugn.
export WORDPOINTS_PROJECT_TYPE=wordpoints

# The dev lib uses a non-default path.
export DEV_LIB_PATH=dev-lib-wordpoints

# Sets up custom configuration.
function wordpoints-dev-lib-config() {

# Use the develop branch for WPCS.
export WPCS_GIT_TREE=develop

# Ignore the WordPress dev lib when codesniffing.
CODESNIFF_PATH+=('!' -path "./dev-lib/*")
export CODESNIFF_PATH

# Fix failures on HHVM. See #317.
if [[ $DO_CODE_COVERAGE == 1 ]]; then
alias phpunit-ms-network='phpunit-ms-network; composer remove --dev jdgrimes/wp-filesystem-mock'
fi

if [[ $TRAVIS_PHP_VERSION == nightly ]]; then
alias setup-phpunit='setup-phpunit; wget -O /tmp/31982.1.diff https://core.trac.wordpress.org/raw-attachment/ticket/31982/31982.1.diff; cd $WP_DEVELOP_DIR; patch -p0 < /tmp/31982.1.diff; cd -'
fi
}

# EOF
14 changes: 8 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

153 changes: 125 additions & 28 deletions src/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
*/
include_once WORDPOINTS_DIR . 'admin/screens/configure.php';

/**
* Deprecated administration-side code.
*
* @since 1.7.0
*/
include_once WORDPOINTS_DIR . 'admin/includes/deprecated.php';

/**
* Get the slug of the main administration menu item for the plugin.
*
Expand Down Expand Up @@ -229,7 +222,7 @@ function wordpoints_admin_activate_components() {
* @uses wordpoints_show_admin_message()
*
* @param string $message The text for the error message.
* @param array $args Other optional arguments.
* @param array $args Other optional arguments.
*/
function wordpoints_show_admin_error( $message, array $args = array() ) {

Expand Down Expand Up @@ -443,6 +436,10 @@ function wordpoints_upload_module_zip() {
* if it is a module instead of a plugin.
*
* @since 1.9.0
*
* @param string|WP_Error $source The module source.
*
* @return string|WP_Error The filtered module source.
*/
function wordpoints_plugin_upload_error_filter( $source ) {

Expand Down Expand Up @@ -540,36 +537,136 @@ function wordpoints_admin_notices() {
);

if ( $is_notice_dismissed && isset( $_POST['wordpoints_notice'] ) ) {
wordpoints_delete_network_option( sanitize_key( $_POST['wordpoints_notice'] ) );

$option = sanitize_key( $_POST['wordpoints_notice'] );

if ( ! is_network_admin() && 'wordpoints_incompatible_modules' === $option ) {
delete_option( $option );
} else {
wordpoints_delete_network_option( $option );
}
}

if ( current_user_can( 'manage_network_plugins' ) ) {
if ( current_user_can( 'activate_wordpoints_modules' ) ) {

if ( is_network_admin() ) {

$deactivated_modules = get_site_option( 'wordpoints_breaking_deactivated_modules' );

if ( is_array( $deactivated_modules ) ) {
wordpoints_show_admin_error(
sprintf(
// translators: 1 is plugin version, 2 is list of modules
__( 'WordPoints has deactivated the following modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' )
, WORDPOINTS_VERSION
, implode( ', ', $deactivated_modules )
)
, array(
'dismissible' => true,
'option' => 'wordpoints_breaking_deactivated_modules',
)
);
}

unset( $message ); // Future proofing.
$incompatible_modules = get_site_option( 'wordpoints_incompatible_modules' );

if ( is_array( $incompatible_modules ) ) {
wordpoints_show_admin_error(
sprintf(
// translators: 1 is plugin version, 2 is list of modules
__( 'WordPoints has deactivated the following network-active modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' )
, WORDPOINTS_VERSION
, implode( ', ', $incompatible_modules )
)
, array(
'dismissible' => true,
'option' => 'wordpoints_incompatible_modules',
)
);
}

// Show a notice if we've skipped part of the install/update process.
if ( get_site_option( 'wordpoints_network_install_skipped' ) ) {
$message = esc_html__( 'WordPoints detected a large network and has skipped part of the installation process.', 'wordpoints' );
$option = 'wordpoints_network_install_skipped';
} elseif ( get_site_option( 'wordpoints_network_update_skipped' ) ) {
$message = esc_html( sprintf( __( 'WordPoints detected a large network and has skipped part of the update process for version %s (and possibly later versions).', 'wordpoints' ), get_site_option( 'wordpoints_network_update_skipped' ) ) );
$option = 'wordpoints_network_update_skipped';
} else {

$incompatible_modules = get_option( 'wordpoints_incompatible_modules' );

if ( is_array( $incompatible_modules ) ) {
wordpoints_show_admin_error(
sprintf(
// translators: 1 is plugin version, 2 is list of modules
__( 'WordPoints has deactivated the following modules on this site because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' )
, WORDPOINTS_VERSION
, implode( ', ', $incompatible_modules )
)
, array(
'dismissible' => true,
'option' => 'wordpoints_incompatible_modules',
)
);
}
}
}
}
add_action( 'admin_notices', 'wordpoints_admin_notices' );

if ( isset( $message ) ) {
/**
* Save the screen options.
*
* @since 2.0.0
*
* @param mixed $sanitized The sanitized option value, or false if not sanitized.
* @param string $option The option being saved.
* @param mixed $value The raw value supplied by the user.
*
* @return mixed The option value, sanitized if it is for one of the plugin's screens.
*/
function wordpoints_admin_set_screen_option( $sanitized, $option, $value ) {

$message .= ' ' . esc_html__( 'The rest of the process needs to be completed manually. If this has not been done already, some parts of the plugin may not function properly.', 'wordpoints' );
$message .= ' <a href="http://wordpoints.org/user-guide/multisite/" target="_blank">' . esc_html__( 'Learn more.', 'wordpoints' ) . '</a>';
switch ( $option ) {

$args = array(
'dismissable' => true,
'option' => $option,
);
case 'wordpoints_page_wordpoints_modules_per_page':
case 'wordpoints_page_wordpoints_modules_network_per_page':
case 'toplevel_page_wordpoints_modules_per_page':
$sanitized = wordpoints_posint( $value );
break;
}

wordpoints_show_admin_error( $message, $args );
}
return $sanitized;
}
add_action( 'set-screen-option', 'wordpoints_admin_set_screen_option', 10, 3 );

/**
* Ajax callback to load the modules admin screen when running module compat checks.
*
* We run this Ajax action to check module compatibility before loading modules
* after WordPoints is updated to a new major version. This avoids breaking the site
* if some modules aren't compatible with the backward-incompatible changes that are
* present in a major version.
*
* @since 2.0.0
*/
function wordpoints_admin_ajax_breaking_module_check() {

if ( ! isset( $_GET['wordpoints_module_check'] ) ) {
wp_die( '', 400 );
}

if ( is_network_admin() ) {
$nonce = get_site_option( 'wordpoints_module_check_nonce' );
} else {
$nonce = get_option( 'wordpoints_module_check_nonce' );
}

if ( ! $nonce || $nonce !== $_GET['wordpoints_module_check'] ) {
wp_die( '', 403 );
}

// The list table constructor calls WP_Screen::get(), which expects this.
$GLOBALS['hook_suffix'] = null;

wordpoints_admin_screen_modules();

wp_die( '', 200 );
}
add_action( 'admin_notices', 'wordpoints_admin_notices' );
add_action( 'wp_ajax_nopriv_wordpoints_breaking_module_check', 'wordpoints_admin_ajax_breaking_module_check' );

// EOF
6 changes: 5 additions & 1 deletion src/admin/includes/class-wordpoints-module-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function install( $package ) {

add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );

$this->run(
$result = $this->run(
array(
'package' => $package,
'destination' => wordpoints_modules_dir(),
Expand All @@ -133,6 +133,10 @@ public function install( $package ) {

remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );

if ( ! $result || is_wp_error( $result ) ) {
return $result;
}

if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
Expand Down
Loading

0 comments on commit c29a6ac

Please sign in to comment.