diff --git a/classes/class-connectors.php b/classes/class-connectors.php index 5af5469c1..aca75bb4d 100644 --- a/classes/class-connectors.php +++ b/classes/class-connectors.php @@ -115,7 +115,7 @@ public function load_connectors() { } // Initialize connector. - $class = new $class_name(); + $class = new $class_name(); $classes[ $class->name ] = $class; } diff --git a/classes/class-export.php b/classes/class-export.php index 2411c4ac2..d1bf2bc2a 100644 --- a/classes/class-export.php +++ b/classes/class-export.php @@ -162,7 +162,14 @@ public function build_record( $item, $columns ) { * @return int */ public function disable_paginate() { - return 10000; + + /** + * Filter to change how many records are exported. + * Increasing this too much could cause your export to time out. + * + * @return int The number of records to export. + */ + return apply_filters( 'wp_stream_export_limit', 10000 ); } /** diff --git a/tests/phpunit/test-class-export.php b/tests/phpunit/test-class-export.php index 939641415..ddaab4045 100644 --- a/tests/phpunit/test-class-export.php +++ b/tests/phpunit/test-class-export.php @@ -88,6 +88,23 @@ public function test_disable_paginate() { $this->assertEquals( $limit, 10000 ); } + /** + * Test pagination limit filter + */ + public function test_export_limit_filter() { + add_filter( + 'wp_stream_export_limit', + static function () { + return 5; + } + ); + + $filtered_limit = $this->export->disable_paginate(); + $this->assertEquals( $filtered_limit, 5 ); + + remove_all_filters( 'wp_stream_export_limit' ); + } + /** * Test for present columns returning */