'; if ( !isset( $_REQUEST['action'] ) ) { $url = add_query_arg( array( 'section' => 'general' ), admin_url( 'admin.php?page=affiliates-admin-settings' ) ); } else { $url = add_query_arg( array( 'section' => 'general', 'subsection' => 'robot-cleaner' ), admin_url( 'admin.php?page=affiliates-admin-settings' ) ); } printf( '%s', esc_url( $url ), esc_html__( 'Back', 'affiliates' ) ); echo '

'; return; } $robots_table = _affiliates_get_tablename( 'robots' ); if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST[AFFILIATES_ADMIN_SETTINGS_NONCE], 'admin' ) ) { // 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 ); } } } $pname = !empty( $_POST['pname'] ) ? trim( $_POST['pname'] ) : get_option( 'aff_pname', AFFILIATES_PNAME ); $forbidden_names = array(); if ( !empty( $wp->public_query_vars ) ) { $forbidden_names += $wp->public_query_vars; } if ( !empty( $wp->private_query_vars ) ) { $forbidden_names += $wp->private_query_vars; } if ( !empty( $wp->extra_query_vars ) ) { $forbidden_names += $wp->extra_query_vars; } if ( !preg_match( '/[a-z_]+/', $pname, $matches ) || !isset( $matches[0] ) || $pname !== $matches[0] ) { $pname = get_option( 'aff_pname', AFFILIATES_PNAME ); echo '
' . __( 'The Affiliate URL parameter name has not been changed, the suggested name is not valid. Only lower case letters and the underscore _ are allowed.', 'affiliates' ) . '
'; } else if ( in_array( $pname, $forbidden_names ) ) { $pname = get_option( 'aff_pname', AFFILIATES_PNAME ); echo '
' . __( 'The Affiliate URL parameter name has not been changed, the suggested name is forbidden.', 'affiliates' ) . '
'; } $old_pname = get_option( 'aff_pname', AFFILIATES_PNAME ); if ( $pname !== $old_pname ) { update_option( 'aff_pname', $pname ); affiliates_update_rewrite_rules(); echo '
' . '

' . sprintf( __( 'The Affiliate URL parameter name has been changed from %s to %s.', 'affiliates' ), $old_pname, $pname ) . '

' . '

' . __( 'If your affiliates are using affiliate links based on the previous Affiliate URL parameter name, they NEED to update their affiliate links.', 'affiliates' ) . '

' . '

' . __( 'Unless the incoming affiliate links reflect the current Affiliate URL parameter name, no affiliate hits, visits or referrals will be recorded.', 'affiliates' ) . '

' . '
'; } $redirect = !empty( $_POST['redirect'] ); if ( $redirect ) { if ( get_option( 'aff_redirect', null ) === null ) { add_option( 'aff_redirect', 'yes', '', 'no' ); } else { update_option( 'aff_redirect', 'yes' ); } } else { delete_option( 'aff_redirect' ); } $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' ), AFFILIATES_ADMINISTER_AFFILIATES => __( 'Administer affiliates', 'affiliates' ), AFFILIATES_ADMINISTER_OPTIONS => __( 'Administer options', 'affiliates' ), ); 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 ( !affiliates_is_sitewide_plugin() ) { delete_option( 'aff_delete_data' ); add_option( 'aff_delete_data', !empty( $_POST['delete-data'] ), '', 'no' ); } self::settings_saved_notice(); } } $robots = ''; $db_robots = $wpdb->get_results( "SELECT name FROM $robots_table", OBJECT ); foreach ($db_robots as $db_robot ) { $robots .= $db_robot->name . "\n"; } $pname = get_option( 'aff_pname', AFFILIATES_PNAME ); $redirect = get_option( 'aff_redirect', false ); $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' ), AFFILIATES_ADMINISTER_AFFILIATES => __( 'Administer affiliates', 'affiliates' ), AFFILIATES_ADMINISTER_OPTIONS => __( 'Administer options', 'affiliates' ), ); $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' ); $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 = get_option( 'aff_delete_data', false ); echo '
' . '
'; echo '

' . __( 'Affiliate URL parameter name', 'affiliates' ) . '

' . '

' . '' . '

' . '

' . sprintf( __( 'The current Affiliate URL parameter name is: %s', 'affiliates' ), $pname ) . '

' . '

' . sprintf( __( 'The default Affiliate URL parameter name is %s.', 'affiliates' ), AFFILIATES_PNAME ) . '

' . '

' . __( '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 URL parameter name, no affiliate hits, visits or referrals will be recorded.', 'affiliates' ) . '

'; echo '

' . __( 'Redirection', 'affiliates' ) . '

' . '

' . '' . '

' . '

' . __( 'Redirect to destination without Affiliate URL parameter, after a hit on an affiliate link has been detected.', 'affiliates' ) . '

'; echo '

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

' . '

' . $id_encoding_select . '

' . '

' . sprintf( __( 'The current encoding in effect is: %s', 'affiliates' ), $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' ) . '

'; echo '

' . __( 'Permissions', 'affiliates' ) . '

' . '

' . __( 'Do not assign permissions to open access for affiliates here.', 'affiliates' ) . ' ' . __( 'This section is only intended to grant administrative access on affiliate management functions to privileged roles.', 'affiliates' ) . '

' . $caps_table . '

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

'; echo '

' . __( 'Robots', 'affiliates' ) . '

' . '

' . //'' . '' . '

' . '

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

'; echo '

' . sprintf( esc_html__( 'Use the robot cleaner to remove existing hits from robots: %s', 'affiliates' ), sprintf( '%s', add_query_arg( array( 'section' => 'general', 'subsection' => 'robot-cleaner' ), admin_url( 'admin.php?page=affiliates-admin-settings' ) ), esc_html__( 'Robot Cleaner', 'affiliates' ) ) ); echo '

'; if ( !affiliates_is_sitewide_plugin() ) { echo '

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

' . '

' . '' . '

' . '

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

'; } echo '

' . wp_nonce_field( 'admin', AFFILIATES_ADMIN_SETTINGS_NONCE, true, false ) . '' . '

' . '
' . '
'; affiliates_footer(); } }