| @@ -351,15 +351,16 @@ | ||
| 351 | 351 | // don't show an update if the plugin isn't installed |
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 356 | - $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 355 | + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 356 | + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 357 | + $plugin->slug = explode( '/', $folder )[0]; | |
| 357 | 358 | |
| 358 | 359 | if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { |
| 359 | - $slug = explode( '/', $folder ); | |
| 360 | - $plugin->slug = $slug[0]; | |
| 361 | 360 | $transient->response[ $folder ] = $plugin; |
| 361 | + } else { | |
| 362 | + $transient->no_update[ $folder ] = $plugin; | |
| 362 | 363 | } |
| 363 | 364 | |
| 364 | 365 | $transient->checked[ $folder ] = $wp_version; |
| 365 | 366 | |
| @@ -1023,10 +1024,8 @@ | ||
| 1023 | 1024 | * |
| 1024 | 1025 | * @since 3.04.02 |
| 1025 | 1026 | */ |
| 1026 | 1027 | protected static function install_addon() { |
| 1027 | - FrmAppHelper::permission_check( 'install_plugins' ); | |
| 1028 | - | |
| 1029 | 1028 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 1030 | 1029 | |
| 1031 | 1030 | $download_url = self::get_current_plugin(); |
| 1032 | 1031 | |
| @@ -1179,17 +1178,13 @@ | ||
| 1179 | 1178 | * |
| 1180 | 1179 | * @return bool |
| 1181 | 1180 | */ |
| 1182 | 1181 | public static function can_install_addon_api() { |
| 1183 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 1184 | - return false; | |
| 1185 | - } | |
| 1186 | - | |
| 1187 | 1182 | // Verify params present (auth & download link). |
| 1188 | 1183 | $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' ); |
| 1189 | 1184 | $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' ); |
| 1190 | 1185 | |
| 1191 | - if ( empty( $post_auth ) || empty( $post_url ) ) { | |
| 1186 | + if ( ! $post_auth || ! $post_url ) { | |
| 1192 | 1187 | return false; |
| 1193 | 1188 | } |
| 1194 | 1189 | |
| 1195 | 1190 | // Verify auth. |
| @@ -1260,9 +1255,11 @@ | ||
| 1260 | 1255 | } |
| 1261 | 1256 | |
| 1262 | 1257 | $addon = self::get_addon( $plugin ); |
| 1263 | 1258 | $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args ); |
| 1264 | - self::addon_upgrade_link( $addon, $upgrade_link ); | |
| 1259 | + | |
| 1260 | + $upgrade_link_args['link'] = $upgrade_link; | |
| 1261 | + self::addon_upgrade_link( $addon, $upgrade_link_args ); | |
| 1265 | 1262 | } |
| 1266 | 1263 | |
| 1267 | 1264 | /** |
| 1268 | 1265 | * Render a conditional action button for an add on |
| @@ -1284,13 +1281,17 @@ | ||
| 1284 | 1281 | |
| 1285 | 1282 | /** |
| 1286 | 1283 | * @since 4.09.01 |
| 1287 | 1284 | * |
| 1288 | - * @param array|false $addon | |
| 1285 | + * @param array|false $addon | |
| 1286 | + * @param string|array $upgrade_link | |
| 1289 | 1287 | * |
| 1290 | 1288 | * @return void |
| 1291 | 1289 | */ |
| 1292 | 1290 | protected static function addon_upgrade_link( $addon, $upgrade_link ) { |
| 1291 | + $atts = is_array( $upgrade_link ) ? $upgrade_link : array(); | |
| 1292 | + $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link; | |
| 1293 | + | |
| 1293 | 1294 | if ( $addon ) { |
| 1294 | 1295 | $upgrade_link .= '&utm_content=' . $addon['slug']; |
| 1295 | 1296 | } |
| 1296 | 1297 | |
| @@ -1297,10 +1298,15 @@ | ||
| 1297 | 1298 | if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) { |
| 1298 | 1299 | // Solutions will go to a separate page. |
| 1299 | 1300 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1300 | 1301 | } |
| 1302 | + | |
| 1303 | + $class = ! empty( $atts['class'] ) ? $atts['class'] : ''; | |
| 1304 | + if ( strpos( $class, 'frm-button' ) === false ) { | |
| 1305 | + $class .= ' frm-button-secondary frm-button-sm'; | |
| 1306 | + } | |
| 1301 | 1307 | ?> |
| 1302 | - <a class="install-now button frm-button-secondary frm-button-sm" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>"> | |
| 1308 | + <a class="install-now button <?php echo esc_attr( $class ); ?>" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>"> | |
| 1303 | 1309 | <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?> |
| 1304 | 1310 | </a> |
| 1305 | 1311 | <?php |
| 1306 | 1312 | } |