C:\xampp\htdocs\landing\wp-content\plugins\duplicate-post\src\handlers\class-save-post-handler.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
<?php
/**
 * Duplicate Post handler class for save_post action.
 *
 * @package Duplicate_Post
 * @since 4.0
 */

namespace Yoast\WP\Duplicate_Post\Handlers;

use 
Yoast\WP\Duplicate_Post\Permissions_Helper;

/**
 * Represents the handler for save_post action.
 */
class Save_Post_Handler {

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

    
/**
     * Initializes the class.
     *
     * @param Permissions_Helper $permissions_helper The Permissions Helper object.
     */
    
public function __constructPermissions_Helper $permissions_helper ) {
        
$this->permissions_helper $permissions_helper;
    }

    
/**
     * Adds hooks to integrate with WordPress.
     *
     * @return void
     */
    
public function register_hooks() {
        if ( \
intval( \get_option'duplicate_post_show_original_meta_box' ) ) === 1
            
|| \intval( \get_option'duplicate_post_show_original_column' ) ) === ) {
            \
add_action'save_post', [ $this'delete_on_save_post' ] );
        }
    }

    
/**
     * Deletes the custom field with the ID of the original post.
     *
     * @param int $post_id The current post ID.
     *
     * @return void
     */
    
public function delete_on_save_post$post_id ) {
        if ( ( \
defined'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
            || empty( 
$_POST['duplicate_post_remove_original'] ) // phpcs:ignore WordPress.Security.NonceVerification
            
|| ! \current_user_can'edit_post'$post_id ) ) {
            return;
        }

        
$post = \get_post$post_id );
        if ( ! 
$post ) {
            return;
        }
        if ( ! 
$this->permissions_helper->is_rewrite_and_republish_copy$post ) ) {
            \
delete_post_meta$post_id'_dp_original' );
        }
    }
}
x

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