Code Duplication    Length = 29-29 lines in 2 locations

includes/admin/tools/export/class-batch-export.php 1 location

@@ 195-223 (lines=29) @@
192
	 * @since  1.5
193
	 * @return string|false
194
	 */
195
	public function print_csv_rows() {
196
197
		$row_data = '';
198
		$data     = $this->get_data();
199
		$cols     = $this->get_csv_cols();
200
201
		if ( $data ) {
202
203
			// Output each row
204
			foreach ( $data as $row ) {
205
				$i = 1;
206
				foreach ( $row as $col_id => $column ) {
207
					// Make sure the column is valid
208
					if ( array_key_exists( $col_id, $cols ) ) {
209
						$row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"';
210
						$row_data .= $i == count( $cols ) ? '' : ',';
211
						$i ++;
212
					}
213
				}
214
				$row_data .= "\r\n";
215
			}
216
217
			$this->stash_step_data( $row_data );
218
219
			return $row_data;
220
		}
221
222
		return false;
223
	}
224
225
	/**
226
	 * Return the calculated completion percentage.

includes/admin/tools/export/give-export-donations-exporter.php 1 location

@@ 633-661 (lines=29) @@
630
	 *
631
	 * @return string|false
632
	 */
633
	public function print_csv_rows() {
634
635
		$row_data = '';
636
		$data     = $this->get_data();
637
		$cols     = $this->get_csv_cols();
638
639
		if ( $data ) {
640
641
			// Output each row
642
			foreach ( $data as $row ) {
643
				$i = 1;
644
				foreach ( $row as $col_id => $column ) {
645
					// Make sure the column is valid
646
					if ( array_key_exists( $col_id, $cols ) ) {
647
						$row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"';
648
						$row_data .= $i == count( $cols ) ? '' : ',';
649
						$i ++;
650
					}
651
				}
652
				$row_data .= "\r\n";
653
			}
654
655
			$this->stash_step_data( $row_data );
656
657
			return $row_data;
658
		}
659
660
		return false;
661
	}
662
}
663