C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\duplicate-post\src\ui\class-column.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/**
 * Duplicate Post class to manage the custom column + quick edit.
 *
 * @package Duplicate_Post
 */

namespace Yoast\WP\Duplicate_Post\UI;

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

/**
 * Represents the Column class.
 */
class Column {

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

    
/**
     * Holds the asset manager.
     *
     * @var Asset_Manager
     */
    
protected $asset_manager;

    
/**
     * Initializes the class.
     *
     * @param Permissions_Helper $permissions_helper The permissions helper.
     * @param Asset_Manager      $asset_manager      The asset manager.
     */
    
public function __constructPermissions_Helper $permissions_helperAsset_Manager $asset_manager ) {
        
$this->permissions_helper $permissions_helper;
        
$this->asset_manager      $asset_manager;
    }

    
/**
     * Adds hooks to integrate with WordPress.
     *
     * @return void
     */
    
public function register_hooks() {
        if ( \
intval( \get_option'duplicate_post_show_original_column' ) ) === ) {
            
$enabled_post_types $this->permissions_helper->get_enabled_post_types();
            if ( \
count$enabled_post_types ) ) {
                foreach ( 
$enabled_post_types as $enabled_post_type ) {
                    \
add_filter"manage_{$enabled_post_type}_posts_columns", [ $this'add_original_column' ] );
                    \
add_action"manage_{$enabled_post_type}_posts_custom_column", [ $this'show_original_item' ], 10);
                }
                \
add_action'quick_edit_custom_box', [ $this'quick_edit_remove_original' ], 10);
                \
add_action'admin_enqueue_scripts', [ $this'admin_enqueue_scripts' ] );
                \
add_action'admin_enqueue_scripts', [ $this'admin_enqueue_styles' ] );
            }
        }
    }

    
/**
     * Adds Original item column to the post list.
     *
     * @param array $post_columns The post columns array.
     *
     * @return array The updated array.
     */
    
public function add_original_column$post_columns ) {
        if ( \
is_array$post_columns ) ) {
            
$post_columns['duplicate_post_original_item'] = \__'Original item''duplicate-post' );
        }
        return 
$post_columns;
    }

    
/**
     * Sets the text to be displayed in the Original item column for the current post.
     *
     * @param string $column_name The name for the current column.
     * @param int    $post_id     The ID for the current post.
     *
     * @return void
     */
    
public function show_original_item$column_name$post_id ) {
        if ( 
'duplicate_post_original_item' === $column_name ) {
            
$column_content '-';
            
$data_attr      ' data-no-original="1"';
            
$original_item  Utils::get_original$post_id );
            if ( 
$original_item ) {
                
$post                          = \get_post$post_id );
                
$is_rewrite_and_republish_copy = \is_null$post ) ? false $this->permissions_helper->is_rewrite_and_republish_copy$post );

                
$data_attr      $is_rewrite_and_republish_copy ' data-copy-is-for-rewrite-and-republish="1"' '';
                
$column_content Utils::get_edit_or_view_link$original_item );
            }
            echo \
sprintf(
                
'<span class="duplicate_post_original_link"%s>%s</span>',
                
$data_attr// phpcs:ignore WordPress.Security.EscapeOutput
                
$column_content // phpcs:ignore WordPress.Security.EscapeOutput
            
);
        }
    }

    
/**
     * Adds original item checkbox + edit link in the Quick Edit.
     *
     * @param string $column_name The name for the current column.
     *
     * @return void
     */
    
public function quick_edit_remove_original$column_name ) {
        if ( 
'duplicate_post_original_item' !== $column_name ) {
            return;
        }
        \
printf(
            
'<fieldset class="inline-edit-col-left" id="duplicate_post_quick_edit_fieldset">
            <div class="inline-edit-col">
                <input type="checkbox"
                name="duplicate_post_remove_original"
                id="duplicate-post-remove-original"
                value="duplicate_post_remove_original"
                aria-describedby="duplicate-post-remove-original-description">
                <label for="duplicate-post-remove-original">
                    <span class="checkbox-title">%s</span>
                </label>
                <span id="duplicate-post-remove-original-description" class="checkbox-title">%s</span>
            </div>
        </fieldset>'
,
            \
esc_html__(
                
'Delete reference to original item.',
                
'duplicate-post'
            
),
            \
wp_kses(
                \
__(
                    
'The original item this was copied from is: <span class="duplicate_post_original_item_title_span"></span>',
                    
'duplicate-post'
                
),
                [
                    
'span' => [
                        
'class' => [],
                    ],
                ]
            )
        );
    }

    
/**
     * Enqueues the Javascript file to inject column data into the Quick Edit.
     *
     * @param string $hook The current admin page.
     *
     * @return void
     */
    
public function admin_enqueue_scripts$hook ) {
        if ( 
'edit.php' === $hook ) {
            
$this->asset_manager->enqueue_quick_edit_script();
        }
    }

    
/**
     * Enqueues the CSS file to for the Quick edit
     *
     * @param string $hook The current admin page.
     *
     * @return void
     */
    
public function admin_enqueue_styles$hook ) {
        if ( 
'edit.php' === $hook ) {
            
$this->asset_manager->enqueue_styles();
        }
    }
}
x

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