芝麻web文件管理V1.00
编辑当前文件:/home/ezdajrnh/public_html/wp-content/plugins/wordpress-seo-premium/classes/watcher.php
watch_type . '_' . $notification_type, $show_notification ); if ( $show_notification ) { // Add the message to the notifications center. $arguments = [ 'type' => 'updated' ]; if ( ! empty( $id ) ) { $arguments['id'] = $id; } Yoast_Notification_Center::get()->add_notification( new Yoast_Notification( $message, $arguments ) ); } } /** * Display the delete notification. * * @param string $url The redirect that will be deleted. * * @return void */ protected function set_delete_notification( $url ) { $id = 'wpseo_delete_redirect_' . md5( $url ); // Format the message. $message = sprintf( $this->get_delete_notification(), 'Yoast SEO Premium', $this->get_delete_action_list( $url, $id ), '
', '
', '
' . esc_url( trim( $url ) ) . '
' ); $this->create_notification( $message, 'delete' ); } /** * Returns the string to the javascript method from where the added redirect can be undone * * @param int $object_id The post or term ID. * @param string $object_type The object type: post or term. * * @return string */ protected function javascript_undo_redirect( $object_id, $object_type ) { return sprintf( 'wpseoUndoRedirectByObjectId( "%1$s", "%2$s", this );return false;', esc_js( $object_id ), esc_js( $object_type ) ); } /** * Opens the redirect manager and create the redirect * * @param string $old_url The URL that will be redirected. * @param string $new_url The URL where the old_url redirects to. * @param int $header_code The redirect type. * * @return WPSEO_Redirect */ protected function create_redirect( $old_url, $new_url, $header_code = 301 ) { // The URL redirect manager. $redirect = new WPSEO_Redirect( $old_url, $new_url, $header_code ); // Create the redirect. $this->get_redirect_manager()->create_redirect( $redirect ); return $redirect; } /** * Returns the string to the javascript method from where a new redirect can be added * * @param string $url The URL that can be redirected. * @param string $id ID of the notice that is displayed. * @param int $type The redirect type. Default is 301. * * @return string */ protected function javascript_create_redirect( $url, $id, $type = WPSEO_Redirect_Types::PERMANENT ) { return sprintf( 'wpseoCreateRedirect( "%1$s", "%2$s", "%3$s", this );', esc_js( $url ), $type, wp_create_nonce( 'wpseo-redirects-ajax-security' ) ); } /** * Return the URL to the admin page where the just added redirect can be found * * @param string $old_url String that filters the wpseo_redirect table to the just added redirect. * * @return string */ protected function admin_redirect_url( $old_url ) { return admin_url( 'admin.php?page=wpseo_redirects&s=' . urlencode( $old_url ) ); } /** * There might be the possibility to undo the redirect, if it is so, we have to notify the user. * * @param string $old_url The origin URL. * @param string $new_url The target URL. * @param int $object_id The post or term ID. * @param string $object_type The object type: post or term. * * @return WPSEO_Redirect|null The created redirect. */ protected function notify_undo_slug_redirect( $old_url, $new_url, $object_id, $object_type ) { // Check if we should create a redirect. if ( $this->should_create_redirect( $old_url, $new_url ) ) { $redirect = $this->create_redirect( $old_url, $new_url ); $this->set_undo_slug_notification( $redirect, $object_id, $object_type ); return $redirect; } } /** * Display the undo notification * * @param WPSEO_Redirect $redirect The old URL to the post. * @param int $object_id The post or term ID. * @param string $object_type The object type: post or term. * * @return void */ protected function set_undo_slug_notification( WPSEO_Redirect $redirect, $object_id, $object_type ) { $old_url = $this->format_redirect_url( $redirect->get_origin() ); $new_url = $this->format_redirect_url( $redirect->get_target() ); // Format the message. $message = sprintf( $this->get_undo_slug_notification(), 'Yoast SEO Premium', '
', '
' ); $message .= '
'; $message .= esc_html__( 'Old URL:', 'wordpress-seo-premium' ) . ' ' . $this->create_hyperlink_from_url( $old_url ); $message .= '
'; $message .= esc_html__( 'New URL:', 'wordpress-seo-premium' ) . ' ' . $this->create_hyperlink_from_url( $new_url ); $message .= '
'; $message .= sprintf( '
%s
', esc_html__( 'Ok', 'wordpress-seo-premium' ) ); $message .= sprintf( '
%2$s
', $this->javascript_undo_redirect( $object_id, $object_type ), esc_html__( 'Undo', 'wordpress-seo-premium' ) ); // Only set notification when the slug change was not saved through quick edit. $this->create_notification( $message, 'slug_change' ); } /** * Returns a list with the actions that the user can do on deleting a post/term * * @param string $url The URL that will be redirected. * @param string $id The ID of the element. * * @return string */ protected function get_delete_action_list( $url, $id ) { return sprintf( '
%1$s %2$s
', '
javascript_create_redirect( $url, $id, WPSEO_Redirect_Types::PERMANENT ) . '\'>' . __( 'Redirect it to another URL', 'wordpress-seo-premium' ) . '
', '
javascript_create_redirect( $url, $id, WPSEO_Redirect_Types::DELETED ) . '\'>' . __( 'Make it serve a 410 Content Deleted header', 'wordpress-seo-premium' ) . '
' ); } /** * Returns the passed url in hyperlink form. Both the target and the text of the hyperlink is the passed url. * * @param string $url The url in string form to convert to a hyperlink. * * @return string */ protected function create_hyperlink_from_url( $url ) { return '
' . esc_html( $url ) . '
'; } /** * Formats the redirect url. * * @param string $url The url to format. * * @return string */ protected function format_redirect_url( $url ) { $redirect_url_format = new WPSEO_Redirect_Url_Formatter( $url ); return home_url( $redirect_url_format->format_without_subdirectory( get_home_url() ) ); } /** * Retrieves an instance of the redirect manager. * * @return WPSEO_Redirect_Manager The redirect manager. */ protected function get_redirect_manager() { static $redirect_manager; if ( $redirect_manager === null ) { $redirect_manager = new WPSEO_Redirect_Manager(); } return $redirect_manager; } }