helpers
3 years ago
routes
3 years ago
src
3 years ago
config.php
3 years ago
helpers.php
3 years ago
hooks.php
3 years ago
hooks.php
34 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Declare any actions and filters here. USE THIS SPARINGLY. |
| 4 | * |
| 5 | * In most cases you should use a service provider, but in cases where you |
| 6 | * just need to add an action/filter and forget about it you can add it here. |
| 7 | * |
| 8 | * @package SureCart |
| 9 | */ |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | |
| 15 | // register uninstall. |
| 16 | register_uninstall_hook( SURECART_PLUGIN_FILE, 'surecart_uninstall' ); |
| 17 | function surecart_uninstall() { |
| 18 | if ( (bool) get_option( 'sc_uninstall', false ) ) { |
| 19 | \SureCart::activation()->uninstall(); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | // redirect to an admin page that they can't access instead of homepage. |
| 24 | // Otherwise the homepage if they cannot access admin. |
| 25 | add_filter( |
| 26 | 'surecart.middleware.user.can.redirect_url', |
| 27 | function( $url ) { |
| 28 | if ( current_user_can( 'read' ) ) { |
| 29 | return get_admin_url() . 'admin.php?page=sc-denied'; |
| 30 | } |
| 31 | return $url; |
| 32 | } |
| 33 | ); |
| 34 |