Plugin Directory

Changeset 3355759


Ignore:
Timestamp:
09/04/2025 03:04:56 AM (7 months ago)
Author:
perfecty
Message:

Sync trunk

Location:
perfecty-push-notifications/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • perfecty-push-notifications/trunk/README.txt

    r3214080 r3355759  
    44Tags: Push Notifications, Web Push Notifications, Notifications, User engagement
    55Requires at least: 5.0
    6 Tested up to: 6.7
    7 Stable tag: 1.6.3
     6Tested up to: 6.8.2
     7Stable tag: 1.6.4
    88Requires PHP: 7.2
    99License: GPLv2 or later
     
    9595
    9696== Changelog ==
     97
     98= 1.6.4 =
     99* Publish notification when future posts are published
     100* Updated WordPress support to 6.8.2
    97101
    98102= 1.6.3 =
  • perfecty-push-notifications/trunk/admin/class-perfecty-push-admin.php

    r2682780 r3355759  
    632632
    633633                Perfecty_Push_Lib_Utils::show_message( '<strong>Perfecty Push</strong> ' . esc_html__( 'has sent a notification for the recently published post:', 'perfecty-push-notifications' ) . ' ' . $body );
     634            }
     635        }
     636    }
     637
     638    /**
     639     * Handles scheduled posts that are published by WP-Cron
     640     *
     641     * @param WP_Post $post The post being published
     642     * @since 1.6.4
     643     */
     644    public function on_publish_future_post( $post ) {
     645        $send_notification = ! empty( get_post_meta( $post->ID, '_perfecty_push_send_on_publish', true ) );
     646
     647        if ( $send_notification ) {
     648            $notification_title = get_post_meta( $post->ID, '_perfecty_push_notification_custom_title', true );
     649            $notification_body  = get_post_meta( $post->ID, '_perfecty_push_notification_custom_body', true );
     650
     651            $body               = trim( $notification_body ) ? $notification_body : html_entity_decode( get_the_title( $post ) );
     652            $url_to_open        = get_the_permalink( $post );
     653            $notification_title = trim( $notification_title ) ? $notification_title : '';
     654
     655            // We use this to check if the post has a thumbnail because has_post_thumbnail could return true even if no post thumbnail is set.
     656            $featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
     657            if ( ! empty( $featured_image_url ) ) {
     658                $post_thumbnail = get_the_post_thumbnail_url( $post->ID );
     659            } else {
     660                $post_thumbnail = $this->get_first_image_url( $post );
     661            }
     662
     663            $payload = Perfecty_Push_Lib_Payload::build( $body, $notification_title, $post_thumbnail, $url_to_open );
     664            $result  = Perfecty_Push_Lib_Push_Server::schedule_broadcast_async( $payload );
     665
     666            if ( $result === false ) {
     667                error_log( esc_html__( 'Could not schedule the broadcast async for scheduled post, check the logs', 'perfecty-push-notifications' ) );
     668            } else {
     669                // Reset the notification flag after sending the notification
     670                update_post_meta( $post->ID, '_perfecty_push_send_on_publish', false );
    634671            }
    635672        }
  • perfecty-push-notifications/trunk/includes/class-perfecty-push.php

    r2673866 r3355759  
    325325        $this->loader->add_action( 'save_post', $plugin_admin, 'on_save_post' );
    326326        $this->loader->add_action( 'transition_post_status', $plugin_admin, 'on_transition_post_status', 10, 3 );
     327        $this->loader->add_action( 'publish_future_post', $plugin_admin, 'on_publish_future_post', 10, 1 );
    327328        $this->loader->add_action( 'admin_notices', $plugin_admin, 'show_admin_notice' );
    328329        $this->loader->add_filter( 'plugin_action_links_' . PERFECTY_PUSH_BASENAME, $plugin_admin, 'plugin_directory_links' );
  • perfecty-push-notifications/trunk/perfecty-push.php

    r3214080 r3355759  
    1616 * Plugin URI:        https://wordpress.org/plugins/perfecty-push-notifications
    1717 * Description:       Self-hosted, Open Source and powerful <strong>Web Push Notifications</strong> plugin to send push notifications <strong>from your own server for free!</strong>
    18  * Version:           1.6.3
     18 * Version:           1.6.4
    1919 * Author:            Perfecty
    2020 * Author URI:        https://perfecty.org
     
    3535 * Rename this for your plugin and update it as you release new versions.
    3636 */
    37 define( 'PERFECTY_PUSH_VERSION', '1.6.3' );
     37define( 'PERFECTY_PUSH_VERSION', '1.6.4' );
    3838
    3939/**
Note: See TracChangeset for help on using the changeset viewer.