Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/watchers.tar
Назад
copied-post-watcher.php 0000755 00000006255 14721556052 0011160 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; use WP_Post; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Duplicate Post class to watch if the current post has a Rewrite & Republish copy. */ class Copied_Post_Watcher { /** * Holds the permissions helper. * * @var Permissions_Helper */ protected $permissions_helper; /** * Initializes the class. * * @param Permissions_Helper $permissions_helper The Permissions helper object. */ public function __construct( $permissions_helper ) { $this->permissions_helper = $permissions_helper; $this->register_hooks(); } /** * Adds hooks to integrate with WordPress. * * @return void */ public function register_hooks() { \add_action( 'admin_notices', [ $this, 'add_admin_notice' ] ); \add_action( 'enqueue_block_editor_assets', [ $this, 'add_block_editor_notice' ], 11 ); } /** * Generates the translated text for the notice. * * @param WP_Post $post The current post object. * * @return string The translated text for the notice. */ public function get_notice_text( $post ) { if ( $this->permissions_helper->has_trashed_rewrite_and_republish_copy( $post ) ) { return \__( 'You can only make one Rewrite & Republish duplicate at a time, and a duplicate of this post already exists in the trash. Permanently delete it if you want to make a new duplicate.', 'duplicate-post' ); } $scheduled_copy = $this->permissions_helper->has_scheduled_rewrite_and_republish_copy( $post ); if ( ! $scheduled_copy ) { return \__( 'A duplicate of this post was made. Please note that any changes you make to this post will be replaced when the duplicated version is republished.', 'duplicate-post' ); } return \sprintf( /* translators: %1$s: scheduled date of the copy, %2$s: scheduled time of the copy. */ \__( 'A duplicate of this post was made, which is scheduled to replace this post on %1$s at %2$s.', 'duplicate-post' ), \get_the_time( \get_option( 'date_format' ), $scheduled_copy ), \get_the_time( \get_option( 'time_format' ), $scheduled_copy ) ); } /** * Shows a notice on the Classic editor. * * @return void */ public function add_admin_notice() { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } $post = \get_post(); if ( ! $post instanceof WP_Post ) { return; } if ( $this->permissions_helper->has_rewrite_and_republish_copy( $post ) ) { print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' . \esc_html( $this->get_notice_text( $post ) ) . '</p></div>'; } } /** * Shows a notice on the Block editor. * * @return void */ public function add_block_editor_notice() { $post = \get_post(); if ( ! $post instanceof WP_Post ) { return; } if ( $this->permissions_helper->has_rewrite_and_republish_copy( $post ) ) { $notice = [ 'text' => \wp_slash( $this->get_notice_text( $post ) ), 'status' => 'warning', 'isDismissible' => true, ]; \wp_add_inline_script( 'duplicate_post_edit_script', "duplicatePostNotices.has_rewrite_and_republish_notice = '" . \wp_json_encode( $notice ) . "';", 'before' ); } } } republished-post-watcher.php 0000755 00000005150 14721556052 0012214 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Duplicate Post class to watch if the post has been republished for Rewrite & Republish. * * @since 4.0 */ class Republished_Post_Watcher { /** * Holds the permissions helper. * * @var Permissions_Helper */ protected $permissions_helper; /** * Initializes the class. * * @param Permissions_Helper $permissions_helper The Permissions helper object. */ public function __construct( Permissions_Helper $permissions_helper ) { $this->permissions_helper = $permissions_helper; $this->register_hooks(); } /** * Adds hooks to integrate with WordPress. * * @return void */ public function register_hooks() { \add_filter( 'removable_query_args', [ $this, 'add_removable_query_args' ] ); \add_action( 'admin_notices', [ $this, 'add_admin_notice' ] ); \add_action( 'enqueue_block_editor_assets', [ $this, 'add_block_editor_notice' ], 11 ); } /** * Adds vars to the removable query args. * * @param array $removable_query_args Array of query args keys. * * @return array The updated array of query args keys. */ public function add_removable_query_args( $removable_query_args ) { if ( \is_array( $removable_query_args ) ) { $removable_query_args[] = 'dprepublished'; $removable_query_args[] = 'dpcopy'; $removable_query_args[] = 'dpnonce'; } return $removable_query_args; } /** * Generates the translated text for the republished notice. * * @return string The translated text for the republished notice. */ public function get_notice_text() { return \__( 'Your original post has been replaced with the rewritten post. You are now viewing the (rewritten) original post.', 'duplicate-post' ); } /** * Shows a notice on the Classic editor. * * @return void */ public function add_admin_notice() { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } if ( ! empty( $_REQUEST['dprepublished'] ) ) { echo '<div id="message" class="notice notice-success is-dismissible"><p>' . \esc_html( $this->get_notice_text() ) . '</p></div>'; } } /** * Shows a notice on the Block editor. * * @return void */ public function add_block_editor_notice() { if ( ! empty( $_REQUEST['dprepublished'] ) ) { $notice = [ 'text' => \wp_slash( $this->get_notice_text() ), 'status' => 'success', 'isDismissible' => true, ]; \wp_add_inline_script( 'duplicate_post_edit_script', "duplicatePostNotices.republished_notice = '" . \wp_json_encode( $notice ) . "';", 'before' ); } } } watchers.php 0000755 00000003012 14721556052 0007103 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Duplicate Post user interface. */ class Watchers { /** * Holds the permissions helper. * * @var Permissions_Helper */ protected $permissions_helper; /** * Holds the original post watcher. * * @var Original_Post_Watcher */ protected $original_post_watcher; /** * Holds the copied post watcher. * * @var Copied_Post_Watcher */ protected $copied_post_watcher; /** * Holds the bulk actions watcher. * * @var Bulk_Actions_Watcher */ protected $bulk_actions_watcher; /** * Holds the link actions watcher. * * @var Link_Actions_Watcher */ protected $link_actions_watcher; /** * Holds the republished post watcher. * * @var Republished_Post_Watcher */ protected $republished_post_watcher; /** * Initializes the class. * * @param Permissions_Helper $permissions_helper The permissions helper object. */ public function __construct( Permissions_Helper $permissions_helper ) { $this->permissions_helper = $permissions_helper; $this->copied_post_watcher = new Copied_Post_Watcher( $this->permissions_helper ); $this->original_post_watcher = new Original_Post_Watcher( $this->permissions_helper ); $this->bulk_actions_watcher = new Bulk_Actions_Watcher(); $this->link_actions_watcher = new Link_Actions_Watcher( $this->permissions_helper ); $this->republished_post_watcher = new Republished_Post_Watcher( $this->permissions_helper ); } } link-actions-watcher.php 0000755 00000006707 14721556052 0011327 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Duplicate Post class to watch for the link actions and show notices. */ class Link_Actions_Watcher { /** * Holds the permissions helper. * * @var Permissions_Helper */ protected $permissions_helper; /** * Initializes the class. * * @param Permissions_Helper $permissions_helper The Permissions helper object. */ public function __construct( Permissions_Helper $permissions_helper ) { $this->permissions_helper = $permissions_helper; $this->register_hooks(); } /** * Adds hooks to integrate with WordPress. * * @return void */ public function register_hooks() { \add_filter( 'removable_query_args', [ $this, 'add_removable_query_args' ], 10, 1 ); \add_action( 'admin_notices', [ $this, 'add_clone_admin_notice' ] ); \add_action( 'admin_notices', [ $this, 'add_rewrite_and_republish_admin_notice' ] ); \add_action( 'enqueue_block_editor_assets', [ $this, 'add_rewrite_and_republish_block_editor_notice' ] ); } /** * Adds vars to the removable query args. * * @param array $removable_query_args Array of query args keys. * * @return array The updated array of query args keys. */ public function add_removable_query_args( $removable_query_args ) { if ( \is_array( $removable_query_args ) ) { $removable_query_args[] = 'cloned'; $removable_query_args[] = 'rewriting'; } return $removable_query_args; } /** * Shows a notice after the Clone link action has succeeded. * * @return void */ public function add_clone_admin_notice() { if ( ! empty( $_REQUEST['cloned'] ) ) { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } $copied_posts = \intval( $_REQUEST['cloned'] ); \printf( '<div id="message" class="notice notice-success fade"><p>' . \esc_html( /* translators: %s: Number of posts copied. */ \_n( '%s item copied.', '%s items copied.', $copied_posts, 'duplicate-post' ) ) . '</p></div>', \esc_html( $copied_posts ) ); } } /** * Shows a notice in Classic editor after the Rewrite & Republish action via link has succeeded. * * @return void */ public function add_rewrite_and_republish_admin_notice() { if ( ! empty( $_REQUEST['rewriting'] ) ) { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' . \esc_html__( 'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", your changes will be merged into the original post and you’ll be redirected there.', 'duplicate-post' ) . '</p></div>'; } } /** * Shows a notice on the Block editor after the Rewrite & Republish action via link has succeeded. * * @return void */ public function add_rewrite_and_republish_block_editor_notice() { if ( ! empty( $_REQUEST['rewriting'] ) ) { $notice = [ 'text' => \wp_slash( \__( 'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", this rewritten post will replace the original post.', 'duplicate-post' ) ), 'status' => 'warning', 'isDismissible' => true, ]; \wp_add_inline_script( 'duplicate_post_edit_script', "duplicatePostNotices.rewriting_notice = '" . \wp_json_encode( $notice ) . "';", 'before' ); } } } original-post-watcher.php 0000755 00000004414 14721556052 0011514 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; use WP_Post; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Duplicate Post Original post watcher class. * * Watches the original post for changes. * * @since 4.0 */ class Original_Post_Watcher { /** * Holds the permissions helper. * * @var Permissions_Helper */ protected $permissions_helper; /** * Initializes the class. * * @param Permissions_Helper $permissions_helper The Permissions helper object. */ public function __construct( Permissions_Helper $permissions_helper ) { $this->permissions_helper = $permissions_helper; $this->register_hooks(); } /** * Registers the hooks. * * @return void */ public function register_hooks() { \add_action( 'admin_notices', [ $this, 'add_admin_notice' ] ); \add_action( 'enqueue_block_editor_assets', [ $this, 'add_block_editor_notice' ], 11 ); } /** * Generates the translated text for the notice. * * @return string The translated text for the notice. */ public function get_notice_text() { return \__( 'The original post has been edited in the meantime. If you click "Republish", this rewritten post will replace the original post.', 'duplicate-post' ); } /** * Shows a notice on the Classic editor. * * @return void */ public function add_admin_notice() { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } $post = \get_post(); if ( ! $post instanceof WP_Post ) { return; } if ( $this->permissions_helper->has_original_changed( $post ) ) { print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' . \esc_html( $this->get_notice_text() ) . '</p></div>'; } } /** * Shows a notice on the Block editor. * * @return void */ public function add_block_editor_notice() { $post = \get_post(); if ( ! $post instanceof WP_Post ) { return; } if ( $this->permissions_helper->has_original_changed( $post ) ) { $notice = [ 'text' => \wp_slash( $this->get_notice_text() ), 'status' => 'warning', 'isDismissible' => true, ]; \wp_add_inline_script( 'duplicate_post_edit_script', "duplicatePostNotices.has_original_changed_notice = '" . \wp_json_encode( $notice ) . "';", 'before' ); } } } bulk-actions-watcher.php 0000755 00000005014 14721556052 0011315 0 ustar 00 <?php namespace Yoast\WP\Duplicate_Post\Watchers; /** * Duplicate Post class to watch for the bulk actions and show notices. */ class Bulk_Actions_Watcher { /** * Initializes the class. */ public function __construct() { $this->register_hooks(); } /** * Adds hooks to integrate with WordPress. * * @return void */ public function register_hooks() { \add_filter( 'removable_query_args', [ $this, 'add_removable_query_args' ] ); \add_action( 'admin_notices', [ $this, 'add_bulk_clone_admin_notice' ] ); \add_action( 'admin_notices', [ $this, 'add_bulk_rewrite_and_republish_admin_notice' ] ); } /** * Adds vars to the removable query args. * * @param array $removable_query_args Array of query args keys. * * @return array The updated array of query args keys. */ public function add_removable_query_args( $removable_query_args ) { if ( \is_array( $removable_query_args ) ) { $removable_query_args[] = 'bulk_cloned'; $removable_query_args[] = 'bulk_rewriting'; } return $removable_query_args; } /** * Shows a notice after the Clone bulk action has succeeded. * * @return void */ public function add_bulk_clone_admin_notice() { if ( ! empty( $_REQUEST['bulk_cloned'] ) ) { $copied_posts = \intval( $_REQUEST['bulk_cloned'] ); \printf( '<div id="message" class="notice notice-success fade"><p>' . \esc_html( /* translators: %s: Number of posts copied. */ \_n( '%s item copied.', '%s items copied.', $copied_posts, 'duplicate-post' ) ) . '</p></div>', \esc_html( $copied_posts ) ); } } /** * Shows a notice after the Rewrite & Republish bulk action has succeeded. * * @return void */ public function add_bulk_rewrite_and_republish_admin_notice() { if ( ! empty( $_REQUEST['bulk_rewriting'] ) ) { $copied_posts = \intval( $_REQUEST['bulk_rewriting'] ); \printf( '<div id="message" class="notice notice-success fade"><p>' . \esc_html( /* translators: %s: Number of posts copied. */ \_n( '%s post duplicated. You can now start rewriting your post in the duplicate of the original post. Once you choose to republish it your changes will be merged back into the original post.', '%s posts duplicated. You can now start rewriting your posts in the duplicates of the original posts. Once you choose to republish them your changes will be merged back into the original post.', $copied_posts, 'duplicate-post' ) ) . '</p></div>', \esc_html( $copied_posts ) ); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка