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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
<?php
$plugins_allowed_tags = [ 'a' => [ 'href' => [], 'title' => [], 'target' => [], ], 'abbr' => [ 'title' => [] ], 'acronym' => [ 'title' => [] ], 'code' => [], 'pre' => [], 'em' => [], 'strong' => [], 'ul' => [], 'ol' => [], 'li' => [], 'p' => [], 'br' => [], ];
foreach ( (array) $recommended_plugins as $recommended_plugin ) { if ( is_object( $recommended_plugin ) ) { $recommended_plugin = (array) $recommended_plugin; }
$plugin_title = wp_kses( $recommended_plugin['name'], $plugins_allowed_tags );
// Remove any HTML from the description. $description = wp_strip_all_tags( $recommended_plugin['short_description'] );
$name = wp_strip_all_tags( $plugin_title );
$download_link = isset( $recommended_plugin['download_link'] ) ? $recommended_plugin['download_link'] : null;
$compatible_php = true; $compatible_wp = true; $tested_wp = true;
$action_links = [];
$plugin_status = '<span class="plugin-status-not-install">Not installed</span>';
if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { $plugin_pro_ver = $this->check_pro_version_exists( $recommended_plugin ); if ( false === $plugin_pro_ver ) { if ( 'yaypricing' === $recommended_plugin['slug'] ) { $install_status = [ 'status' => 'install', 'url' => $recommended_plugin['download_link'], 'version' => '', 'file' => $plugin_pro_ver, ]; } else { $install_status = \install_plugin_install_status( $recommended_plugin ); } } else { $install_status = [ 'status' => 'latest_installed', 'url' => false, 'version' => '', 'file' => $plugin_pro_ver, ]; }
switch ( $install_status['status'] ) { case 'install': if ( $install_status['url'] ) { if ( $compatible_php && $compatible_wp ) { if ( 'yaymail' === $recommended_plugin['slug'] ) { $action_links[] = sprintf( '<a href="%s" target="_bank"><button class="button button-primary" data-install-url="%s" aria-label="%s">%s</button></a>', esc_attr( $download_link ), esc_attr( $download_link ), /* translators: %s: Plugin name and version. */ esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), __( 'Install Now', 'ninjateam-whatsapp' ) ); } else { $action_links[] = sprintf( '<button class="install-now button button-primary" data-install-url="%s" aria-label="%s">%s</button>', esc_attr( $download_link ), /* translators: %s: Plugin name and version. */ esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), __( 'Install Now', 'ninjateam-whatsapp' ) ); } } else { $action_links[] = sprintf( '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', _x( 'Cannot Install', 'plugin', 'ninjateam-whatsapp' ) ); }//end if }//end if $plugin_status = '<span class="plugin-status-not-install" data-plugin-url="' . esc_attr( $download_link ) . '">Not installed</span>'; break;
case 'update_available': if ( $install_status['url'] ) { if ( $compatible_php && $compatible_wp ) { if ( 'yaymail' === $recommended_plugin['slug'] ) { $action_links[] = sprintf( '<button class="button aria-button-if-js" data-plugin="%s" data-slug="%s" data-update-url="%s" aria-label="%s" data-name="%s">%s</button>', esc_attr( $install_status['file'] ), esc_attr( $recommended_plugin['slug'] ), esc_url( $install_status['url'] ), /* translators: %s: Plugin name and version. */ esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), esc_attr( $name ), __( 'Update Now', 'ninjateam-whatsapp' ) ); } else { $action_links[] = sprintf( '<button class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" data-update-url="%s" aria-label="%s" data-name="%s">%s</button>', esc_attr( $install_status['file'] ), esc_attr( $recommended_plugin['slug'] ), esc_url( $install_status['url'] ), /* translators: %s: Plugin name and version. */ esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), esc_attr( $name ), __( 'Update Now', 'ninjateam-whatsapp' ) ); }//end if } else { $action_links[] = sprintf( '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', _x( 'Cannot Update', 'plugin', 'ninjateam-whatsapp' ) ); }//end if }//end if if ( is_plugin_active( $install_status['file'] ) ) { $plugin_status = '<span class="plugin-status-active">Active</span>'; } else { $plugin_status = '<span class="plugin-status-inactive" data-plugin-file="' . esc_attr( $install_status['file'] ) . '">Inactive</span>'; } break;
case 'latest_installed': case 'newer_installed': if ( is_plugin_active( $install_status['file'] ) ) { $plugin_status = '<span class="plugin-status-active">Active</span>'; $action_links[] = sprintf( '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', _x( 'Activated', 'plugin', 'ninjateam-whatsapp' ) ); } elseif ( current_user_can( 'activate_plugin', $install_status['file'] ) ) { $plugin_status = '<span class="plugin-status-inactive" data-plugin-file="' . esc_attr( $install_status['file'] ) . '">Inactive</span>'; if ( $compatible_php && $compatible_wp ) { $button_text = __( 'Activate', 'ninjateam-whatsapp' ); /* translators: %s: Plugin name. */ $button_label = _x( 'Activate %s', 'plugin', 'ninjateam-whatsapp' ); $activate_url = add_query_arg( [ '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ), 'action' => 'activate', 'plugin' => $install_status['file'], ], network_admin_url( 'plugins.php' ) );
if ( is_network_admin() ) { $button_text = __( 'Network Activate', 'ninjateam-whatsapp' ); /* translators: %s: Plugin name. */ $button_label = _x( 'Network Activate %s', 'plugin', 'ninjateam-whatsapp' ); $activate_url = add_query_arg( [ 'networkwide' => 1 ], $activate_url ); }
$action_links[] = sprintf( '<button class="button activate-now" data-plugin-file="%1$s" aria-label="%2$s">%3$s</button>', esc_attr( $install_status['file'] ), esc_attr( sprintf( $button_label, $recommended_plugin['name'] ) ), $button_text ); } else { $action_links[] = sprintf( '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', _x( 'Cannot Activate', 'plugin', 'ninjateam-whatsapp' ) ); }//end if } else { $action_links[] = sprintf( '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', _x( 'Installed', 'plugin', 'ninjateam-whatsapp' ) ); }//end if break; }//end switch }//end if
$details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $recommended_plugin['slug'] . '&TB_iframe=true&width=600&height=550' );
$plugin_icon_url = $recommended_plugin['icon'];
/** * Filters the install action links for a plugin. * * @since 2.7.0 * * @param string[] $action_links An array of plugin action links. Defaults are links to Details and Install Now. * @param array $plugin The plugin currently being listed. */ $action_links = apply_filters( 'plugin_install_action_links', $action_links, $recommended_plugin );
?> <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $recommended_plugin['slug'] ); ?>"> <?php if ( ! $compatible_php || ! $compatible_wp ) { echo '<div class="notice inline notice-error notice-alt"><p>'; if ( ! $compatible_php && ! $compatible_wp ) { echo esc_html__( 'This plugin doesn’t work with your versions of WordPress and PHP.', 'ninjateam-whatsapp' ); if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { printf( /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ ' ' . esc_html__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), esc_url( self_admin_url( 'update-core.php' ) ), esc_url( wp_get_update_php_url() ) ); wp_update_php_annotation( '</p><p><em>', '</em>' ); } elseif ( current_user_can( 'update_core' ) ) { printf( /* translators: %s: URL to WordPress Updates screen. */ ' ' . esc_html__( '<a href="%s">Please update WordPress</a>.', 'ninjateam-whatsapp' ), esc_url( self_admin_url( 'update-core.php' ) ) ); } elseif ( current_user_can( 'update_php' ) ) { printf( /* translators: %s: URL to Update PHP page. */ ' ' . esc_html__( '<a href="%s">Learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), esc_url( wp_get_update_php_url() ) ); wp_update_php_annotation( '</p><p><em>', '</em>' ); }//end if } elseif ( ! $compatible_wp ) { echo esc_html__( 'This plugin doesn’t work with your version of WordPress.', 'ninjateam-whatsapp' ); if ( current_user_can( 'update_core' ) ) { printf( /* translators: %s: URL to WordPress Updates screen. */ ' ' . esc_html__( '<a href="%s">Please update WordPress</a>.', 'ninjateam-whatsapp' ), esc_url( self_admin_url( 'update-core.php' ) ) ); } } elseif ( ! $compatible_php ) { echo esc_html__( 'This plugin doesn’t work with your version of PHP.', 'ninjateam-whatsapp' ); if ( current_user_can( 'update_php' ) ) { printf( /* translators: %s: URL to Update PHP page. */ ' ' . esc_html__( '<a href="%s">Learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), esc_url( wp_get_update_php_url() ) ); wp_update_php_annotation( '</p><p><em>', '</em>' ); } }//end if echo '</p></div>'; }//end if ?> <div class="plugin-card-top"> <div class="name column-name"> <h3> <a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal"> <?php echo wp_kses_post( $plugin_title ); ?> <img src="<?php echo esc_url( $plugin_icon_url ); ?>" class="plugin-icon" alt="" /> </a> </h3> </div> <div class="desc column-description"> <p><?php echo wp_kses_post( $description ); ?></p> </div> </div> <div class="plugin-card-bottom"> <div class="vers column-rating"> <?php printf( '<span class="plugin-status" >%s: %s</span>', esc_html( 'Status' ), wp_kses_post( $plugin_status ) ); ?> </div> <div class="column-updated"> <?php if ( $action_links ) { echo '<ul class="plugin-action-buttons"><li>' . wp_kses_post( implode( '</li><li>', $action_links ) ) . '</li></ul>'; } ?> </div> </div> </div> <?php }//end foreach ?>
|