|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Plugin Name: Cloudinary Update Tester |
| 4 | + * Plugin URI: |
| 5 | + * Description: Test Cloudinary Plugin Update Process (This will deactivate itself, once activated.) |
| 6 | + * Version: 1.0 |
| 7 | + * Author: XWP |
| 8 | + * Author URI: https://xwp.co |
| 9 | + * Text Domain: cld-update-tester |
| 10 | + * License: GPL2+ |
| 11 | + * |
| 12 | + * @package Cloudinary |
| 13 | + */ |
| 14 | + |
| 15 | +// If this file is called directly, abort. |
| 16 | +if ( ! defined( 'WPINC' ) ) { |
| 17 | + die; |
| 18 | +} |
| 19 | + |
| 20 | + |
| 21 | +// Exit if accessed directly. |
| 22 | +if ( ! defined( 'ABSPATH' ) ) { |
| 23 | + exit; |
| 24 | +} |
| 25 | + |
| 26 | +/** |
| 27 | + * Alter the update plugins object. |
| 28 | + * |
| 29 | + * @param object $data plugin update data. |
| 30 | + * |
| 31 | + * @return object |
| 32 | + */ |
| 33 | +function cld_test_check_update( $data ) { |
| 34 | + if ( ! empty( $data->no_update ) ) { |
| 35 | + $slug = 'cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php'; |
| 36 | + if ( ! empty( $data->no_update[ $slug ] ) ) { |
| 37 | + $file = plugin_dir_path( __FILE__ ) . 'cloudinary.zip'; |
| 38 | + $data->no_update[ $slug ]->package = $file; |
| 39 | + $data->no_update[ $slug ]->new_version = 2.0; |
| 40 | + $data->response[ $slug ] = $data->no_update[ $slug ]; |
| 41 | + unset( $data->no_update[ $slug ] ); |
| 42 | + deactivate_plugins( 'cloudinary-update-tester/cloudinary-update-tester.php' ); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + return $data; |
| 47 | +} |
| 48 | + |
| 49 | +add_filter( 'pre_set_site_transient_update_plugins', 'cld_test_check_update', 100 ); |
| 50 | + |
| 51 | +/** |
| 52 | + * Delete the update transient on activation. |
| 53 | + */ |
| 54 | +function cld_test_init_update() { |
| 55 | + delete_site_transient( 'update_plugins' ); |
| 56 | +} |
| 57 | + |
| 58 | +register_activation_hook( __FILE__, 'cld_test_init_update' ); |
0 commit comments