' . '

' . __( 'Affiliates options', AFFILIATES_PLUGIN_DOMAIN ) . '

' . ''; // // handle options form submission // if ( isset( $_POST['timeout'] ) ) { if ( wp_verify_nonce( $_POST[AFFILIATES_ADMIN_OPTIONS_NONCE], plugin_basename( __FILE__ ) ) ) { // timeout $timeout = intval ( $_POST['timeout'] ); if ( $timeout < 0 ) { $timeout = 0; } $affiliates_options->update_option( 'cookie_timeout_days', $timeout ); // robots $robots = wp_filter_nohtml_kses( trim ( $_POST['robots'] ) ); $wpdb->query("DELETE FROM $robots_table;"); if ( !empty( $robots ) ) { $robots = str_replace( ",", "\n", $robots ); $robots = str_replace( "\r", "", $robots ); $robots = explode( "\n", $robots ); foreach ( $robots as $robot ) { $robot = trim( $robot ); if (!empty($robot)) { $query = $wpdb->prepare( "INSERT INTO $robots_table (name) VALUES (%s);", $robot ); $wpdb->query( $query ); } } } $encoding_id = $_POST['id_encoding']; if ( key_exists( $encoding_id, affiliates_get_id_encodings() ) ) { // important: must use normal update_option/get_option otherwise we'd have a per-user encoding update_option( 'aff_id_encoding', $encoding_id ); } $rolenames = $wp_roles->get_names(); $caps = array( AFFILIATES_ACCESS_AFFILIATES => __( 'Access affiliates', AFFILIATES_PLUGIN_DOMAIN ), AFFILIATES_ADMINISTER_AFFILIATES => __( 'Administer affiliates', AFFILIATES_PLUGIN_DOMAIN ), AFFILIATES_ADMINISTER_OPTIONS => __( 'Administer options', AFFILIATES_PLUGIN_DOMAIN ), ); foreach ( $rolenames as $rolekey => $rolename ) { $role = $wp_roles->get_role( $rolekey ); foreach ( $caps as $capkey => $capname ) { $role_cap_id = $rolekey.'-'.$capkey; if ( !empty($_POST[$role_cap_id] ) ) { $role->add_cap( $capkey ); } else { $role->remove_cap( $capkey ); } } } // prevent locking out _affiliates_assure_capabilities(); if ( !empty( $_POST['delete-data'] ) ) { $affiliates_options->update_option( 'delete_data', true ); } else { $affiliates_options->update_option( 'delete_data', false ); } if ( !empty( $_POST['use-direct'] ) ) { $affiliates_options->update_option( 'use_direct', true ); } else { $affiliates_options->update_option( 'use_direct', false ); } } } $use_direct = $affiliates_options->get_option( 'use_direct', true ); $timeout = $affiliates_options->get_option( 'cookie_timeout_days', 1 ); $robots = ''; $db_robots = $wpdb->get_results( $wpdb->prepare( "SELECT name FROM $robots_table" ), OBJECT ); foreach ($db_robots as $db_robot ) { $robots .= $db_robot->name . "\n"; } $id_encoding = get_option( 'aff_id_encoding', AFFILIATES_NO_ID_ENCODING ); $id_encoding_select = ''; $encodings = affiliates_get_id_encodings(); if ( !empty( $encodings ) ) { $id_encoding_select .= ''; $id_encoding_select .= ''; } $rolenames = $wp_roles->get_names(); $caps = array( AFFILIATES_ACCESS_AFFILIATES => __( 'Access affiliates', AFFILIATES_PLUGIN_DOMAIN ), AFFILIATES_ADMINISTER_AFFILIATES => __( 'Administer affiliates', AFFILIATES_PLUGIN_DOMAIN ), AFFILIATES_ADMINISTER_OPTIONS => __( 'Administer options', AFFILIATES_PLUGIN_DOMAIN ), ); $caps_table = ''; $caps_table .= ''; $caps_table .= ''; $caps_table .= ''; foreach ( $caps as $cap ) { $caps_table .= ''; } $caps_table .= ''; $caps_table .= ''; $caps_table .= ''; foreach ( $rolenames as $rolekey => $rolename ) { $role = $wp_roles->get_role( $rolekey ); $caps_table .= ''; $caps_table .= ''; foreach ( $caps as $capkey => $capname ) { if ( $role->has_cap( $capkey ) ) { $checked = ' checked="checked" '; } else { $checked = ''; } $caps_table .= ''; } $caps_table .= ''; } $caps_table .= ''; $caps_table .= '
'; $caps_table .= __( 'Role', AFFILIATES_PLUGIN_DOMAIN ); $caps_table .= ''; $caps_table .= $cap; $caps_table .= '
'; $caps_table .= translate_user_role( $rolename ); $caps_table .= ''; $role_cap_id = $rolekey.'-'.$capkey; $caps_table .= ''; $caps_table .= '
'; $delete_data = $affiliates_options->get_option( 'delete_data', false ); // // print the options form // echo '
' . '
' . '

' . __( 'Referral timeout') . '

' . '

' . '' . '' . '

' . '

' . __( 'This is the number of days since a visitor accessed your site via an affiliate link, for which a suggested referral will be valid.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'If you enter 0, referrals will only be valid until the visitor closes the browser (session).', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'The default value is 1. In this case, if a visitor comes to your site via an affiliate link, a suggested referral will be valid until one day after she or he clicked that affiliate link.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'Direct referrals', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . '' . '' . '

' . '

' . __( 'If this option is enabled, whenever a referral is suggested and no affiliate is attributable to it, the referral will be attributed to Direct.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'Robots') . '

' . '

' . //'' . '' . '

' . '

' . __( 'Hits on affiliate links from these robots will be marked or not recorded. Put one entry on each line.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'Affiliate ID encoding', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . $id_encoding_select . '

' . '

' . sprintf( __( 'The current encoding in effect is: %s', AFFILIATES_PLUGIN_DOMAIN ), $encodings[$id_encoding] ) . '

' . '

' . __( 'CAUTION: If you change this setting and have distributed affiliate links or permalinks, make sure that these are updated. Unless the incoming affiliate links reflect the current encoding, no affiliate hits, visits or referrals will be recorded.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'Permissions', AFFILIATES_PLUGIN_DOMAIN ) . '

' . $caps_table . '

' . __( 'A minimum set of permissions will be preserved.', AFFILIATES_PLUGIN_DOMAIN ) . '
' . __( 'If you lock yourself out, please ask an administrator to help.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . __( 'Deactivation and data persistence', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . '' . '' . '

' . '

' . __( 'CAUTION: If this option is active while the plugin is deactivated, ALL affiliate and referral data will be DELETED. If you want to retrieve data about your affiliates and their referrals and are going to deactivate the plugin, make sure to back up your data or do not enable this option. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', AFFILIATES_PLUGIN_DOMAIN ) . '

' . '

' . wp_nonce_field( plugin_basename( __FILE__ ), AFFILIATES_ADMIN_OPTIONS_NONCE, true, false ) . '' . '

' . '
' . '
'; affiliates_footer(); } ?>