Plugin Directory

Changeset 3162486


Ignore:
Timestamp:
10/04/2024 06:41:02 AM (18 months ago)
Author:
givingxcelerator
Message:

Redirect to a specific page after activation

Location:
givingx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • givingx/tags/1.0.0/admin/class-givingx-admin.php

    r3146804 r3162486  
    243243    }   
    244244
     245    /**
     246     * Redirect to a specific page after activation
     247     *
     248     * @since    1.0.0
     249     */
     250    public function givingx_redirect_after_activation() {
     251        // Check if the transient is set
     252        if (get_transient('givingx_activation_redirect')) {
     253            // Delete the transient to avoid future redirects
     254            delete_transient('givingx_activation_redirect');
     255           
     256            // Prevent redirect on multisite activation
     257            if (is_network_admin() || isset($_GET['activate-multi'])) {
     258                return;
     259            }
     260   
     261            // Redirect to your desired page
     262            wp_redirect(admin_url('admin.php?page=givingx'));
     263            exit;
     264        }
     265    }   
     266
    245267}
  • givingx/tags/1.0.0/includes/class-givingx-activator.php

    r3146804 r3162486  
    3333     */
    3434    public static function activate() {
    35 
     35        // Set a transient to trigger redirect after activation
     36        set_transient('givingx_activation_redirect', true, 30);
    3637    }
    3738
  • givingx/tags/1.0.0/includes/class-givingx.php

    r3146804 r3162486  
    171171
    172172        $plugin_admin = new Givingx_Admin( $this->get_plugin_name(), $this->get_version() );
    173        
     173
     174        /**
     175         * Plugin Page Redirect
     176         */     
     177        $this->loader->add_action( 'admin_init', $plugin_admin, 'givingx_redirect_after_activation' );
     178
    174179        /**
    175180         * Admin Menu Ui Prepare
  • givingx/trunk/admin/class-givingx-admin.php

    r3146804 r3162486  
    243243    }   
    244244
     245    /**
     246     * Redirect to a specific page after activation
     247     *
     248     * @since    1.0.0
     249     */
     250    public function givingx_redirect_after_activation() {
     251        // Check if the transient is set
     252        if (get_transient('givingx_activation_redirect')) {
     253            // Delete the transient to avoid future redirects
     254            delete_transient('givingx_activation_redirect');
     255           
     256            // Prevent redirect on multisite activation
     257            if (is_network_admin() || isset($_GET['activate-multi'])) {
     258                return;
     259            }
     260   
     261            // Redirect to your desired page
     262            wp_redirect(admin_url('admin.php?page=givingx'));
     263            exit;
     264        }
     265    }   
     266
    245267}
  • givingx/trunk/includes/class-givingx-activator.php

    r3146804 r3162486  
    3333     */
    3434    public static function activate() {
    35 
     35        // Set a transient to trigger redirect after activation
     36        set_transient('givingx_activation_redirect', true, 30);
    3637    }
    3738
  • givingx/trunk/includes/class-givingx.php

    r3146804 r3162486  
    171171
    172172        $plugin_admin = new Givingx_Admin( $this->get_plugin_name(), $this->get_version() );
    173        
     173
     174        /**
     175         * Plugin Page Redirect
     176         */     
     177        $this->loader->add_action( 'admin_init', $plugin_admin, 'givingx_redirect_after_activation' );
     178
    174179        /**
    175180         * Admin Menu Ui Prepare
Note: See TracChangeset for help on using the changeset viewer.