1.0 ) { $options[Affiliates_CF7::REFERRAL_RATE] = 1.0; } else if ( $options[Affiliates_CF7::REFERRAL_RATE] < 0 ) { $options[Affiliates_CF7::REFERRAL_RATE] = 0.0; } } $ids = ''; $include_form_ids = array(); if ( !empty( $_POST[Affiliates_CF7::INCLUDED_FORMS] ) ) { $ids = trim( $_POST[Affiliates_CF7::INCLUDED_FORMS] ); if ( !empty( $ids ) ) { $ids = explode( ',', $ids ); foreach ( $ids as $id ) { $id = intval( trim( $id ) ); if ( $id >= 0 && !in_array( $id, $include_form_ids ) ) { $include_form_ids[] = $id; } } } } $options[Affiliates_CF7::INCLUDED_FORMS] = $include_form_ids; $ids = ''; $exclude_form_ids = array(); if ( !empty( $_POST[Affiliates_CF7::EXCLUDED_FORMS] ) ) { $ids = trim( $_POST[Affiliates_CF7::EXCLUDED_FORMS] ); if ( !empty( $ids ) ) { $ids = explode( ',', $ids ); foreach ( $ids as $id ) { $id = intval( trim( $id ) ); if ( $id >= 0 && !in_array( $id, $exclude_form_ids ) ) { $exclude_form_ids[] = $id; } } } } $options[Affiliates_CF7::EXCLUDED_FORMS] = $exclude_form_ids; $ids = ''; $petition_form_ids = array(); if ( !empty( $_POST[Affiliates_CF7::PETITION_FORMS] ) ) { $ids = trim( $_POST[Affiliates_CF7::PETITION_FORMS] ); if ( !empty( $ids ) ) { $ids = explode( ',', $ids ); foreach ( $ids as $id ) { $id = intval( trim( $id ) ); if ( $id >= 0 && !in_array( $id, $petition_form_ids ) ) { $petition_form_ids[] = $id; } } } } $options[Affiliates_CF7::PETITION_FORMS] = $petition_form_ids; if ( isset( $_POST[Affiliates_CF7::CURRENCY] ) && in_array( $_POST[Affiliates_CF7::CURRENCY], Affiliates_CF7::$supported_currencies ) ) { $options[Affiliates_CF7::CURRENCY] = $_POST[Affiliates_CF7::CURRENCY]; } $options[Affiliates_CF7::USE_FORM_AMOUNT] = !empty( $_POST[Affiliates_CF7::USE_FORM_AMOUNT] ); $options[Affiliates_CF7::USE_FORM_BASE_AMOUNT] = !empty( $_POST[Affiliates_CF7::USE_FORM_BASE_AMOUNT] ); $options[Affiliates_CF7::USE_FORM_CURRENCY] = !empty( $_POST[Affiliates_CF7::USE_FORM_CURRENCY] ); $options[Affiliates_CF7::USAGE_STATS] = !empty( $_POST[Affiliates_CF7::USAGE_STATS] ); } update_option( Affiliates_CF7::PLUGIN_OPTIONS, $options ); } $referral_rate = isset( $options[Affiliates_CF7::REFERRAL_RATE] ) ? $options[Affiliates_CF7::REFERRAL_RATE] : Affiliates_CF7::REFERRAL_RATE_DEFAULT; $included_forms = isset( $options[Affiliates_CF7::INCLUDED_FORMS] ) ? $options[Affiliates_CF7::INCLUDED_FORMS] : array(); $excluded_forms = isset( $options[Affiliates_CF7::EXCLUDED_FORMS] ) ? $options[Affiliates_CF7::EXCLUDED_FORMS] : array(); $petition_forms = isset( $options[Affiliates_CF7::PETITION_FORMS] ) ? $options[Affiliates_CF7::PETITION_FORMS] : array(); $currency = isset( $options[Affiliates_CF7::CURRENCY] ) ? $options[Affiliates_CF7::CURRENCY] : Affiliates_CF7::DEFAULT_CURRENCY; $use_form_amount = isset( $options[Affiliates_CF7::USE_FORM_AMOUNT] ) ? $options[Affiliates_CF7::USE_FORM_AMOUNT] : Affiliates_CF7::DEFAULT_USE_FORM_AMOUNT; $use_form_base_amount = isset( $options[Affiliates_CF7::USE_FORM_BASE_AMOUNT] ) ? $options[Affiliates_CF7::USE_FORM_BASE_AMOUNT] : Affiliates_CF7::DEFAULT_USE_FORM_BASE_AMOUNT; $use_form_currency = isset( $options[Affiliates_CF7::USE_FORM_CURRENCY] ) ? $options[Affiliates_CF7::USE_FORM_CURRENCY] : Affiliates_CF7::DEFAULT_USE_FORM_CURRENCY; $usage_stats = isset( $options[Affiliates_CF7::USAGE_STATS] ) ? $options[Affiliates_CF7::USAGE_STATS] : Affiliates_CF7::USAGE_STATS_DEFAULT; echo '
'; echo '

'; esc_html_e( 'Contact Form 7 Integration Settings', 'affiliates-contact-form-7' ); echo '

'; echo '
'; echo '
'; echo '
'; echo '

' . esc_html__( 'Forms', 'affiliates-contact-form-7' ) . '

'; echo '

' . esc_html__( 'By default, form submissions on all Contact Form 7 forms will originate referrals.', 'affiliates-contact-form-7' ) . '

'; echo '

