Skip to content

Commit 1bcf86e

Browse files
author
David Cramer
authored
Merge pull request #46 from cloudinary/feature/test-package
add test package plugin
2 parents 919b7ba + cba76a4 commit 1bcf86e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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' );
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This tests the update process of the Cloudinary plugin.
2+
3+
To create a new test package, simply add the plugin zip package here and name it cloudinary.zip
4+
5+
Then activate this plugin in WordPress. The cloudinary plugin listing will show an available update and this plugin will disable itself.

0 commit comments

Comments
 (0)