Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes/admin
File: class-wc-admin.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce Admin
[2] Fix | Delete
*
[3] Fix | Delete
* @class WC_Admin
[4] Fix | Delete
* @package WooCommerce\Admin
[5] Fix | Delete
* @version 2.6.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
declare(strict_types=1);
[9] Fix | Delete
[10] Fix | Delete
use Automattic\WooCommerce\Admin\PageController;
[11] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\EmailPreview\EmailPreview;
[12] Fix | Delete
[13] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[14] Fix | Delete
exit; // Exit if accessed directly.
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* WC_Admin class.
[19] Fix | Delete
*/
[20] Fix | Delete
class WC_Admin {
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Constructor.
[24] Fix | Delete
*/
[25] Fix | Delete
public function __construct() {
[26] Fix | Delete
add_action( 'init', array( $this, 'includes' ) );
[27] Fix | Delete
[28] Fix | Delete
// Hook in early (priority 1) to make sure the PageController's hooks are added before any WC admin pages or
[29] Fix | Delete
// menus logic is run, including the enqueuing of assets via \Automattic\WooCommerce\Internal\Admin\WCAdminAssets.
[30] Fix | Delete
// While it may not sound like it, the admin_menu action is triggered quite early,
[31] Fix | Delete
// before the admin_init or admin_enqueue_scripts action.
[32] Fix | Delete
// @see https://developer.wordpress.org/apis/hooks/action-reference/#actions-run-during-an-admin-page-request.
[33] Fix | Delete
add_action( 'admin_menu', array( $this, 'init_page_controller' ), 1 );
[34] Fix | Delete
[35] Fix | Delete
add_action( 'current_screen', array( $this, 'conditional_includes' ) );
[36] Fix | Delete
add_action( 'admin_init', array( $this, 'buffer' ), 1 );
[37] Fix | Delete
add_action( 'admin_init', array( $this, 'preview_emails' ) );
[38] Fix | Delete
add_action( 'admin_init', array( $this, 'preview_email_editor_dummy_content' ) );
[39] Fix | Delete
add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
[40] Fix | Delete
add_action( 'admin_init', array( $this, 'admin_redirects' ) );
[41] Fix | Delete
add_action( 'admin_footer', 'wc_print_js', 25 );
[42] Fix | Delete
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
[43] Fix | Delete
[44] Fix | Delete
// Disable WXR export of schedule action posts.
[45] Fix | Delete
add_filter( 'action_scheduler_post_type_args', array( $this, 'disable_webhook_post_export' ) );
[46] Fix | Delete
[47] Fix | Delete
// Add body class for WP 5.3+ compatibility.
[48] Fix | Delete
add_filter( 'admin_body_class', array( $this, 'include_admin_body_class' ), 9999 );
[49] Fix | Delete
[50] Fix | Delete
// Add body class for Marketplace and My Subscriptions pages.
[51] Fix | Delete
if ( isset( $_GET['page'] ) && 'wc-addons' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[52] Fix | Delete
add_filter( 'admin_body_class', array( 'WC_Admin_Addons', 'filter_admin_body_classes' ) );
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Output buffering allows admin screens to make redirects later on.
[58] Fix | Delete
*/
[59] Fix | Delete
public function buffer() {
[60] Fix | Delete
ob_start();
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Include any classes we need within admin.
[65] Fix | Delete
*/
[66] Fix | Delete
public function includes() {
[67] Fix | Delete
include_once __DIR__ . '/wc-admin-functions.php';
[68] Fix | Delete
include_once __DIR__ . '/wc-meta-box-functions.php';
[69] Fix | Delete
include_once __DIR__ . '/class-wc-admin-post-types.php';
[70] Fix | Delete
include_once __DIR__ . '/class-wc-admin-taxonomies.php';
[71] Fix | Delete
include_once __DIR__ . '/class-wc-admin-menus.php';
[72] Fix | Delete
include_once __DIR__ . '/class-wc-admin-customize.php';
[73] Fix | Delete
include_once __DIR__ . '/class-wc-admin-notices.php';
[74] Fix | Delete
include_once __DIR__ . '/class-wc-admin-assets.php';
[75] Fix | Delete
include_once __DIR__ . '/class-wc-admin-api-keys.php';
[76] Fix | Delete
include_once __DIR__ . '/class-wc-admin-webhooks.php';
[77] Fix | Delete
include_once __DIR__ . '/class-wc-admin-pointers.php';
[78] Fix | Delete
include_once __DIR__ . '/class-wc-admin-importers.php';
[79] Fix | Delete
include_once __DIR__ . '/class-wc-admin-exporters.php';
[80] Fix | Delete
[81] Fix | Delete
// Help Tabs.
[82] Fix | Delete
/**
[83] Fix | Delete
* Filter to enable/disable admin help tab.
[84] Fix | Delete
*
[85] Fix | Delete
* @since 3.6.0
[86] Fix | Delete
*/
[87] Fix | Delete
if ( apply_filters( 'woocommerce_enable_admin_help_tab', true ) ) {
[88] Fix | Delete
include_once __DIR__ . '/class-wc-admin-help.php';
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
// Helper.
[92] Fix | Delete
include_once __DIR__ . '/helper/class-wc-helper.php';
[93] Fix | Delete
[94] Fix | Delete
// Marketplace suggestions & related REST API.
[95] Fix | Delete
include_once __DIR__ . '/marketplace-suggestions/class-wc-marketplace-suggestions.php';
[96] Fix | Delete
include_once __DIR__ . '/marketplace-suggestions/class-wc-marketplace-updater.php';
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Initialize the admin page controller logic.
[101] Fix | Delete
*/
[102] Fix | Delete
public function init_page_controller() {
[103] Fix | Delete
// We only need to make sure the controller is instantiated since the hooking is done in the constructor.
[104] Fix | Delete
PageController::get_instance();
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Include admin files conditionally.
[109] Fix | Delete
*/
[110] Fix | Delete
public function conditional_includes() {
[111] Fix | Delete
$screen = get_current_screen();
[112] Fix | Delete
[113] Fix | Delete
if ( ! $screen ) {
[114] Fix | Delete
return;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
switch ( $screen->id ) {
[118] Fix | Delete
case 'dashboard':
[119] Fix | Delete
case 'dashboard-network':
[120] Fix | Delete
include __DIR__ . '/class-wc-admin-dashboard-setup.php';
[121] Fix | Delete
include __DIR__ . '/class-wc-admin-dashboard.php';
[122] Fix | Delete
break;
[123] Fix | Delete
case 'options-permalink':
[124] Fix | Delete
include __DIR__ . '/class-wc-admin-permalink-settings.php';
[125] Fix | Delete
break;
[126] Fix | Delete
case 'plugins':
[127] Fix | Delete
include __DIR__ . '/plugin-updates/class-wc-plugins-screen-updates.php';
[128] Fix | Delete
break;
[129] Fix | Delete
case 'update-core':
[130] Fix | Delete
include __DIR__ . '/plugin-updates/class-wc-updates-screen-updates.php';
[131] Fix | Delete
break;
[132] Fix | Delete
case 'users':
[133] Fix | Delete
case 'user':
[134] Fix | Delete
case 'profile':
[135] Fix | Delete
case 'user-edit':
[136] Fix | Delete
include __DIR__ . '/class-wc-admin-profile.php';
[137] Fix | Delete
break;
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Handle redirects:
[143] Fix | Delete
* 1. Nonced plugin install redirects.
[144] Fix | Delete
*
[145] Fix | Delete
* The user must have access rights, and we must ignore the network/bulk plugin updaters.
[146] Fix | Delete
*/
[147] Fix | Delete
public function admin_redirects() {
[148] Fix | Delete
// Don't run this fn from Action Scheduler requests.
[149] Fix | Delete
if ( wc_is_running_from_async_action_scheduler() ) {
[150] Fix | Delete
return;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended
[154] Fix | Delete
// Nonced plugin install redirects.
[155] Fix | Delete
if ( ! empty( $_GET['wc-install-plugin-redirect'] ) ) {
[156] Fix | Delete
$plugin_slug = wc_clean( wp_unslash( $_GET['wc-install-plugin-redirect'] ) );
[157] Fix | Delete
[158] Fix | Delete
if ( current_user_can( 'install_plugins' ) && in_array( $plugin_slug, array( 'woocommerce-gateway-stripe' ), true ) ) {
[159] Fix | Delete
$nonce = wp_create_nonce( 'install-plugin_' . $plugin_slug );
[160] Fix | Delete
$url = self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug . '&_wpnonce=' . $nonce );
[161] Fix | Delete
} else {
[162] Fix | Delete
$url = admin_url( 'plugin-install.php?tab=search&type=term&s=' . $plugin_slug );
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
wp_safe_redirect( $url );
[166] Fix | Delete
exit;
[167] Fix | Delete
}
[168] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from accessing admin.
[173] Fix | Delete
*/
[174] Fix | Delete
public function prevent_admin_access() {
[175] Fix | Delete
$prevent_access = false;
[176] Fix | Delete
[177] Fix | Delete
// Do not interfere with admin-post or admin-ajax requests.
[178] Fix | Delete
$exempted_paths = array( 'admin-post.php', 'admin-ajax.php' );
[179] Fix | Delete
[180] Fix | Delete
if (
[181] Fix | Delete
/**
[182] Fix | Delete
* This filter is documented in ../wc-user-functions.php
[183] Fix | Delete
*
[184] Fix | Delete
* @since 3.6.0
[185] Fix | Delete
*/
[186] Fix | Delete
apply_filters( 'woocommerce_disable_admin_bar', true )
[187] Fix | Delete
&& isset( $_SERVER['SCRIPT_FILENAME'] )
[188] Fix | Delete
&& ! in_array( basename( sanitize_text_field( wp_unslash( $_SERVER['SCRIPT_FILENAME'] ) ) ), $exempted_paths, true )
[189] Fix | Delete
) {
[190] Fix | Delete
$has_cap = false;
[191] Fix | Delete
$access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' );
[192] Fix | Delete
[193] Fix | Delete
foreach ( $access_caps as $access_cap ) {
[194] Fix | Delete
if ( current_user_can( $access_cap ) ) {
[195] Fix | Delete
$has_cap = true;
[196] Fix | Delete
break;
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
if ( ! $has_cap ) {
[201] Fix | Delete
$prevent_access = true;
[202] Fix | Delete
}
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Filter to prevent admin access.
[207] Fix | Delete
*
[208] Fix | Delete
* @since 3.6.0
[209] Fix | Delete
*/
[210] Fix | Delete
if ( apply_filters( 'woocommerce_prevent_admin_access', $prevent_access ) ) {
[211] Fix | Delete
wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) );
[212] Fix | Delete
exit;
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Preview email template.
[218] Fix | Delete
*/
[219] Fix | Delete
public function preview_emails() {
[220] Fix | Delete
[221] Fix | Delete
if ( isset( $_GET['preview_woocommerce_mail'] ) ) {
[222] Fix | Delete
if ( ! ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'preview-mail' ) ) ) {
[223] Fix | Delete
die( 'Security check' );
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
$email_preview = wc_get_container()->get( EmailPreview::class );
[227] Fix | Delete
[228] Fix | Delete
if ( isset( $_GET['type'] ) ) {
[229] Fix | Delete
$type_param = sanitize_text_field( wp_unslash( $_GET['type'] ) );
[230] Fix | Delete
try {
[231] Fix | Delete
$email_preview->set_email_type( $type_param );
[232] Fix | Delete
} catch ( InvalidArgumentException $e ) {
[233] Fix | Delete
wp_die( esc_html__( 'Invalid email type.', 'woocommerce' ), 400 );
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
[238] Fix | Delete
$message = $email_preview->render();
[239] Fix | Delete
$message = $email_preview->ensure_links_open_in_new_tab( $message );
[240] Fix | Delete
} else {
[241] Fix | Delete
// Start output buffering to prevent partial renders with PHP notices or warnings.
[242] Fix | Delete
ob_start();
[243] Fix | Delete
try {
[244] Fix | Delete
$message = $email_preview->render();
[245] Fix | Delete
$message = $email_preview->ensure_links_open_in_new_tab( $message );
[246] Fix | Delete
} catch ( Throwable $e ) {
[247] Fix | Delete
ob_end_clean();
[248] Fix | Delete
wp_die(
[249] Fix | Delete
esc_html__(
[250] Fix | Delete
'There was an error rendering the email preview. This doesn\'t affect actual email delivery. Please contact the extension author for assistance.',
[251] Fix | Delete
'woocommerce'
[252] Fix | Delete
),
[253] Fix | Delete
404
[254] Fix | Delete
);
[255] Fix | Delete
}
[256] Fix | Delete
ob_end_clean();
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
// print the preview email.
[260] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput
[261] Fix | Delete
echo $message;
[262] Fix | Delete
// phpcs:enable
[263] Fix | Delete
exit;
[264] Fix | Delete
}
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Preview email editor placeholder dummy content.
[269] Fix | Delete
*/
[270] Fix | Delete
public function preview_email_editor_dummy_content() {
[271] Fix | Delete
$message = '';
[272] Fix | Delete
if ( ! isset( $_GET['preview_woocommerce_mail_editor_content'] ) ) {
[273] Fix | Delete
return;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'preview-mail' ) ) {
[277] Fix | Delete
die( 'Security check' );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
/**
[281] Fix | Delete
* Email preview instance for rendering dummy content.
[282] Fix | Delete
*
[283] Fix | Delete
* @var EmailPreview $email_preview - email preview instance
[284] Fix | Delete
*/
[285] Fix | Delete
$email_preview = wc_get_container()->get( EmailPreview::class );
[286] Fix | Delete
[287] Fix | Delete
$type_param = EmailPreview::DEFAULT_EMAIL_TYPE;
[288] Fix | Delete
if ( isset( $_GET['type'] ) ) {
[289] Fix | Delete
$type_param = sanitize_text_field( wp_unslash( $_GET['type'] ) );
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
try {
[293] Fix | Delete
$message = $email_preview->generate_placeholder_content( $type_param );
[294] Fix | Delete
} catch ( \Exception $e ) {
[295] Fix | Delete
// Catch other potential errors during content generation.
[296] Fix | Delete
wp_die( esc_html__( 'There was an error rendering the email preview.', 'woocommerce' ), 404 );
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
// Print the placeholder content.
[300] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput
[301] Fix | Delete
echo $message;
[302] Fix | Delete
exit;
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
/**
[306] Fix | Delete
* Change the admin footer text on WooCommerce admin pages.
[307] Fix | Delete
*
[308] Fix | Delete
* @since 2.3
[309] Fix | Delete
* @param string $footer_text text to be rendered in the footer.
[310] Fix | Delete
* @return string
[311] Fix | Delete
*/
[312] Fix | Delete
public function admin_footer_text( $footer_text ) {
[313] Fix | Delete
if ( ! current_user_can( 'manage_woocommerce' ) || ! function_exists( 'wc_get_screen_ids' ) ) {
[314] Fix | Delete
return $footer_text;
[315] Fix | Delete
}
[316] Fix | Delete
$current_screen = get_current_screen();
[317] Fix | Delete
$wc_pages = wc_get_screen_ids();
[318] Fix | Delete
[319] Fix | Delete
// Set only WC pages.
[320] Fix | Delete
$wc_pages = array_diff( $wc_pages, array( 'profile', 'user-edit' ) );
[321] Fix | Delete
[322] Fix | Delete
// Check to make sure we're on a WooCommerce admin page.
[323] Fix | Delete
/**
[324] Fix | Delete
* Filter to determine if admin footer text should be displayed.
[325] Fix | Delete
*
[326] Fix | Delete
* @since 2.3
[327] Fix | Delete
*/
[328] Fix | Delete
if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages, true ) ) ) {
[329] Fix | Delete
// Change the footer text.
[330] Fix | Delete
if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
[331] Fix | Delete
$footer_text = sprintf(
[332] Fix | Delete
/* translators: 1: WooCommerce 2:: five stars */
[333] Fix | Delete
__( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'woocommerce' ),
[334] Fix | Delete
sprintf( '<strong>%s</strong>', esc_html__( 'WooCommerce', 'woocommerce' ) ),
[335] Fix | Delete
'<a href="https://wordpress.org/support/plugin/woocommerce/reviews?rate=5#new-post" target="_blank" class="wc-rating-link" aria-label="' . esc_attr__( 'five star', 'woocommerce' ) . '" data-rated="' . esc_attr__( 'Thanks :)', 'woocommerce' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
[336] Fix | Delete
);
[337] Fix | Delete
wc_enqueue_js(
[338] Fix | Delete
"jQuery( 'a.wc-rating-link' ).on( 'click', function() {
[339] Fix | Delete
jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );
[340] Fix | Delete
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
[341] Fix | Delete
});"
[342] Fix | Delete
);
[343] Fix | Delete
} else {
[344] Fix | Delete
$footer_text = __( 'Thank you for selling with WooCommerce.', 'woocommerce' );
[345] Fix | Delete
}
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
return $footer_text;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Check on a Jetpack install queued by the Setup Wizard.
[353] Fix | Delete
*
[354] Fix | Delete
* See: WC_Admin_Setup_Wizard::install_jetpack()
[355] Fix | Delete
*/
[356] Fix | Delete
public function setup_wizard_check_jetpack() {
[357] Fix | Delete
$jetpack_active = class_exists( 'Jetpack' );
[358] Fix | Delete
[359] Fix | Delete
wp_send_json_success(
[360] Fix | Delete
array(
[361] Fix | Delete
'is_active' => $jetpack_active ? 'yes' : 'no',
[362] Fix | Delete
)
[363] Fix | Delete
);
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
/**
[367] Fix | Delete
* Disable WXR export of scheduled action posts.
[368] Fix | Delete
*
[369] Fix | Delete
* @since 3.6.2
[370] Fix | Delete
*
[371] Fix | Delete
* @param array $args Scheduled action post type registration args.
[372] Fix | Delete
*
[373] Fix | Delete
* @return array
[374] Fix | Delete
*/
[375] Fix | Delete
public function disable_webhook_post_export( $args ) {
[376] Fix | Delete
$args['can_export'] = false;
[377] Fix | Delete
return $args;
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
/**
[381] Fix | Delete
* Include admin classes.
[382] Fix | Delete
*
[383] Fix | Delete
* @since 4.2.0
[384] Fix | Delete
* @param string $classes Body classes string.
[385] Fix | Delete
* @return string
[386] Fix | Delete
*/
[387] Fix | Delete
public function include_admin_body_class( $classes ) {
[388] Fix | Delete
if ( in_array( array( 'wc-wp-version-gte-53', 'wc-wp-version-gte-55' ), explode( ' ', $classes ), true ) ) {
[389] Fix | Delete
return $classes;
[390] Fix | Delete
}
[391] Fix | Delete
[392] Fix | Delete
$raw_version = get_bloginfo( 'version' );
[393] Fix | Delete
$version_parts = explode( '-', $raw_version );
[394] Fix | Delete
$version = count( $version_parts ) > 1 ? $version_parts[0] : $raw_version;
[395] Fix | Delete
[396] Fix | Delete
// Add WP 5.3+ compatibility class.
[397] Fix | Delete
if ( $raw_version && version_compare( $version, '5.3', '>=' ) ) {
[398] Fix | Delete
$classes .= ' wc-wp-version-gte-53';
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
// Add WP 5.5+ compatibility class.
[402] Fix | Delete
if ( $raw_version && version_compare( $version, '5.5', '>=' ) ) {
[403] Fix | Delete
$classes .= ' wc-wp-version-gte-55';
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
return $classes;
[407] Fix | Delete
}
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
return new WC_Admin();
[411] Fix | Delete
[412] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function