PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.2
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.2
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / upgrades / class-charitable-upgrade-page.php

class-charitable-upgrade-page.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.2, at includes/upgrades/class-charitable-upgrade-page.php

201 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The class that is responsible for registering the Upgrades page.
4 *
5 * @package Charitable/Classes/Charitable_Upgrade_Page
6 * @version 1.3.0
7 * @author David Bisset
8 * @copyright Copyright (c) 2023, WP Charitable LLC
9 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Upgrade_Page' ) ) :
18
19 /**
20 * Charitable_Upgrade_Page
21 *
22 * @since 1.3.0
23 */
24 class Charitable_Upgrade_Page {
25
26 /**
27 * The one and only class instance.
28 *
29 * @since 1.3.0
30 *
31 * @var Charitable_Upgrade_Page
32 */
33 private static $instance = null;
34
35 /**
36 * Create class object. Private constructor.
37 *
38 * @since 1.3.0
39 */
40 private function __construct() {
41 }
42
43 /**
44 * Create and return the class object.
45 *
46 * @since 1.3.0
47 */
48 public static function get_instance() {
49 if ( is_null( self::$instance ) ) {
50 self::$instance = new self();
51 }
52
53 return self::$instance;
54 }
55
56 /**
57 * Register the page.
58 *
59 * @since 1.3.0
60 *
61 * @return void
62 */
63 public function register_page() {
64 add_dashboard_page(
65 __( 'Upgrade Charitable', 'charitable' ),
66 __( 'Upgrade Charitable', 'charitable' ),
67 'manage_charitable_settings',
68 'charitable-upgrades',
69 array( $this, 'render_page' )
70 );
71 }
72
73 /**
74 * Remove the page from the dashboard menu.
75 *
76 * @since 1.3.0
77 *
78 * @return void
79 */
80 public function remove_page_from_menu() {
81 remove_submenu_page( 'index.php', 'charitable-upgrades' );
82 }
83
84 /**
85 * Render the page.
86 *
87 * @since 1.3.0
88 *
89 * @return void
90 */
91 public function render_page() {
92 charitable_admin_view( 'upgrades-page/page', array( 'page' => $this ) );
93 }
94
95 /**
96 * Return the current upgrade action.
97 *
98 * @since 1.3.0
99 * @version 1.8.9.1
100 *
101 * @return false|string False if no action was specified.
102 */
103 public function get_action() {
104 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
105 if ( ! isset( $_GET['charitable-upgrade'] ) ) {
106 return false;
107 }
108
109 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
110 return sanitize_text_field( wp_unslash( $_GET['charitable-upgrade'] ) );
111 }
112
113 /**
114 * Return the current upgrade step.
115 *
116 * @since 1.3.0
117 * @version 1.8.9.1
118 *
119 * @return int
120 */
121 public function get_step() {
122 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
123 if ( ! isset( $_GET['step'] ) ) {
124 return 1;
125 }
126
127 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
128 return absint( wp_unslash( $_GET['step'] ) );
129 }
130
131 /**
132 * Return the total number of records to be updated.
133 *
134 * @since 1.3.0
135 * @version 1.8.9.1
136 *
137 * @return false|int
138 */
139 public function get_total() {
140 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
141 if ( ! isset( $_GET['total'] ) ) {
142 return false;
143 }
144
145 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
146 return absint( wp_unslash( $_GET['total'] ) );
147 }
148
149 /**
150 * Return the... number?
151 *
152 * @since 1.3.0
153 * @version 1.8.9.1
154 *
155 * @return int
156 */
157 public function get_number() {
158 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
159 if ( ! isset( $_GET['number'] ) ) {
160 return 100;
161 }
162
163 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
164 return absint( wp_unslash( $_GET['number'] ) );
165 }
166
167 /**
168 * Return the nonce
169 *
170 * @since 1.8.1
171 * @version 1.8.9.1
172 *
173 * @return false|string
174 */
175 public function get_nonce() {
176 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
177 if ( ! isset( $_GET['nonce'] ) ) {
178 return false;
179 }
180
181 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
182 return sanitize_text_field( wp_unslash( $_GET['nonce'] ) );
183 }
184
185
186 /**
187 * Return the total number of steps.
188 *
189 * @since 1.3.0
190 *
191 * @param int $total The total number of records to update.
192 * @param int $number The number to update in a single step.
193 * @return int
194 */
195 public function get_steps( $total, $number ) {
196 return round( ( $total / $number ), 0 );
197 }
198 }
199
200 endif;
201