Skip to content

Commit a99f682

Browse files
committed
Avoid running test editor code at respondents results page
* Correctly determine test editor * Introduce wp_testing_editor_tests_screen and use it in feedbacker
1 parent ea6a05d commit a99f682

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Doer/Feedbacker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818
->addFilter('plugin_row_meta', array($this, 'onPluginMeta'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2)
1919
->addAction('admin_menu', array($this, 'addPages'))
2020
->addAction('wp_ajax_wpt_rateus', array($this, 'ajaxRateUs'))
21-
->addAction('wp_testing_editor_customize_ui_after', array($this, 'customizeEditor'))
21+
->addAction('wp_testing_editor_tests_screen', array($this, 'customizeEditor'))
2222
->addAction('add_meta_boxes_wpt_test', array($this, 'customizeEditorMetaboxes'))
2323
;
2424
}

src/Doer/TestEditor.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class WpTesting_Doer_TestEditor extends WpTesting_Doer_AbstractEditor
1515
*/
1616
public function customizeUi($screen)
1717
{
18-
if (!$this->isTestScreen($screen)) {
18+
$isTestEditor = $this->isTestScreen($screen, 'id');
19+
if ($isTestEditor || $this->isTestScreen($screen, 'post_type')) {
20+
$this->wp->doAction('wp_testing_editor_tests_screen');
21+
}
22+
if (!$isTestEditor) {
1923
return $this;
2024
}
2125
$test = $this->createTest($this->getRequestValue('post'));
@@ -420,15 +424,17 @@ private function emulateRedirectMessage(WpTesting_Model_Test $test)
420424
* Do we currently at tests?
421425
*
422426
* @param WP_Screen $screen
427+
* @param string $attribute When comparing by post_type -- we are at any tests screen, by id -- we are at editor
428+
*
423429
* @return boolean
424430
*/
425-
private function isTestScreen($screen)
431+
private function isTestScreen($screen, $attribute)
426432
{
427433
$id = $this->getRequestValue('post');
428434
if (is_array($id)) {
429435
return false;
430436
}
431-
if (!empty($screen->post_type) && $screen->post_type == 'wpt_test') {
437+
if (!empty($screen->$attribute) && $screen->$attribute == 'wpt_test') {
432438
return true;
433439
}
434440
if ($this->isWordPressAlready('3.3')) {

0 commit comments

Comments
 (0)