Edit File by line
/home/barbar84/www/wp-conte.../plugins/duplicat.../src/ui
File: class-metabox.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Duplicate Post class to manage the metabox.
[2] Fix | Delete
*
[3] Fix | Delete
* @package Duplicate_Post
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Yoast\WP\Duplicate_Post\UI;
[7] Fix | Delete
[8] Fix | Delete
use Yoast\WP\Duplicate_Post\Permissions_Helper;
[9] Fix | Delete
use Yoast\WP\Duplicate_Post\Utils;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Represents the Metabox class.
[13] Fix | Delete
*/
[14] Fix | Delete
class Metabox {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Holds the permissions helper.
[18] Fix | Delete
*
[19] Fix | Delete
* @var Permissions_Helper
[20] Fix | Delete
*/
[21] Fix | Delete
protected $permissions_helper;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Initializes the class.
[25] Fix | Delete
*
[26] Fix | Delete
* @param Permissions_Helper $permissions_helper The permissions helper.
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct( Permissions_Helper $permissions_helper ) {
[29] Fix | Delete
$this->permissions_helper = $permissions_helper;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Adds hooks to integrate with WordPress.
[34] Fix | Delete
*
[35] Fix | Delete
* @return void
[36] Fix | Delete
*/
[37] Fix | Delete
public function register_hooks() {
[38] Fix | Delete
if ( \intval( \get_option( 'duplicate_post_show_original_meta_box' ) ) === 1 ) {
[39] Fix | Delete
\add_action( 'add_meta_boxes', [ $this, 'add_custom_metabox' ] );
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Adds a metabox to Edit screen.
[45] Fix | Delete
*
[46] Fix | Delete
* @return void
[47] Fix | Delete
*/
[48] Fix | Delete
public function add_custom_metabox() {
[49] Fix | Delete
$screens = $this->permissions_helper->get_enabled_post_types();
[50] Fix | Delete
if ( ! \is_array( $screens ) ) {
[51] Fix | Delete
$screens = [ $screens ];
[52] Fix | Delete
}
[53] Fix | Delete
foreach ( $screens as $screen ) {
[54] Fix | Delete
\add_meta_box(
[55] Fix | Delete
'duplicate_post_show_original',
[56] Fix | Delete
\__( 'Duplicate Post', 'duplicate-post' ),
[57] Fix | Delete
[ $this, 'custom_metabox_html' ],
[58] Fix | Delete
$screen,
[59] Fix | Delete
'side'
[60] Fix | Delete
);
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Outputs the HTML for the metabox.
[66] Fix | Delete
*
[67] Fix | Delete
* @param \WP_Post $post The current post.
[68] Fix | Delete
*
[69] Fix | Delete
* @return void
[70] Fix | Delete
*/
[71] Fix | Delete
public function custom_metabox_html( $post ) {
[72] Fix | Delete
$original_item = Utils::get_original( $post );
[73] Fix | Delete
if ( $post instanceof \WP_Post && $original_item instanceof \WP_Post ) {
[74] Fix | Delete
if ( ! $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
[75] Fix | Delete
?>
[76] Fix | Delete
<p>
[77] Fix | Delete
<input type="checkbox"
[78] Fix | Delete
name="duplicate_post_remove_original"
[79] Fix | Delete
id="duplicate-post-remove-original"
[80] Fix | Delete
value="duplicate_post_remove_original"
[81] Fix | Delete
aria-describedby="duplicate-post-remove-original-description">
[82] Fix | Delete
<label for="duplicate-post-remove-original">
[83] Fix | Delete
<?php \esc_html_e( 'Delete reference to original item.', 'duplicate-post' ); ?>
[84] Fix | Delete
</label>
[85] Fix | Delete
</p>
[86] Fix | Delete
<?php
[87] Fix | Delete
}
[88] Fix | Delete
?>
[89] Fix | Delete
<p id="duplicate-post-remove-original-description">
[90] Fix | Delete
<?php
[91] Fix | Delete
\printf(
[92] Fix | Delete
\wp_kses(
[93] Fix | Delete
/* translators: %s: post title */
[94] Fix | Delete
\__(
[95] Fix | Delete
'The original item this was copied from is: <span class="duplicate_post_original_item_title_span">%s</span>',
[96] Fix | Delete
'duplicate-post'
[97] Fix | Delete
),
[98] Fix | Delete
[
[99] Fix | Delete
'span' => [
[100] Fix | Delete
'class' => [],
[101] Fix | Delete
],
[102] Fix | Delete
]
[103] Fix | Delete
),
[104] Fix | Delete
Utils::get_edit_or_view_link( $original_item ) // phpcs:ignore WordPress.Security.EscapeOutput
[105] Fix | Delete
);
[106] Fix | Delete
?>
[107] Fix | Delete
</p>
[108] Fix | Delete
<?php
[109] Fix | Delete
} else {
[110] Fix | Delete
?>
[111] Fix | Delete
<script>
[112] Fix | Delete
(function(jQuery){
[113] Fix | Delete
jQuery('#duplicate_post_show_original').hide();
[114] Fix | Delete
})(jQuery);
[115] Fix | Delete
</script>
[116] Fix | Delete
<?php
[117] Fix | Delete
}
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function