Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #130 from xwp/develop
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
westonruter authored Jul 6, 2017
2 parents 7910d6b + b81a30f commit 32930d8
Show file tree
Hide file tree
Showing 26 changed files with 1,321 additions and 668 deletions.
42 changes: 25 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
sudo: false

notifications:
email:
on_success: never
on_failure: change

cache:
directories:
- node_modules
- vendor
- $HOME/phpunit-bin

language:
- php
- node_js
- php
- node_js

php:
- 5.3
- 7.0

node_js:
- stable
- 5.3
- 7.0

env:
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=4.6.1 WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=4.6.1 WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1

install:
- nvm install 4 && nvm use 4
- export DEV_LIB_PATH=dev-lib
- if [ ! -e "$DEV_LIB_PATH" ] && [ -L .travis.yml ]; then export DEV_LIB_PATH=$( dirname $( readlink .travis.yml ) ); fi
- source $DEV_LIB_PATH/travis.install.sh
- nvm install 6 && nvm use 6
- export DEV_LIB_PATH=dev-lib
- if [ ! -e "$DEV_LIB_PATH" ] && [ -L .travis.yml ]; then export DEV_LIB_PATH=$( dirname $( readlink .travis.yml ) ); fi
- source $DEV_LIB_PATH/travis.install.sh

script:
- source $DEV_LIB_PATH/travis.script.sh
- source $DEV_LIB_PATH/travis.script.sh

after_script:
- source $DEV_LIB_PATH/travis.after_script.sh
- source $DEV_LIB_PATH/travis.after_script.sh
42 changes: 4 additions & 38 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module.exports = function( grunt ) {
expand: true,
cwd: 'js/',
src: [
'*.js',
'!*.min.js'
'**.js',
'!**.min.js'
],
dest: 'js/',
ext: '.min.js'
Expand All @@ -55,45 +55,13 @@ module.exports = function( grunt ) {
}
},

// Check textdomain errors.
checktextdomain: {
options:{
text_domain: '<%= pkg.name %>',
keywords: [
'__:1,2d',
'_e:1,2d',
'_x:1,2c,3d',
'esc_html__:1,2d',
'esc_html_e:1,2d',
'esc_html_x:1,2c,3d',
'esc_attr__:1,2d',
'esc_attr_e:1,2d',
'esc_attr_x:1,2c,3d',
'_ex:1,2c,3d',
'_n:1,2,4d',
'_nx:1,2,4c,5d',
'_n_noop:1,2,3d',
'_nx_noop:1,2,3c,4d'
]
},
files: {
src: [
'**/*.php', // Include all files
'!build/**', // Exclude build/
'!node_modules/**', // Exclude node_modules/
'!tests/**' // Exclude tests/
],
expand: true
}
},

