Merge remote-tracking branch 'woocommerce/woocommerce-beta-tester/trunk' into merge/woocommerce-beta-tester
This commit is contained in:
commit
7be60a5b52
|
@ -0,0 +1,17 @@
|
||||||
|
.distignore
|
||||||
|
.editorconfig
|
||||||
|
.gitignore
|
||||||
|
.travis.yml
|
||||||
|
.git/
|
||||||
|
.wordpress-org/
|
||||||
|
composer.json
|
||||||
|
composer.lock
|
||||||
|
package-lock.json
|
||||||
|
package.json
|
||||||
|
phpcs.xml
|
||||||
|
|
||||||
|
# build files
|
||||||
|
woocommerce-beta-tester.zip
|
||||||
|
node_modules/
|
||||||
|
build/
|
||||||
|
bin/
|
|
@ -0,0 +1,24 @@
|
||||||
|
# This file is for unifying the coding style for different editors and IDEs
|
||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
# WordPress Coding Standards
|
||||||
|
# https://make.wordpress.org/core/handbook/coding-standards/
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.txt]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{md,json,yml}]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
|
@ -0,0 +1 @@
|
||||||
|
*.min.js
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"wp": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"camelcase": 0,
|
||||||
|
"indent": 0,
|
||||||
|
"max-len": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"code": 140
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-console": 1
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Contributing ✨
|
||||||
|
|
||||||
|
Your help will be greatly appreciated :)
|
||||||
|
|
||||||
|
WooCommerce is licensed under the GPLv3+, and all contributions to the project will be released under the same license. You maintain copyright over any contribution you make, and by submitting a pull request, you are agreeing to release that contribution under the GPLv3+ license.
|
||||||
|
|
||||||
|
## Coding Guidelines and Development 🛠
|
||||||
|
|
||||||
|
- Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/)
|
||||||
|
- Whenever possible please fix pre-existing code standards errors in the files that you change. It is ok to skip that for larger files or complex fixes.
|
||||||
|
- Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured.
|
||||||
|
- When committing, reference your issue number (#1234) and include a note about the fix.
|
||||||
|
- Push the changes to your fork and submit a pull request on the trunk branch of the repository.
|
||||||
|
- Make sure to write good and detailed commit messages (see [this post](https://chris.beams.io/posts/git-commit/) for more on this) and follow all the applicable sections of the pull request template.
|
||||||
|
- Please avoid modifying the changelog directly or updating the .pot files. These will be updated by the team.
|
|
@ -0,0 +1,7 @@
|
||||||
|
<!-- This form is for other issue types specific to WooCommerce Beta Tester Plugin. This is not a support portal. -->
|
||||||
|
|
||||||
|
**Prerequisites (mark completed items with an [x]):**
|
||||||
|
- [ ] I have checked that my issue type is not listed here https://github.com/woocommerce/woocommerce-beta-tester/issues/new/choose
|
||||||
|
- [ ] My issue is not a security issue, bug report, or enhancement (Please use the link above if it is).
|
||||||
|
|
||||||
|
**Issue Description:**
|
|
@ -0,0 +1,56 @@
|
||||||
|
name: 🐞 Bug Report
|
||||||
|
description: Report a bug if something isn't working as expected in WooCommerce Beta Tester Plugin.
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
### Thanks for contributing!
|
||||||
|
|
||||||
|
Please provide us with the information requested in this bug report.
|
||||||
|
Without these details, we won't be able to fully evaluate this issue.
|
||||||
|
Bug reports lacking detail, or for any other reason than to report a bug, may be closed without action.
|
||||||
|
|
||||||
|
Make sure to look through the [existing `bug` issues](https://github.com/woocommerce/woocommerce-beta-tester/issues?q=is%3Aissue+is%3Aopen+label%3Abug) to see whether your bug has already been submitted.
|
||||||
|
Feel free to contribute to any existing issues.
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: Prerequisites
|
||||||
|
description: Please confirm these before submitting the issue.
|
||||||
|
options:
|
||||||
|
- label: I have carried out troubleshooting steps and I believe I have found a bug.
|
||||||
|
- label: I have searched for similar bugs in both open and closed issues and cannot find a duplicate.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: summary
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: |
|
||||||
|
A clear and concise description of what the bug is and what actually happens. Please be as descriptive as possible.
|
||||||
|
Please also include any error logs or output.
|
||||||
|
If applicable you can attach screenshot(s) or recording(s) directly by dragging & dropping.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: environment
|
||||||
|
attributes:
|
||||||
|
label: WordPress Environment
|
||||||
|
description: |
|
||||||
|
Please share the [WooCommerce System Status Report](https://woocommerce.com/document/understanding-the-woocommerce-system-status-report/) of your site to help us evaluate the issue.
|
||||||
|
placeholder: |
|
||||||
|
The System Status Report is found in your WordPress admin under **WooCommerce > Status**.
|
||||||
|
Please select “Get system report”, then “Copy for support”, and then paste it here.
|
||||||
|
- type: checkboxes
|
||||||
|
id: isolating
|
||||||
|
attributes:
|
||||||
|
label: Isolating the problem
|
||||||
|
description: |
|
||||||
|
Please try testing your site for theme and plugins conflict.
|
||||||
|
To do that deactivate all plugins except for WooCommerce and WooCommerce Beta Tester and switch to a default WordPress theme or [Storefront](https://en-gb.wordpress.org/themes/storefront/). Then test again.
|
||||||
|
If the issue is resolved with the default theme and all plugins deactivated, it means that one of your plugins or a theme is causing the issue.
|
||||||
|
You will then need to enable it one by one and test every time you do that in order to figure out which plugin is causing the issue.
|
||||||
|
options:
|
||||||
|
- label: I have deactivated other plugins and confirmed this bug occurs when only WooCommerce and WooCommerce Beta Tester plugins are active.
|
||||||
|
- label: This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/storefront/).
|
||||||
|
- label: I can reproduce this bug consistently using the steps above.
|
|
@ -0,0 +1,30 @@
|
||||||
|
name: ✨ Enhancement Request
|
||||||
|
description: If you have an idea to improve WooCommerce Beta Tester Plugin or need something for development please let us know or submit a Pull Request!
|
||||||
|
title: "[Enhancement]: "
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
### Thanks for contributing!
|
||||||
|
|
||||||
|
Please provide us with the information requested in this form.
|
||||||
|
|
||||||
|
Make sure to look through [existing `enhancement` issues](https://github.com/woocommerce/woocommerce-beta-tester/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) to see whether your idea is already being discussed.
|
||||||
|
Feel free to contribute to any existing issues.
|
||||||
|
- type: textarea
|
||||||
|
id: summary
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like
|
||||||
|
description: A clear and concise description of what you want to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: alternative
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered
|
||||||
|
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
- type: textarea
|
||||||
|
id: context
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,5 @@
|
||||||
|
blank_issues_enabled: true
|
||||||
|
contact_links:
|
||||||
|
- name: 🔒 Security issue
|
||||||
|
url: https://hackerone.com/automattic/
|
||||||
|
about: For security reasons, please report all security issues via HackerOne. Also, if the issue is valid, a bug bounty will be paid out to you. Please disclose responsibly and not via GitHub (which allows for exploiting issues in the wild before the patch is released).
|
|
@ -0,0 +1,37 @@
|
||||||
|
### All Submissions:
|
||||||
|
|
||||||
|
* [ ] Have you followed the [Contributing guidelines](https://github.com/woocommerce/woocommerce-beta-tester/blob/trunk/.github/CONTRIBUTING.md)?
|
||||||
|
* [ ] Does your code follow the [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)?
|
||||||
|
* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/woocommerce/woocommerce-beta-tester/pulls) for the same update/change?
|
||||||
|
|
||||||
|
<!-- Mark completed items with an [x] -->
|
||||||
|
|
||||||
|
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
|
||||||
|
|
||||||
|
### Changes proposed in this Pull Request:
|
||||||
|
|
||||||
|
<!-- Describe the changes made to this Pull Request and the reason for such changes. -->
|
||||||
|
|
||||||
|
Closes # .
|
||||||
|
|
||||||
|
### How to test the changes in this Pull Request:
|
||||||
|
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
|
||||||
|
### Other information:
|
||||||
|
|
||||||
|
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
|
||||||
|
* [ ] Have you written new tests for your changes, as applicable?
|
||||||
|
* [ ] Have you successfully run tests with your changes locally?
|
||||||
|
|
||||||
|
<!-- Mark completed items with an [x] -->
|
||||||
|
|
||||||
|
### Changelog entry
|
||||||
|
|
||||||
|
> Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.
|
||||||
|
|
||||||
|
### FOR PR REVIEWER ONLY:
|
||||||
|
|
||||||
|
* [ ] I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Operating System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# IDE files
|
||||||
|
.idea
|
||||||
|
.vscode/
|
||||||
|
project.xml
|
||||||
|
project.properties
|
||||||
|
.project
|
||||||
|
.settings*
|
||||||
|
*.sublime-project
|
||||||
|
*.sublime-workspace
|
||||||
|
.sublimelinterrc
|
||||||
|
|
||||||
|
vendor/
|
||||||
|
node_modules/
|
||||||
|
build/
|
||||||
|
woocommerce-beta-tester.zip
|
|
@ -0,0 +1,19 @@
|
||||||
|
language: php
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- |
|
||||||
|
# Remove Xdebug for a huge performance increase:
|
||||||
|
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
||||||
|
phpenv config-rm xdebug.ini
|
||||||
|
else
|
||||||
|
echo "xdebug.ini does not exist"
|
||||||
|
fi
|
||||||
|
- composer install
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./vendor/bin/phpcs -s -n -p *
|
||||||
|
|
||||||
|
# Specifies that Travis should create branch builds only for master.
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
Binary file not shown.
After Width: | Height: | Size: 319 KiB |
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -0,0 +1,3 @@
|
||||||
|
.plugins_page_wc-beta-tester-version-picker .wc-backbone-modal-main .wc-backbone-modal-header h1 {
|
||||||
|
margin: 0 35px 0 0;
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* Handles version information modal.
|
||||||
|
*
|
||||||
|
* @package WooCommerceBetaTester\JS
|
||||||
|
*/
|
||||||
|
|
||||||
|
jQuery(function( $ ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version information
|
||||||
|
*/
|
||||||
|
var wc_beta_tester_version_information = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Version Information click
|
||||||
|
*/
|
||||||
|
init: function() {
|
||||||
|
$( '#wp-admin-bar-show-version-info' )
|
||||||
|
.on( 'click', this.showModal );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for showing/hiding version information modal
|
||||||
|
*/
|
||||||
|
showModal: function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// Prevent multiple modals.
|
||||||
|
if ( 0 < $( '.wc-backbone-modal-beta-tester-version-info' ).length ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$( this ).WCBackboneModal({
|
||||||
|
template: 'wc-beta-tester-version-info',
|
||||||
|
variable: {
|
||||||
|
version: wc_beta_tester_version_info_params.version,
|
||||||
|
description: wc_beta_tester_version_info_params.description,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
wc_beta_tester_version_information.init();
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
jQuery(function(i){({init:function(){i("#wp-admin-bar-show-version-info").on("click",this.showModal)},showModal:function(e){e.preventDefault(),0<i(".wc-backbone-modal-beta-tester-version-info").length||i(this).WCBackboneModal({template:"wc-beta-tester-version-info",variable:{version:wc_beta_tester_version_info_params.version,description:wc_beta_tester_version_info_params.description}})}}).init()});
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* Handles the version picker form.
|
||||||
|
*
|
||||||
|
* @package WooCommerceBetaTester\JS
|
||||||
|
*/
|
||||||
|
|
||||||
|
jQuery(function( $ ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version picker
|
||||||
|
*/
|
||||||
|
var wc_beta_tester_version_picker = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Version Information click
|
||||||
|
*/
|
||||||
|
init: function() {
|
||||||
|
instance = this;
|
||||||
|
instance.new_version = undefined;
|
||||||
|
|
||||||
|
$( '#wcbt-modal-version-switch-confirm' )
|
||||||
|
.on( 'click', this.showConfirmVersionSwitchModal );
|
||||||
|
$( 'input[type=radio][name=wcbt_switch_to_version]' ).change( function() {
|
||||||
|
if ( $( this ).is( ':checked' ) ) {
|
||||||
|
instance.new_version = $( this ).val();
|
||||||
|
}
|
||||||
|
} ).trigger( 'change' );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for showing/hiding version switch modal
|
||||||
|
*/
|
||||||
|
showConfirmVersionSwitchModal: function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
if ( ! instance.new_version ) {
|
||||||
|
alert( wc_beta_tester_version_picker_params.i18n_pick_version );
|
||||||
|
} else {
|
||||||
|
$( this ).WCBackboneModal({
|
||||||
|
template: 'wcbt-version-switch-confirm',
|
||||||
|
variable: {
|
||||||
|
new_version: instance.new_version,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
$( '#wcbt-submit-version-switch' )
|
||||||
|
.on( 'click', instance.submitSwitchVersionForm );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit form to switch version of WooCommerce.
|
||||||
|
*/
|
||||||
|
submitSwitchVersionForm: function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
$( 'form[name=wcbt-select-version]' ).get( 0 ).submit();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
wc_beta_tester_version_picker.init();
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
jQuery(function(n){({init:function(){instance=this,instance.new_version=void 0,n("#wcbt-modal-version-switch-confirm").on("click",this.showConfirmVersionSwitchModal),n("input[type=radio][name=wcbt_switch_to_version]").change(function(){n(this).is(":checked")&&(instance.new_version=n(this).val())}).trigger("change")},showConfirmVersionSwitchModal:function(i){i.preventDefault(),instance.new_version?(n(this).WCBackboneModal({template:"wcbt-version-switch-confirm",variable:{new_version:instance.new_version}}),n("#wcbt-submit-version-switch").on("click",instance.submitSwitchVersionForm)):alert(wc_beta_tester_version_picker_params.i18n_pick_version)},submitSwitchVersionForm:function(i){i.preventDefault(),n("form[name=wcbt-select-version]").get(0).submit()}}).init()});
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PLUGIN_SLUG="woocommerce-beta-tester"
|
||||||
|
PROJECT_PATH=$(pwd)
|
||||||
|
BUILD_PATH="${PROJECT_PATH}/build"
|
||||||
|
DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG"
|
||||||
|
|
||||||
|
echo "Generating build directory..."
|
||||||
|
rm -rf "$BUILD_PATH"
|
||||||
|
mkdir -p "$DEST_PATH"
|
||||||
|
|
||||||
|
echo "Installing PHP and JS dependencies..."
|
||||||
|
npm install
|
||||||
|
echo "Running JS Build..."
|
||||||
|
npm run uglify
|
||||||
|
|
||||||
|
echo "Syncing files..."
|
||||||
|
rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded
|
||||||
|
|
||||||
|
echo "Generating zip file..."
|
||||||
|
cd "$BUILD_PATH" || exit
|
||||||
|
zip -q -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/"
|
||||||
|
|
||||||
|
cd "$PROJECT_PATH" || exit
|
||||||
|
mv "$BUILD_PATH/${PLUGIN_SLUG}.zip" "$PROJECT_PATH"
|
||||||
|
echo "${PLUGIN_SLUG}.zip file generated!"
|
||||||
|
|
||||||
|
echo "Build done!"
|
|
@ -0,0 +1,11 @@
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
2021-12-17 - version 2.0.5
|
||||||
|
- Fix: make WC version comparison case insensitive
|
||||||
|
|
||||||
|
2021-09-29 - version 2.0.4
|
||||||
|
- Dev: Bump tested to version
|
||||||
|
- Fix: enqueue logic for css/js assets
|
||||||
|
|
||||||
|
2021-09-22 - version 2.0.3
|
||||||
|
- Fix: Bump version to release version including admin.css.
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "woocommerce/woocommerce-beta-tester",
|
||||||
|
"description": "Run the beta versions of WooCommerce.",
|
||||||
|
"homepage": "https://woocommerce.com/",
|
||||||
|
"type": "wordpress-plugin",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"require": {
|
||||||
|
"composer/installers": "~1.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "6.5.14",
|
||||||
|
"woocommerce/woocommerce-sniffs": "0.0.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": [
|
||||||
|
"phpunit"
|
||||||
|
],
|
||||||
|
"phpcs": [
|
||||||
|
"phpcs -s -p"
|
||||||
|
],
|
||||||
|
"phpcs-pre-commit": [
|
||||||
|
"phpcs -s -p -n"
|
||||||
|
],
|
||||||
|
"phpcbf": [
|
||||||
|
"phpcbf -p"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"scripts-description": {
|
||||||
|
"test": "Run unit tests",
|
||||||
|
"phpcs": "Analyze code against the WordPress coding standards with PHP_CodeSniffer",
|
||||||
|
"phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester Admin Assets class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WC_Beta_Tester_Admin_Assets Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Admin_Assets {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook in tabs.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enqueue scripts.
|
||||||
|
*/
|
||||||
|
public function admin_scripts() {
|
||||||
|
$screen = get_current_screen();
|
||||||
|
$screen_id = $screen ? $screen->id : '';
|
||||||
|
|
||||||
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||||
|
$version = WC_VERSION;
|
||||||
|
|
||||||
|
// Need admin styles for the modal.
|
||||||
|
wp_register_style( 'wc-beta-tester-admin', WC_Beta_Tester::instance()->plugin_url() . '/assets/css/admin.css', array( 'woocommerce_admin_styles' ) );
|
||||||
|
|
||||||
|
// Register scripts.
|
||||||
|
wp_register_script( 'wc-beta-tester-version-info', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-information' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION );
|
||||||
|
wp_register_script( 'wc-beta-tester-version-picker', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-picker' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION );
|
||||||
|
|
||||||
|
wp_localize_script(
|
||||||
|
'wc-beta-tester-version-info',
|
||||||
|
'wc_beta_tester_version_info_params',
|
||||||
|
array(
|
||||||
|
'version' => $version,
|
||||||
|
/* translators: %s: Release version number */
|
||||||
|
'description' => sprintf( __( 'Release of version %s', 'woocommerce-beta-tester' ), $version ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_localize_script(
|
||||||
|
'wc-beta-tester-version-picker',
|
||||||
|
'wc_beta_tester_version_picker_params',
|
||||||
|
array(
|
||||||
|
'i18n_pick_version' => __( 'Please pick a WooCommerce version.', 'woocommerce-beta-tester' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( in_array( $screen_id, array( 'plugins_page_wc-beta-tester', 'plugins_page_wc-beta-tester-version-picker' ) ) ) {
|
||||||
|
wp_enqueue_style( 'wc-beta-tester-admin' );
|
||||||
|
wp_enqueue_script( 'wc-beta-tester-version-info' );
|
||||||
|
wp_enqueue_script( 'wc-beta-tester-version-picker' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WC_Beta_Tester_Admin_Assets();
|
|
@ -0,0 +1,379 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester Admin Menus class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WC_Beta_Tester_Admin_Menus Main Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Admin_Menus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
if ( class_exists( 'WC_Admin_Status' ) ) {
|
||||||
|
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 50 );
|
||||||
|
}
|
||||||
|
add_action( 'admin_footer', array( $this, 'version_information_template' ) );
|
||||||
|
add_action( 'admin_head', array( $this, 'hide_from_menus' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get issue template from GitHub.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_ticket_template() {
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Isolating the problem (mark completed items with an [x]):**
|
||||||
|
- [ ] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
|
||||||
|
- [ ] This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/storefront/).
|
||||||
|
- [ ] I can reproduce this bug consistently using the steps above.
|
||||||
|
|
||||||
|
**WordPress Environment**
|
||||||
|
<details>
|
||||||
|
```
|
||||||
|
Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin.
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$bug_tpl = ob_get_clean();
|
||||||
|
return $bug_tpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get info about the current theme for SSR.
|
||||||
|
*
|
||||||
|
* @param string $theme Current theme.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function get_theme_ssr_info( $theme ) {
|
||||||
|
$theme_info = __( "\n\n### Theme ###\n\n", 'woocommerce-beta-tester' );
|
||||||
|
|
||||||
|
$version = $theme['version'];
|
||||||
|
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
|
||||||
|
/* translators: 1: latest version */
|
||||||
|
$version .= sprintf( __( ' - %s is available', 'woocommerce-beta-tester' ), esc_html( $theme['version_latest'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$child_theme = $theme['is_child_theme'] ? __( 'Yes', 'woocommerce-beta-tester' ) : __( 'No - If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme.', 'woocommerce-beta-tester' );
|
||||||
|
|
||||||
|
if ( $theme['is_child_theme'] ) {
|
||||||
|
$parent_version = $theme['parent_version'];
|
||||||
|
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
|
||||||
|
/* translators: 1: latest version */
|
||||||
|
$parent_version .= sprintf( __( ' - %s is available', 'woocommerce-beta-tester' ), esc_html( $theme['parent_version_latest'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$child_theme .= sprintf(
|
||||||
|
__( "Parent theme name: %1\$s\nParent theme version: %2\$s\nParent theme author URL: %3\$s\n", 'woocommerce-beta-tester' ),
|
||||||
|
$theme['parent_name'],
|
||||||
|
$parent_version,
|
||||||
|
$theme['parent_author_url']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$theme_info .= sprintf(
|
||||||
|
__( "Name: %1\$s\nVersion: %2\$s\nAuthor URL: %3\$s\nChild Theme: %4\$s\nWooCommerce Support: %5\$s", 'woocommerce-beta-tester' ),
|
||||||
|
$theme['name'],
|
||||||
|
$version,
|
||||||
|
esc_html( $theme['author_url'] ),
|
||||||
|
$child_theme,
|
||||||
|
! $theme['has_woocommerce_support'] ? __( 'Not declared', 'woocommerce-beta-tester' ) : __( 'Yes', 'woocommerce-beta-tester' )
|
||||||
|
);
|
||||||
|
|
||||||
|
return $theme_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get info about the current plugins for SSR.
|
||||||
|
*
|
||||||
|
* @param array $active_plugins List of active plugins.
|
||||||
|
* @param array $untested_plugins List of untested plugins.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function get_plugins_ssr_info( $active_plugins, $untested_plugins ) {
|
||||||
|
$plugins_info = __( "\n\n### Plugins ###\n\n", 'woocommerce-beta-tester' );
|
||||||
|
|
||||||
|
foreach ( $active_plugins as $plugin ) {
|
||||||
|
if ( ! empty( $plugin['name'] ) ) {
|
||||||
|
// Link the plugin name to the plugin url if available.
|
||||||
|
$plugin_name = esc_html( $plugin['name'] );
|
||||||
|
|
||||||
|
$version_string = '';
|
||||||
|
$network_string = '';
|
||||||
|
if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
|
||||||
|
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
|
||||||
|
/* translators: %s: plugin latest version */
|
||||||
|
$version_string = sprintf( esc_html__( '%s is available', 'woocommerce-beta-tester' ), $plugin['version_latest'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( false !== (bool) $plugin['network_activated'] ) {
|
||||||
|
$network_string = __( 'Network enabled', 'woocommerce-beta-tester' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$untested_string = '';
|
||||||
|
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
|
||||||
|
$untested_string = __( 'Not tested with the active version of WooCommerce', 'woocommerce-beta-tester' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$plugins_info .= sprintf( __( "%1\$s: by %2\$s - %3\$s - %4\$s\n", 'woocommerce-beta-tester' ), $plugin_name, $plugin['author_name'], $plugin['version'], $version_string . $untested_string . $network_string );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $plugins_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a WC System Status Report.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function construct_ssr() {
|
||||||
|
if ( version_compare( WC()->version, '3.6', '<' ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$transient_name = 'wc-beta-tester-ssr';
|
||||||
|
$ssr = get_transient( $transient_name );
|
||||||
|
|
||||||
|
if ( false === $ssr ) {
|
||||||
|
// When running WC 3.6 or greater it is necessary to manually load the REST API classes.
|
||||||
|
if ( ! did_action( 'rest_api_init' ) ) {
|
||||||
|
WC()->api->rest_api_includes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! class_exists( 'WC_REST_System_Status_Controller' ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get SSR.
|
||||||
|
$api = new WC_REST_System_Status_Controller();
|
||||||
|
$schema = $api->get_item_schema();
|
||||||
|
$mappings = $api->get_item_mappings();
|
||||||
|
$response = array();
|
||||||
|
|
||||||
|
foreach ( $mappings as $section => $values ) {
|
||||||
|
foreach ( $values as $key => $value ) {
|
||||||
|
if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) {
|
||||||
|
settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settype( $values, $schema['properties'][ $section ]['type'] );
|
||||||
|
$response[ $section ] = $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ssr = '';
|
||||||
|
foreach ( $response['environment'] as $key => $value ) {
|
||||||
|
$index = $key;
|
||||||
|
if ( 'external_object_cache' === $index ) {
|
||||||
|
$ssr .= sprintf( "%s: %s\n", 'External object cache', wc_bool_to_string( $value ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_bool( $value ) ) {
|
||||||
|
$value = wc_bool_to_string( $value );
|
||||||
|
}
|
||||||
|
|
||||||
|
$ssr .= sprintf( "%s: %s\n", $schema['properties']['environment']['properties'][ $index ]['description'], $value );
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_plugins = $api->get_active_plugins();
|
||||||
|
$plugin_updates = new WC_Plugin_Updates();
|
||||||
|
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor' );
|
||||||
|
$ssr .= $this->get_plugins_ssr_info( $active_plugins, $untested_plugins );
|
||||||
|
$theme = $api->get_theme_info();
|
||||||
|
$ssr .= $this->get_theme_ssr_info( $theme );
|
||||||
|
|
||||||
|
set_transient( $transient_name, $ssr, DAY_IN_SECONDS );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ssr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get URL for creating a GitHub ticket.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_github_ticket_url() {
|
||||||
|
$bug_tpl = $this->get_ticket_template();
|
||||||
|
$ssr = $this->construct_ssr();
|
||||||
|
$body = str_replace( 'Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin.', $ssr, $bug_tpl );
|
||||||
|
$body = str_replace( '```', '', $body ); // Remove since this break how is displayed.
|
||||||
|
|
||||||
|
$wc_plugin_data = get_plugin_data( WC_PLUGIN_FILE );
|
||||||
|
if ( isset( $wc_plugin_data['Version'] ) ) {
|
||||||
|
$version = $wc_plugin_data['Version'];
|
||||||
|
} else {
|
||||||
|
$version = '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return add_query_arg(
|
||||||
|
array(
|
||||||
|
'body' => rawurlencode( $body ),
|
||||||
|
/* translators: %s: woocommerce version */
|
||||||
|
'title' => rawurlencode( sprintf( __( '[WC Beta Tester] Bug report for version "%s"', 'woocommerce-beta-tester' ), $version ) ),
|
||||||
|
),
|
||||||
|
'https://github.com/woocommerce/woocommerce/issues/new'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the "Visit Store" link in admin bar main menu.
|
||||||
|
*
|
||||||
|
* @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
|
||||||
|
*/
|
||||||
|
public function admin_bar_menus( $wp_admin_bar ) {
|
||||||
|
if ( ! is_admin() || ! is_user_logged_in() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show only when the user is a member of this site, or they're a super admin.
|
||||||
|
if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the beta tester root node.
|
||||||
|
$wp_admin_bar->add_node(
|
||||||
|
array(
|
||||||
|
'parent' => 0,
|
||||||
|
'id' => 'wc-beta-tester',
|
||||||
|
'title' => __( 'WC Beta Tester', 'woocommerce-beta-tester' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$settings = WC_Beta_Tester::get_settings();
|
||||||
|
switch ( $settings->channel ) {
|
||||||
|
case 'beta':
|
||||||
|
$current_channel = __( 'Beta', 'woocommerce-beta-tester' );
|
||||||
|
break;
|
||||||
|
case 'rc':
|
||||||
|
$current_channel = __( 'Release Candidate', 'woocommerce-beta-tester' );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$current_channel = __( 'Stable', 'woocommerce-beta-tester' );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nodes = array(
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'update-channel',
|
||||||
|
/* translators: %s: current channel */
|
||||||
|
'title' => sprintf( __( 'Channel: %s', 'woocommerce-beta-tester' ), $current_channel ),
|
||||||
|
'href' => admin_url( 'plugins.php?page=wc-beta-tester' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'import-export-settings',
|
||||||
|
'title' => __( 'Import/Export Settings', 'woocommerce-beta-tester' ),
|
||||||
|
'href' => admin_url( 'admin.php?page=wc-beta-tester-settings' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'show-version-info',
|
||||||
|
/* translators: %s: current version */
|
||||||
|
'title' => sprintf( __( 'Release %s information', 'woocommerce-beta-tester' ), WC_VERSION ),
|
||||||
|
'href' => '#',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'switch-version',
|
||||||
|
'title' => __( 'Switch versions', 'woocommerce-beta-tester' ),
|
||||||
|
'href' => admin_url( 'plugins.php?page=wc-beta-tester-version-picker' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'submit-gh-ticket',
|
||||||
|
'title' => __( 'Submit bug report', 'woocommerce-beta-tester' ),
|
||||||
|
'href' => '#',
|
||||||
|
'meta' => array(
|
||||||
|
// We can't simply use the href here since WP core calls esc_url on it which strips some parts.
|
||||||
|
'onclick' => 'javascript:window.open( "' . esc_js( $this->get_github_ticket_url() ) . '" );',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $nodes as $node ) {
|
||||||
|
$wp_admin_bar->add_node( $node );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide menu items from view so the pages exist, but the menu items do not.
|
||||||
|
*/
|
||||||
|
public function hide_from_menus() {
|
||||||
|
global $submenu;
|
||||||
|
|
||||||
|
$items_to_remove = array( 'wc-beta-tester-settings', 'wc-beta-tester-version-picker', 'wc-beta-tester' );
|
||||||
|
if ( isset( $submenu['plugins.php'] ) ) {
|
||||||
|
foreach ( $submenu['plugins.php'] as $key => $menu ) {
|
||||||
|
if ( in_array( $menu[2], $items_to_remove ) ) {
|
||||||
|
unset( $submenu['plugins.php'][ $key ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template for version information.
|
||||||
|
*/
|
||||||
|
public function version_information_template() {
|
||||||
|
?>
|
||||||
|
<script type="text/template" id="tmpl-wc-beta-tester-version-info">
|
||||||
|
<div class="wc-backbone-modal wc-backbone-modal-beta-tester-version-info">
|
||||||
|
<div class="wc-backbone-modal-content">
|
||||||
|
<section class="wc-backbone-modal-main" role="main">
|
||||||
|
<header class="wc-backbone-modal-header">
|
||||||
|
<h1>
|
||||||
|
<?php
|
||||||
|
/* translators: %s: version number */
|
||||||
|
echo esc_html( sprintf( __( 'Release %s information', 'woocommerce-beta-tester' ), '{{ data.version }}' ) );
|
||||||
|
?>
|
||||||
|
</h1>
|
||||||
|
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
|
||||||
|
<span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce-beta-tester' ); ?></span>
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
<article>
|
||||||
|
<?php do_action( 'woocommerce_admin_version_information_start' ); ?>
|
||||||
|
{{ data.description }}
|
||||||
|
<?php do_action( 'woocommerce_admin_version_information_end' ); ?>
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
<a target="_blank" href="https://github.com/woocommerce/woocommerce/releases/tag/{{ data.version }}"><?php esc_html_e( 'Read more on GitHub', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WC_Beta_Tester_Admin_Menus();
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin notices
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester\Admin
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin notices class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Admin_Notices {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WooCommerce not installed notice.
|
||||||
|
*/
|
||||||
|
public function woocoommerce_not_installed() {
|
||||||
|
include_once dirname( __FILE__ ) . '/views/html-admin-missing-woocommerce.php';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester plugin settings class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Settings {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
||||||
|
add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise settings
|
||||||
|
*/
|
||||||
|
public function settings_init() {
|
||||||
|
register_setting( 'wc-beta-tester', 'wc_beta_tester_options' );
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'wc-beta-tester-update',
|
||||||
|
__( 'Settings', 'woocommerce-beta-tester' ),
|
||||||
|
array( $this, 'update_section_html' ),
|
||||||
|
'wc-beta-tester'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'wc-beta-tester-channel',
|
||||||
|
__( 'Release Channel', 'woocommerce-beta-tester' ),
|
||||||
|
array( $this, 'version_select_html' ),
|
||||||
|
'wc-beta-tester',
|
||||||
|
'wc-beta-tester-update',
|
||||||
|
array(
|
||||||
|
'label_for' => 'channel',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'wc-beta-tester-auto-update',
|
||||||
|
__( 'Automatic Updates', 'woocommerce-beta-tester' ),
|
||||||
|
array( $this, 'automatic_update_checkbox_html' ),
|
||||||
|
'wc-beta-tester',
|
||||||
|
'wc-beta-tester-update',
|
||||||
|
array(
|
||||||
|
'label_for' => 'auto_update',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update section HTML output.
|
||||||
|
*
|
||||||
|
* @param array $args Arguments.
|
||||||
|
*/
|
||||||
|
public function update_section_html( $args ) {
|
||||||
|
?>
|
||||||
|
<p id="<?php echo esc_attr( $args['id'] ); ?>"><?php esc_html_e( 'The following settings allow you to choose which WooCommerce updates to receive on this site, including beta and RC versions not quite ready for production deployment.', 'woocommerce-beta-tester' ); ?></p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version select markup output.
|
||||||
|
*
|
||||||
|
* @param array $args Arguments.
|
||||||
|
*/
|
||||||
|
public function version_select_html( $args ) {
|
||||||
|
$settings = WC_Beta_Tester::get_settings();
|
||||||
|
$channels = array(
|
||||||
|
'beta' => array(
|
||||||
|
'name' => __( 'Beta Releases', 'woocommerce-beta-tester' ),
|
||||||
|
'description' => __( 'Beta releases contain experimental functionality for testing purposes only. This channel will also include RC and stable releases if more current.', 'woocommerce-beta-tester' ),
|
||||||
|
),
|
||||||
|
'rc' => array(
|
||||||
|
'name' => __( 'Release Candidates', 'woocommerce-beta-tester' ),
|
||||||
|
'description' => __( 'Release candidates are released to ensure any critical problems have not gone undetected. This channel will also include stable releases if more current.', 'woocommerce-beta-tester' ),
|
||||||
|
),
|
||||||
|
'stable' => array(
|
||||||
|
'name' => __( 'Stable Releases', 'woocommerce-beta-tester' ),
|
||||||
|
'description' => __( 'This is the default behavior in WordPress.', 'woocommerce-beta-tester' ),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
echo '<fieldset><legend class="screen-reader-text"><span>' . esc_html__( 'Update Channel', 'woocommerce-beta-tester' ) . '</span></legend>';
|
||||||
|
foreach ( $channels as $channel_id => $channel ) {
|
||||||
|
?>
|
||||||
|
<label>
|
||||||
|
<input type="radio" id="<?php echo esc_attr( $args['label_for'] ); ?>" name="wc_beta_tester_options[<?php echo esc_attr( $args['label_for'] ); ?>]" value="<?php echo esc_attr( $channel_id ); ?>" <?php checked( $settings->{ $args['label_for'] }, $channel_id ); ?> />
|
||||||
|
<?php echo esc_html( $channel['name'] ); ?>
|
||||||
|
<p class="description">
|
||||||
|
<?php echo esc_html( $channel['description'] ); ?>
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
echo '</fieldset>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto updates checkbox markup output.
|
||||||
|
*
|
||||||
|
* @param array $args Arguments.
|
||||||
|
*/
|
||||||
|
public function automatic_update_checkbox_html( $args ) {
|
||||||
|
$settings = WC_Beta_Tester::get_settings();
|
||||||
|
?>
|
||||||
|
<label for="<?php echo esc_attr( $args['label_for'] ); ?>">
|
||||||
|
<input type="checkbox" id="<?php echo esc_attr( $args['label_for'] ); ?>" name="wc_beta_tester_options[<?php echo esc_attr( $args['label_for'] ); ?>]" value="1" <?php checked( $settings->{ $args['label_for'] }, true ); ?> />
|
||||||
|
<?php echo esc_html__( 'If enabled, WooCommerce will update to the latest release in the background. Use with caution; we do not recommend using this on production stores!', 'woocommerce-beta-tester' ); ?>
|
||||||
|
</label>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add options page to menu
|
||||||
|
*/
|
||||||
|
public function add_to_menus() {
|
||||||
|
add_submenu_page( 'plugins.php', __( 'WooCommerce Beta Tester', 'woocommerce-beta-tester' ), __( 'WC Beta Tester', 'woocommerce-beta-tester' ), 'install_plugins', 'wc-beta-tester', array( $this, 'settings_page_html' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output settings HTML
|
||||||
|
*/
|
||||||
|
public function settings_page_html() {
|
||||||
|
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $_GET['settings-updated'] ) ) { // WPCS: input var.
|
||||||
|
add_settings_error( 'wc-beta-tester-messages', 'wc-beta-tester-message', __( 'Settings Saved', 'woocommerce-beta-tester' ), 'updated' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// show error/update messages.
|
||||||
|
settings_errors( 'wc-beta-tester-messages' );
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||||
|
<form action="options.php" method="post">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
settings_fields( 'wc-beta-tester' );
|
||||||
|
do_settings_sections( 'wc-beta-tester' );
|
||||||
|
submit_button();
|
||||||
|
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new WC_Beta_Tester_Settings();
|
|
@ -0,0 +1,213 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester settings export class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WC_Beta_Tester_Settings_Export Main Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Import_Export {
|
||||||
|
/**
|
||||||
|
* @var string WordPress ajax hook
|
||||||
|
*/
|
||||||
|
protected const AJAX_HOOK = 'wc_beta_tester_export_settings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string WordPress nonce action
|
||||||
|
*/
|
||||||
|
protected const NONCE_ACTION = 'wc-beta-tester-import-settings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string WordPress import action
|
||||||
|
*/
|
||||||
|
protected const IMPORT_ACTION = 'wc-beta-tester-import';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string WordPress import capability
|
||||||
|
*/
|
||||||
|
protected const IMPORT_CAP = 'install_plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string WordPress import file name
|
||||||
|
*/
|
||||||
|
protected const IMPORT_FILENAME = 'woocommerce-settings-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Import status message
|
||||||
|
*/
|
||||||
|
protected $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->add_hooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook into WordPress.
|
||||||
|
*/
|
||||||
|
public function add_hooks() {
|
||||||
|
add_action( 'admin_menu', array( $this, 'add_to_menu' ), 55 );
|
||||||
|
add_action( 'wp_ajax_' . static::AJAX_HOOK, array( $this, 'export_settings' ) );
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Add options page to menu
|
||||||
|
*/
|
||||||
|
public function add_to_menu() {
|
||||||
|
add_submenu_page( 'plugins.php', __( 'WC Beta Tester Import/Export', 'woocommerce-beta-tester' ), __( 'WC Import/Export', 'woocommerce-beta-tester' ), static::IMPORT_CAP, 'wc-beta-tester-settings', array( $this, 'settings_page_html' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output settings HTML
|
||||||
|
*/
|
||||||
|
public function settings_page_html() {
|
||||||
|
if ( ! current_user_can( static::IMPORT_CAP ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$export_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wc_beta_tester_export_settings' ), static::NONCE_ACTION );
|
||||||
|
$this->maybe_import_settings();
|
||||||
|
|
||||||
|
// show error/update messages.
|
||||||
|
if ( ! empty( $this->message ) ) {
|
||||||
|
?>
|
||||||
|
<div class="notice <?php
|
||||||
|
echo ! empty( $this->message['type'] ) ? esc_attr( $this->message['type'] ) : '';
|
||||||
|
?>"><?php echo esc_html( $this->message['message'] ); ?></div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||||
|
<p><?php esc_html_e( 'Export your WooCommerce Settings. The export file should not contain any fields that identify your site or reveal secrets (eg. API keys).', 'woocommerce-beta-tester' ); ?></p>
|
||||||
|
<a href="<?php echo esc_url( $export_url ) ?>" class="button-primary"><?php
|
||||||
|
/* translators Export WooCommerce settings button text. */
|
||||||
|
esc_html_e( 'Export WooCommerce Settings', 'woocommerce-beta-tester' );
|
||||||
|
?></a>
|
||||||
|
<hr />
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
<?php wp_nonce_field( static::NONCE_ACTION ); ?>
|
||||||
|
<input type="hidden" name="action" value="<?php echo static::IMPORT_ACTION; ?>" />
|
||||||
|
<p><?php esc_html_e( 'Import WooCommerce Settings exported with this tool. Some settings like store address, payment gateways, etc. will need to be configured manually.', 'woocommerce-beta-tester' ); ?></p>
|
||||||
|
<button type="submit" class="button-primary"><?php
|
||||||
|
/* translators Import WooCommerce settings button text. */
|
||||||
|
esc_html_e( 'Import WooCommerce Settings', 'woocommerce-beta-tester' );
|
||||||
|
?></button>
|
||||||
|
<input type="file" name="<?php echo static::IMPORT_FILENAME; ?>" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export settings in json format.
|
||||||
|
*/
|
||||||
|
public function export_settings() {
|
||||||
|
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], static::NONCE_ACTION ) ) {
|
||||||
|
header( 'HTTP/1.1 403 Forbidden' );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = sprintf( 'woocommerce-settings-%s.json', gmdate( 'Ymdgi' ) );
|
||||||
|
wc_set_time_limit( 0 );
|
||||||
|
wc_nocache_headers();
|
||||||
|
header( 'Content-Type: text/csv; charset=utf-8' );
|
||||||
|
header( 'Content-Disposition: attachment; filename=' . $filename );
|
||||||
|
header( 'Pragma: no-cache' );
|
||||||
|
header( 'Expires: 0' );
|
||||||
|
echo wp_json_encode( $this->get_settings() );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import settings in json format if submitted.
|
||||||
|
*/
|
||||||
|
public function maybe_import_settings() {
|
||||||
|
if ( empty( $_POST ) || empty( $_POST['action'] ) || $_POST['action'] !== static::IMPORT_ACTION ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! wp_verify_nonce( $_POST['_wpnonce'], static::NONCE_ACTION ) ) {
|
||||||
|
$this->add_message( __( 'Invalid submission', 'woocommerce-beta-tester' ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $_FILES[ static::IMPORT_FILENAME ] ) ) {
|
||||||
|
$this->add_message( __( 'No file uploaded.', 'woocommerce-beta-tester' ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp_file = $_FILES[ static::IMPORT_FILENAME ]['tmp_name'];
|
||||||
|
if ( empty( $tmp_file ) ) {
|
||||||
|
$this->add_message( __( 'No file uploaded.', 'woocommerce-beta-tester' ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! is_readable( $tmp_file ) ) {
|
||||||
|
$this->add_message( __( 'File could not be read.', 'woocommerce-beta-tester' ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$maybe_json = file_get_contents( $tmp_file );
|
||||||
|
$settings = json_decode( $maybe_json, true );
|
||||||
|
if ( $settings !== null ) {
|
||||||
|
foreach ( $this->get_setting_list() as $option_name ) {
|
||||||
|
if ( ! isset( $settings[ $option_name ] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$setting = maybe_unserialize( $settings[ $option_name ] );
|
||||||
|
if ( is_null( $setting ) ) {
|
||||||
|
delete_option( $option_name );
|
||||||
|
} else {
|
||||||
|
update_option( $option_name, $setting );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->add_message( __( 'Settings Imported', 'woocommerce-beta-tester' ), 'updated' );
|
||||||
|
} else {
|
||||||
|
$this->add_message( __( 'File did not contain well formed JSON.', 'woocommerce-beta-tester' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an array of the WooCommerce related settings.
|
||||||
|
*/
|
||||||
|
protected function get_settings() {
|
||||||
|
$settings = array();
|
||||||
|
if ( current_user_can( 'manage_woocommerce' ) ) {
|
||||||
|
foreach ( $this->get_setting_list() as $option_name ) {
|
||||||
|
$setting = get_option( $option_name );
|
||||||
|
if ( false === $setting ) {
|
||||||
|
$setting = null;
|
||||||
|
}
|
||||||
|
$settings[ $option_name ] = is_string( $setting ) ? $setting : serialize( $setting );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a settings import status message.
|
||||||
|
*
|
||||||
|
* @param string $message Message string.
|
||||||
|
* @param string $type Message type. Optional. Default 'error'.
|
||||||
|
*/
|
||||||
|
protected function add_message( $message, $type = 'error' ) {
|
||||||
|
$this->message = array(
|
||||||
|
'message' => $message,
|
||||||
|
'type' => $type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the WooCommerce settings list keys.
|
||||||
|
*/
|
||||||
|
private function get_setting_list() {
|
||||||
|
require_once( dirname(__FILE__ ) . '/wc-beta-tester-settings-list.php');
|
||||||
|
return wc_beta_tester_setting_list();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WooCommerce Beta Tester Plugin Upgrader
|
||||||
|
*
|
||||||
|
* Class that extends the WP Core Plugin_Upgrader found in core to do version switch.
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'Plugin_Upgrader' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class WC_Beta_Tester_Plugin_Upgrader
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Plugin_Upgrader extends Plugin_Upgrader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch plugin version.
|
||||||
|
*
|
||||||
|
* @param string $plugin Plugin we're switching.
|
||||||
|
* @param array $args Args.
|
||||||
|
*
|
||||||
|
* @return array|bool|\WP_Error
|
||||||
|
*/
|
||||||
|
public function switch_version( $plugin, $args = array() ) {
|
||||||
|
$defaults = array(
|
||||||
|
'clear_update_cache' => true,
|
||||||
|
);
|
||||||
|
$parsed_args = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
|
$this->init();
|
||||||
|
$this->upgrade_strings();
|
||||||
|
|
||||||
|
$plugin_version = $this->skin->options['version'];
|
||||||
|
|
||||||
|
$download_url = WC_Beta_Tester::instance()->get_download_url( $plugin_version );
|
||||||
|
|
||||||
|
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
|
||||||
|
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
|
||||||
|
|
||||||
|
$this->run(
|
||||||
|
array(
|
||||||
|
'package' => $download_url,
|
||||||
|
'destination' => WP_PLUGIN_DIR,
|
||||||
|
'clear_destination' => true,
|
||||||
|
'clear_working' => true,
|
||||||
|
'hook_extra' => array(
|
||||||
|
'plugin' => $plugin,
|
||||||
|
'type' => 'plugin',
|
||||||
|
'action' => 'update',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||||
|
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
|
||||||
|
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
|
||||||
|
|
||||||
|
if ( ! $this->result || is_wp_error( $this->result ) ) {
|
||||||
|
return $this->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force refresh of plugin update information.
|
||||||
|
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,238 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester plugin Version Picker class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Version_Picker {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently installed version of WooCommerce plugin.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $current_version = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
|
||||||
|
add_action( 'admin_init', array( $this, 'handle_version_switch' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for the version switch button.
|
||||||
|
*
|
||||||
|
* @throws Exception On update error.
|
||||||
|
*/
|
||||||
|
public function handle_version_switch() {
|
||||||
|
if ( ! isset( $_GET['wcbt_switch_to_version'], $_GET['_wpnonce'] ) ) { // WPCS: Input var ok.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'wcbt_switch_version_nonce' ) ) { // WPCS: Input var ok, sanitization ok.
|
||||||
|
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce-beta-tester' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = isset( $_GET['wcbt_switch_to_version'] ) ? sanitize_text_field( wp_unslash( $_GET['wcbt_switch_to_version'] ) ) : ''; // WPCS: Input var ok, sanitization ok.
|
||||||
|
|
||||||
|
if ( empty( $version ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
include dirname( __FILE__ ) . '/class-wc-beta-tester-plugin-upgrader.php';
|
||||||
|
|
||||||
|
$plugin_name = 'woocommerce';
|
||||||
|
$plugin = 'woocommerce/woocommerce.php';
|
||||||
|
$skin_args = array(
|
||||||
|
'type' => 'web',
|
||||||
|
'url' => 'plugins.php?page=wc-beta-tester-version-picker',
|
||||||
|
'title' => 'Version switch result',
|
||||||
|
'plugin' => $plugin_name,
|
||||||
|
'version' => $version,
|
||||||
|
'nonce' => wp_unslash( $_GET['_wpnonce'] ), // WPCS: Input var ok, sanitization ok.
|
||||||
|
);
|
||||||
|
|
||||||
|
$skin = new Automatic_Upgrader_Skin( $skin_args );
|
||||||
|
$upgrader = new WC_Beta_Tester_Plugin_Upgrader( $skin );
|
||||||
|
$result = $upgrader->switch_version( $plugin );
|
||||||
|
|
||||||
|
// Try to reactivate.
|
||||||
|
activate_plugin( $plugin, '', is_network_admin(), true );
|
||||||
|
|
||||||
|
if ( is_wp_error( $skin->result ) ) {
|
||||||
|
throw new Exception( $skin->result->get_error_message() );
|
||||||
|
} elseif ( false === $result ) {
|
||||||
|
throw new Exception( __( 'Update failed', 'woocommerce-beta-tester' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_safe_redirect( admin_url( 'plugins.php?page=wc-beta-tester-version-picker&switched=' . rawurlencode( $version ) ) );
|
||||||
|
exit;
|
||||||
|
} catch ( Exception $e ) {
|
||||||
|
if ( class_exists( 'WC_Admin_Notices' ) ) {
|
||||||
|
WC_Admin_Notices::add_custom_notice(
|
||||||
|
$plugin . '_update_error',
|
||||||
|
sprintf(
|
||||||
|
// translators: 1: plugin name, 2: error message.
|
||||||
|
__( '%1$s could not be updated (%2$s).', 'woocommerce-beta-tester' ),
|
||||||
|
$plugin,
|
||||||
|
$e->getMessage()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
wp_safe_redirect( admin_url( 'plugins.php?page=wc-beta-tester-version-picker' ) );
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
wp_die( esc_html( $e->getMessage() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add options page to menu.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add_to_menus() {
|
||||||
|
add_submenu_page(
|
||||||
|
'plugins.php',
|
||||||
|
__( 'WooCommerce Version Switch', 'woocommerce-beta-tester' ),
|
||||||
|
__( 'WooCommerce Version Switch', 'woocommerce-beta-tester' ),
|
||||||
|
'install_plugins',
|
||||||
|
'wc-beta-tester-version-picker',
|
||||||
|
array( $this, 'select_versions_form_html' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return HTML code representation of list of WooCommerce versions for the selected channel.
|
||||||
|
*
|
||||||
|
* @param string $channel Filter versions by channel: all|beta|rc|stable.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_versions_html( $channel ) {
|
||||||
|
$tags = WC_Beta_Tester::instance()->get_tags( $channel );
|
||||||
|
|
||||||
|
if ( ! $tags ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
usort( $tags, 'version_compare' );
|
||||||
|
$tags = array_reverse( $tags );
|
||||||
|
$versions_html = '';
|
||||||
|
|
||||||
|
if ( ! empty( $_GET['switched'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||||
|
/* translators: %s: WooCoomerce version */
|
||||||
|
$versions_html .= '<div class="notice notice-success"><p>' . sprintf( esc_html__( 'Successfully switched version to %s.', 'woocommerce-beta-tester' ), esc_html( sanitize_text_field( wp_unslash( $_GET['switched'] ) ) ) ) . '</p></div>'; // WPCS: input var ok, CSRF ok.
|
||||||
|
}
|
||||||
|
|
||||||
|
$versions_html .= '<ul class="wcbt-version-list">';
|
||||||
|
$plugin_data = WC_Beta_Tester::instance()->get_plugin_data();
|
||||||
|
$this->current_version = $plugin_data['Version'];
|
||||||
|
|
||||||
|
// Loop through versions and output in a radio list.
|
||||||
|
foreach ( $tags as $tag_version ) {
|
||||||
|
|
||||||
|
$versions_html .= '<li class="wcbt-version-li">';
|
||||||
|
$versions_html .= '<label><input type="radio" ' . checked( strtolower($tag_version), strtolower($this->current_version), false ) . ' value="' . esc_attr( $tag_version ) . '" name="wcbt_switch_to_version">' . $tag_version;
|
||||||
|
|
||||||
|
// Is this the current version?
|
||||||
|
if ( strcasecmp($tag_version, $this->current_version) === 0 ) {
|
||||||
|
$versions_html .= '<span class="wcbt-current-version"><strong>' . esc_html__( ' Installed Version', 'woocommerce-beta-tester' ) . '</strong></span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$versions_html .= '</label>';
|
||||||
|
$versions_html .= '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$versions_html .= '</ul>';
|
||||||
|
|
||||||
|
return $versions_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Echo HTML form to switch WooCommerce versions, filtered for the selected channel.
|
||||||
|
*/
|
||||||
|
public function select_versions_form_html() {
|
||||||
|
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = WC_Beta_Tester::get_settings();
|
||||||
|
$channel = $settings->channel;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
<div class="wcbt-content-wrap">
|
||||||
|
<h1><?php esc_html_e( 'Available WooCommerce Releases', 'woocommerce-beta-tester' ); ?></h1>
|
||||||
|
<form name="wcbt-select-version" class="wcbt-select-version-form" action="<?php echo esc_attr( admin_url( '/tools.php' ) ); ?>">
|
||||||
|
<div class="wcbt-versions-wrap">
|
||||||
|
<?php echo $this->get_versions_html( $channel ); // WPCS: XSS ok. ?>
|
||||||
|
</div>
|
||||||
|
<div class="wcbt-submit-wrap">
|
||||||
|
<a href="#wcbt-modal-version-switch-confirm" class="button-primary" id="wcbt-modal-version-switch-confirm"><?php esc_html_e( 'Switch version', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
</div>
|
||||||
|
<?php wp_nonce_field( 'wcbt_switch_version_nonce' ); ?>
|
||||||
|
<input type="hidden" name="noheader" value="1">
|
||||||
|
<input type="hidden" name="page" value="wc-beta-tester-version-picker">
|
||||||
|
|
||||||
|
<script type="text/template" id="tmpl-wcbt-version-switch-confirm">
|
||||||
|
<div class="wc-backbone-modal wc-backbone-modal-beta-tester-version-info">
|
||||||
|
<div class="wc-backbone-modal-content">
|
||||||
|
<section class="wc-backbone-modal-main" role="main">
|
||||||
|
<header class="wc-backbone-modal-header">
|
||||||
|
<h1>
|
||||||
|
<?php
|
||||||
|
esc_html_e( 'Are you sure you want to switch the version of WooCommerce plugin?', 'woocommerce-beta-tester' );
|
||||||
|
?>
|
||||||
|
</h1>
|
||||||
|
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
|
||||||
|
<span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce-beta-tester' ); ?></span>
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<table class="wcbt-widefat widefat">
|
||||||
|
<tbody>
|
||||||
|
<tr class="alternate">
|
||||||
|
<td class="row-title">
|
||||||
|
<label for="tablecell"><?php esc_html_e( 'Installed Version:', 'woocommerce-beta-tester' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td><span class="wcbt-installed-version"><?php echo esc_html( $this->current_version ); ?></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="row-title">
|
||||||
|
<label for="tablecell"><?php esc_html_e( 'New Version:', 'woocommerce-beta-tester' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td><span class="wcbt-new-version">{{ data.new_version }}</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p class="wcbt-notice"><?php esc_html_e( 'Notice: We strongly recommend you perform the test on a staging site and create a complete backup of your WordPress files and database prior to performing a version switch. We are not responsible for any misuse, deletions, white screens, fatal errors, or any other issue arising from using this plugin.', 'woocommerce-beta-tester' ); ?></p>
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
<input type="submit" value="<?php esc_attr_e( 'Switch version', 'woocommerce-beta-tester' ); ?>" class="button-primary wcbt-go" id="wcbt-submit-version-switch"/>
|
||||||
|
<a href="#" class="modal-close modal-close-link"><?php esc_attr_e( 'Cancel', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new WC_Beta_Tester_Version_Picker();
|
|
@ -0,0 +1,468 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester plugin main class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WC_Beta_Tester Main Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $plugin_config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin instance.
|
||||||
|
*
|
||||||
|
* @var WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
protected static $_instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main Instance.
|
||||||
|
*/
|
||||||
|
public static function instance() {
|
||||||
|
self::$_instance = is_null( self::$_instance ) ? new self() : self::$_instance;
|
||||||
|
|
||||||
|
return self::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ran on activation to flush update cache
|
||||||
|
*/
|
||||||
|
public static function activate() {
|
||||||
|
delete_site_transient( 'update_plugins' );
|
||||||
|
delete_site_transient( 'woocommerce_latest_tag' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin settings.
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public static function get_settings() {
|
||||||
|
$settings = (object) wp_parse_args(
|
||||||
|
get_option( 'wc_beta_tester_options', array() ),
|
||||||
|
array(
|
||||||
|
'channel' => 'beta',
|
||||||
|
'auto_update' => false,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$settings->channel = $settings->channel;
|
||||||
|
$settings->auto_update = (bool) $settings->auto_update;
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plugin url.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function plugin_url() {
|
||||||
|
return untrailingslashit( plugins_url( '/', WC_BETA_TESTER_FILE ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->plugin_name = plugin_basename( WC_BETA_TESTER_FILE );
|
||||||
|
$this->plugin_config = array(
|
||||||
|
'plugin_file' => 'woocommerce/woocommerce.php',
|
||||||
|
'slug' => 'woocommerce',
|
||||||
|
'proper_folder_name' => 'woocommerce',
|
||||||
|
'api_url' => 'https://api.wordpress.org/plugins/info/1.0/woocommerce.json',
|
||||||
|
'repo_url' => 'https://wordpress.org/plugins/woocommerce/',
|
||||||
|
);
|
||||||
|
|
||||||
|
add_filter( "plugin_action_links_{$this->plugin_name}", array( $this, 'plugin_action_links' ), 10, 1 );
|
||||||
|
add_filter( 'auto_update_plugin', array( $this, 'auto_update_woocommerce' ), 100, 2 );
|
||||||
|
|
||||||
|
if ( 'stable' !== $this->get_settings()->channel ) {
|
||||||
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
|
||||||
|
add_filter( 'plugins_api_result', array( $this, 'plugins_api_result' ), 10, 3 );
|
||||||
|
add_filter( 'upgrader_source_selection', array( $this, 'upgrader_source_selection' ), 10, 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->includes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include any classes we need within admin.
|
||||||
|
*/
|
||||||
|
public function includes() {
|
||||||
|
include_once dirname( __FILE__ ) . '/class-wc-beta-tester-admin-menus.php';
|
||||||
|
include_once dirname( __FILE__ ) . '/class-wc-beta-tester-admin-assets.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not the transients need to be overruled and API needs to be called for every single page load
|
||||||
|
*
|
||||||
|
* @return bool overrule or not
|
||||||
|
*/
|
||||||
|
public function overrule_transients() {
|
||||||
|
return defined( 'WC_BETA_TESTER_FORCE_UPDATE' ) && WC_BETA_TESTER_FORCE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a given version is a pre-release.
|
||||||
|
*
|
||||||
|
* @param string $version Version to compare.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_prerelease( $version ) {
|
||||||
|
return preg_match( '/(.*)?-(beta|rc)(.*)/', $version );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get New Version from WPorg
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @return int $version the version number
|
||||||
|
*/
|
||||||
|
public function get_latest_channel_release() {
|
||||||
|
$tagged_version = get_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag' );
|
||||||
|
|
||||||
|
if ( $this->overrule_transients() || empty( $tagged_version ) ) {
|
||||||
|
|
||||||
|
$data = $this->get_wporg_data();
|
||||||
|
|
||||||
|
$latest_version = $data->version;
|
||||||
|
$versions = (array) $data->versions;
|
||||||
|
$channel = $this->get_settings()->channel;
|
||||||
|
|
||||||
|
foreach ( $versions as $version => $download_url ) {
|
||||||
|
if ( 'trunk' === $version ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch ( $channel ) {
|
||||||
|
case 'stable':
|
||||||
|
if ( $this->is_in_stable_channel( $version ) ) {
|
||||||
|
$tagged_version = $version;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'rc':
|
||||||
|
if ( $this->is_in_rc_channel( $version ) ) {
|
||||||
|
$tagged_version = $version;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'beta':
|
||||||
|
if ( $this->is_in_beta_channel( $version ) ) {
|
||||||
|
$tagged_version = $version;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh every 6 hours.
|
||||||
|
if ( ! empty( $tagged_version ) ) {
|
||||||
|
set_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag', $tagged_version, HOUR_IN_SECONDS * 6 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tagged_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Data from .org API.
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @return array $wporg_data The data.
|
||||||
|
*/
|
||||||
|
public function get_wporg_data() {
|
||||||
|
if ( ! empty( $this->wporg_data ) ) {
|
||||||
|
return $this->wporg_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wporg_data = get_site_transient( md5( $this->plugin_config['slug'] ) . '_wporg_data' );
|
||||||
|
|
||||||
|
if ( $this->overrule_transients() || ( ! isset( $wporg_data ) || ! $wporg_data || '' === $wporg_data ) ) {
|
||||||
|
$wporg_data = wp_remote_get( $this->plugin_config['api_url'] );
|
||||||
|
|
||||||
|
if ( is_wp_error( $wporg_data ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wporg_data = json_decode( $wporg_data['body'] );
|
||||||
|
|
||||||
|
// Refresh every 6 hours.
|
||||||
|
set_site_transient( md5( $this->plugin_config['slug'] ) . '_wporg_data', $wporg_data, HOUR_IN_SECONDS * 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the data in this class instance for future calls.
|
||||||
|
$this->wporg_data = $wporg_data;
|
||||||
|
|
||||||
|
return $wporg_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin download URL.
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @param string $version The version.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_download_url( $version ) {
|
||||||
|
$data = $this->get_wporg_data();
|
||||||
|
|
||||||
|
if ( empty( $data->versions->$version ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data->versions->$version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin data.
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @return object $data The data.
|
||||||
|
*/
|
||||||
|
public function get_plugin_data() {
|
||||||
|
return get_plugin_data( WP_PLUGIN_DIR . '/' . $this->plugin_config['plugin_file'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook into the plugin update check and connect to WPorg.
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @param object $transient The plugin data transient.
|
||||||
|
* @return object $transient Updated plugin data transient.
|
||||||
|
*/
|
||||||
|
public function api_check( $transient ) {
|
||||||
|
// Clear our transient.
|
||||||
|
delete_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag' );
|
||||||
|
|
||||||
|
// Get version data.
|
||||||
|
$plugin_data = $this->get_plugin_data();
|
||||||
|
$version = $plugin_data['Version'];
|
||||||
|
$new_version = $this->get_latest_channel_release();
|
||||||
|
|
||||||
|
// check the version and decide if it's new.
|
||||||
|
$update = version_compare( $new_version, $version, '>' );
|
||||||
|
|
||||||
|
if ( ! $update ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate response data.
|
||||||
|
if ( ! isset( $transient->response['woocommerce/woocommerce.php'] ) ) {
|
||||||
|
$transient->response['woocommerce/woocommerce.php'] = (object) $this->plugin_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transient->response['woocommerce/woocommerce.php']->new_version = $new_version;
|
||||||
|
$transient->response['woocommerce/woocommerce.php']->zip_url = $this->get_download_url( $new_version );
|
||||||
|
$transient->response['woocommerce/woocommerce.php']->package = $this->get_download_url( $new_version );
|
||||||
|
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the Plugin Installation API response results.
|
||||||
|
*
|
||||||
|
* @param object|WP_Error $response Response object or WP_Error.
|
||||||
|
* @param string $action The type of information being requested from the Plugin Installation API.
|
||||||
|
* @param object $args Plugin API arguments.
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function plugins_api_result( $response, $action, $args ) {
|
||||||
|
// Check if this call API is for the right plugin.
|
||||||
|
if ( ! isset( $response->slug ) || $response->slug !== $this->plugin_config['slug'] ) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_version = $this->get_latest_channel_release();
|
||||||
|
|
||||||
|
if ( version_compare( $response->version, $new_version, '=' ) ) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->is_beta_version( $new_version ) ) {
|
||||||
|
$warning = __( '<h1><span>⚠</span>This is a beta release<span>⚠</span></h1>', 'woocommerce-beta-tester' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->is_rc_version( $new_version ) ) {
|
||||||
|
$warning = __( '<h1><span>⚠</span>This is a pre-release version<span>⚠</span></h1>', 'woocommerce-beta-tester' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are returning a different version than the stable tag on .org, manipulate the returned data.
|
||||||
|
$response->version = $new_version;
|
||||||
|
$response->download_link = $this->get_download_url( $new_version );
|
||||||
|
|
||||||
|
$response->sections['changelog'] = sprintf(
|
||||||
|
'<p><a target="_blank" href="%s">' . __( 'Read the changelog and find out more about the release on GitHub.', 'woocommerce-beta-tester' ) . '</a></p>',
|
||||||
|
'https://github.com/woocommerce/woocommerce/blob/' . $response->version . '/readme.txt'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $response->sections as $key => $section ) {
|
||||||
|
$response->sections[ $key ] = $warning . $section;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename the downloaded zip
|
||||||
|
*
|
||||||
|
* @param string $source File source location.
|
||||||
|
* @param string $remote_source Remote file source location.
|
||||||
|
* @param WP_Upgrader $upgrader WordPress Upgrader instance.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function upgrader_source_selection( $source, $remote_source, $upgrader ) {
|
||||||
|
global $wp_filesystem;
|
||||||
|
|
||||||
|
if ( strstr( $source, '/woocommerce-woocommerce-' ) ) {
|
||||||
|
$corrected_source = trailingslashit( $remote_source ) . trailingslashit( $this->plugin_config['proper_folder_name'] );
|
||||||
|
|
||||||
|
if ( $wp_filesystem->move( $source, $corrected_source, true ) ) {
|
||||||
|
return $corrected_source;
|
||||||
|
} else {
|
||||||
|
return new WP_Error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable auto updates for WooCommerce.
|
||||||
|
*
|
||||||
|
* @param bool $update Should this autoupdate.
|
||||||
|
* @param object $plugin Plugin being checked.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function auto_update_woocommerce( $update, $plugin ) {
|
||||||
|
if ( true === $this->get_settings()->auto_update && 'woocommerce' === $plugin->slug ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if version string is a beta version.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_beta_version( $version_str ) {
|
||||||
|
return strpos( $version_str, 'beta' ) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if version string is a Release Candidate.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_rc_version( $version_str ) {
|
||||||
|
return strpos( $version_str, 'rc' ) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if version string is a stable version.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_stable_version( $version_str ) {
|
||||||
|
return ! self::is_beta_version( $version_str ) && ! self::is_rc_version( $version_str );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if release's version string belongs to beta channel, i.e.
|
||||||
|
* if it's beta, rc or stable release.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string of the release.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_in_beta_channel( $version_str ) {
|
||||||
|
return self::is_beta_version( $version_str ) || self::is_rc_version( $version_str ) || self::is_stable_version( $version_str );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if release's version string belongs to release candidate channel, i.e.
|
||||||
|
* if it's rc or stable release.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string of the release.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_in_rc_channel( $version_str ) {
|
||||||
|
return self::is_rc_version( $version_str ) || self::is_stable_version( $version_str );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if release's version string belongs to stable channel, i.e.
|
||||||
|
* if it's stable release and not a beta or rc.
|
||||||
|
*
|
||||||
|
* @param string $version_str Version string of the release.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function is_in_stable_channel( $version_str ) {
|
||||||
|
return self::is_stable_version( $version_str );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return available versions from wp.org tags belonging to selected channel.
|
||||||
|
*
|
||||||
|
* @param string $channel Filter versions by channel: all|beta|rc|stable.
|
||||||
|
* @return array(string)
|
||||||
|
*/
|
||||||
|
public function get_tags( $channel = 'all' ) {
|
||||||
|
$data = $this->get_wporg_data();
|
||||||
|
$releases = (array) $data->versions;
|
||||||
|
|
||||||
|
unset( $releases['trunk'] );
|
||||||
|
|
||||||
|
$releases = array_keys( $releases );
|
||||||
|
foreach ( $releases as $index => $version ) {
|
||||||
|
if ( version_compare( $version, '3.6', '<' ) ) {
|
||||||
|
unset( $releases[ $index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'beta' === $channel ) {
|
||||||
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_beta_channel' ) );
|
||||||
|
} elseif ( 'rc' === $channel ) {
|
||||||
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_rc_channel' ) );
|
||||||
|
} elseif ( 'stable' === $channel ) {
|
||||||
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_stable_channel' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $releases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show action links on the plugin screen.
|
||||||
|
*
|
||||||
|
* @param mixed $links Plugin Action links.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function plugin_action_links( $links ) {
|
||||||
|
$action_links = array(
|
||||||
|
'switch-version' => sprintf(
|
||||||
|
'<a href="%s">%s</a>',
|
||||||
|
esc_url( admin_url( 'plugins.php?page=wc-beta-tester-version-picker' ) ),
|
||||||
|
esc_html__( 'Switch versions', 'woocommerce-beta-tester' )
|
||||||
|
),
|
||||||
|
'settings' => sprintf(
|
||||||
|
'<a href="%s">%s</a>',
|
||||||
|
esc_url( admin_url( 'plugins.php?page=wc-beta-tester' ) ),
|
||||||
|
esc_html__( 'Settings', 'woocommerce-beta-tester' )
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return array_merge( $action_links, $links );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Missing WooCommerce notice.
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester\Admin\Views
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="notice notice-error">
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
// Translators: %s Plugin name.
|
||||||
|
echo sprintf( esc_html__( '%s requires WooCommerce to be installed and activated in order to serve updates.', 'woocommerce-beta-tester' ), '<strong>' . esc_html__( 'WooCommerce Beta Tester', 'woocommerce-beta-tester' ) . '</strong>' );
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && current_user_can( 'activate_plugin', 'woocommerce/woocommerce.php' ) ) : ?>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
$installed_plugins = get_plugins();
|
||||||
|
if ( isset( $installed_plugins['woocommerce/woocommerce.php'] ) ) :
|
||||||
|
?>
|
||||||
|
<a href="<?php echo esc_url( wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=active' ), 'activate-plugin_woocommerce/woocommerce.php' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Activate WooCommerce', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ( current_user_can( 'deactivate_plugin', 'woocommerce-beta-tester/woocommerce-beta-tester.php' ) ) : ?>
|
||||||
|
<a href="<?php echo esc_url( wp_nonce_url( 'plugins.php?action=deactivate&plugin=woocommerce-beta-tester/woocommerce-beta-tester.php&plugin_status=inactive', 'deactivate-plugin_woocommerce-beta-tester/woocommerce-beta-tester.php' ) ); ?>" class="button button-secondary"><?php esc_html_e( 'Turn off Beta Tester plugin', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
<?php else : ?>
|
||||||
|
<?php
|
||||||
|
if ( current_user_can( 'install_plugins' ) ) {
|
||||||
|
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
|
||||||
|
} else {
|
||||||
|
$url = 'http://wordpress.org/plugins/woocommerce/';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<p>
|
||||||
|
<a href="<?php echo esc_url( $url ); ?>" class="button button-primary"><?php esc_html_e( 'Install WooCommerce', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
<?php if ( current_user_can( 'deactivate_plugin', 'woocommerce-beta-tester/woocommerce-beta-tester.php' ) ) : ?>
|
||||||
|
<a href="<?php echo esc_url( wp_nonce_url( 'plugins.php?action=deactivate&plugin=woocommerce-beta-tester/woocommerce-beta-tester.php&plugin_status=inactive', 'deactivate-plugin_woocommerce-beta-tester/woocommerce-beta-tester.php' ) ); ?>" class="button button-secondary"><?php esc_html_e( 'Turn off Beta Tester plugin', 'woocommerce-beta-tester' ); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* List of settings to be exported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function wc_beta_tester_setting_list() {
|
||||||
|
$settings_list = array(
|
||||||
|
'date_format',
|
||||||
|
'gmt_offset',
|
||||||
|
'permalink_structure',
|
||||||
|
'posts_per_page',
|
||||||
|
'shop_catalog_image_size',
|
||||||
|
'shop_single_image_size',
|
||||||
|
'time_format',
|
||||||
|
'timezone_string',
|
||||||
|
'woocommerce_all_except_countries',
|
||||||
|
'woocommerce_allowed_countries',
|
||||||
|
'woocommerce_api_enabled',
|
||||||
|
'woocommerce_calc_discounts_sequentially',
|
||||||
|
'woocommerce_calc_shipping',
|
||||||
|
'woocommerce_calc_taxes',
|
||||||
|
'woocommerce_cart_redirect_after_add',
|
||||||
|
'woocommerce_catalog_columns',
|
||||||
|
'woocommerce_catalog_rows',
|
||||||
|
'woocommerce_category_archive_display',
|
||||||
|
'woocommerce_checkout_address_2_field',
|
||||||
|
'woocommerce_checkout_company_field',
|
||||||
|
'woocommerce_checkout_highlight_required_fields',
|
||||||
|
'woocommerce_checkout_order_received_endpoint',
|
||||||
|
'woocommerce_checkout_pay_endpoint',
|
||||||
|
'woocommerce_checkout_phone_field',
|
||||||
|
'woocommerce_currency',
|
||||||
|
'woocommerce_currency_pos',
|
||||||
|
'woocommerce_db_version',
|
||||||
|
'woocommerce_default_catalog_orderby',
|
||||||
|
'woocommerce_default_country',
|
||||||
|
'woocommerce_default_customer_address',
|
||||||
|
'woocommerce_delete_inactive_accounts',
|
||||||
|
'woocommerce_dimension_unit',
|
||||||
|
'woocommerce_downloads_add_hash_to_filename',
|
||||||
|
'woocommerce_downloads_grant_access_after_payment',
|
||||||
|
'woocommerce_downloads_require_login',
|
||||||
|
'woocommerce_enable_ajax_add_to_cart',
|
||||||
|
'woocommerce_enable_coupons',
|
||||||
|
'woocommerce_enable_guest_checkout',
|
||||||
|
'woocommerce_enable_myaccount_registration',
|
||||||
|
'woocommerce_enable_order_comments',
|
||||||
|
'woocommerce_enable_review_rating',
|
||||||
|
'woocommerce_enable_reviews',
|
||||||
|
'woocommerce_enable_shipping_calc',
|
||||||
|
'woocommerce_enable_signup_and_login_from_checkout',
|
||||||
|
'woocommerce_erasure_request_removes_download_data',
|
||||||
|
'woocommerce_erasure_request_removes_order_data',
|
||||||
|
'woocommerce_file_download_method',
|
||||||
|
'woocommerce_force_ssl_checkout',
|
||||||
|
'woocommerce_hide_out_of_stock_items',
|
||||||
|
'woocommerce_hide_products_when_showing_subcategories',
|
||||||
|
'woocommerce_hold_stock_minutes',
|
||||||
|
'woocommerce_local_tax_rates',
|
||||||
|
'woocommerce_logout_endpoint',
|
||||||
|
'woocommerce_manage_stock',
|
||||||
|
'woocommerce_myaccount_add_payment_method_endpoint',
|
||||||
|
'woocommerce_myaccount_delete_payment_method_endpoint',
|
||||||
|
'woocommerce_myaccount_downloads_endpoint',
|
||||||
|
'woocommerce_myaccount_edit_account_endpoint',
|
||||||
|
'woocommerce_myaccount_edit_address_endpoint',
|
||||||
|
'woocommerce_myaccount_lost_password_endpoint',
|
||||||
|
'woocommerce_myaccount_orders_endpoint',
|
||||||
|
'woocommerce_myaccount_payment_methods_endpoint',
|
||||||
|
'woocommerce_myaccount_set_default_payment_method_endpoint',
|
||||||
|
'woocommerce_myaccount_view_order_endpoint',
|
||||||
|
'woocommerce_new_order_settings',
|
||||||
|
'woocommerce_notify_low_stock',
|
||||||
|
'woocommerce_notify_low_stock_amount',
|
||||||
|
'woocommerce_notify_no_stock',
|
||||||
|
'woocommerce_notify_no_stock_amount',
|
||||||
|
'woocommerce_permalinks',
|
||||||
|
'woocommerce_placeholder_image',
|
||||||
|
'woocommerce_prepend_category_to_products',
|
||||||
|
'woocommerce_prepend_shop_page_to_products',
|
||||||
|
'woocommerce_prepend_shop_page_to_urls',
|
||||||
|
'woocommerce_price_decimal_sep',
|
||||||
|
'woocommerce_price_display_suffix',
|
||||||
|
'woocommerce_price_num_decimals',
|
||||||
|
'woocommerce_price_thousand_sep',
|
||||||
|
'woocommerce_prices_include_tax',
|
||||||
|
'woocommerce_product_category_slug',
|
||||||
|
'woocommerce_product_slug',
|
||||||
|
'woocommerce_product_tag_slug',
|
||||||
|
'woocommerce_product_type',
|
||||||
|
'woocommerce_registration_generate_password',
|
||||||
|
'woocommerce_registration_generate_username',
|
||||||
|
'woocommerce_review_rating_required',
|
||||||
|
'woocommerce_ship_to_billing',
|
||||||
|
'woocommerce_ship_to_billing_address_only',
|
||||||
|
'woocommerce_ship_to_countries',
|
||||||
|
'woocommerce_ship_to_destination',
|
||||||
|
'woocommerce_shipping_cost_requires_address',
|
||||||
|
'woocommerce_shipping_debug_mode',
|
||||||
|
'woocommerce_shipping_tax_class',
|
||||||
|
'woocommerce_shop_page_display',
|
||||||
|
'woocommerce_shop_show_subcategories',
|
||||||
|
'woocommerce_show_marketplace_suggestions',
|
||||||
|
'woocommerce_show_subcategories',
|
||||||
|
'woocommerce_single_image_width',
|
||||||
|
'woocommerce_specific_allowed_countries',
|
||||||
|
'woocommerce_specific_ship_to_countries',
|
||||||
|
'woocommerce_stock_format',
|
||||||
|
'woocommerce_tax_based_on',
|
||||||
|
'woocommerce_tax_classes',
|
||||||
|
'woocommerce_tax_display_cart',
|
||||||
|
'woocommerce_tax_display_shop',
|
||||||
|
'woocommerce_tax_rates',
|
||||||
|
'woocommerce_tax_round_at_subtotal',
|
||||||
|
'woocommerce_tax_total_display',
|
||||||
|
'woocommerce_thumbnail_cropping',
|
||||||
|
'woocommerce_thumbnail_cropping_custom_height',
|
||||||
|
'woocommerce_thumbnail_cropping_custom_width',
|
||||||
|
'woocommerce_thumbnail_image_width',
|
||||||
|
'woocommerce_trash_cancelled_orders',
|
||||||
|
'woocommerce_trash_failed_orders',
|
||||||
|
'woocommerce_trash_pending_orders',
|
||||||
|
'woocommerce_unforce_ssl_checkout',
|
||||||
|
'woocommerce_version',
|
||||||
|
'woocommerce_weight_unit'
|
||||||
|
);
|
||||||
|
return apply_filters( 'wc_beta_tester_setting_list', $settings_list );
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
"name": "woocommerce-beta-tester",
|
||||||
|
"description": "Setting up the local beta tester scripts.",
|
||||||
|
"license": "GPL-2.0",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/woocommerce/woocommerce-beta-tester.git"
|
||||||
|
},
|
||||||
|
"title": "WooCommerce Beta Tester",
|
||||||
|
"version": "2.0.5",
|
||||||
|
"homepage": "http://github.com/woocommerce/woocommerce-beta-tester",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "5.16.0",
|
||||||
|
"husky": "1.3.1",
|
||||||
|
"lint-staged": "8.1.5",
|
||||||
|
"uglify-js": "^3.5.3"
|
||||||
|
},
|
||||||
|
"assets": {
|
||||||
|
"js": {
|
||||||
|
"min": "assets/js/*.min.js",
|
||||||
|
"js": "assets/js/*.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "./bin/build-zip.sh",
|
||||||
|
"build:dev": "npm run lint:js && npm run uglify",
|
||||||
|
"preuglify": "rm -f $npm_package_assets_js_min",
|
||||||
|
"uglify": "for f in $npm_package_assets_js_js; do file=${f%.js}; node_modules/.bin/uglifyjs $f -c -m > $file.min.js; done",
|
||||||
|
"lint:js": "eslint assets/js --ext=js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.15.0",
|
||||||
|
"npm": ">=6.4.1"
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "lint-staged"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"linters": {
|
||||||
|
"*.php": [
|
||||||
|
"php -d display_errors=1 -l",
|
||||||
|
"composer run-script phpcs-pre-commit"
|
||||||
|
],
|
||||||
|
"*.js": [
|
||||||
|
"eslint --fix",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ignore": [
|
||||||
|
"*.min.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"woorelease": {
|
||||||
|
"svn_reauth": "true",
|
||||||
|
"wp_org_slug": "woocommerce-beta-tester"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="WordPress Coding Standards">
|
||||||
|
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
||||||
|
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
|
||||||
|
|
||||||
|
<description>WooCommerce dev PHP_CodeSniffer ruleset.</description>
|
||||||
|
|
||||||
|
<!-- Exclude paths -->
|
||||||
|
<exclude-pattern>*/node_modules/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Configs -->
|
||||||
|
<config name="minimum_supported_wp_version" value="4.7" />
|
||||||
|
<config name="testVersion" value="5.2-"/>
|
||||||
|
|
||||||
|
<!-- Rules -->
|
||||||
|
<rule ref="WooCommerce-Core" />
|
||||||
|
<rule ref="PHPCompatibility">
|
||||||
|
<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound" />
|
||||||
|
<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound" />
|
||||||
|
<exclude name="PHPCompatibility.PHP.NewKeywords.t_namespaceFound" />
|
||||||
|
<exclude-pattern>tests/</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="WordPress">
|
||||||
|
<exclude name="WordPress.VIP.DirectDatabaseQuery.NoCaching" />
|
||||||
|
<exclude name="WordPress.VIP.DirectDatabaseQuery.DirectQuery" />
|
||||||
|
<exclude name="WordPress.VIP.DirectDatabaseQuery.SchemaChange" />
|
||||||
|
<exclude name="WordPress.VIP.FileSystemWritesDisallow.file_ops_fwrite" />
|
||||||
|
<exclude name="WordPress.VIP.OrderByRand" />
|
||||||
|
<exclude name="WordPress.VIP.RestrictedFunctions" />
|
||||||
|
<exclude name="WordPress.VIP.RestrictedVariables.user_meta__wpdb__usermeta" />
|
||||||
|
<exclude name="WordPress.VIP.PostsPerPage.posts_per_page_posts_per_page" />
|
||||||
|
<exclude name="WordPress.VIP.RestrictedVariables.cache_constraints___COOKIE" />
|
||||||
|
</rule>
|
||||||
|
<rule ref="WordPress.VIP.ValidatedSanitizedInput">
|
||||||
|
<properties>
|
||||||
|
<property name="customSanitizingFunctions" type="array" value="wc_clean,wc_sanitize_tooltip,wc_format_decimal,wc_stock_amount,wc_sanitize_permalink,wc_sanitize_textarea" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="WordPress.XSS.EscapeOutput">
|
||||||
|
<properties>
|
||||||
|
<property name="customEscapingFunctions" type="array" value="wc_help_tip,wc_sanitize_tooltip" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="WordPress.WP.I18n">
|
||||||
|
<properties>
|
||||||
|
<property name="text_domain" type="array" value="woocommerce-beta-tester" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
|
@ -0,0 +1,95 @@
|
||||||
|
=== WooCommerce Beta Tester ===
|
||||||
|
Contributors: automattic, bor0, claudiosanches, claudiulodro, kloon, mikejolley, peterfabian1000, rodrigosprimo, wpmuguru
|
||||||
|
Tags: woocommerce, woo commerce, beta, beta tester, bleeding edge, testing
|
||||||
|
Requires at least: 4.7
|
||||||
|
Tested up to: 5.6
|
||||||
|
Stable tag: 2.0.5
|
||||||
|
License: GPLv3
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Easily update to prerelease versions of WooCommerce for testing and development purposes.
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
**WooCommerce Beta Tester** allows you to try out new versions of WooCommerce before they are officially released.
|
||||||
|
|
||||||
|
**Use with caution, not on production sites. Beta releases may not be stable.**
|
||||||
|
|
||||||
|
After activation, you'll be able to choose an update channel:
|
||||||
|
|
||||||
|
1. Beta - Update to beta releases, RC, or stable, depending on what is newest.
|
||||||
|
2. Release Candidate - Update to RC releases or stable, depending on what is newest.
|
||||||
|
3. Stable - No beta updates. Default WordPress behavior.
|
||||||
|
|
||||||
|
These will surface pre-releases via automatic updates in WordPress. Updates will replace your installed version of WooCommerce.
|
||||||
|
|
||||||
|
**Note**, this will not check for updates on every admin page load unless you explicitly tell it to. You can do this by clicking the "Check Again" button from the WordPress updates screen or you can set the `WC_BETA_TESTER_FORCE_UPDATE` to true in your `wp-config.php` file.
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
= Does this allow me to install multiple versions of WooCommerce at the same time?
|
||||||
|
|
||||||
|
No; updates will replace your currently installed version of WooCommerce. You can switch to any version from this plugin via the interface however.
|
||||||
|
|
||||||
|
= Where do updates come from? =
|
||||||
|
|
||||||
|
Updates are downloaded from the WordPress.org SVN repository where we tag prerelease versions specifically for this purpose.
|
||||||
|
|
||||||
|
= Does this rollback my data? =
|
||||||
|
|
||||||
|
This plugin does not rollback or update data on your store automatically.
|
||||||
|
|
||||||
|
Database updates are manually ran like after regular updates. If you downgrade, data will not be modified. We don't recommend using this in production.
|
||||||
|
|
||||||
|
= Where can I report bugs or contribute to WooCommerce Beta Tester? =
|
||||||
|
|
||||||
|
Bugs can be reported to the [WooCommerce Beta Tester GitHub issue tracker](https://github.com/woocommerce/woocommerce-beta-tester).
|
||||||
|
|
||||||
|
= Where can I report bugs or contribute to WooCommerce? =
|
||||||
|
|
||||||
|
Join in on our [GitHub repository](https://github.com/woocommerce/woocommerce/).
|
||||||
|
|
||||||
|
See our [contributing guidelines here](https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md).
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 2.0.5 - 2021-12-17 =
|
||||||
|
* Fix: make WC version comparison case insensitive
|
||||||
|
|
||||||
|
= 2.0.4 - 2021-09-29 =
|
||||||
|
* Dev: Bump tested to version
|
||||||
|
* Fix: enqueue logic for css/js assets
|
||||||
|
|
||||||
|
= 2.0.3 - 2021-09-22 =
|
||||||
|
* Fix: Bump version to release version including admin.css.
|
||||||
|
|
||||||
|
= 2.0.2 =
|
||||||
|
|
||||||
|
* Fix notice for undefined `item`
|
||||||
|
* Fix auto_update_plugin filter reference
|
||||||
|
* Fix including SSR in bug report
|
||||||
|
* Fix style in version modal header
|
||||||
|
* Add check for WooCommerce installed in default location
|
||||||
|
|
||||||
|
= 2.0.1 =
|
||||||
|
* Changes to make this plugin compatible with the upcoming WooCommerce 3.6
|
||||||
|
|
||||||
|
= 2.0.0 =
|
||||||
|
* Enhancement - Re-built to pull updates from the WordPress.org repository rather than GitHub.
|
||||||
|
* Enhancement - Channel selection; choose to receive RC or beta versions.
|
||||||
|
* Enhancement - Admin bar item shows version information, and offers shortcuts to functionality.
|
||||||
|
* Enhancement - Shortcut to log GitHub issues.
|
||||||
|
* Enhancement - Version switcher; choose which release or prerelease to switch to.
|
||||||
|
* Enhancement - Setting to enable auto-updates.
|
||||||
|
|
||||||
|
= 1.0.3 =
|
||||||
|
* Fix repo URLs and directory renaming.
|
||||||
|
|
||||||
|
= 1.0.2 =
|
||||||
|
* Updated API URL.
|
||||||
|
|
||||||
|
= 1.0.1 =
|
||||||
|
* Switched to releases API to get latest release, rather than tag which are not chronological.
|
||||||
|
|
||||||
|
= 1.0 =
|
||||||
|
* First release.
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: WooCommerce Beta Tester
|
||||||
|
* Plugin URI: https://github.com/woocommerce/woocommerce-beta-tester
|
||||||
|
* Description: Run bleeding edge versions of WooCommerce. This will replace your installed version of WooCommerce with the latest tagged release - use with caution, and not on production sites.
|
||||||
|
* Version: 2.0.5
|
||||||
|
* Author: WooCommerce
|
||||||
|
* Author URI: http://woocommerce.com/
|
||||||
|
* Requires at least: 4.4
|
||||||
|
* Tested up to: 5.8
|
||||||
|
* WC requires at least: 3.6.0
|
||||||
|
* WC tested up to: 5.7.0
|
||||||
|
* Text Domain: woocommerce-beta-tester
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
// Define WC_BETA_TESTER_FILE.
|
||||||
|
if ( ! defined( 'WC_BETA_TESTER_FILE' ) ) {
|
||||||
|
define( 'WC_BETA_TESTER_FILE', __FILE__ );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! defined( 'WC_BETA_TESTER_VERSION' ) ) {
|
||||||
|
define( 'WC_BETA_TESTER_VERSION', '2.0.2' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load text domain before all other code.
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
function _wc_beta_tester_load_textdomain() {
|
||||||
|
load_plugin_textdomain( 'woocommerce-beta-tester', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action( 'plugins_loaded', '_wc_beta_tester_load_textdomain' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boostrap plugin.
|
||||||
|
*/
|
||||||
|
function _wc_beta_tester_bootstrap() {
|
||||||
|
|
||||||
|
// Check if WooCommerce is enabled.
|
||||||
|
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||||
|
include dirname( __FILE__ ) . '/includes/class-wc-beta-tester-admin-notices.php';
|
||||||
|
$notices = new WC_Beta_Tester_Admin_Notices();
|
||||||
|
|
||||||
|
add_action( 'admin_notices', array( $notices, 'woocoommerce_not_installed' ) );
|
||||||
|
} elseif ( ! class_exists( 'WC_Beta_Tester' ) ) {
|
||||||
|
include dirname( __FILE__ ) . '/includes/class-wc-beta-tester.php';
|
||||||
|
// Settings.
|
||||||
|
include dirname( __FILE__ ) . '/includes/class-wc-beta-tester-channel.php';
|
||||||
|
include dirname( __FILE__ ) . '/includes/class-wc-beta-tester-import-export.php';
|
||||||
|
new WC_Beta_Tester_Import_Export();
|
||||||
|
// Tools.
|
||||||
|
include dirname( __FILE__ ) . '/includes/class-wc-beta-tester-version-picker.php';
|
||||||
|
|
||||||
|
register_activation_hook( __FILE__, array( 'WC_Beta_Tester', 'activate' ) );
|
||||||
|
|
||||||
|
add_action( 'admin_init', array( 'WC_Beta_Tester', 'instance' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action( 'plugins_loaded', '_wc_beta_tester_bootstrap' );
|
Loading…
Reference in New Issue