PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.17.0
GiveWP – Donation Plugin and Fundraising Platform v2.17.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Onboarding / Setup / Page.php
Page.php
107 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Onboarding class
5 *
6 * @package Give
7 */
8
9 namespace Give\Onboarding\Setup;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Organizes WordPress actions and helper methods for Onboarding.
15 *
16 * @since 2.8.0
17 */
18 class Page {
19
20 const ENABLED = 'enabled';
21 const DISABLED = 'disabled';
22
23 /**
24 * Dissmiss the Setup Page.
25 *
26 * @since 2.8.0
27 */
28 public function dismissSetupPage() {
29 if ( wp_verify_nonce( $_GET['_wpnonce'], 'dismiss_setup_page' ) ) {
30 give_update_option( 'setup_page_enabled', self::DISABLED );
31
32 wp_redirect( add_query_arg( [ 'post_type' => 'give_forms' ], admin_url( 'edit.php' ) ) );
33 exit;
34 }
35 }
36
37 /**
38 * Helper method for checking the if the Setup Page is enabled.
39 *
40 * @since 2.8.0
41 *
42 * @return string
43 */
44 public static function getSetupPageEnabledOrDisabled() {
45 return give_get_option( 'setup_page_enabled', self::DISABLED );
46 }
47
48 /**
49 * Add Setup submenu page to admin menu
50 *
51 * @since 2.8.0
52 */
53 public function add_page() {
54 add_submenu_page(
55 'edit.php?post_type=give_forms',
56 esc_html__( 'Setup GiveWP', 'give' ),
57 esc_html__( 'Setup', 'give' ),
58 'manage_give_settings',
59 'give-setup',
60 [ $this, 'render_page' ],
61 $position = 0
62 );
63 }
64
65 /**
66 * Enqueue scripts and styles.
67 *
68 * @since 2.8.0
69 */
70 public function enqueue_scripts() {
71
72 if ( ! isset( $_GET['page'] ) || 'give-setup' !== $_GET['page'] ) {
73 return;
74 }
75
76 wp_enqueue_style(
77 'give-admin-setup-style',
78 GIVE_PLUGIN_URL . 'assets/dist/css/admin-setup.css',
79 [],
80 GIVE_VERSION
81 );
82 wp_enqueue_style(
83 'give-admin-setup-google-fonts',
84 'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap',
85 [],
86 GIVE_VERSION
87 );
88 wp_enqueue_script(
89 'give-admin-setup-script',
90 GIVE_PLUGIN_URL . 'assets/dist/js/admin-setup.js',
91 [ 'jquery' ],
92 GIVE_VERSION,
93 $in_footer = true
94 );
95 }
96
97 /**
98 * Render the submenu page
99 *
100 * @since 2.8.0
101 */
102 public function render_page() {
103 $view = give()->make( PageView::class );
104 echo $view->render();
105 }
106 }
107