| 1 |
<?php namespace TierPricingTable\Addons\Tools\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 |
|
| 15 |
if ( $section->getSlug() === 'advanced' ) { |
| 16 |
$_sections[] = new ToolsSettingsSection(); |
| 17 |
} |
| 18 |
|
| 19 |
$_sections[] = $section; |
| 20 |
} |
| 21 |
|
| 22 |
return $_sections; |
| 23 |
}, 10 ); |
| 24 |
|
| 25 |
add_action( 'woocommerce_admin_field_tiered-pricing_tools-ui', function () { |
| 26 |
?> |
| 27 |
<style> |
| 28 |
p.submit { |
| 29 |
display: none !important; |
| 30 |
} |
| 31 |
</style> |
| 32 |
<tr valign="top"> |
| 33 |
<td colspan="2" class="forminp"> |
| 34 |
<div id="tiered-pricing__feature__tools"></div> |
| 35 |
</td> |
| 36 |
</tr> |
| 37 |
<?php |
| 38 |
} ); |
| 39 |
|
| 40 |
add_action( 'admin_enqueue_scripts', function () { |
| 41 |
|
| 42 |
$settingsTab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : ''; |
| 43 |
$section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : ''; |
| 44 |
|
| 45 |
if ( MainSettings::SETTINGS_PAGE !== $settingsTab ) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
if ( 'tools' !== $section ) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
$assetFile = include( plugin_dir_path( __FILE__ ) . '../build/index.asset.php' ); |
| 54 |
|
| 55 |
wp_enqueue_script( 'tiered-pricing/feature/tools', |
| 56 |
plugins_url( 'build/index.js', dirname( __FILE__ . '../' ) ), $assetFile['dependencies'], |
| 57 |
$assetFile['version'], true ); |
| 58 |
|
| 59 |
wp_set_script_translations( 'tiered-pricing/feature/tools', 'tier-pricing-table', |
| 60 |
dirname( __FILE__, 5 ) . '/languages' ); |
| 61 |
|
| 62 |
wp_enqueue_style( 'wp-components' ); |
| 63 |
} ); |
| 64 |
} |
| 65 |
} |
| 66 |
|