PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.2
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / uninstall.php

uninstall.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.2, at uninstall.php

69 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall.php for cleaning plugin database.
4 *
5 * Trigger the file when plugin is deleted.
6 *
7 * - This method should be static
8 * - Check if the $_REQUEST content actually is the plugin name
9 * - Run an admin referrer check to make sure it goes through authentication
10 * - Verify the output of $_GET makes sense
11 * - Repeat with other user roles. Best directly by using the links/query string parameters.
12 * - Repeat things for multisite. Once for a single site in the network, once sitewide.
13 *
14 * @link https://wpsmartpost.com/
15 * @since 2.0.0
16 *
17 * @package Smart_Post_Show
18 */
19
20 // If uninstall not called from WordPress, then exit.
21 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
22 exit;
23 }
24
25 /**
26 * Collect and delete all data of the plugin.
27 *
28 * @return void
29 */
30 function sp_post_carousel_data_delete() {
31 // Delete plugin option settings.
32 $option_name = 'sp_post_carousel_settings';
33 delete_option( $option_name );
34 // For a multi-site.
35 delete_site_option( $option_name );
36 // Delete Smart Post Show post type.
37 $post_carousel_posts = get_posts(
38 array(
39 'numberposts' => -1,
40 'post_type' => 'sp_post_carousel',
41 'post_status' => 'any',
42 )
43 );
44 foreach ( $post_carousel_posts as $post_carousel ) {
45 wp_delete_post( $post_carousel->ID, true );
46 }
47
48 // Delete Smart Post Show post meta.
49 delete_post_meta_by_key( 'sp_pcp_layouts' );
50 delete_post_meta_by_key( 'sp_pcp_view_options' );
51
52 // Delete offer banner related option keys.
53 delete_option( 'shapedplugin_offer_banner_dismissed_black_friday_2025' );
54 delete_option( 'shapedplugin_offer_banner_dismissed_new_year_2026' );
55
56 // Unschedule previously scheduled event.
57 $timestamp = wp_next_scheduled( 'smart_post_show_weekly_scheduled_events' );
58 wp_unschedule_event( $timestamp, 'smart_post_show_weekly_scheduled_events', array() );
59 }
60
61 // Load Smart Post Show file.
62 require plugin_dir_path( __FILE__ ) . '/main.php';
63 $pcp_options = get_option( 'sp_post_carousel_settings' );
64 $delete_data = isset( $pcp_options['pcp_delete_all_data'] ) ? $pcp_options['pcp_delete_all_data'] : false;
65
66 if ( $delete_data ) {
67 sp_post_carousel_data_delete();
68 }
69