plugin updates
This commit is contained in:
@@ -155,8 +155,14 @@ class WcPayWelcomePage {
|
||||
call_user_func_array( 'add_menu_page', $menu_with_nav_data );
|
||||
}
|
||||
} else {
|
||||
// Determine the path to the active Payments task page.
|
||||
$menu_path = 'admin.php?page=wc-admin&task=' . $this->get_active_payments_task_slug();
|
||||
// Default to linking to the Payments settings page.
|
||||
$menu_path = 'admin.php?page=wc-settings&tab=checkout';
|
||||
|
||||
// Determine the path to the active Payments task page, if any.
|
||||
$task_slug = $this->get_active_payments_task_slug();
|
||||
if ( ! empty( $task_slug ) ) {
|
||||
$menu_path = 'admin.php?page=wc-admin&task=' . $task_slug;
|
||||
}
|
||||
|
||||
add_menu_page(
|
||||
$menu_title,
|
||||
@@ -583,23 +589,38 @@ class WcPayWelcomePage {
|
||||
private function get_active_payments_task_slug(): string {
|
||||
$setup_task_list = TaskLists::get_list( 'setup' );
|
||||
$extended_task_list = TaskLists::get_list( 'extended' );
|
||||
if ( empty( $setup_task_list ) && empty( $extended_task_list ) ) {
|
||||
|
||||
// The task pages are not available if the task lists don't exist or are not visible.
|
||||
// Bail early if we have no task to work with.
|
||||
if (
|
||||
( empty( $setup_task_list ) || ! $setup_task_list->is_visible() ) &&
|
||||
( empty( $extended_task_list ) || ! $extended_task_list->is_visible() )
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$payments_task = $setup_task_list->get_task( 'payments' );
|
||||
if ( ! empty( $payments_task ) && $payments_task->can_view() ) {
|
||||
return 'payments';
|
||||
// The Payments task in the setup task list.
|
||||
if ( ! empty( $setup_task_list ) && $setup_task_list->is_visible() ) {
|
||||
$payments_task = $setup_task_list->get_task( 'payments' );
|
||||
if ( ! empty( $payments_task ) && $payments_task->can_view() ) {
|
||||
return 'payments';
|
||||
}
|
||||
}
|
||||
|
||||
$payments_task = $extended_task_list->get_task( 'payments' );
|
||||
if ( ! empty( $payments_task ) && $payments_task->can_view() ) {
|
||||
return 'payments';
|
||||
// The Additional Payments task in the extended task list.
|
||||
if ( ! empty( $extended_task_list ) && $extended_task_list->is_visible() ) {
|
||||
$payments_task = $extended_task_list->get_task( 'payments' );
|
||||
if ( ! empty( $payments_task ) && $payments_task->can_view() ) {
|
||||
return 'payments';
|
||||
}
|
||||
}
|
||||
|
||||
$woopayments_task = $setup_task_list->get_task( 'woocommerce-payments' );
|
||||
if ( ! empty( $woopayments_task ) && $woopayments_task->can_view() ) {
|
||||
return 'woocommerce-payments';
|
||||
// The WooPayments task in the setup task list.
|
||||
if ( ! empty( $setup_task_list ) && $setup_task_list->is_visible() ) {
|
||||
$payments_task = $setup_task_list->get_task( 'woocommerce-payments' );
|
||||
if ( ! empty( $payments_task ) && $payments_task->can_view() ) {
|
||||
return 'woocommerce-payments';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@@ -4,6 +4,7 @@ declare( strict_types = 1 );
|
||||
namespace Automattic\WooCommerce\Internal\Utilities;
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use Automattic\WooCommerce\Proxies\LegacyProxy;
|
||||
use Exception;
|
||||
use WP_Filesystem_Base;
|
||||
|
||||
@@ -31,6 +32,35 @@ class FilesystemUtil {
|
||||
return $wp_filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WP filesystem method, with a fallback to 'direct' if no FS_METHOD constant exists and there are not FTP related options/credentials set.
|
||||
*
|
||||
* @return string|false The name of the WP filesystem method to use.
|
||||
*/
|
||||
public static function get_wp_filesystem_method_or_direct() {
|
||||
$proxy = wc_get_container()->get( LegacyProxy::class );
|
||||
if ( ! self::constant_exists( 'FS_METHOD' ) && false === $proxy->call_function( 'get_option', 'ftp_credentials' ) && ! self::constant_exists( 'FTP_HOST' ) ) {
|
||||
return 'direct';
|
||||
}
|
||||
|
||||
$method = $proxy->call_function( 'get_filesystem_method' );
|
||||
if ( $method ) {
|
||||
return $method;
|
||||
}
|
||||
|
||||
return 'direct';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a constant exists and is not null.
|
||||
*
|
||||
* @param string $name Constant name.
|
||||
* @return bool True if the constant exists and its value is not null.
|
||||
*/
|
||||
private static function constant_exists( string $name ): bool {
|
||||
return Constants::is_defined( $name ) && ! is_null( Constants::get_constant( $name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively creates a directory (if it doesn't exist) and adds an empty index.html and a .htaccess to prevent
|
||||
* directory listing.
|
||||
@@ -75,7 +105,7 @@ class FilesystemUtil {
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
$method = get_filesystem_method();
|
||||
$method = self::get_wp_filesystem_method_or_direct();
|
||||
$initialized = false;
|
||||
|
||||
if ( 'direct' === $method ) {
|
||||
|
||||
Reference in New Issue
Block a user