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; 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] ); // @todo see below // $options[Affiliates_CF7::NOTIFY_ADMIN] = !empty( $_POST[Affiliates_CF7::NOTIFY_ADMIN] ); // $options[Affiliates_CF7::NOTIFY_AFFILIATE] = !empty( $_POST[Affiliates_CF7::NOTIFY_AFFILIATE] ); // $options[Affiliates_CF7::SUBJECT] = $_POST[Affiliates_CF7::SUBJECT]; // $options[Affiliates_CF7::MESSAGE] = $_POST[Affiliates_CF7::MESSAGE]; $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(); $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; $notify_admin = isset( $options[Affiliates_CF7::NOTIFY_ADMIN] ) ? $options[Affiliates_CF7::NOTIFY_ADMIN] : Affiliates_CF7::NOTIFY_ADMIN_DEFAULT; $notify_affiliate = isset( $options[Affiliates_CF7::NOTIFY_AFFILIATE] ) ? $options[Affiliates_CF7::NOTIFY_AFFILIATE] : Affiliates_CF7::NOTIFY_AFFILIATE_DEFAULT; $affiliate_subject = isset( $options[Affiliates_CF7::SUBJECT] ) ? esc_attr( wp_filter_nohtml_kses( $options[Affiliates_CF7::SUBJECT] ) ) : Affiliates_CF7::DEFAULT_SUBJECT; $affiliate_message = isset( $options[Affiliates_CF7::MESSAGE] ) ? $options[Affiliates_CF7::MESSAGE] : Affiliates_CF7::DEFAULT_MESSAGE; $usage_stats = isset( $options[Affiliates_CF7::USAGE_STATS] ) ? $options[Affiliates_CF7::USAGE_STATS] : Affiliates_CF7::USAGE_STATS_DEFAULT; echo '
' . '

' . __( 'Contact Form 7 Integration Settings', AFF_CF7_PLUGIN_DOMAIN ) . '

' . '
'; $output .= '
'; $output .= '
'; $output .= '

' . __( 'Forms', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'By default, form submissions on all Contact Form 7 forms will originate referrals.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( '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.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( '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"]', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Separate form ids by comma.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Included forms', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( 'Excluded forms', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( 'Referral Rate', AFF_CF7_PLUGIN_DOMAIN ) . '

'; if ( class_exists( 'Affiliates_Referral' ) ) { $output .= '

'; $output .= __( 'The referral rate settings are as determined in Affiliates > Settings.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; } else { $output .= '

'; $output .= ''; $output .= ' '; $output .= ''; $output .= '

'; $output .= '

'; $output .= __( 'The referral rate determines the referral amount (or commission) calculated from the base amount.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; $output .= '

'; $output .= __( 'Example: Set the referral rate to 0.1 if you want your affiliates to get a 10% commission on each referral.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; } $output .= '

' . __( 'Referral amount and currency', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Default currency', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $currency_select = ''; $output .= '

'; $output .= ''; $output .= ' '; $output .= $currency_select; $output .= '

'; $output .= '

' . __( 'Form amount (base)', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( 'This will assign a referral amount (commission) resulting from the calculation based on the form field named base-amount.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Form amount (fixed)', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( 'If you want to have the referral amount provided through a form, add a field to your form named amount.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Form currency', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( '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.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

' . __( 'Notifications', AFF_CF7_PLUGIN_DOMAIN ) . '

'; if ( !class_exists( 'Affiliates_Notifications' ) ) { $output .= '

'; $output .= __( 'Notifications require Affiliates Pro or Affiliates Enterprise', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; } else { $output .= '

'; $output .= sprintf( __( 'The settings for Notifications apply.', AFF_CF7_PLUGIN_DOMAIN ), esc_url( admin_url( 'admin.php?page=affiliates-admin-notifications' ) ) ); $output .= '

'; // @todo provide the alternative when filters are added // $output .= '

'; // $output .= sprintf( __( 'Here you can customize the message sent to the referring affiliate. When enabled, this message is used for referrals created through Contact Form 7 form submissions, instead of the message set in the Notifications section.', AFF_CF7_PLUGIN_DOMAIN ), esc_url( admin_url( 'admin.php?page=affiliates-admin-notifications' ) ) ); // $output .= '

'; // $output .= '

' . __( 'Notify the admin', AFF_CF7_PLUGIN_DOMAIN ) . '

'; // $output .= '

'; // $output .= ''; // $output .= ' '; // $output .= ''; // $output .= '

'; // $output .= '

' . __( 'Sends a notification email to the site administrator when a referral has been created for a form submission.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; // $output .= '

' . __( 'Notify the affiliate', AFF_CF7_PLUGIN_DOMAIN ) . '

'; // $output .= '

'; // $output .= ''; // $output .= ' '; // $output .= ''; // $output .= '

'; // $output .= '

' . __( 'Sends a notification email to the referring affiliate when a referral has been created for a form submission.', AFF_CF7_PLUGIN_DOMAIN ) . '

'; // $output .= '

' . __( 'Affiliate notification', AFF_CF7_PLUGIN_DOMAIN ) . '

'; // $output .= '

'; // $output .= ''; // $output .= ''; // $output .= '

'; // $output .= '

'; // $output .= __( 'The default subject is:', AFF_CF7_PLUGIN_DOMAIN ); // $output .= '

';
// 			$output .= htmlentities( Affiliates_CF7::DEFAULT_SUBJECT );
// 			$output .= '
'; // $output .= '

'; // $output .= '

'; // $output .= ''; // $output .= ''; // $output .= '

'; // $output .= '

'; // $output .= __( 'The default message is:', AFF_CF7_PLUGIN_DOMAIN ); // $output .= '

';
// 			$output .= htmlentities( Affiliates_CF7::DEFAULT_MESSAGE );
// 			$output .= '
'; // $output .= '

'; // $output .= '

' . __( 'These default tokens can be used in the subject and message: [site_title] [site_url].', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= __( '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.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; $output .= '

'; $output .= __( '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.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; $output .= '

'; $output .= __( 'Text form fields and the values submitted through fields of other types (e.g. checkbox, select, ...) are represented in a consistent manner when supported.', AFF_CF7_PLUGIN_DOMAIN ); $output .= '

'; } $output .= '

' . __( 'Usage stats', AFF_CF7_PLUGIN_DOMAIN ) . '

'; $output .= '

'; $output .= ''; $output .= '

'; $output .= '

' . __( '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.', AFF_CF7_PLUGIN_DOMAIN ) . ''; $output .= '

'; $output .= '

'; $output .= wp_nonce_field( self::SET_ADMIN_OPTIONS, self::NONCE, true, false ); $output .= ''; $output .= '

'; $output .= '
'; $output .= '
'; echo $output; 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; return '
' . '

' . ( $usage_stats ? "" : '' ) . __( "Powered by Affiliates Contact Form 7 Integration.", AFF_CF7_PLUGIN_DOMAIN ) . ( !class_exists( 'Affiliates_Attributes' ) ? ' ' . __( 'Get additional features with Affiliates Pro.', AFF_CF7_PLUGIN_DOMAIN ) : '' ) . '

' . '
' . $footer; } } Affiliates_CF7_Admin::init();