Plugin Directory

Changeset 2932187


Ignore:
Timestamp:
06/29/2023 10:24:37 AM (3 years ago)
Author:
appfulapp
Message:

Updated post-update/save processing hook

Location:
appful-app
Files:
3 deleted
3 edited
73 copied

Legend:

Unmodified
Added
Removed
  • appful-app/tags/3.1.6/appful-app.php

    r2930682 r2932187  
    1212 * Plugin URI:        https://appful.io
    1313 * Description:       Appful® is the number 1 plugin for turning your WordPress Content into a native, beautiful app on iOS & Android in under 5 minutes.
    14  * Version:           3.1.5
     14 * Version:           3.1.6
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/tags/3.1.6/includes/hooks/PostHook.php

    r2920030 r2932187  
    1717    public function init() {
    1818        add_action(
    19             "transition_post_status",
    20             function ( string $new_status, string $old_status, WP_Post $post ) {
    21                 $this->on_post_transition( $new_status, $old_status, $post );
     19            "wp_after_insert_post",
     20            function ( int $post_id, WP_Post $post ) {
     21                $this->after_save_post( $post );
    2222            },
    2323            99,
    24             3,
     24            2,
    2525        );
    26 
    27 //      add_action(
    28 //          "save_post",
    29 //          function ( int $post_id, WP_Post $post, bool $update ) {
    30 //              $this->on_save_post( $post_id, $post, $update );
    31 //          },
    32 //          10,
    33 //          3
    34 //      );
    3526
    3627        add_action(
     
    4435    }
    4536
    46     private function on_post_transition( string $new_status, ?string $old_status, WP_Post $post ) {
     37    private function on_delete_post( int $post_id, WP_Post $post ) {
     38        if ( $post->post_type != "post" ) {
     39            return;
     40        }
     41
     42        Logger::log( "Post with id " . $post->ID . " deleted!" );
     43
     44        $this->use_case_manager->post_delete_use_case()->invoke( $post_id );
     45    }
     46
     47    private function after_save_post( WP_Post $post ) {
    4748        if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
    4849            return;
     
    5758        }
    5859
    59         Logger::log( "Post with id " . $post->ID . " moved from " . ( ( $old_status == null ) ? "null" : $old_status ) . " to " . $new_status . "!" );
    60 
    61         $domain_post = PostMapper::to_domain( $post );
    62         $this->use_case_manager->post_save_use_case()->invoke( $domain_post );
    63     }
    64 
    65     private function on_delete_post( int $post_id, WP_Post $post ) {
    66         if ( $post->post_type != "post" ) {
    67             return;
    68         }
    69 
    70         Logger::log( "Post with id " . $post->ID . " deleted!" );
    71 
    72         $this->use_case_manager->post_delete_use_case()->invoke( $post_id );
    73     }
    74 
    75     private function on_save_post( int $post_id, WP_Post $post, bool $update ) {
    76         if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
    77             return;
    78         }
    79 
    80         if ( $post->post_type != "post" ) {
    81             return;
    82         }
    83 
    84         if ( $post->post_status == "auto-draft" || $post->post_status == "inherit" ) {
    85             return;
    86         }
    87 
    88         $this->send_new_post( $post );
    89     }
    90 
    91     private function send_new_post( WP_Post $post ) {
    92         Logger::log( "Post with id " . $post->ID . " saved!" );
     60        Logger::log( "Post with id " . $post->ID . " inserted with status " . $post->post_status . "!" );
    9361
    9462        $domain_post = PostMapper::to_domain( $post );
  • appful-app/tags/3.1.6/readme.txt

    r2930682 r2932187  
    66Tested up to: 6.2
    77Requires PHP: 7.4
    8 Stable tag: 3.1.5
     8Stable tag: 3.1.6
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • appful-app/trunk/appful-app.php

    r2930682 r2932187  
    1212 * Plugin URI:        https://appful.io
    1313 * Description:       Appful® is the number 1 plugin for turning your WordPress Content into a native, beautiful app on iOS & Android in under 5 minutes.
    14  * Version:           3.1.5
     14 * Version:           3.1.6
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/trunk/includes/hooks/PostHook.php

    r2920030 r2932187  
    1717    public function init() {
    1818        add_action(
    19             "transition_post_status",
    20             function ( string $new_status, string $old_status, WP_Post $post ) {
    21                 $this->on_post_transition( $new_status, $old_status, $post );
     19            "wp_after_insert_post",
     20            function ( int $post_id, WP_Post $post ) {
     21                $this->after_save_post( $post );
    2222            },
    2323            99,
    24             3,
     24            2,
    2525        );
    26 
    27 //      add_action(
    28 //          "save_post",
    29 //          function ( int $post_id, WP_Post $post, bool $update ) {
    30 //              $this->on_save_post( $post_id, $post, $update );
    31 //          },
    32 //          10,
    33 //          3
    34 //      );
    3526
    3627        add_action(
     
    4435    }
    4536
    46     private function on_post_transition( string $new_status, ?string $old_status, WP_Post $post ) {
     37    private function on_delete_post( int $post_id, WP_Post $post ) {
     38        if ( $post->post_type != "post" ) {
     39            return;
     40        }
     41
     42        Logger::log( "Post with id " . $post->ID . " deleted!" );
     43
     44        $this->use_case_manager->post_delete_use_case()->invoke( $post_id );
     45    }
     46
     47    private function after_save_post( WP_Post $post ) {
    4748        if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
    4849            return;
     
    5758        }
    5859
    59         Logger::log( "Post with id " . $post->ID . " moved from " . ( ( $old_status == null ) ? "null" : $old_status ) . " to " . $new_status . "!" );
    60 
    61         $domain_post = PostMapper::to_domain( $post );
    62         $this->use_case_manager->post_save_use_case()->invoke( $domain_post );
    63     }
    64 
    65     private function on_delete_post( int $post_id, WP_Post $post ) {
    66         if ( $post->post_type != "post" ) {
    67             return;
    68         }
    69 
    70         Logger::log( "Post with id " . $post->ID . " deleted!" );
    71 
    72         $this->use_case_manager->post_delete_use_case()->invoke( $post_id );
    73     }
    74 
    75     private function on_save_post( int $post_id, WP_Post $post, bool $update ) {
    76         if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
    77             return;
    78         }
    79 
    80         if ( $post->post_type != "post" ) {
    81             return;
    82         }
    83 
    84         if ( $post->post_status == "auto-draft" || $post->post_status == "inherit" ) {
    85             return;
    86         }
    87 
    88         $this->send_new_post( $post );
    89     }
    90 
    91     private function send_new_post( WP_Post $post ) {
    92         Logger::log( "Post with id " . $post->ID . " saved!" );
     60        Logger::log( "Post with id " . $post->ID . " inserted with status " . $post->post_status . "!" );
    9361
    9462        $domain_post = PostMapper::to_domain( $post );
  • appful-app/trunk/readme.txt

    r2930682 r2932187  
    66Tested up to: 6.2
    77Requires PHP: 7.4
    8 Stable tag: 3.1.5
     8Stable tag: 3.1.6
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.