PluginProbe
Faust.js / 0.7.1
Faust.js v0.7.1
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
faustwp / includes / utilities / callbacks.php

callbacks.php in Faust.js 0.7.1, at includes/utilities/callbacks.php

71 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Utility callbacks.
4 *
5 * @package FaustWP
6 */
7
8 namespace WPE\FaustWP\Utilities;
9
10 use function WPE\FaustWP\Settings\{
11 get_secret_key,
12 faustwp_get_settings,
13 faustwp_update_setting
14 };
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 register_activation_hook( FAUSTWP_FILE, __NAMESPACE__ . '\\handle_activation' );
21 /**
22 * Callback for WordPress register_activation_hook() function.
23 *
24 * 1. Deactivate the WPE Headless plugin if it's active.
25 * 2. Set default settings if no settings exist.
26 * 3. Set secret_key if does not exist.
27 * 4. Flush rewrite rules.
28 *
29 * @todo is flush_rewrite_rules() needed?
30 *
31 * @link https://developer.wordpress.org/reference/functions/register_activation_hook/
32 *
33 * @return void
34 */
35 function handle_activation() {
36 if ( is_plugin_active( 'wpe-headless/wpe-headless.php' ) ) {
37 deactivate_plugins( 'wpe-headless/wpe-headless.php', true );
38 }
39
40 $secret_key = get_secret_key();
41 $settings = faustwp_get_settings();
42
43 if ( empty( $settings ) ) {
44 faustwp_update_setting( 'disable_theme', '1' );
45 faustwp_update_setting( 'enable_rewrites', '1' );
46 faustwp_update_setting( 'enable_redirects', '1' );
47 }
48
49 if ( ! $secret_key ) {
50 faustwp_update_setting( 'secret_key', wp_generate_uuid4() );
51 }
52
53 flush_rewrite_rules();
54 }
55
56 register_deactivation_hook( FAUSTWP_FILE, __NAMESPACE__ . '\\handle_deactivation' );
57 /**
58 * Callback for WordPress register_deactivation_hook() function.
59 *
60 * Flush rewrite rules on plugin deactivation.
61 *
62 * @todo is flush_rewrite_rules() needed?
63 *
64 * @link https://developer.wordpress.org/reference/functions/register_deactivation_hook/
65 *
66 * @return void
67 */
68 function handle_deactivation() {
69 flush_rewrite_rules();
70 }
71