C:\xampp\htdocs\landing\wp-content\plugins\duplicate-post\src\ui\class-row-actions.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
 * Duplicate Post class to manage the row actions.
 *
 * @package Duplicate_Post
 */

namespace Yoast\WP\Duplicate_Post\UI;

use 
WP_Post;
use 
Yoast\WP\Duplicate_Post\Permissions_Helper;
use 
Yoast\WP\Duplicate_Post\Utils;

/**
 * Represents the Row_Action class.
 */
class Row_Actions {

    
/**
     * Holds the object to create the action link to duplicate.
     *
     * @var Link_Builder
     */
    
protected $link_builder;

    
/**
     * Holds the permissions helper.
     *
     * @var Permissions_Helper
     */
    
protected $permissions_helper;

    
/**
     * Initializes the class.
     *
     * @param Link_Builder       $link_builder       The link builder.
     * @param Permissions_Helper $permissions_helper The permissions helper.
     */
    
public function __constructLink_Builder $link_builderPermissions_Helper $permissions_helper ) {
        
$this->link_builder       $link_builder;
        
$this->permissions_helper $permissions_helper;
    }

    
/**
     * Adds hooks to integrate with WordPress.
     *
     * @return void
     */
    
public function register_hooks() {
        if ( \
intvalUtils::get_option'duplicate_post_show_link_in''row' ) ) === ) {
            return;
        }

        if ( \
intvalUtils::get_option'duplicate_post_show_link''clone' ) ) === ) {
            \
add_filter'post_row_actions', [ $this'add_clone_action_link' ], 10);
            \
add_filter'page_row_actions', [ $this'add_clone_action_link' ], 10);
        }

        if ( \
intvalUtils::get_option'duplicate_post_show_link''new_draft' ) ) === ) {
            \
add_filter'post_row_actions', [ $this'add_new_draft_action_link' ], 10);
            \
add_filter'page_row_actions', [ $this'add_new_draft_action_link' ], 10);
        }

        if ( \
intvalUtils::get_option'duplicate_post_show_link''rewrite_republish' ) ) === ) {
            \
add_filter'post_row_actions', [ $this'add_rewrite_and_republish_action_link' ], 10);
            \
add_filter'page_row_actions', [ $this'add_rewrite_and_republish_action_link' ], 10);
        }
    }

    
/**
     * Hooks in the `post_row_actions` and `page_row_actions` filters to add a 'Clone' link.
     *
     * @param array    $actions The array of actions from the filter.
     * @param \WP_Post $post    The post object.
     *
     * @return array The updated array of actions.
     */
    
public function add_clone_action_link$actions$post ) {
        if ( ! 
$post instanceof WP_Post
            
|| ! $this->permissions_helper->should_links_be_displayed$post )
            || ! \
is_array$actions ) ) {
            return 
$actions;
        }

        
$title = \_draft_or_post_title$post );

        
$actions['clone'] = '<a href="' $this->link_builder->build_clone_link$post->ID ) .
            
'" aria-label="' . \esc_attr(
            
/* translators: %s: Post title. */
                
\sprintf( \__'Clone &#8220;%s&#8221;''duplicate-post' ), $title )
            ) . 
'">' .
            \
esc_html_x'Clone''verb''duplicate-post' ) . '</a>';

        return 
$actions;
    }

    
/**
     * Hooks in the `post_row_actions` and `page_row_actions` filters to add a 'New Draft' link.
     *
     * @param array    $actions The array of actions from the filter.
     * @param \WP_Post $post    The post object.
     *
     * @return array The updated array of actions.
     */
    
public function add_new_draft_action_link$actions$post ) {
        if ( ! 
$post instanceof WP_Post
            
|| ! $this->permissions_helper->should_links_be_displayed$post )
            || ! \
is_array$actions ) ) {
            return 
$actions;
        }

        
$title = \_draft_or_post_title$post );

        
$actions['edit_as_new_draft'] = '<a href="' $this->link_builder->build_new_draft_link$post->ID ) .
            
'" aria-label="' . \esc_attr(
            
/* translators: %s: Post title. */
                
\sprintf( \__'New draft of &#8220;%s&#8221;''duplicate-post' ), $title )
            ) . 
'">' .
            \
esc_html__'New Draft''duplicate-post' ) .
            
'</a>';

        return 
$actions;
    }

    
/**
     * Hooks in the `post_row_actions` and `page_row_actions` filters to add a 'Rewrite & Republish' link.
     *
     * @param array    $actions The array of actions from the filter.
     * @param \WP_Post $post    The post object.
     *
     * @return array The updated array of actions.
     */
    
public function add_rewrite_and_republish_action_link$actions$post ) {
        if (
            ! 
$post instanceof WP_Post
            
|| ! $this->permissions_helper->should_rewrite_and_republish_be_allowed$post )
            || ! 
$this->permissions_helper->should_links_be_displayed$post )
            || ! \
is_array$actions )
        ) {
            return 
$actions;
        }

        
$title = \_draft_or_post_title$post );

        
$actions['rewrite'] = '<a href="' $this->link_builder->build_rewrite_and_republish_link$post->ID ) .
            
'" aria-label="' . \esc_attr(
            
/* translators: %s: Post title. */
                
\sprintf( \__'Rewrite & Republish &#8220;%s&#8221;''duplicate-post' ), $title )
            ) . 
'">' .
            \
esc_html_x'Rewrite & Republish''verb''duplicate-post' ) . '</a>';

        return 
$actions;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586