Skip to content

Commit

Permalink
bump: version
Browse files Browse the repository at this point in the history
  • Loading branch information
lightningspirit committed Mar 27, 2024
1 parent 377655e commit f3f8d1f
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
**Contributors:** lightningspirit\
**Tags:** email, logging\
**Requires at least:** 4.5\
**Tested up to:** 6.4\
**Tested up to:** 6.4.3\
**Requires PHP:** 7.4\
**Stable tag:** 0.3.1\
**Stable tag:** 0.3.7\
**License:** GPLv2 or later\
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

Expand Down
Binary file added assets/banner-1544x500.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banner-772x250.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion email-logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Email Logs
* Plugin URI: https://github.com/moveyourdigital/wp-email-logs
* Description: Log all emails sent from WordPress
* Version: 0.3.1
* Version: 0.3.7
* Requires: PHP: 7.4
* Author: Move Your Digital, Inc.
* Author URI: https://moveyourdigital.com
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: lightningspirit
Tags: email, logging
Requires at least: 4.5
Tested up to: 6.4
Tested up to: 6.4.3
Requires PHP: 7.4
Stable tag: 0.3.1
Stable tag: 0.3.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down
84 changes: 62 additions & 22 deletions updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,37 @@
exit;
}

/**
* Gets and updates plugin Update URI
*
* @since 0.3.5
*/
add_filter(
'plugin_update_uri_' . plugin_basename( __DIR__ ),
function ( $delete = false ) {
if ( true === $delete ) {
delete_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ) );
}

$update_uri = get_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ) );

if ( ! $update_uri ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

$basename_file = apply_filters( 'plugin_basename_file_' . plugin_basename( __DIR__ ), '' );

$plugin_data = get_plugin_data( trailingslashit( WP_PLUGIN_DIR ) . $basename_file );
$update_uri = $plugin_data['UpdateURI'];

update_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ), $update_uri );
}

return $update_uri;
}
);

/**
* Fetch and return plugin data from declared remote
*
Expand All @@ -20,7 +51,7 @@
'plugin_update_remote_data_' . plugin_basename( __DIR__ ),
function ( $default_result = '' ) {
$remote_data = wp_remote_get(
get_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ) ),
apply_filters( 'plugin_update_uri_' . plugin_basename( __DIR__ ), null ),
array(
'timeout' => 10,
'headers' => array(
Expand Down Expand Up @@ -64,9 +95,17 @@ function ( $result, $action, $args ) {
return $result;
}

$result = apply_filters( 'plugin_update_remote_data_' . plugin_basename( __DIR__ ), $result );
$result->slug = plugin_basename( __DIR__ );
$result->trunk = $remote->download_url;
$result = apply_filters( 'plugin_update_remote_data_' . plugin_basename( __DIR__ ), $result );
$result->slug = plugin_basename( __DIR__ );
$result->trunk = $result->download_url;
$result->sections = array(
'description' => $result->sections->description,
'installation' => $result->sections->installation,
);
$result->banners = array(
'low' => $result->banners->low,
'high' => $result->banners->high,
);

return $result;
},
Expand All @@ -84,25 +123,14 @@ function ( $result, $action, $args ) {
add_action(
'init',
function () {
$basename_file = apply_filters( 'plugin_basename_file_' . plugin_basename( __DIR__ ), '' );
$update_uri = get_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ) );

if ( ! $update_uri ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

$plugin_data = get_plugin_data( WP_PLUGIN_DIR . $basename_file );
$update_uri = $plugin_data['UpdateURI'];

add_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ), $update_uri );
}

$hostname = wp_parse_url( sanitize_url( $update_uri ), PHP_URL_HOST );
$update_uri = apply_filters( 'plugin_update_uri_' . plugin_basename( __DIR__ ), null );
$hostname = wp_parse_url( sanitize_url( $update_uri ), PHP_URL_HOST );

add_filter(
'update_plugins_' . $hostname,
function ( $update, $plugin_data, $plugin_file ) {
$basename_file = apply_filters( 'plugin_basename_file_' . plugin_basename( __DIR__ ), '' );

if ( $plugin_file !== $basename_file ) {
return $update;
}
Expand All @@ -111,9 +139,21 @@ function ( $update, $plugin_data, $plugin_file ) {
return $update;
}

$remote_data = apply_filter( 'plugin_update_remote_data_' . plugin_basename( __DIR__ ), $result );
$remote_data = apply_filters( 'plugin_update_remote_data_' . plugin_basename( __DIR__ ), $update );

if ( ! $remote_data ) {
return $update;
}

if ( version_compare( $remote_data->version, $plugin_data['Version'], '<=' ) ) {
return $update;
}

if ( version_compare( get_bloginfo( 'version' ), $remote_data->requires, '<' ) ) {
return $update;
}

if ( ! version_compare( $plugin_data['Version'], $remote_data->version, '<' ) ) {
if ( version_compare( PHP_VERSION, $remote_data->requires_php, '<' ) ) {
return $update;
}

Expand Down Expand Up @@ -168,7 +208,7 @@ function ( $upgrader_object, $options ) {
if ( 'update' === $options['action'] && 'plugin' === $options['type'] ) {
foreach ( $options['plugins'] as $each_plugin ) {
if ( $each_plugin === $basename_file ) {
delete_option( 'plugin_update_uri_' . plugin_basename( __DIR__ ) );
apply_filters( 'plugin_update_uri_' . plugin_basename( __DIR__ ), true );
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions wp-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"slug": "wp-email-logs",
"author": "<a href='https://github.com/moveyourdigital'>Move Your Digital</a>",
"author_profile": "https://github.com/moveyourdigital",
"version": "0.3.1",
"version": "0.3.7",
"download_url": "https://github.com/moveyourdigital/wp-email-logs/archive/refs/heads/main.zip",
"requires": "5.8",
"tested": "6.4",
"tested": "6.4.3",
"requires_php": "7.4",
"last_updated": "2024-03-27 18:35:00",
"last_updated": "2024-03-27 22:45:00",
"sections": {
"description": "This simple plugin does nothing, only gets updates from a custom server",
"installation": "Click the activate button and that's it."
"description": "Log all emails sent from WordPress.",
"installation": "Click the <i>activate</i> button. No further configuration."
},
"banners": {
"low": "https://github.com/moveyourdigital/wp-email-logs/raw/main/assets/banner-772x250.jpg",
"high": "https://github.com/moveyourdigital/wp-email-logs/raw/main/assets/banner-1544x500.jpg"
}
}

0 comments on commit f3f8d1f

Please sign in to comment.