Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/watchers.tar
Ðазад
class-republished-post-watcher.php 0000644 00000005447 15154233630 0013320 0 ustar 00 <?php /** * Duplicate Post class to watch if the post has been republished for Rewrite & Republish. * * @package Duplicate_Post * @since 4.0 */ namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Represents the Republished_Post_Watcher class. */ 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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification 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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $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' ); } } } class-link-actions-watcher.php 0000644 00000007351 15154233630 0012416 0 ustar 00 <?php /** * Duplicate Post class to watch for the link actions and show notices. * * @package Duplicate_Post */ namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Represents the Link_Actions_Watcher class. */ 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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification if ( ! $this->permissions_helper->is_classic_editor() ) { return; } $copied_posts = \intval( $_REQUEST['cloned'] ); // phpcs:ignore WordPress.Security.NonceVerification \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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification 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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $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' ); } } } class-original-post-watcher.php 0000644 00000004476 15154233630 0012617 0 ustar 00 <?php /** * Duplicate Post Original post watcher class. * * @package Duplicate_Post * @since 4.0 */ namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Original post watcher. * * Watches the original post for changes. */ 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' ); } } } class-bulk-actions-watcher.php 0000644 00000005462 15154233630 0012417 0 ustar 00 <?php /** * Duplicate Post class to watch for the bulk actions and show notices. * * @package Duplicate_Post */ namespace Yoast\WP\Duplicate_Post\Watchers; /** * Represents the Bulk_Actions_Watcher class. */ 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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $copied_posts = \intval( $_REQUEST['bulk_cloned'] ); // phpcs:ignore WordPress.Security.NonceVerification \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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $copied_posts = \intval( $_REQUEST['bulk_rewriting'] ); // phpcs:ignore WordPress.Security.NonceVerification \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 ) ); } } } class-watchers.php 0000644 00000003147 15154233630 0010207 0 ustar 00 <?php /** * Duplicate Post user interface. * * @package Duplicate_Post */ namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Represents the Duplicate Post User Interface class. */ 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 ); } } class-copied-post-watcher.php 0000644 00000006366 15154233630 0012256 0 ustar 00 <?php /** * Duplicate Post class to watch if the current post has a Rewrite & Republish copy. * * @package Duplicate_Post */ namespace Yoast\WP\Duplicate_Post\Watchers; use Yoast\WP\Duplicate_Post\Permissions_Helper; /** * Represents the Copied_Post_Watcher class. */ 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' ); } } } class-slug-change-watcher.php 0000644 00000015241 15154374674 0012233 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Watchers */ /** * Class WPSEO_Slug_Change_Watcher. */ class WPSEO_Slug_Change_Watcher implements WPSEO_WordPress_Integration { /** * Registers all hooks to WordPress. * * @return void */ public function register_hooks() { // If the current plugin is Yoast SEO Premium, stop registering. if ( YoastSEO()->helpers->product->is_premium() ) { return; } add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); // Detect a post trash. add_action( 'wp_trash_post', [ $this, 'detect_post_trash' ] ); // Detect a post delete. add_action( 'before_delete_post', [ $this, 'detect_post_delete' ] ); // Detects deletion of a term. add_action( 'delete_term_taxonomy', [ $this, 'detect_term_delete' ] ); } /** * Enqueues the quick edit handler. * * @return void */ public function enqueue_assets() { global $pagenow; if ( ! in_array( $pagenow, [ 'edit.php', 'edit-tags.php' ], true ) ) { return; } $asset_manager = new WPSEO_Admin_Asset_Manager(); $asset_manager->enqueue_script( 'quick-edit-handler' ); } /** * Shows an message when a post is about to get trashed. * * @param int $post_id The current post ID. * * @return void */ public function detect_post_trash( $post_id ) { if ( ! $this->is_post_viewable( $post_id ) ) { return; } /* translators: %1$s expands to the translated name of the post type. */ $first_sentence = sprintf( __( 'You just trashed a %1$s.', 'wordpress-seo' ), $this->get_post_type_label( get_post_type( $post_id ) ) ); $message = $this->get_message( $first_sentence ); $this->add_notification( $message ); } /** * Shows an message when a post is about to get trashed. * * @param int $post_id The current post ID. * * @return void */ public function detect_post_delete( $post_id ) { if ( ! $this->is_post_viewable( $post_id ) ) { return; } /* translators: %1$s expands to the translated name of the post type. */ $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $this->get_post_type_label( get_post_type( $post_id ) ) ); $message = $this->get_message( $first_sentence ); $this->add_notification( $message ); } /** * Shows a message when a term is about to get deleted. * * @param int $term_id The term ID that will be deleted. * * @return void */ public function detect_term_delete( $term_id ) { if ( ! $this->is_term_viewable( $term_id ) ) { return; } $first_sentence = sprintf( /* translators: 1: term label */ __( 'You just deleted a %1$s.', 'wordpress-seo' ), $this->get_taxonomy_label_for_term( $term_id ) ); $message = $this->get_message( $first_sentence ); $this->add_notification( $message ); } /** * Checks if the post is viewable. * * @param string $post_id The post id to check. * * @return bool Whether the post is viewable or not. */ protected function is_post_viewable( $post_id ) { $post_type = get_post_type( $post_id ); if ( ! WPSEO_Post_Type::is_post_type_accessible( $post_type ) ) { return false; } $post_status = get_post_status( $post_id ); if ( ! $this->check_visible_post_status( $post_status ) ) { return false; } return true; } /** * Checks if the term is viewable. * * @param string $term_id The term ID to check. * * @return bool Whether the term is viewable or not. */ protected function is_term_viewable( $term_id ) { $term = get_term( $term_id ); if ( ! $term || is_wp_error( $term ) ) { return false; } $taxonomy = get_taxonomy( $term->taxonomy ); if ( ! $taxonomy ) { return false; } return $taxonomy->publicly_queryable || $taxonomy->public; } /** * Gets the taxonomy label to use for a term. * * @param int $term_id The term ID. * * @return string The taxonomy's singular label. */ protected function get_taxonomy_label_for_term( $term_id ) { $term = get_term( $term_id ); $taxonomy = get_taxonomy( $term->taxonomy ); return $taxonomy->labels->singular_name; } /** * Retrieves the singular post type label. * * @param string $post_type Post type to retrieve label from. * * @return string The singular post type name. */ protected function get_post_type_label( $post_type ) { $post_type_object = get_post_type_object( $post_type ); // If the post type of this post wasn't registered default back to post. if ( $post_type_object === null ) { $post_type_object = get_post_type_object( 'post' ); } return $post_type_object->labels->singular_name; } /** * Checks whether the given post status is visible or not. * * @param string $post_status The post status to check. * * @return bool Whether or not the post is visible. */ protected function check_visible_post_status( $post_status ) { $visible_post_statuses = [ 'publish', 'static', 'private', ]; return in_array( $post_status, $visible_post_statuses, true ); } /** * Returns the message around changed URLs. * * @param string $first_sentence The first sentence of the notification. * * @return string The full notification. */ protected function get_message( $first_sentence ) { return '<h2>' . __( 'Make sure you don\'t miss out on traffic!', 'wordpress-seo' ) . '</h2>' . '<p>' . $first_sentence . ' ' . __( 'Search engines and other websites can still send traffic to your deleted post.', 'wordpress-seo' ) . ' ' . __( 'You should create a redirect to ensure your visitors do not get a 404 error when they click on the no longer working URL.', 'wordpress-seo' ) /* translators: %s expands to Yoast SEO Premium */ . ' ' . sprintf( __( 'With %s, you can easily create such redirects.', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '</p>' . '<p><a class="yoast-button-upsell" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/1d0' ) . '" target="_blank">' /* translators: %s expands to Yoast SEO Premium */ . sprintf( __( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '<span class="screen-reader-text">' . __( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>' . '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>' . '</a></p>'; } /** * Adds a notification to be shown on the next page request since posts are updated in an ajax request. * * @param string $message The message to add to the notification. * * @return void */ protected function add_notification( $message ) { $notification = new Yoast_Notification( $message, [ 'type' => 'notice-warning is-dismissible', 'yoast_branding' => true, ] ); $notification_center = Yoast_Notification_Center::get(); $notification_center->add_notification( $notification ); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка