| 1 |
<?php |
| 2 |
/** |
| 3 |
* Woo Additional Terms Class. |
| 4 |
* |
| 5 |
* @author Mahdi Yazdani |
| 6 |
* @package Woo Additional Terms |
| 7 |
* @since 1.0 |
| 8 |
*/ |
| 9 |
// Prevent direct file access |
| 10 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 11 |
if ( !class_exists( 'WooAdditionalTerms' ) ) : |
| 12 |
class WooAdditionalTerms { |
| 13 |
private $file; |
| 14 |
public function __construct($file) { |
| 15 |
$this->file = $file; |
| 16 |
add_action( 'woocommerce_payment_gateways_settings', array( $this, 'woo_additional_terms_setting' ), 10 ); |
| 17 |
add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'woo_additional_terms_settings_link' ), 10 ); |
| 18 |
} |
| 19 |
public function woo_additional_terms_setting( $settings ) { |
| 20 |
$updated_settings = array(); |
| 21 |
foreach ( $settings as $section ) : |
| 22 |
if ( isset( $section['id'] ) && 'checkout_page_options' == $section['id'] && isset( $section['type'] ) && 'sectionend' == $section['type'] ) : |
| 23 |
$updated_settings[] = array( |
| 24 |
'name' => __( 'Additional Terms', 'woo-additional-terms' ), |
| 25 |
'desc' => __( 'If you define a "Additional Terms" page the customer will be asked if they accept them when checking out.', 'woo-additional-terms' ), |
| 26 |
'id' => 'woo_additional_terms_page', |
| 27 |
'default' => '', |
| 28 |
'class' => 'wc-enhanced-select-nostd', |
| 29 |
'css' => 'min-width:300px;', |
| 30 |
'type' => 'single_select_page', |
| 31 |
'desc_tip' => true, |
| 32 |
'autoload' => false |
| 33 |
); |
| 34 |
$updated_settings[] = array( |
| 35 |
'title' => __( 'Additional Terms Title', 'woo-additional-terms' ), |
| 36 |
'desc' => __( 'Enter you custom title for additional terms, the title will appear in link shortcode and order details page.', 'woo-additional-terms' ), |
| 37 |
'id' => 'woo_additional_terms_title', |
| 38 |
'type' => 'text', |
| 39 |
'default' => '', |
| 40 |
'desc_tip' => true, |
| 41 |
'css' => 'min-width:350px;' |
| 42 |
); |
| 43 |
$updated_settings[] = array( |
| 44 |
'title' => __( 'Additional Terms Notice', 'woo-additional-terms' ), |
| 45 |
'desc' => __( 'Use %link% for appending terms page link into notice content.', 'woo-additional-terms' ), |
| 46 |
'id' => 'woo_additional_terms_notice', |
| 47 |
'type' => 'text', |
| 48 |
'default' => '', |
| 49 |
'desc_tip' => __( 'Enter you custom notice for additional terms, the customer will be asked if they accept them when checking out.', 'woo-additional-terms' ), |
| 50 |
'css' => 'min-width:350px;' |
| 51 |
); |
| 52 |
$updated_settings[] = array( |
| 53 |
'title' => __( 'Additional Terms Notice Error', 'woo-additional-terms' ), |
| 54 |
'desc' => __( 'Display friendly notice whenever customer doesn\'t accept additional terms.', 'woo-additional-terms' ), |
| 55 |
'id' => 'woo_additional_terms_notice_error', |
| 56 |
'type' => 'text', |
| 57 |
'default' => __('You must accept our additional terms.', 'woo-additional-terms'), |
| 58 |
'desc_tip' => true, |
| 59 |
'css' => 'min-width:350px;' |
| 60 |
); |
| 61 |
endif; |
| 62 |
$updated_settings[] = $section; |
| 63 |
endforeach; |
| 64 |
return $updated_settings; |
| 65 |
} |
| 66 |
/** |
| 67 |
* Display plugin settings link in plugins table page. |
| 68 |
* |
| 69 |
*@since 1.0 |
| 70 |
*/ |
| 71 |
public function woo_additional_terms_settings_link($links) { |
| 72 |
// Add settings link to plugin list table |
| 73 |
$settings_link = '<a href="admin.php?page=wc-settings&tab=checkout">' . __( 'Settings', 'woocommerce-store-vacation' ) . '</a>'; |
| 74 |
array_push( $links, $settings_link ); |
| 75 |
return $links; |
| 76 |
} |
| 77 |
} |
| 78 |
endif; |