class-affiliates-affiliates-wordpress.php 28.5 KB
<?php
class Affiliates_Affiliates_WordPress extends Affiliates_Affiliates { public function view() { global $wpdb, $wp_rewrite, $affiliates_options; global $affiliates_db; $IXAP62 = ''; $IXAP101 = date( 'Y-m-d', time() ); $IXAP147 = get_option( 'aff_pname', AFFILIATES_PNAME ); if ( !current_user_can( AFFILIATES_ADMINISTER_AFFILIATES ) ) { wp_die( __( 'Access denied.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } if ( isset( $_POST['action'] ) ) { switch( $_POST['action'] ) { case 'add' : if ( !affiliates_admin_affiliates_add_submit() ) { return affiliates_admin_affiliates_add(); } break; case 'edit' : $IXAP352 = new Affiliates_Affiliate_WordPress(); if ( !$IXAP352->edit_submit() ) { return $IXAP352->edit( $_POST['affiliate-id-field'] ); } break; case 'remove' : affiliates_admin_affiliates_remove_submit(); break; case 'add-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); if ( !$IXAP353->add_submit() ) { if ( isset( $_POST['affiliate_id'] ) ) { return $IXAP353->add( $_POST['affiliate_id' ] ); } } else { $IXAP352 = new Affiliates_Affiliate_WordPress(); return $IXAP352->edit( $_POST['affiliate_id'] ); } break; case 'edit-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); if ( !$IXAP353->edit_submit() ) { if ( isset( $_POST['affiliate_id'] ) && isset( $_GET['attr_key'] ) ) { return $IXAP353->edit( $_POST['affiliate_id' ], $_GET['attr_key'] ); } } else { $IXAP352 = new Affiliates_Affiliate_WordPress(); return $IXAP352->edit( $_POST['affiliate_id'] ); } break; case 'remove-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); $IXAP353->remove_submit(); $IXAP352 = new Affiliates_Affiliate_WordPress(); return $IXAP352->edit( $_POST['affiliate_id'] ); break; case 'add-relation' : break; case 'edit-relation' : break; case 'remove-relation' : break; } } else if ( isset ( $_GET['action'] ) ) { switch( $_GET['action'] ) { case 'add' : return affiliates_admin_affiliates_add(); break; case 'edit' : if ( isset( $_GET['affiliate_id'] ) ) { $IXAP352 = new Affiliates_Affiliate_WordPress(); return $IXAP352->edit( $_GET['affiliate_id'] ); } break; case 'remove' : if ( isset( $_GET['affiliate_id'] ) ) { return affiliates_admin_affiliates_remove( $_GET['affiliate_id'] ); } break; case 'add-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); if ( isset( $_GET['affiliate_id'] ) ) { return $IXAP353->add( $_GET['affiliate_id' ] ); } break; case 'edit-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); if ( isset( $_GET['affiliate_id'] ) && isset( $_GET['attr_key'] ) ) { return $IXAP353->edit( $_GET['affiliate_id' ], $_GET['attr_key'] ); } break; case 'remove-attribute' : $IXAP353 = new Affiliates_Attributes_WordPress(); if ( isset( $_GET['affiliate_id'] ) && isset( $_GET['attr_key'] ) ) { return $IXAP353->remove( $_GET['affiliate_id' ], $_GET['attr_key'] ); } break; case 'add-relation' : break; case 'edit-relation' : break; case 'remove-relation' : break; } } if ( isset( $_POST['clear_filters'] ) || isset( $_POST['submitted'] ) ) { if ( !wp_verify_nonce( $_POST[AFFILIATES_ADMIN_AFFILIATES_FILTER_NONCE], plugin_basename( __FILE__ ) ) ) { wp_die( __( 'Access denied.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } } $IXAP36 = $affiliates_options->get_option( 'affiliates_from_date', null ); $IXAP37 = null; $IXAP38 = $affiliates_options->get_option( 'affiliates_thru_date', null ); $IXAP39 = null; $IXAP24 = $affiliates_options->get_option( 'affiliates_affiliate_id', null ); $IXAP43 = $affiliates_options->get_option( 'affiliates_affiliate_name', null ); $IXAP354 = $affiliates_options->get_option( 'affiliates_affiliate_email', null ); $IXAP44 = $affiliates_options->get_option( 'affiliates_affiliate_user_login', null ); $IXAP289 = $affiliates_options->get_option( 'affiliates_show_deleted', false ); $IXAP290 = $affiliates_options->get_option( 'affiliates_show_inoperative', false ); $IXAP228 = $affiliates_options->get_option( 'affiliates_show_totals', true ); if ( isset( $_POST['clear_filters'] ) ) { $affiliates_options->delete_option( 'affiliates_from_date' ); $affiliates_options->delete_option( 'affiliates_thru_date' ); $affiliates_options->delete_option( 'affiliates_affiliate_id' ); $affiliates_options->delete_option( 'affiliates_affiliate_name' ); $affiliates_options->delete_option( 'affiliates_affiliate_email' ); $affiliates_options->delete_option( 'affiliates_affiliate_user_login' ); $affiliates_options->delete_option( 'affiliates_show_deleted' ); $affiliates_options->delete_option( 'affiliates_show_inoperative' ); $affiliates_options->delete_option( 'affiliates_show_totals' ); $IXAP36 = null; $IXAP37 = null; $IXAP38 = null; $IXAP39 = null; $IXAP24 = null; $IXAP43 = null; $IXAP354 = null; $IXAP44 = null; $IXAP289 = false; $IXAP290 = false; $IXAP228 = true; } else if ( isset( $_POST['submitted'] ) ) { if ( !empty( $_POST['affiliate_name'] ) ) { $IXAP43 = trim( $_POST['affiliate_name'] ); if ( strlen( $IXAP43 ) > 0 ) { $affiliates_options->update_option( 'affiliates_affiliate_name', $IXAP43 ); } else { $IXAP43 = null; $affiliates_options->delete_option( 'affiliates_affiliate_name' ); } } else { $IXAP43 = null; $affiliates_options->delete_option( 'affiliates_affiliate_name' ); } if ( !empty( $_POST['affiliate_email'] ) ) { $IXAP354 = trim( $_POST['affiliate_email'] ); if ( strlen( $IXAP354 ) > 0 ) { $affiliates_options->update_option( 'affiliates_affiliate_email', $IXAP354 ); } else { $IXAP354 = null; $affiliates_options->delete_option( 'affiliates_affiliate_email' ); } } else { $IXAP354 = null; $affiliates_options->delete_option( 'affiliates_affiliate_email' ); } if ( !empty( $_POST['affiliate_user_login'] ) ) { $IXAP44 = trim( $_POST['affiliate_user_login'] ); if ( strlen( $IXAP44 ) > 0 ) { $affiliates_options->update_option( 'affiliates_affiliate_user_login', $IXAP44 ); } else { $IXAP44 = null; $affiliates_options->delete_option( 'affiliates_affiliate_user_login' ); } } else { $IXAP44 = null; $affiliates_options->delete_option( 'affiliates_affiliate_user_login' ); } $IXAP289 = isset( $_POST['show_deleted'] ); $affiliates_options->update_option( 'affiliates_show_deleted', $IXAP289 ); $IXAP290 = isset( $_POST['show_inoperative'] ); $affiliates_options->update_option( 'affiliates_show_inoperative', $IXAP290 ); $IXAP228 = isset( $_POST['show_totals'] ); $affiliates_options->update_option( 'affiliates_show_totals', $IXAP228 ); if ( !empty( $_POST['from_date'] ) ) { $IXAP36 = date( 'Y-m-d', strtotime( $_POST['from_date'] ) ); $affiliates_options->update_option( 'affiliates_from_date', $IXAP36 ); } else { $affiliates_options->delete_option( 'affiliates_from_date' ); } if ( !empty( $_POST['thru_date'] ) ) { $IXAP38 = date( 'Y-m-d', strtotime( $_POST['thru_date'] ) ); $affiliates_options->update_option( 'affiliates_thru_date', $IXAP38 ); } else { $affiliates_options->delete_option( 'affiliates_thru_date' ); } if ( $IXAP36 && $IXAP38 ) { if ( strtotime( $IXAP36 ) > strtotime( $IXAP38 ) ) { $IXAP38 = null; $affiliates_options->delete_option( 'affiliates_thru_date' ); } } if ( $IXAP36 ) { $IXAP37 = DateHelper::u2s( $IXAP36 ); } if ( $IXAP38 ) { $IXAP39 = DateHelper::u2s( $IXAP38, 24*3600 ); } if ( !empty( $_POST['affiliate_id'] ) ) { $IXAP24 = affiliates_check_affiliate_id( $_POST['affiliate_id'] ); if ( $IXAP24 ) { $affiliates_options->update_option( 'affiliates_affiliate_id', $IXAP24 ); } } else if ( isset( $_POST['affiliate_id'] ) ) { $IXAP24 = null; $affiliates_options->delete_option( 'affiliates_affiliate_id' ); } } if ( isset( $_POST['row_count'] ) ) { if ( !wp_verify_nonce( $_POST[AFFILIATES_ADMIN_AFFILIATES_NONCE_1], plugin_basename( __FILE__ ) ) ) { wp_die( __( 'Access denied.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } } if ( isset( $_POST['paged'] ) ) { if ( !wp_verify_nonce( $_POST[AFFILIATES_ADMIN_AFFILIATES_NONCE_2], plugin_basename( __FILE__ ) ) ) { wp_die( __( 'Access denied.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } } $IXAP70 = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $IXAP70 = remove_query_arg( 'paged', $IXAP70 ); $IXAP70 = remove_query_arg( 'action', $IXAP70 ); $IXAP70 = remove_query_arg( 'affiliate_id', $IXAP70 ); $IXAP47 = _affiliates_get_tablename( 'affiliates' ); $IXAP48 = _affiliates_get_tablename( 'affiliates_users' ); $IXAP25 = _affiliates_get_tablename( 'affiliates_attributes' ); $IXAP62 .= '<div class="manage-affiliates">' . '<h1>' . __( 'Manage Affiliates', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</h1>'; $IXAP355 = $affiliates_options->get_option( 'show_filters', true ); $IXAP356 = $affiliates_options->get_option( 'show_columns', true ); $IXAP62 .= '<div class="manage">'; $IXAP62 .= "<a title='" . __( 'Click to add a new affiliate', AFFILIATES_PRO_PLUGIN_DOMAIN ) . "' class='button add' href='" . esc_url( $IXAP70 ) . "&action=add'><img class='icon' alt='" . __( 'Add', AFFILIATES_PRO_PLUGIN_DOMAIN) . "' src='". AFFILIATES_PRO_PLUGIN_URL ."images/add.png'/><span class='label'>" . __( 'New Affiliate', AFFILIATES_PRO_PLUGIN_DOMAIN) . "</span></a>"; $IXAP62 .= '<div style="float:right">'; $IXAP62 .= '<div style="display:inline">'; $IXAP62 .= '<form style="display:inline" id="export-affiliates" action="" method="post">'; $IXAP62 .= sprintf( '<input class="button" type="submit" value="%s" />', __( 'Export', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); $IXAP62 .= '<input type="hidden" name="action" value="export" />'; $IXAP62 .= wp_nonce_field( 'export-affiliates', 'export-nonce', true, false ); $IXAP62 .= '</form>'; $IXAP62 .= '</div>'; $IXAP62 .= ' '; $IXAP62 .= sprintf( '<div class="button toggle-button %s" id="filters-toggle">', ( $IXAP355 ? 'on' : 'off' ) ); $IXAP62 .= __( 'Filters', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</div>'; $IXAP62 .= ' '; $IXAP62 .= sprintf( '<div class="button toggle-button %s" id="columns-toggle">', ( $IXAP356 ? 'on' : 'off' ) ); $IXAP62 .= __( 'Columns', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</div>'; $IXAP62 .= '</div>'; $IXAP62 .= '</div>'; $IXAP187 = isset( $_POST['row_count'] ) ? intval( $_POST['row_count'] ) : 0; if ($IXAP187 <= 0) { $IXAP187 = $affiliates_options->get_option( 'affiliates_per_page', AFFILIATES_AFFILIATES_PER_PAGE ); } else { $affiliates_options->update_option('affiliates_per_page', $IXAP187 ); } $IXAP189 = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0; if ( $IXAP189 < 0 ) { $IXAP189 = 0; } $IXAP190 = isset( $_REQUEST['paged'] ) ? intval( $_REQUEST['paged'] ) : 0; if ( $IXAP190 < 0 ) { $IXAP190 = 0; } $IXAP45 = isset( $_GET['orderby'] ) ? $_GET['orderby'] : null; switch ( $IXAP45 ) { case 'from_date' : case 'thru_date' : case 'email' : case 'affiliate_id' : case 'name' : case 'user_login' : break; default: $IXAP45 = 'name'; } $IXAP46 = isset( $_GET['order'] ) ? $_GET['order'] : null; switch ( $IXAP46 ) { case 'asc' : case 'ASC' : $IXAP191 = 'DESC'; break; case 'desc' : case 'DESC' : $IXAP191 = 'ASC'; break; default: $IXAP46 = 'ASC'; $IXAP191 = 'DESC'; } $IXAP51 = array( " 1=%d " ); $IXAP52 = array( 1 ); if ( $IXAP24 ) { $IXAP51[] = " $IXAP47.affiliate_id = %d "; $IXAP52[] = $IXAP24; } if ( $IXAP43 ) { $IXAP51[] = " $IXAP47.name LIKE '%%%s%%' "; $IXAP52[] = $IXAP43; } if ( $IXAP354 ) { $IXAP51[] = " $IXAP47.email LIKE '%%%s%%' "; $IXAP52[] = $IXAP354; } if ( $IXAP44 ) { $IXAP51[] = " $wpdb->users.user_login LIKE '%%%s%%' "; $IXAP52[] = $IXAP44; } if ( !$IXAP289 ) { $IXAP51[] = " $IXAP47.status = %s "; $IXAP52[] = 'active'; } if ( !$IXAP290 ) { $IXAP51[] = " $IXAP47.from_date <= %s AND ( $IXAP47.thru_date IS NULL OR $IXAP47.thru_date >= %s ) "; $IXAP52[] = $IXAP101; $IXAP52[] = $IXAP101; } if ( $IXAP37 && $IXAP39 ) { $IXAP51[] = " $IXAP47.from_date >= %s AND ( $IXAP47.thru_date IS NULL OR $IXAP47.thru_date < %s ) "; $IXAP52[] = $IXAP37; $IXAP52[] = $IXAP39; } else if ( $IXAP37 ) { $IXAP51[] = " $IXAP47.from_date >= %s "; $IXAP52[] = $IXAP37; } else if ( $IXAP39 ) { $IXAP51[] = " $IXAP47.thru_date < %s "; $IXAP52[] = $IXAP39; } if ( !empty( $IXAP51 ) ) { $IXAP51 = " WHERE " . implode( " AND ", $IXAP51 ); } else { $IXAP51 = ''; } $IXAP197 = $wpdb->prepare( "SELECT COUNT(*) FROM $IXAP47 LEFT JOIN $IXAP48 ON $IXAP47.affiliate_id = $IXAP48.affiliate_id LEFT JOIN $wpdb->users on $IXAP48.user_id = $wpdb->users.ID $IXAP51", $IXAP52 ); $IXAP198 = $wpdb->get_var( $IXAP197 ); if ( $IXAP198 > $IXAP187 ) { $IXAP199 = true; } else { $IXAP199 = false; } $IXAP19 = ceil ( $IXAP198 / $IXAP187 ); if ( $IXAP190 > $IXAP19 ) { $IXAP190 = $IXAP19; } if ( $IXAP190 != 0 ) { $IXAP189 = ( $IXAP190 - 1 ) * $IXAP187; } $IXAP98 = $wpdb->prepare( "SELECT $IXAP47.*, $wpdb->users.* " . "FROM $IXAP47 " . "LEFT JOIN $IXAP48 ON $IXAP47.affiliate_id = $IXAP48.affiliate_id " . "LEFT JOIN $wpdb->users on $IXAP48.user_id = $wpdb->users.ID " . "$IXAP51 " . "ORDER BY $IXAP45 $IXAP46 " . "LIMIT $IXAP187 OFFSET $IXAP189", $IXAP52 ); $IXAP55 = $wpdb->get_results( $IXAP98, OBJECT ); $IXAP76 = array( 'affiliate_id' => __( 'Id', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'name' => __( 'Affiliate', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'email' => __( 'Email', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'user_login' => __( 'Username', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'from_date' => __( 'From', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'thru_date' => __( 'Until', AFFILIATES_PRO_PLUGIN_DOMAIN ), 'links' => __( 'Links', AFFILIATES_PRO_PLUGIN_DOMAIN ), ); $IXAP76 = $IXAP76 + Affiliates_Attributes::get_keys(); require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings.php'; require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-registration.php'; $IXAP357 = Affiliates_Settings_Registration::get_fields(); foreach( Affiliates_Registration::get_skip_meta_fields() as $IXAP78 ) { unset( $IXAP357[$IXAP78] ); } if ( !empty( $IXAP357 ) ) { foreach( $IXAP357 as $name => $IXAP212 ) { if ( $IXAP212['enabled'] ) { $IXAP76[$name] = stripslashes( $IXAP212['label'] ); } } } $IXAP358 = array(); foreach( array_keys( $IXAP76 ) as $IXAP78 ) { $IXAP78 = preg_replace( '/(\.|\-)/', '_', $IXAP78 ); switch( $IXAP78 ) { case 'name' : case 'email' : case 'user_login' : $IXAP358[$IXAP78] = true; break; default : $IXAP358[$IXAP78] = false; } } $IXAP359 = $IXAP358; foreach( $affiliates_options->get_option( 'affiliates_overview_columns', array() ) as $IXAP78 => $IXAP87 ) { $IXAP359[$IXAP78] = $IXAP87; } $IXAP360 = 0; $IXAP62 .= '<script type="text/javascript">'; $IXAP62 .= 'affiliates_overview_columns={'; $IXAP361 = array(); foreach( $IXAP359 as $IXAP78 => $IXAP87 ) { $IXAP361[] = wp_strip_all_tags( $IXAP78 ).':' . ( $IXAP87 ? 'true' : 'false' ); if ( $IXAP87 ) { $IXAP360++; } } $IXAP62 .= implode( ',', $IXAP361 ); $IXAP62 .= '};'; $IXAP62 .= '</script>'; $IXAP62 .= '<div class="affiliates-overview">'; $IXAP62 .= sprintf( '<div id="filters-container" class="filters" style="%s">', $IXAP355 ? '' : 'display:none' ); $IXAP62 .= '<label class="description" for="setfilters">' . __( 'Filters', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>'; $IXAP62 .= '<div>'; $IXAP62 .= '<form id="setfilters" action="" method="post">'; $IXAP62 .= '<div class="filter-section">' . '<label class="affiliate-id-filter">' . __( 'Id', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="affiliate-id-filter" name="affiliate_id" type="text" value="' . esc_attr( $IXAP24 ) . '"/>' . '</label>' . ' ' . '<label class="affiliate-name-filter">' . __( 'Name', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="affiliate-name-filter" name="affiliate_name" type="text" value="' . $IXAP43 . '"/>' . '</label>' . ' ' . '<label class="affiliate-email-filter">' . __( 'Email', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="affiliate-email-filter" name="affiliate_email" type="text" value="' . $IXAP354 . '"/>' . '</label>' . ' ' . '<label class="affiliate-user-login-filter">' . __( 'Username', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="affiliate-user-login-filter" name="affiliate_user_login" type="text" value="' . $IXAP44 . '" />' . '</label>' . '</div>' . '<div class="filter-section">' . '<label class="from-date-filter">' . __( 'From', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="datefield from-date-filter" name="from_date" type="text" value="' . esc_attr( $IXAP36 ) . '"/>'. '</label>' . ' ' . '<label class="thru-date-filter">' . __( 'Until', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ' ' . '<input class="datefield thru-date-filter" name="thru_date" type="text" class="datefield" value="' . esc_attr( $IXAP38 ) . '"/>'. '</label>' . ' ' . '<label class="show-inoperative-filter">' . '<input class="show-inoperative-filter" name="show_inoperative" type="checkbox" ' . ( $IXAP290 ? 'checked="checked"' : '' ) . '/>' . ' ' . __( 'Include inoperative affiliates', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . ' ' . '<label class="show-deleted-filter">' . '<input class="show-deleted-filter" name="show_deleted" type="checkbox" ' . ( $IXAP289 ? 'checked="checked"' : '' ) . '/>' . ' ' . __( 'Include removed affiliates', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . ' ' . '<label class="show-totals-filter">' . '<input class="show-totals-filter" name="show_totals" type="checkbox" ' . ( $IXAP228 ? 'checked="checked"' : '' ) . '/>' . ' ' . __( 'Show accumulated referral totals', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '</div>'; $IXAP62 .= '<div class="filter-buttons">' . wp_nonce_field( plugin_basename( __FILE__ ), AFFILIATES_ADMIN_AFFILIATES_FILTER_NONCE, true, false ) . '<input class="button" type="submit" value="' . __( 'Apply', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '"/>' . '<input class="button" type="submit" name="clear_filters" value="' . __( 'Clear', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '"/>' . '<input type="hidden" value="submitted" name="submitted"/>' . '</div>'; $IXAP62 .= '</form>'; $IXAP62 .= '</div>'; $IXAP62 .= '</div>'; $IXAP62 .= sprintf( '<div id="columns-container" class="filters" style="%s">', $IXAP356 ? '' : 'display:none' ); $IXAP62 .= '<div>'; $IXAP62 .= __( 'Columns', AFFILIATES_PRO_PLUGIN_DOMAIN ); $IXAP62 .= '</div>'; $IXAP62 .= '<div id="column-toggles" class="column-toggles">'; foreach( $IXAP76 as $IXAP78 => $IXAP133 ) { $IXAP362 = preg_replace( '/(\.|\-)/', '_', $IXAP78 ); $IXAP62 .= '<div class="column-toggle-container">'; $IXAP62 .= '<label>'; $IXAP62 .= sprintf( '<input class="column-toggle" type="checkbox" name="column-toggle-%s" id="column-toggle-%s" value="%s" %s />', esc_attr( $IXAP362 ), esc_attr( $IXAP362 ), esc_attr( $IXAP362 ), isset( $IXAP359[$IXAP362] ) && $IXAP359[$IXAP362] ? ' checked="checked" ' : '' ); $IXAP62 .= $IXAP133; $IXAP62 .= '</label>'; $IXAP62 .= '</div>'; } $IXAP62 .= '</div>'; $IXAP62 .= '</div>'; $IXAP62 .= '
			<div class="page-options">
				<form id="setrowcount" action="" method="post">
					<div>
						<label for="row_count">' . __( 'Results per page', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '<input name="row_count" type="text" size="2" value="' . esc_attr( $IXAP187 ) .'" />
						' . wp_nonce_field( plugin_basename( __FILE__ ), AFFILIATES_ADMIN_AFFILIATES_NONCE_1, true, false ) . '
						<input class="button" type="submit" value="' . __( 'Apply', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '"/>
					</div>
				</form>
			</div>
			'; if ( $IXAP199 ) { $IXAP200 = new Affiliates_Pagination($IXAP198, null, $IXAP187); $IXAP62 .= '<form id="posts-filter" method="post" action="">'; $IXAP62 .= '<div>'; $IXAP62 .= wp_nonce_field( plugin_basename( __FILE__ ), AFFILIATES_ADMIN_AFFILIATES_NONCE_2, true, false ); $IXAP62 .= '</div>'; $IXAP62 .= '<div class="tablenav top">'; $IXAP62 .= $IXAP200->pagination( 'top' ); $IXAP62 .= '</div>'; $IXAP62 .= '</form>'; } $IXAP62 .= '<table id="affiliates-overview-table" class="wp-list-table widefat fixed" cellspacing="0">'; $IXAP62 .= '<thead>'; $IXAP62 .= '<tr>'; foreach ( $IXAP76 as $IXAP78 => $IXAP79 ) { $IXAP78 = preg_replace( '/(\.|\-)/', '_', $IXAP78 ); $IXAP105 = array( 'orderby' => $IXAP78, 'order' => $IXAP191 ); $IXAP143 = $IXAP78; if ( in_array( $IXAP78, array( 'affiliate_id', 'name', 'email', 'user_login', 'from_date', 'thru_date' ) ) ) { if ( strcmp( $IXAP78, $IXAP45 ) == 0 ) { $IXAP209 = strtolower( $IXAP46 ); $IXAP143 = "$IXAP78 manage-column sorted $IXAP209"; } else { $IXAP143 = "$IXAP78 manage-column sortable"; } $IXAP79 = '<a href="' . esc_url( add_query_arg( $IXAP105, $IXAP70 ) ) . '"><span>' . $IXAP79 . '</span><span class="sorting-indicator"></span></a>'; } $IXAP62 .= sprintf( '<th scope="col" class="%s" style="%s">%s</th>', esc_attr( $IXAP143 ), isset( $IXAP359[$IXAP78] ) && $IXAP359[$IXAP78] ? '' : 'display:none', $IXAP79 ); } $IXAP62 .= '</tr>'; $IXAP62 .= '</thead>'; $IXAP62 .= '<tbody>'; if ( count( $IXAP55 ) > 0 ) { for ( $IXAP80 = 0; $IXAP80 < count( $IXAP55 ); $IXAP80++ ) { $IXAP15 = $IXAP55[$IXAP80]; $name_suffix = ''; $IXAP296 = ''; if ( $IXAP297 = ( strcmp( $IXAP15->status, 'deleted' ) == 0 ) ) { $IXAP296 = ' deleted '; $name_suffix .= " " . __( '(removed)', AFFILIATES_PRO_PLUGIN_DOMAIN ); } $IXAP298 = ''; if ( $IXAP299 = ! ( ( $IXAP15->from_date <= $IXAP101 ) && ( $IXAP15->thru_date == null || $IXAP15->thru_date >= $IXAP101 ) ) ) { $IXAP298 = ' inoperative '; $name_suffix .= " " . __( '(inoperative)', AFFILIATES_PRO_PLUGIN_DOMAIN ); } $IXAP62 .= '<tr class="' . $IXAP296 . $IXAP298 . ( $IXAP80 % 2 == 0 ? 'even' : 'odd' ) . '">'; $IXAP62 .= sprintf( '<td class="affiliate_id" style="%s">', isset( $IXAP359['affiliate_id'] ) && $IXAP359['affiliate_id'] ? '' : 'display:none' ); if ( affiliates_encode_affiliate_id( $IXAP15->affiliate_id ) != $IXAP15->affiliate_id ) { $IXAP62 .= '<span class="encoded-hint" title="' . affiliates_encode_affiliate_id( $IXAP15->affiliate_id ) . '">' . $IXAP15->affiliate_id . '</span>'; } else { $IXAP62 .= $IXAP15->affiliate_id; } $IXAP62 .= '</td>'; $IXAP363 = remove_query_arg( array( 'paged', 'action', 'affiliate_id' ), $IXAP70 ); $IXAP363 = add_query_arg( array( 'paged' => $IXAP190, 'action' => 'edit', 'affiliate_id' => $IXAP15->affiliate_id ), $IXAP70 ); $IXAP62 .= sprintf( '<td class="name affiliate-name" style="%s">', isset( $IXAP359['name'] ) && $IXAP359['name'] ? '' : 'display:none' ); $IXAP62 .= '<div>'; $IXAP62 .= sprintf( '<a href="%s">%s</a>', esc_url( $IXAP363 ), stripslashes( wp_filter_nohtml_kses( $IXAP15->name ) ) . $name_suffix ); $IXAP62 .= '</div>'; $IXAP62 .= '<div>'; $IXAP62 .= sprintf( '<a class="edit" href="%s">%s</a>', esc_url( $IXAP363 ), __( 'Edit', AFFILIATES_PRO_PLUGIN_DOMAIN ), __( 'Edit', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); if ( !$IXAP297 && ( !isset( $IXAP15->type ) || ( $IXAP15->type != AFFILIATES_DIRECT_TYPE ) ) ) { $IXAP364 = remove_query_arg( array( 'paged', 'action', 'affiliate_id' ), $IXAP70 ); $IXAP364 = add_query_arg( array( 'paged' => $IXAP190, 'action' => 'remove', 'affiliate_id' => $IXAP15->affiliate_id ), $IXAP70 ); $IXAP62 .= ' '; $IXAP62 .= sprintf( '<a class="remove" href="%s">%s</a>', esc_url( $IXAP364 ), __( 'Remove', AFFILIATES_PRO_PLUGIN_DOMAIN ), __( 'Remove', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } $IXAP62 .= '</div>'; $IXAP62 .= '</td>'; $IXAP62 .= sprintf( '<td class="email affiliate-email" style="%s">', isset( $IXAP359['email'] ) && $IXAP359['email'] ? '' : 'display:none' ); $IXAP62 .= $IXAP15->email; if ( isset( $IXAP15->email ) && isset( $IXAP15->user_email ) && strcmp( $IXAP15->email, $IXAP15->user_email ) !== 0 ) { $IXAP62 .= '<span title="' . sprintf( __( 'There are different email addresses on record for the affiliate and the associated user. This might be ok, but if in doubt please check. The email address on file for the user is %s', AFFILIATES_PRO_PLUGIN_DOMAIN ), $IXAP15->user_email ) . '" class="warning"> [&nbsp;!&nbsp]</span>'; } $IXAP62 .= '</td>'; $IXAP62 .= sprintf( '<td class="user_login affiliate-user-login" style="%s">', isset( $IXAP359['user_login'] ) && $IXAP359['user_login'] ? '' : 'display:none' ); if ( !empty( $IXAP15->ID ) ) { if ( current_user_can( 'edit_user', $IXAP15->ID ) ) { $IXAP62 .= '<a target="_blank" href="' . esc_url( "user-edit.php?user_id=$IXAP15->ID" ) . '">' . $IXAP15->user_login . '</a>'; } else { $IXAP62 .= $IXAP15->user_login; } } $IXAP62 .= '</td>'; $IXAP62 .= sprintf( '<td class="from_date from-date" style="%s">', isset( $IXAP359['from_date'] ) && $IXAP359['from_date'] ? '' : 'display:none' ); $IXAP62 .= $IXAP15->from_date; $IXAP62 .= '</td>'; $IXAP62 .= sprintf( '<td class="thru_date thru-date" style="%s">', isset( $IXAP359['thru_date'] ) && $IXAP359['thru_date'] ? '' : 'display:none' ); $IXAP62 .= $IXAP15->thru_date; $IXAP62 .= '</td>'; $IXAP62 .= sprintf( '<td class="links" style="%s">', isset( $IXAP359['links'] ) && $IXAP359['links'] ? '' : 'display:none' ); $IXAP152 = affiliates_encode_affiliate_id( $IXAP15->affiliate_id ); $IXAP62 .= __( 'Link', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ': ' . '<span class="affiliate-link">' . Affiliates_Url_Renderer::get_affiliate_url( get_bloginfo( 'url' ), $IXAP15->affiliate_id ) . '</span>' . '<br/>' . __( 'URL Parameter', AFFILIATES_PRO_PLUGIN_DOMAIN ) . ': ' . '<span class="affiliate-link-param">' . '?' . $IXAP147 . '=' . $IXAP152 . '</span>'; $IXAP62 .= '</td>'; foreach( Affiliates_Attributes::get_keys() as $IXAP365 => $IXAP366 ) { $IXAP367 = $IXAP365; $IXAP365 = preg_replace( '/(\.|\-)/', '_', $IXAP365 ); $IXAP145 = isset( $IXAP359[$IXAP365] ) && $IXAP359[$IXAP365] ? '' : 'display:none'; $IXAP368 = $affiliates_db->get_value( "SELECT attr_value FROM $IXAP25 WHERE affiliate_id = %d AND attr_key = %s", $IXAP15->affiliate_id, $IXAP367 ); $IXAP62 .= sprintf( '<td class="%s" style="%s">', $IXAP365, $IXAP145 ); $IXAP62 .= wp_filter_nohtml_kses( $IXAP368 ); $IXAP62 .= '</td>'; } foreach( $IXAP357 as $name => $IXAP212 ) { if ( $IXAP212['enabled'] ) { $IXAP252 = isset( $IXAP212['type'] ) ? $IXAP212['type'] : 'text'; $IXAP87 = ''; switch( $name ) { case 'user_login' : $IXAP87 = $IXAP95->user_login; break; case 'user_email' : $IXAP87 = $IXAP95->user_email; break; case 'user_url' : $IXAP87 = $IXAP95->user_url; break; case 'password' : $IXAP87 = ''; break; default : $IXAP87 = get_user_meta( $IXAP15->ID, $name , true ); } $IXAP145 = isset( $IXAP359[$name] ) && $IXAP359[$name] ? '' : 'display:none'; $IXAP62 .= sprintf( '<td class="%s" style="%s">', $name, $IXAP145 ); $IXAP62 .= stripslashes( wp_filter_nohtml_kses( $IXAP87 ) ); $IXAP62 .= '</td>'; } } $IXAP62 .= '</tr>'; if ( $IXAP228 ) { $IXAP62 .= '<tr class="' . $IXAP296 . $IXAP298 . ( $IXAP80 % 2 == 0 ? 'even' : 'odd' ) . '">'; $IXAP248 = array(); $IXAP248[AFFILIATES_REFERRAL_STATUS_CLOSED] = Affiliates_Shortcodes::get_total( $IXAP15->affiliate_id, null, null, AFFILIATES_REFERRAL_STATUS_CLOSED ); $IXAP248[AFFILIATES_REFERRAL_STATUS_ACCEPTED] = Affiliates_Shortcodes::get_total( $IXAP15->affiliate_id, null, null, AFFILIATES_REFERRAL_STATUS_ACCEPTED ); $IXAP248[AFFILIATES_REFERRAL_STATUS_PENDING] = Affiliates_Shortcodes::get_total( $IXAP15->affiliate_id, null, null, AFFILIATES_REFERRAL_STATUS_PENDING ); $IXAP248[AFFILIATES_REFERRAL_STATUS_REJECTED] = Affiliates_Shortcodes::get_total( $IXAP15->affiliate_id, null, null, AFFILIATES_REFERRAL_STATUS_REJECTED ); $IXAP62 .= '<td class="dynamic-colspan" colspan="' . $IXAP360 . '">'; $IXAP62 .= '<table class="affiliate-referral-totals">'; $IXAP62 .= '<thead>'; $IXAP62 .= '<tr>'; foreach( $IXAP248 as $IXAP250 => $IXAP238 ) { if ( $IXAP238 ) { $IXAP62 .= '<th>'; $IXAP62 .= '<strong>'; switch( $IXAP250 ) { case AFFILIATES_REFERRAL_STATUS_CLOSED : $IXAP62 .= sprintf( __( '<span style="cursor:help" title="%s">Closed</span>', AFFILIATES_PRO_PLUGIN_DOMAIN ), esc_attr( __( 'Accumulated total for closed referrals (commissions paid).', AFFILIATES_PRO_PLUGIN_DOMAIN ) ) ); break; case AFFILIATES_REFERRAL_STATUS_ACCEPTED : $IXAP62 .= sprintf( __( '<span style="cursor:help" title="%s">Accepted</span>', AFFILIATES_PRO_PLUGIN_DOMAIN ), esc_attr( __( 'Accumulated total for accepted referrals (commissions unpaid).', AFFILIATES_PRO_PLUGIN_DOMAIN ) ) ); break; case AFFILIATES_REFERRAL_STATUS_PENDING : $IXAP62 .= sprintf( __( '<span style="cursor:help" title="%s">Pending</span>', AFFILIATES_PRO_PLUGIN_DOMAIN ), esc_attr( __( 'Accumulated total for pending referrals.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ) ); break; case AFFILIATES_REFERRAL_STATUS_REJECTED : $IXAP62 .= sprintf( __( '<span style="cursor:help" title="%s">Rejected</span>', AFFILIATES_PRO_PLUGIN_DOMAIN ), esc_attr( __( 'Accumulated total for rejected referrals.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ) ); break; } $IXAP62 .= '</strong>'; $IXAP62 .= '</th>'; } } $IXAP62 .= '</thead>'; $IXAP62 .= '</tr>'; $IXAP62 .= '<tbody>'; $IXAP62 .= '<tr>'; foreach( $IXAP248 as $IXAP250 => $IXAP238 ) { if ( $IXAP238 ) { $IXAP62 .= '<td>'; $IXAP62 .= '<ul>'; foreach( $IXAP238 as $IXAP295 => $IXAP28 ) { $IXAP62 .= '<li>'; $IXAP62 .= sprintf( __( '%1$s %2$s', AFFILIATES_PRO_PLUGIN_DOMAIN ), $IXAP295, $IXAP28 ); $IXAP62 .= '</li>'; } $IXAP62 .= '</ul>'; $IXAP62 .= '</td>'; } } $IXAP62 .= '</tr>'; $IXAP62 .= '<tbody>'; $IXAP62 .= '</table>'; $IXAP62 .= '</td>'; $IXAP62 .= '</tr>'; } } } else { $IXAP62 .= '<tr><td class="dynamic-colspan" colspan="' . $IXAP360 . '">' . __('There are no results.', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</td></tr>'; } $IXAP62 .= '</tbody>'; $IXAP62 .= '</table>'; if ( $IXAP199 ) { $IXAP200 = new Affiliates_Pagination( $IXAP198, null, $IXAP187 ); $IXAP62 .= '<div class="tablenav bottom">'; $IXAP62 .= $IXAP200->pagination( 'bottom' ); $IXAP62 .= '</div>'; } $IXAP62 .= '</div>'; $IXAP62 .= '</div>'; echo $IXAP62; affiliates_footer(); } }