| 1 |
<?php namespace TierPricingTable\Addons\TierLabels\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 LabelsSettingsSection(); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
return $_sections; |
| 22 |
}, 10 ); |
| 23 |
|
| 24 |
add_action( 'woocommerce_admin_field_tiered-pricing_tier-labels-crud', 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__tier-labels"></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 ( 'tier-labels' !== $section ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
$assetFile = include( plugin_dir_path( __FILE__ ) . '../build/index.asset.php' ); |
| 53 |
|
| 54 |
wp_enqueue_script( 'tiered-pricing/feature/tier-labels', |
| 55 |
plugins_url( 'build/index.js', dirname( __FILE__ . '../' ) ), $assetFile['dependencies'], |
| 56 |
$assetFile['version'], true ); |
| 57 |
} ); |
| 58 |
} |
| 59 |
} |
| 60 |
|