Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions cloudinary-update-tester/cloudinary-update-tester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Plugin Name: Cloudinary Update Tester
* Plugin URI:
* Description: Test Cloudinary Plugin Update Process (This will deactivate itself, once activated.)
* Version: 1.0
* Author: XWP
* Author URI: https://xwp.co
* Text Domain: cld-update-tester
* License: GPL2+
*
* @package Cloudinary
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}


// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Alter the update plugins object.
*
* @param object $data plugin update data.
*
* @return object
*/
function cld_test_check_update( $data ) {
if ( ! empty( $data->no_update ) ) {
$slug = 'cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php';
if ( ! empty( $data->no_update[ $slug ] ) ) {
$file = plugin_dir_path( __FILE__ ) . 'cloudinary.zip';
$data->no_update[ $slug ]->package = $file;
$data->no_update[ $slug ]->new_version = 2.0;
$data->response[ $slug ] = $data->no_update[ $slug ];
unset( $data->no_update[ $slug ] );
deactivate_plugins( 'cloudinary-update-tester/cloudinary-update-tester.php' );
}
}

return $data;
}

add_filter( 'pre_set_site_transient_update_plugins', 'cld_test_check_update', 100 );

/**
* Delete the update transient on activation.
*/
function cld_test_init_update() {
delete_site_transient( 'update_plugins' );
}

register_activation_hook( __FILE__, 'cld_test_init_update' );
5 changes: 5 additions & 0 deletions cloudinary-update-tester/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This tests the update process of the Cloudinary plugin.

To create a new test package, simply add the plugin zip package here and name it cloudinary.zip

Then activate this plugin in WordPress. The cloudinary plugin listing will show an available update and this plugin will disable itself.