/var/www/hkosl.com/aga/wp-content/plugins/wordpress-seo/admin/links/class-link-notifier.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
 * WPSEO plugin file.
 *
 * @package WPSEO\Admin
 */

/**
 * Represents the notifier for adding link indexing notification to the dashboard.
 */
class WPSEO_Link_Notifier {

    
/**
     * @var string
     */
    
const NOTIFICATION_ID 'wpseo-reindex-links';

    
/**
     * Registers all hooks to WordPress.
     */
    
public function register_hooks() {
        if ( 
filter_inputINPUT_GET'page' ) === 'wpseo_dashboard' ) {
            
add_action'admin_init', array( $this'cleanup_notification' ) );
        }

        if ( ! 
wp_next_scheduledself::NOTIFICATION_ID ) ) {
            
wp_schedule_eventtime(), 'daily'self::NOTIFICATION_ID );
        }

        
add_actionself::NOTIFICATION_ID, array( $this'manage_notification' ) );
    }

    
/**
     * Removes the notification when it is set and the amount of unindexed items is lower than the threshold.
     */
    
public function cleanup_notification() {
        if ( ! 
$this->has_notification() || $this->requires_notification() ) {
            return;
        }

        
$this->remove_notification$this->get_notification() );
    }

    
/**
     * Adds the notification when it isn't set already and the amount of unindexed items is greater than the set
     * threshold.
     */
    
public function manage_notification() {
        if ( 
$this->has_notification() || ! $this->requires_notification() ) {
            return;
        }

        
$this->add_notification$this->get_notification() );
    }

    
/**
     * Checks if the notification has been set already.
     *
     * @return bool True when there is a notification.
     */
    
public function has_notification() {
        
$notification Yoast_Notification_Center::get()->get_notification_by_idself::NOTIFICATION_ID );

        return 
$notification instanceof Yoast_Notification;
    }

    
/**
     * Adds a notification to the notification center.
     *
     * @param Yoast_Notification $notification The notification to add.
     */
    
protected function add_notificationYoast_Notification $notification ) {
        
Yoast_Notification_Center::get()->add_notification$notification );
    }

    
/**
     * Removes the notification from the notification center.
     *
     * @param Yoast_Notification $notification The notification to remove.
     */
    
protected function remove_notificationYoast_Notification $notification ) {
        
Yoast_Notification_Center::get()->remove_notification$notification );
    }

    
/**
     * Returns an instance of the notification.
     *
     * @return Yoast_Notification The notification to show.
     */
    
protected function get_notification() {
        return new 
Yoast_Notification(
            
esc_html__'To make sure all the links in your texts are counted, we need to analyze all your texts.''wordpress-seo' ) . ' ' .
            
esc_html__'All you have to do is press the following button and we\'ll go through all your texts for you.''wordpress-seo' ) . '<br><br>' .
            
'<button type="button" id="noticeRunLinkIndex" class="button">' esc_html__'Count links''wordpress-seo' ) . '</button><br><br>' .
            
sprintf(
                
/* translators: 1: link to yoast.com post about internal linking suggestion. 2: is anchor closing. */
                
esc_html__'The Text link counter feature provides insights in how many links are found in your text and how many links are referring to your text. This is very helpful when you are improving your %1$sinternal linking%2$s.''wordpress-seo' ),
                
'<a href="' WPSEO_Shortlinker::get'https://yoa.st/15m' ) . '" target="_blank">',
                
'</a>'
            
),
            array(
                
'type'         => Yoast_Notification::WARNING,
                
'id'           => self::NOTIFICATION_ID,
                
'capabilities' => 'wpseo_manage_options',
                
'priority'     => 0.8,
            )
        );
    }

    
/**
     * Checks if the unindexed threshold is exceeded.
     *
     * @return bool True when the threshold is exceeded.
     */
    
protected function requires_notification() {
        
$post_types apply_filters'wpseo_link_count_post_types'WPSEO_Post_Type::get_accessible_post_types() );
        if ( ! 
is_array$post_types ) ) {
            return 
false;
        }

        return 
WPSEO_Link_Query::has_unprocessed_posts$post_types );
    }
}