content.php
286 lines
| 1 | <?php |
| 2 | |
| 3 | $pluginsAllowedTags = array( |
| 4 | 'a' => array( |
| 5 | 'href' => array(), |
| 6 | 'title' => array(), |
| 7 | 'target' => array(), |
| 8 | ), |
| 9 | 'abbr' => array( 'title' => array() ), |
| 10 | 'acronym' => array( 'title' => array() ), |
| 11 | 'code' => array(), |
| 12 | 'pre' => array(), |
| 13 | 'em' => array(), |
| 14 | 'strong' => array(), |
| 15 | 'ul' => array(), |
| 16 | 'ol' => array(), |
| 17 | 'li' => array(), |
| 18 | 'p' => array(), |
| 19 | 'br' => array(), |
| 20 | ); |
| 21 | |
| 22 | foreach ( (array) $recommendedPlugins as $recommendedPlugin ) { |
| 23 | if ( is_object( $recommendedPlugin ) ) { |
| 24 | $recommendedPlugin = (array) $recommendedPlugin; |
| 25 | } |
| 26 | |
| 27 | $pluginTitle = wp_kses( $recommendedPlugin['name'], $pluginsAllowedTags ); |
| 28 | |
| 29 | // Remove any HTML from the description. |
| 30 | $description = wp_strip_all_tags( $recommendedPlugin['short_description'] ); |
| 31 | |
| 32 | $name = wp_strip_all_tags( $pluginTitle ); |
| 33 | |
| 34 | $downloadLink = isset( $recommendedPlugin['download_link'] ) ? $recommendedPlugin['download_link'] : null; |
| 35 | |
| 36 | $compatible_php = true; |
| 37 | $compatible_wp = true; |
| 38 | $tested_wp = true; |
| 39 | |
| 40 | $actionLinks = array(); |
| 41 | |
| 42 | $pluginStatus = '<span class="plugin-status-not-install">Not installed</span>'; |
| 43 | |
| 44 | if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { |
| 45 | $pluginProVer = $this->check_pro_version_exists( $recommendedPlugin ); |
| 46 | if ( false === $pluginProVer ) { |
| 47 | if ( 'yaypricing' === $recommendedPlugin['slug'] ) { |
| 48 | $installStatus = array( |
| 49 | 'status' => 'install', |
| 50 | 'url' => $recommendedPlugin['download_link'], |
| 51 | 'version' => '', |
| 52 | 'file' => $pluginProVer, |
| 53 | ); |
| 54 | } else { |
| 55 | $installStatus = install_plugin_install_status( $recommendedPlugin ); |
| 56 | } |
| 57 | } else { |
| 58 | $installStatus = array( |
| 59 | 'status' => 'latest_installed', |
| 60 | 'url' => false, |
| 61 | 'version' => '', |
| 62 | 'file' => $pluginProVer, |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | switch ( $installStatus['status'] ) { |
| 67 | case 'install': |
| 68 | if ( $installStatus['url'] ) { |
| 69 | if ( $compatible_php && $compatible_wp ) { |
| 70 | if ( 'yaypricing' === $recommendedPlugin['slug'] ) { |
| 71 | $actionLinks[] = sprintf( |
| 72 | '<a href="%s" target="_bank"><button class="button button-primary" data-install-url="%s" aria-label="%s">%s</button></a>', |
| 73 | esc_attr( $downloadLink ), |
| 74 | esc_attr( $downloadLink ), |
| 75 | /* translators: %s: Plugin name and version. */ |
| 76 | esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), |
| 77 | __( 'Install Now', 'ninjateam-whatsapp' ) |
| 78 | ); |
| 79 | } else { |
| 80 | $actionLinks[] = sprintf( |
| 81 | '<button class="install-now button button-primary" data-install-url="%s" aria-label="%s">%s</button>', |
| 82 | esc_attr( $downloadLink ), |
| 83 | /* translators: %s: Plugin name and version. */ |
| 84 | esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), |
| 85 | __( 'Install Now', 'ninjateam-whatsapp' ) |
| 86 | ); |
| 87 | } |
| 88 | } else { |
| 89 | $actionLinks[] = sprintf( |
| 90 | '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
| 91 | _x( 'Cannot Install', 'plugin', 'ninjateam-whatsapp' ) |
| 92 | ); |
| 93 | } |
| 94 | } |
| 95 | $pluginStatus = '<span class="plugin-status-not-install" data-plugin-url="' . esc_attr( $downloadLink ) . '">Not installed</span>'; |
| 96 | break; |
| 97 | |
| 98 | case 'update_available': |
| 99 | if ( $installStatus['url'] ) { |
| 100 | if ( $compatible_php && $compatible_wp ) { |
| 101 | if ( 'yaypricing' === $recommendedPlugin['slug'] ) { |
| 102 | $actionLinks[] = sprintf( |
| 103 | '<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>', |
| 104 | esc_attr( $installStatus['file'] ), |
| 105 | esc_attr( $recommendedPlugin['slug'] ), |
| 106 | esc_url( $installStatus['url'] ), |
| 107 | /* translators: %s: Plugin name and version. */ |
| 108 | esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), |
| 109 | esc_attr( $name ), |
| 110 | __( 'Update Now', 'ninjateam-whatsapp' ) |
| 111 | ); |
| 112 | } else { |
| 113 | $actionLinks[] = sprintf( |
| 114 | '<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>', |
| 115 | esc_attr( $installStatus['file'] ), |
| 116 | esc_attr( $recommendedPlugin['slug'] ), |
| 117 | esc_url( $installStatus['url'] ), |
| 118 | /* translators: %s: Plugin name and version. */ |
| 119 | esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), |
| 120 | esc_attr( $name ), |
| 121 | __( 'Update Now', 'ninjateam-whatsapp' ) |
| 122 | ); |
| 123 | } |
| 124 | } else { |
| 125 | $actionLinks[] = sprintf( |
| 126 | '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
| 127 | _x( 'Cannot Update', 'plugin', 'ninjateam-whatsapp' ) |
| 128 | ); |
| 129 | } |
| 130 | } |
| 131 | if ( is_plugin_active( $installStatus['file'] ) ) { |
| 132 | $pluginStatus = '<span class="plugin-status-active">Active</span>'; |
| 133 | } else { |
| 134 | $pluginStatus = '<span class="plugin-status-inactive" data-plugin-file="' . esc_attr( $installStatus['file'] ) . '">Inactive</span>'; |
| 135 | } |
| 136 | break; |
| 137 | |
| 138 | case 'latest_installed': |
| 139 | case 'newer_installed': |
| 140 | if ( is_plugin_active( $installStatus['file'] ) ) { |
| 141 | $pluginStatus = '<span class="plugin-status-active">Active</span>'; |
| 142 | $actionLinks[] = sprintf( |
| 143 | '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
| 144 | _x( 'Activated', 'plugin', 'ninjateam-whatsapp' ) |
| 145 | ); |
| 146 | } elseif ( current_user_can( 'activate_plugin', $installStatus['file'] ) ) { |
| 147 | $pluginStatus = '<span class="plugin-status-inactive" data-plugin-file="' . esc_attr( $installStatus['file'] ) . '">Inactive</span>'; |
| 148 | if ( $compatible_php && $compatible_wp ) { |
| 149 | $buttonText = __( 'Activate', 'ninjateam-whatsapp' ); |
| 150 | /* translators: %s: Plugin name. */ |
| 151 | $buttonLabel = _x( 'Activate %s', 'plugin', 'ninjateam-whatsapp' ); |
| 152 | $activateUrl = add_query_arg( |
| 153 | array( |
| 154 | '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $installStatus['file'] ), |
| 155 | 'action' => 'activate', |
| 156 | 'plugin' => $installStatus['file'], |
| 157 | ), |
| 158 | network_admin_url( 'plugins.php' ) |
| 159 | ); |
| 160 | |
| 161 | if ( is_network_admin() ) { |
| 162 | $buttonText = __( 'Network Activate', 'ninjateam-whatsapp' ); |
| 163 | /* translators: %s: Plugin name. */ |
| 164 | $buttonLabel = _x( 'Network Activate %s', 'plugin', 'ninjateam-whatsapp' ); |
| 165 | $activateUrl = add_query_arg( array( 'networkwide' => 1 ), $activateUrl ); |
| 166 | } |
| 167 | |
| 168 | $actionLinks[] = sprintf( |
| 169 | '<button class="button activate-now" data-plugin-file="%1$s" aria-label="%2$s">%3$s</button>', |
| 170 | esc_attr( $installStatus['file'] ), |
| 171 | esc_attr( sprintf( $buttonLabel, $recommendedPlugin['name'] ) ), |
| 172 | $buttonText |
| 173 | ); |
| 174 | } else { |
| 175 | $actionLinks[] = sprintf( |
| 176 | '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
| 177 | _x( 'Cannot Activate', 'plugin', 'ninjateam-whatsapp' ) |
| 178 | ); |
| 179 | } |
| 180 | } else { |
| 181 | $actionLinks[] = sprintf( |
| 182 | '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
| 183 | _x( 'Installed', 'plugin', 'ninjateam-whatsapp' ) |
| 184 | ); |
| 185 | } |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | $detailsLink = self_admin_url( |
| 191 | 'plugin-install.php?tab=plugin-information&plugin=' . $recommendedPlugin['slug'] . |
| 192 | '&TB_iframe=true&width=600&height=550' |
| 193 | ); |
| 194 | |
| 195 | $pluginIconUrl = $recommendedPlugin['icon']; |
| 196 | |
| 197 | /** |
| 198 | * Filters the install action links for a plugin. |
| 199 | * |
| 200 | * @since 2.7.0 |
| 201 | * |
| 202 | * @param string[] $actionLinks An array of plugin action links. Defaults are links to Details and Install Now. |
| 203 | * @param array $plugin The plugin currently being listed. |
| 204 | */ |
| 205 | $actionLinks = apply_filters( 'plugin_install_action_links', $actionLinks, $recommendedPlugin ); |
| 206 | |
| 207 | ?> |
| 208 | <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $recommendedPlugin['slug'] ); ?>"> |
| 209 | <?php |
| 210 | if ( ! $compatible_php || ! $compatible_wp ) { |
| 211 | echo '<div class="notice inline notice-error notice-alt"><p>'; |
| 212 | if ( ! $compatible_php && ! $compatible_wp ) { |
| 213 | echo esc_html__( 'This plugin doesn’t work with your versions of WordPress and PHP.', 'ninjateam-whatsapp' ); |
| 214 | if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
| 215 | printf( |
| 216 | /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
| 217 | ' ' . esc_html__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), |
| 218 | esc_url( self_admin_url( 'update-core.php' ) ), |
| 219 | esc_url( wp_get_update_php_url() ) |
| 220 | ); |
| 221 | wp_update_php_annotation( '</p><p><em>', '</em>' ); |
| 222 | } elseif ( current_user_can( 'update_core' ) ) { |
| 223 | printf( |
| 224 | /* translators: %s: URL to WordPress Updates screen. */ |
| 225 | ' ' . esc_html__( '<a href="%s">Please update WordPress</a>.', 'ninjateam-whatsapp' ), |
| 226 | esc_url( self_admin_url( 'update-core.php' ) ) |
| 227 | ); |
| 228 | } elseif ( current_user_can( 'update_php' ) ) { |
| 229 | printf( |
| 230 | /* translators: %s: URL to Update PHP page. */ |
| 231 | ' ' . esc_html__( '<a href="%s">Learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), |
| 232 | esc_url( wp_get_update_php_url() ) |
| 233 | ); |
| 234 | wp_update_php_annotation( '</p><p><em>', '</em>' ); |
| 235 | } |
| 236 | } elseif ( ! $compatible_wp ) { |
| 237 | echo esc_html__( 'This plugin doesn’t work with your version of WordPress.', 'ninjateam-whatsapp' ); |
| 238 | if ( current_user_can( 'update_core' ) ) { |
| 239 | printf( |
| 240 | /* translators: %s: URL to WordPress Updates screen. */ |
| 241 | ' ' . esc_html__( '<a href="%s">Please update WordPress</a>.', 'ninjateam-whatsapp' ), |
| 242 | esc_url( self_admin_url( 'update-core.php' ) ) |
| 243 | ); |
| 244 | } |
| 245 | } elseif ( ! $compatible_php ) { |
| 246 | echo esc_html__( 'This plugin doesn’t work with your version of PHP.', 'ninjateam-whatsapp' ); |
| 247 | if ( current_user_can( 'update_php' ) ) { |
| 248 | printf( |
| 249 | /* translators: %s: URL to Update PHP page. */ |
| 250 | ' ' . esc_html__( '<a href="%s">Learn more about updating PHP</a>.', 'ninjateam-whatsapp' ), |
| 251 | esc_url( wp_get_update_php_url() ) |
| 252 | ); |
| 253 | wp_update_php_annotation( '</p><p><em>', '</em>' ); |
| 254 | } |
| 255 | } |
| 256 | echo '</p></div>'; |
| 257 | } |
| 258 | ?> |
| 259 | <div class="plugin-card-top"> |
| 260 | <div class="name column-name"> |
| 261 | <h3> |
| 262 | <a href="<?php echo esc_url( $detailsLink ); ?>" class="thickbox open-plugin-details-modal"> |
| 263 | <?php echo wp_kses_post( $pluginTitle ); ?> |
| 264 | <img src="<?php echo esc_url( $pluginIconUrl ); ?>" class="plugin-icon" alt="" /> |
| 265 | </a> |
| 266 | </h3> |
| 267 | </div> |
| 268 | <div class="desc column-description"> |
| 269 | <p><?php echo wp_kses_post( $description ); ?></p> |
| 270 | </div> |
| 271 | </div> |
| 272 | <div class="plugin-card-bottom"> |
| 273 | <div class="vers column-rating"> |
| 274 | <?php echo sprintf( '<span class="plugin-status" >%s: %s</span>', esc_html( 'Status' ), wp_kses_post( $pluginStatus ) ); ?> |
| 275 | </div> |
| 276 | <div class="column-updated"> |
| 277 | <?php |
| 278 | if ( $actionLinks ) { |
| 279 | echo '<ul class="plugin-action-buttons"><li>' . wp_kses_post( implode( '</li><li>', $actionLinks ) ) . '</li></ul>'; |
| 280 | } |
| 281 | ?> |
| 282 | </div> |
| 283 | </div> |
| 284 | </div> |
| 285 | <?php } ?> |
| 286 |