";
}
/**
* Helper function to determine if current page is Give Add-ons admin page
*
* @return bool
*/
public static function isShowing()
{
return isset($_GET['page']) && $_GET['page'] === 'give-add-ons';
}
}
PK 0[ ` LegacyFormEditor.phpnu [ esc_url_raw(rest_url('give-api/v2')),
'apiNonce' => wp_create_nonce('wp_rest'),
];
EnqueueScript::make(
'give-in-plugin-upsells-legacy-form-editor',
'assets/dist/js/donation-options.js'
)
->loadInFooter()
->registerTranslations()
->registerLocalizeData('GiveLegacyFormEditor', $data)
->enqueue();
}
/**
*
* @since 2.27.1
*
*/
public function renderDonationOptionsRecurringRecommendation()
{
$isDismissed = get_option('givewp_form_editor_donation_options_recurring_recommendation', false);
$recurringAddonIsActive = Utils::isPluginActive('give-recurring/give-recurring.php');
if ($recurringAddonIsActive | $isDismissed) {
return;
}
require_once GIVE_PLUGIN_DIR . 'src/Promotions/InPluginUpsells/resources/views/donation-options-form-editor.php';
}
/**
*
* @since 2.27.1
*
*/
public static function isShowing(): bool
{
$queryParameters = $_GET;
if (isset($queryParameters['action']) && $queryParameters['action'] === 'edit' && $queryParameters['post']) {
return true;
}
return false;
}
}
PK 0[R} } AddonsRepository.phpnu [ endpoint, [
'headers' => [
'Content-Type' => 'application/json',
],
]);
if (is_wp_error($request)) {
return [];
}
$body = wp_remote_retrieve_body($request);
if (empty($body)) {
return [];
}
$json = json_decode($body, true);
// Sanitize JSON
array_walk_recursive($json, function (&$item) {
$item = wp_kses($item, [
'strong' => [],
]);
});
return $json;
}
/**
* @return array
*/
public function getAddons()
{
$cache = get_transient($this->transient);
if (false === $cache) {
$addons = $this->fetchAddons();
set_transient(
$this->transient,
serialize($addons),
DAY_IN_SECONDS
);
return $addons;
}
return unserialize($cache);
}
}
PK 0[ ! Endpoints/HideSaleBannerRoute.phpnu [ endpoint,
[
[
'methods' => 'POST',
'callback' => [$this, 'handleRequest'],
'permission_callback' => 'is_user_logged_in',
'args' => [
'id' => [
'type' => 'string',
'required' => true,
],
],
],
]
);
}
/**
* @param WP_REST_Request $request
*
* @return WP_REST_Response
*/
public function handleRequest(WP_REST_Request $request)
{
give(SaleBanners::class)->hideBanner(
$request->get_param('id') . get_current_user_id()
);
return new WP_REST_Response();
}
}
PK 0[S^]/ / ) Endpoints/ProductRecommendationsRoute.phpnu [ endpoint,
[
[
'methods' => ['POST'],
'callback' => [$this, 'handleRequest'],
'permission_callback' => [$this, 'permissionsCheck'],
'args' => [
'option' => [
'type' => 'string',
'required' => true,
'enum' => [
'givewp_donations_recurring_recommendation_dismissed',
'givewp_donations_fee_recovery_recommendation_dismissed',
'givewp_donations_designated_funds_recommendation_dismissed',
'givewp_reports_recurring_recommendation_dismissed',
'givewp_reports_fee_recovery_recommendation_dismissed',
'givewp_donors_fee_recovery_recommendation_dismissed',
'givewp_form_editor_donation_options_recurring_recommendation',
'givewp_payment_gateway_fee_recovery_recommendation',
],
],
],
],
]
);
}
/**
* @since 2.27.1
*/
public function permissionsCheck()
{
if ( ! current_user_can('manage_options')) {
return new WP_Error(
'rest_forbidden',
esc_html__('You don\'t have permission to dismiss options. Only users with the "manage_options" capability can perform this action.',
'give'),
['status' => $this->authorizationStatusCode()]
);
}
return true;
}
/**
* Sets up the proper HTTP status code for authorization.
* @since 2.27.1
*
* @return int
*/
public function authorizationStatusCode()
{
if (is_user_logged_in()) {
return 403;
}
return 401;
}
/**
* @since 2.27.1
*
* @param WP_REST_Request $request
*
* @return WP_REST_Response
*/
public function handleRequest(WP_REST_Request $request)
{
update_option($request->get_param('option'), time());
return new WP_REST_Response(['option_updated' => $request->get_param('option')]);
}
}
PK 0[ Z PaymentGateways.phpnu [ esc_url_raw(rest_url('give-api/v2')),
'apiNonce' => wp_create_nonce('wp_rest'),
];
EnqueueScript::make(
'give-in-plugin-upsells-payment-gateway',
'assets/dist/js/payment-gateway.js'
)
->loadInFooter()
->registerTranslations()
->registerLocalizeData('GiveSettings', $data)
->enqueue();
}
/**
*
* @since 2.27.1
*
*/
public function renderPaymentGatewayRecommendation()
{
$isDismissed = get_option('givewp_payment_gateway_fee_recovery_recommendation', false);
$feeRecoveryIsActive = Utils::isPluginActive('give-fee-recovery/give-fee-recovery.php');
if ($feeRecoveryIsActive | $isDismissed) {
return;
}
require_once GIVE_PLUGIN_DIR . 'src/Promotions/InPluginUpsells/resources/views/payment-gateway.php';
}
/**
*
* @since 2.27.1
*
*/
public static function isShowing(): bool
{
$isGatewaysTab = isset($_GET['tab']) && $_GET['tab'] === 'gateways';
$isGiveFormsPostType = isset($_GET['post_type']) && $_GET['post_type'] === 'give_forms';
return $isGiveFormsPostType && $isGatewaysTab;
}
}
PK 0[C SaleBanners.phpnu [ hiddenBanners = get_option($this->optionName, []);
}
/**
* Get banners definitions
*
* @since 2.23.2 add Giving Tuesday 2022 banner
* @since 2.17.0
*
* @note id must be unique for each definition
*/
public function getBanners(): array
{
return [
[
'id' => 'bfgt2021',
'iconURL' => GIVE_PLUGIN_URL . 'assets/dist/images/admin/sale-icon.png',
'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'),
'leadText' => __('Save 40% on all Plans for a limited time.', 'give'),
'contentText' => __('Black Friday through Giving Tuesday.', 'give'),
'actionText' => __('Shop Now', 'give'),
'actionURL' => 'https://go.givewp.com/bfgt21',
'startDate' => '2021-11-26 00:00',
'endDate' => '2021-11-30 23:59',
],
[
'id' => 'bfgt2022',
'iconURL' => GIVE_PLUGIN_URL . 'assets/dist/images/admin/sale-icon.png',
'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'),
'leadText' => __('Save 40% on all Plans for a limited time.', 'give'),
'contentText' => __('Black Friday through Giving Tuesday.', 'give'),
'actionText' => __('Shop Now', 'give'),
'actionURL' => 'https://go.givewp.com/bf22',
'startDate' => '2022-11-01 00:00',
'endDate' => '2022-11-29 23:59',
],
];
}
/**
* Get the banners that should be displayed.
*
* @since 2.17.0
*/
public function getVisibleBanners(): array
{
$currentDateTime = current_datetime();
$currentUserId = get_current_user_id();
$giveWPWebsiteTimezone = new DateTimeZone('America/Los_Angeles');
return array_filter(
$this->getBanners(),
function ($banner) use ($currentDateTime, $currentUserId, $giveWPWebsiteTimezone) {
$isHidden = in_array($banner['id'] . $currentUserId, $this->hiddenBanners, true);
try {
$isFuture = $currentDateTime < new DateTimeImmutable($banner['startDate'], $giveWPWebsiteTimezone);
$isPast = $currentDateTime > new DateTimeImmutable($banner['endDate'], $giveWPWebsiteTimezone);
} catch(Exception $exception) {
return false;
}
return !($isHidden || $isFuture || $isPast);
}
);
}
/**
* Marks the given banner id as hidden for the current user so it will not display again.
*
* @since 2.17.0
*
* @return void
*/
public function hideBanner(string $banner)
{
$this->hiddenBanners[] = $banner;
update_option(
$this->optionName,
array_unique($this->hiddenBanners)
);
}
/**
* Render admin page
*
* @since 2.17.0
*/
public function render()
{
$banners = $this->getVisibleBanners();
if (!empty($banners)) {
include __DIR__ . '/resources/views/sale-banners.php';
}
}
/**
* Load scripts
*
* @since 2.17.0
*/
public function loadScripts()
{
wp_enqueue_script(
'give-in-plugin-upsells-sale-banners',
GIVE_PLUGIN_URL . 'assets/dist/js/admin-upsell-sale-banner.js',
[],
GIVE_VERSION,
true
);
wp_localize_script(
'give-in-plugin-upsells-sale-banners',
'GiveSaleBanners',
[
'apiRoot' => esc_url_raw(rest_url('give-api/v2/sale-banner')),
'apiNonce' => wp_create_nonce('wp_rest'),
]
);
wp_enqueue_style('givewp-admin-fonts');
}
/**
* Helper function to determine if the current page Give admin page
*
* @since 2.17.0
*/
public static function isShowing(): bool
{
return isset($_GET['post_type']) && $_GET['post_type'] === 'give_forms';
}
}
PK 0[
e # resources/views/payment-gateway.phpnu [
';
_e(
'Dramatically reduce the impact of gateway credit card processing fees by providing donors the option to cover that cost regardless of the gateway selected.',
'give'
);
echo '
);
PK 0[c * resources/js/components/AddonsAdminPage.jsnu [ import {useMemo, useState} from 'react';
import {Tabs, TabList, Tab, TabPanels, TabPanel} from '@reach/tabs';
import {__, sprintf} from '@wordpress/i18n';
import {MustHaveAddons} from './MustHaveAddons';
import {AdditionalAddons} from './AdditionalAddons';
import {PricingPlans} from './PricingPlans';
import {FreeAddOnTab} from './FreeAddOnTab';
import {assetUrl} from '../utils';
import styles from './AddonsAdminPage.module.css';
export function AddonsAdminPage({startingTab = 0}) {
// We control the tabs only so we can use `tabIndex` to change the decor.
const [tabIndex, setTabIndex] = useState(startingTab);
const addonDecorAssets = useMemo(
() =>
[
'images/addons-admin-page-decor-1.png',
'images/addons-admin-page-decor-2.png',
'images/addons-admin-page-decor-3.png',
'images/addons-admin-page-decor-4.png',
].map(assetUrl),
[]
);
return (
There was an issue submitting your information. Please try again. If the problem
persists, try refreshing the page. If it still doesn't work, please{' '}
contact support.