/
home
/
techb158
/
balacoffee.com
/
wp-content
/
plugins
/
woocommerce
/
src
/
Admin
/
API
/
/home/techb158/balacoffee.com/wp-content/plugins/woocommerce/src/Admin/API
mkdir
upload
Name
Size
Mode
Actions
AI/
-
0755
rm
Reports/
-
0755
rm
Templates/
-
0755
rm
AnalyticsImports.php
9304
0644
edit
dl
rm
Coupons.php
2202
0644
edit
dl
rm
CustomAttributeTraits.php
3484
0644
edit
dl
rm
Customers.php
2163
0644
edit
dl
rm
Data.php
939
0644
edit
dl
rm
DataCountries.php
1149
0644
edit
dl
rm
DataDownloadIPs.php
4248
0644
edit
dl
rm
Experiments.php
1864
0644
edit
dl
rm
Features.php
1740
0644
edit
dl
rm
Init.php
10823
0644
edit
dl
rm
LaunchYourStore.php
5273
0644
edit
dl
rm
Leaderboards.php
18660
0644
edit
dl
rm
Marketing.php
4960
0644
edit
dl
rm
MarketingCampaigns.php
9868
0644
edit
dl
rm
MarketingCampaignTypes.php
6160
0644
edit
dl
rm
MarketingChannels.php
5878
0644
edit
dl
rm
MarketingOverview.php
3443
0644
edit
dl
rm
MarketingRecommendations.php
6085
0644
edit
dl
rm
MobileAppMagicLink.php
2147
0644
edit
dl
rm
NoteActions.php
2449
0644
edit
dl
rm
Notes.php
25925
0644
edit
dl
rm
Notice.php
2437
0644
edit
dl
rm
OnboardingFreeExtensions.php
2639
0644
edit
dl
rm
OnboardingPlugins.php
10920
0644
edit
dl
rm
OnboardingProducts.php
1983
0644
edit
dl
rm
OnboardingProductTypes.php
1840
0644
edit
dl
rm
OnboardingProfile.php
18817
0644
edit
dl
rm
OnboardingTasks.php
32790
0644
edit
dl
rm
OnboardingThemes.php
5620
0644
edit
dl
rm
Options.php
10236
0644
edit
dl
rm
Orders.php
10376
0644
edit
dl
rm
PaymentGatewaySuggestions.php
5998
0644
edit
dl
rm
Plugins.php
21729
0644
edit
dl
rm
ProductAttributes.php
4568
0644
edit
dl
rm
ProductAttributeTerms.php
4467
0644
edit
dl
rm
ProductCategories.php
458
0644
edit
dl
rm
ProductForm.php
3137
0644
edit
dl
rm
ProductReviews.php
1330
0644
edit
dl
rm
Products.php
9963
0644
edit
dl
rm
ProductsLowInStock.php
18046
0644
edit
dl
rm
ProductVariations.php
6178
0644
edit
dl
rm
SettingOptions.php
878
0644
edit
dl
rm
Settings.php
4299
0644
edit
dl
rm
ShippingPartnerSuggestions.php
6235
0644
edit
dl
rm
Taxes.php
5020
0644
edit
dl
rm
Themes.php
6263
0644
edit
dl
rm
Edit:
/home/techb158/balacoffee.com/wp-content/plugins/woocommerce/src/Admin/API/OnboardingThemes.php
(5620B)
<?php /** * REST API Onboarding Themes Controller * * Handles requests to install and activate themes. */ namespace Automattic\WooCommerce\Admin\API; defined( 'ABSPATH' ) || exit; /** * Onboarding Themes Controller. * * @internal * @extends WC_REST_Data_Controller */ class OnboardingThemes extends \WC_REST_Data_Controller { /** * Endpoint namespace. * * @var string */ protected $namespace = 'wc-admin'; /** * Route base. * * @var string */ protected $rest_base = 'onboarding/themes'; /** * Register routes. */ public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/install', array( array( 'methods' => \WP_REST_Server::EDITABLE, 'callback' => array( $this, 'install_theme' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), ), 'schema' => array( $this, 'get_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/activate', array( array( 'methods' => \WP_REST_Server::EDITABLE, 'callback' => array( $this, 'activate_theme' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), ), 'schema' => array( $this, 'get_item_schema' ), ) ); } /** * Check if a given request has access to manage themes. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|boolean */ public function update_item_permissions_check( $request ) { if ( ! current_user_can( 'switch_themes' ) ) { return new \WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot manage themes.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } /** * Installs the requested theme. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|array Theme installation status. */ public function install_theme( $request ) { $theme = sanitize_text_field( $request['theme'] ); $installed_themes = wp_get_themes(); if ( in_array( $theme, array_keys( $installed_themes ), true ) ) { return( array( 'slug' => $theme, 'name' => $installed_themes[ $theme ]->get( 'Name' ), 'status' => 'success', ) ); } include_once ABSPATH . '/wp-admin/includes/admin.php'; include_once ABSPATH . '/wp-admin/includes/theme-install.php'; include_once ABSPATH . '/wp-admin/includes/theme.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . '/wp-admin/includes/class-theme-upgrader.php'; $api = themes_api( 'theme_information', array( 'slug' => $theme, 'fields' => array( 'sections' => false, ), ) ); if ( is_wp_error( $api ) ) { return new \WP_Error( 'woocommerce_rest_theme_install', sprintf( /* translators: %s: theme slug (example: woocommerce-services) */ __( 'The requested theme `%s` could not be installed. Theme API call failed.', 'woocommerce' ), $theme ), 500 ); } $upgrader = new \Theme_Upgrader( new \Automatic_Upgrader_Skin() ); $result = $upgrader->install( $api->download_link ); if ( is_wp_error( $result ) || is_null( $result ) ) { return new \WP_Error( 'woocommerce_rest_theme_install', sprintf( /* translators: %s: theme slug (example: woocommerce-services) */ __( 'The requested theme `%s` could not be installed.', 'woocommerce' ), $theme ), 500 ); } return array( 'slug' => $theme, 'name' => $api->name, 'status' => 'success', ); } /** * Activate the requested theme. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|array Theme activation status. */ public function activate_theme( $request ) { $theme = sanitize_text_field( $request['theme'] ); require_once ABSPATH . 'wp-admin/includes/theme.php'; $installed_themes = wp_get_themes(); if ( ! in_array( $theme, array_keys( $installed_themes ), true ) ) { /* translators: %s: theme slug (example: woocommerce-services) */ return new \WP_Error( 'woocommerce_rest_invalid_theme', sprintf( __( 'Invalid theme %s.', 'woocommerce' ), $theme ), 404 ); } $result = switch_theme( $theme ); if ( ! is_null( $result ) ) { return new \WP_Error( 'woocommerce_rest_invalid_theme', sprintf( __( 'The requested theme could not be activated.', 'woocommerce' ), $theme ), 500 ); } return( array( 'slug' => $theme, 'name' => $installed_themes[ $theme ]->get( 'Name' ), 'status' => 'success', ) ); } /** * Get the schema, conforming to JSON Schema. * * @return array */ public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'onboarding_theme', 'type' => 'object', 'properties' => array( 'slug' => array( 'description' => __( 'Theme slug.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'name' => array( 'description' => __( 'Theme name.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'status' => array( 'description' => __( 'Theme status.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), ), ); return $this->add_additional_fields_schema( $schema ); } }
Save
cmd:
run