' . esc_html__( 'If you only want specific forms to originate referrals, or if you want to exclude some forms from originating referrals, input their form ids in the fields below.', 'affiliates-contact-form-7' ) . '

'; echo '

' . wp_kses( __( 'The id of a form is the X that can be found in the Contact Form 7 shortcode [contact-form-7 id="X" title="Form title"]', 'affiliates-contact-form-7' ), array( 'b' => array() ) ) . '

'; echo '

' . esc_html__( 'Separate form ids by comma.', 'affiliates-contact-form-7' ) . '

'; echo '

' . esc_html__( 'Included forms', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . esc_html__( 'Excluded forms', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . esc_html__( 'Petition forms', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

'; echo esc_html__( 'Petition forms allow affiliates to submit referrals directly. Include form ids of those forms which should credit referrals directly to the affiliate who submits the form.', 'affiliates-contact-form-7' ); echo '

'; echo '

' . esc_html__( 'Referral Rate', 'affiliates-contact-form-7' ) . '

'; if ( class_exists( 'Affiliates_Referral' ) ) { echo '

'; echo wp_kses( __( 'The referral rate settings are as determined in Affiliates > Settings.', 'affiliates-contact-form-7' ), array( 'strong' => array() ) ); echo '

'; } else { echo '

'; echo ''; echo ' '; echo ''; echo '

'; echo '

'; echo esc_html__( 'The referral rate determines the referral amount (or commission) calculated from the base amount.', 'affiliates-contact-form-7' ); echo '

'; echo '

'; echo wp_kses( __( 'Example: Set the referral rate to 0.1 if you want your affiliates to get a 10% commission on each referral.', 'affiliates-contact-form-7' ), array( 'strong' => array() ) ); echo '

'; } echo '

' . esc_html__( 'Referral amount and currency', 'affiliates-contact-form-7' ) . '

'; echo '

' . esc_html__( 'Default currency', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo ' '; echo ''; echo '

'; echo '

' . esc_html__( 'Form amount (base)', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . wp_kses( __( 'This will assign a referral amount (commission) resulting from the calculation based on the form field named base-amount.', 'affiliates-contact-form-7' ), array( 'b' => array() ) ) . '

'; echo '

' . esc_html__( 'Form amount (fixed)', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . wp_kses( __( 'If you want to have the referral amount provided through a form, add a field to your form named amount.', 'affiliates-contact-form-7' ), array( 'b' => array() ) ) . '

'; echo '

' . esc_html__( 'Form currency', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . wp_kses( __( 'If you want to have the referral in a currency other than the default currency, add a field to your form named currency. The value of that field must be a three-letter currency code of those selectable for the default currency.', 'affiliates-contact-form-7' ), array( 'b' => array() ) ) . '

'; echo '

' . esc_html__( 'Notifications', 'affiliates-contact-form-7' ) . '

'; if ( !class_exists( 'Affiliates_Notifications' ) ) { echo '

'; echo wp_kses( __( 'Notifications require Affiliates Pro or Affiliates Enterprise', 'affiliates-contact-form-7' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ); echo '

'; } else { echo '

'; echo sprintf( wp_kses( __( 'The settings for Notifications apply.', 'affiliates-contact-form-7' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( admin_url( 'admin.php?page=affiliates-admin-notifications' ) ) ); echo '

'; echo '

'; echo wp_kses( __( 'Contact Form 7 field names can also be used as tokens. The tokens are replaced by the text or values that have been submitted through a form.', 'affiliates-contact-form-7' ), array( 'b' => array() ) ); echo '

'; echo '

'; echo wp_kses( __( 'For example, assuming you have a text field in your form named your-name and the field is represented by the code [text your-name] in your form, you can use [your-name] in the notification email subject and message body.', 'affiliates-contact-form-7' ), array( 'b' => array() ) ); echo '

'; echo '

'; echo esc_html__( 'Text form fields and the values submitted through fields of other types (e.g. checkbox, select, ...) are represented in a consistent manner when supported.', 'affiliates-contact-form-7' ); echo '

'; } echo '

' . esc_html__( 'Usage stats', 'affiliates-contact-form-7' ) . '

'; echo '

'; echo ''; echo '

'; echo '

' . esc_html__( 'This will allow the plugin to help in computing how many installations are actually using it. No personal or site data is transmitted, this simply embeds an icon on the bottom of the Affiliates admin pages, so that the number of visits to these can be counted. This is useful to help prioritize development.', 'affiliates-contact-form-7' ) . ''; echo '

'; echo '

'; echo wp_nonce_field( self::SET_ADMIN_OPTIONS, self::NONCE, true, false ); echo ''; echo '

'; echo '
'; echo '
'; affiliates_footer(); } /** * Add a notice to the footer that the integration is active. * * @param string $footer */ public static function affiliates_footer( $footer ) { $options = get_option( Affiliates_CF7::PLUGIN_OPTIONS , array() ); $usage_stats = isset( $options[Affiliates_CF7::USAGE_STATS] ) ? $options[Affiliates_CF7::USAGE_STATS] : Affiliates_CF7::USAGE_STATS_DEFAULT; $output = ''; $output .= '
'; $output .= '

'; $image_html = $usage_stats ? "" : ''; $output .= wp_kses( $image_html, array( 'img' => array( 'src' => array(), 'alt' => array() ) ) ); $output .= wp_kses( sprintf( __( 'Affiliates Contact Form 7 integration by itthinx.com', 'affiliates-contact-form-7' ), 'https://www.itthinx.com/shop/' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ); $output .= '

'; $output .= '
'; return $output . $footer; } } Affiliates_CF7_Admin::init();