// Build a deploy-able plugin
copy: {
build: {
src: [
'*.php',
'css/*',
'js/*',
'js/**',
'php/*',
'readme.txt'
],
Expand Down Expand Up @@ -147,7 +115,6 @@ module.exports = function( grunt ) {
} );

// Load tasks
grunt.loadNpmTasks( 'grunt-checktextdomain' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
Expand All @@ -160,8 +127,7 @@ module.exports = function( grunt ) {
grunt.registerTask( 'default', [
'jshint',
'uglify',
'cssmin',
'checktextdomain'
'cssmin'
] );

grunt.registerTask( 'readme', [
Expand Down
2 changes: 1 addition & 1 deletion customize-snapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Customize Snapshots
* Plugin URI: https://github.com/xwp/wp-customize-snapshots
* Description: Allow Customizer states to be drafted, and previewed with a private URL.
* Version: 0.6.0-rc1
* Version: 0.6.0
* Author: XWP
* Author URI: https://xwp.co/
* License: GPLv2+
Expand Down
2 changes: 1 addition & 1 deletion dev-lib
79 changes: 52 additions & 27 deletions js/compat/customize-snapshots.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global jQuery, wp, _customizeSnapshotsCompatSettings */
/* eslint consistent-this: ["error", "snapshot"] */
/* global jQuery, wp, _customizeSnapshotsCompatSettings, JSON */
/* eslint consistent-this: ["error", "snapshot"], no-magic-numbers: [ "error", { "ignore": [0,1,2] } ] */

( function( api, $ ) {
'use strict';
Expand All @@ -20,7 +20,6 @@

api.bind( 'ready', function() {
api.state.create( 'snapshot-exists', snapshot.data.snapshotExists );
snapshot.extendPreviewerQuery();

if ( api.state( 'snapshot-exists' ).get() ) {
api.state( 'saved' ).set( false );
Expand Down Expand Up @@ -48,6 +47,8 @@
snapshot.previewLink.attr( 'target', snapshot.data.uuid );
}

snapshot.removeParamFromClose( 'customize_snapshot_uuid' );

api.state( 'snapshot-exists' ).set( false );

// Replace the history state with an updated Customizer URL that does not include the Snapshot UUID.
Expand Down Expand Up @@ -226,6 +227,8 @@

api.previewer.query = function() {
var retval = originalQuery.apply( this, arguments );
retval.customizer_state_query_vars = JSON.stringify( snapshot.getStateQueryVars() );

if ( api.state( 'snapshot-exists' ).get() ) {
retval.customize_snapshot_uuid = snapshot.data.uuid;
if ( snapshot.snapshotTitle && snapshot.snapshotTitle.val() ) {
Expand All @@ -244,7 +247,9 @@
addButtons: function addButtons() {
var snapshot = this,
header = $( '#customize-header-actions' ),
templateData = {}, setPreviewLinkHref;
disableButton = true,
templateData = {}, setPreviewLinkHref, currentTheme,
savedPreviewingTheme, themeNotActiveOrSaved;

snapshot.publishButton = header.find( '#save' );
snapshot.spinner = header.find( '.spinner' );
Expand All @@ -266,7 +271,17 @@
if ( ! snapshot.data.currentUserCanPublish ) {
snapshot.snapshotButton.attr( 'title', api.state( 'snapshot-exists' ).get() ? snapshot.data.i18n.permsMsg.update : snapshot.data.i18n.permsMsg.save );
}
snapshot.snapshotButton.prop( 'disabled', true );

currentTheme = api.settings.theme.stylesheet; // Or previewing theme.
savedPreviewingTheme = snapshot.data.previewingTheme;
themeNotActiveOrSaved = ! api.state( 'activated' ).get() && ! savedPreviewingTheme;
snapshot.isNotSavedPreviewingTheme = savedPreviewingTheme && savedPreviewingTheme !== currentTheme;

if ( themeNotActiveOrSaved || snapshot.isNotSavedPreviewingTheme ) {
disableButton = false;
}

snapshot.snapshotButton.prop( 'disabled', disableButton );

snapshot.snapshotButton.on( 'click', function( event ) {
var status;
Expand Down Expand Up @@ -348,7 +363,7 @@
}
} );

snapshot.editControlSettings.bind( function() {
snapshot.editControlSettings.bind( 'change', function() {
snapshot.snapshotButton.prop( 'disabled', false );
snapshot.updateButtonText();
} );
Expand Down Expand Up @@ -390,18 +405,6 @@
api.state( 'saved' )._value = true;
},

/**
* Toggles date notification.
*
* @return {void}.
*/
toggleDateNotification: function showDateNotification() {
var snapshot = this;
if ( ! _.isEmpty( snapshot.dateNotification ) ) {
snapshot.dateNotification.toggle( ! snapshot.isFutureDate() );
}
},

/**
* Overrides the autoSaveEditBox method used in api.Snapshots
* because we do not auto save in < 4.7.
Expand Down Expand Up @@ -480,13 +483,11 @@
populateSetting: function populateSetting() {
var snapshot = this,
date = snapshot.getDateFromInputs(),
scheduled, isDirtyDate, editControlSettings;
scheduled, isDirtyDate;

editControlSettings = _.extend( {}, snapshot.editControlSettings.get() );
snapshot.editControlSettings( 'title' ).set( snapshot.snapshotTitle.val() );

if ( ! date || ! snapshot.data.currentUserCanPublish ) {
editControlSettings.title = snapshot.snapshotTitle.val();
snapshot.editControlSettings.set( editControlSettings );
return;
}

Expand All @@ -495,14 +496,38 @@

isDirtyDate = scheduled && snapshot.isFutureDate();
snapshot.dirtyScheduleDate.set( isDirtyDate );

editControlSettings.title = snapshot.snapshotTitle.val();
editControlSettings.date = snapshot.formatDate( date );

snapshot.editControlSettings.set( editControlSettings );
snapshot.editControlSettings( 'date' ).set( snapshot.formatDate( date ) );

snapshot.updateCountdown();
snapshot.editContainer.find( '.reset-time' ).toggle( scheduled );
},

/**
* Parse query string.
*
* Polyfill for function was introduced into core in 4.7 as wp.customize.utils.parseQueryString.
*
* @param {string} queryString Query string.
* @returns {object} Parsed query string.
*/
parseQueryString: function parseQueryString( queryString ) {
var queryParams = {};
_.each( queryString.split( '&' ), function( pair ) {
var parts, key, value;
parts = pair.split( '=', 2 );
if ( ! parts[0] ) {
return;
}
key = decodeURIComponent( parts[0].replace( /\+/g, ' ' ) );
key = key.replace( / /g, '_' ); // What PHP does.
if ( _.isUndefined( parts[1] ) ) {
value = null;
} else {
value = decodeURIComponent( parts[1].replace( /\+/g, ' ' ) );
}
queryParams[ key ] = value;
} );
return queryParams;
}
} );

Expand Down
2 changes: 1 addition & 1 deletion js/customize-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';
var component = {
doingAjax: false,
postMigrationCount: 20
postMigrationCount: 5
};

/**
Expand Down
Loading

0 comments on commit 32930d8

Please sign in to comment.