| 1 |
<?php namespace TierPricingTable\Addons\RequestAQuote\Settings; |
| 2 |
|
| 3 |
use TierPricingTable\Settings\Settings as MainSettings; |
| 4 |
|
| 5 |
class Settings { |
| 6 |
|
| 7 |
public function __construct() { |
| 8 |
|
| 9 |
add_filter( 'tiered_pricing_table/settings/sections', function ( $sections ) { |
| 10 |
|
| 11 |
$_sections = array(); |
| 12 |
|
| 13 |
foreach ( $sections as $section ) { |
| 14 |
$_sections[] = $section; |
| 15 |
|
| 16 |
if ( $section->getSlug() === 'general' ) { |
| 17 |
$_sections[] = new RequestAQuoteSettingsSection(); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
return $_sections; |
| 22 |
}, 15 ); |
| 23 |
|
| 24 |
add_action( 'woocommerce_admin_field_tiered-pricing_request-a-quote-ui', function () { |
| 25 |
?> |
| 26 |
<style> |
| 27 |
p.submit { |
| 28 |
display: none !important; |
| 29 |
} |
| 30 |
</style> |
| 31 |
<tr valign="top"> |
| 32 |
<td colspan="2" class="forminp"> |
| 33 |
<div id="tiered-pricing__feature__request-a-quote"></div> |
| 34 |
</td> |
| 35 |
</tr> |
| 36 |
<?php |
| 37 |
} ); |
| 38 |
|
| 39 |
add_action( 'admin_enqueue_scripts', function () { |
| 40 |
|
| 41 |
$settingsTab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : ''; |
| 42 |
$section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : ''; |
| 43 |
|
| 44 |
if ( MainSettings::SETTINGS_PAGE !== $settingsTab ) { |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
if ( 'request-a-quote' !== $section ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
$assetFile = include( plugin_dir_path( __FILE__ ) . '../build/index.asset.php' ); |
| 53 |
|
| 54 |
wp_enqueue_script( 'tiered-pricing/feature/request-a-quote', |
| 55 |
plugins_url( 'build/index.js', dirname( __FILE__ . '../' ) ), $assetFile['dependencies'], |
| 56 |
$assetFile['version'], true ); |
| 57 |
|
| 58 |
$isPremium = tpt_fs()->can_use_premium_code__premium_only() ? 'true' : 'false'; |
| 59 |
$upgradeUrl = tpt_fs()->get_upgrade_url(); |
| 60 |
$script = "window.tptRequestAQuote = { isPremium: {$isPremium}, upgradeUrl: '" . esc_url( $upgradeUrl ) . "' };"; |
| 61 |
wp_add_inline_script( 'tiered-pricing/feature/request-a-quote', $script, 'before' ); |
| 62 |
|
| 63 |
wp_set_script_translations( 'tiered-pricing/feature/request-a-quote', 'tier-pricing-table', |
| 64 |
dirname( __FILE__, 5 ) . '/languages' ); |
| 65 |
|
| 66 |
wp_enqueue_style( 'wp-components' ); |
| 67 |
} ); |
| 68 |
} |
| 69 |
} |
| 70 |
|