Completed
Branch EDTR/master (da238f)
by
unknown
09:58 queued 01:23
created

WordPressPageEditorEdit::isMatchingRoute()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
nc 5
nop 0
dl 13
loc 13
rs 9.5222
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\specifications\admin;
4
5
use EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecification;
6
use WP_Post;
7
8
/**
9
 * Class WordPressPageEditorEdit
10
 * Returns true when the current request is for the WordPress Page Editor admin page while editing an existing page
11
 *
12
 * @package EventEspresso\core\domain\entities\routing\specifications\admin
13
 * @author  Brent Christensen
14
 * @since   4.9.71.p
15
 */
16 View Code Duplication
class WordPressPageEditorEdit extends RouteMatchSpecification
17
{
18
    /**
19
     * returns true if current request matches specification
20
     *
21
     * @since 4.9.71.p
22
     * @return boolean
23
     */
24
    public function isMatchingRoute()
25
    {
26
        global $post;
27
        return strpos($this->request->requestUri(), 'wp-admin/post.php') !== false
28
            && (
29
                $this->request->getRequestParam('post_type', 'post') === 'page'
30
                || (
31
                    $post instanceof WP_Post
0 ignored issues
show
Bug introduced by
The class WP_Post does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
32
                    && $post->post_type === 'page'
33
                )
34
            )
35
            && $this->request->getRequestParam('action') === 'edit';
36
    }
37
}
38