@@ -17,390 +17,390 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class GetPaid_Admin_Setup_Wizard { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string Current Step |
|
| 22 | - */ |
|
| 23 | - protected $step = ''; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string|false Previous Step |
|
| 27 | - */ |
|
| 28 | - protected $previous_step = ''; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var string|false Next Step |
|
| 32 | - */ |
|
| 33 | - protected $next_step = ''; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var array All available steps for the setup wizard |
|
| 37 | - */ |
|
| 38 | - protected $steps = array(); |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class constructor. |
|
| 42 | - * |
|
| 43 | - * @since 2.4.0 |
|
| 44 | - */ |
|
| 45 | - public function __construct() { |
|
| 46 | - |
|
| 47 | - if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
| 48 | - add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
| 49 | - add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Add admin menus/screens. |
|
| 56 | - * |
|
| 57 | - * @since 2.4.0 |
|
| 58 | - */ |
|
| 59 | - public function add_menu() { |
|
| 60 | - add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Sets up the setup wizard. |
|
| 65 | - * |
|
| 66 | - * @since 2.4.0 |
|
| 67 | - */ |
|
| 68 | - public function setup_wizard() { |
|
| 69 | - |
|
| 70 | - if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
| 71 | - $this->setup_globals(); |
|
| 72 | - $this->maybe_save_current_step(); |
|
| 73 | - $this->display_wizard(); |
|
| 74 | - exit; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Sets up class variables. |
|
| 81 | - * |
|
| 82 | - * @since 2.4.0 |
|
| 83 | - */ |
|
| 84 | - protected function setup_globals() { |
|
| 85 | - $this->steps = $this->get_setup_steps(); |
|
| 86 | - $this->step = $this->get_current_step(); |
|
| 87 | - $this->previous_step = $this->get_previous_step(); |
|
| 88 | - $this->next_step = $this->get_next_step(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Saves the current step. |
|
| 93 | - * |
|
| 94 | - * @since 2.4.0 |
|
| 95 | - */ |
|
| 96 | - protected function maybe_save_current_step() { |
|
| 97 | - if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
| 98 | - call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Returns the setup steps. |
|
| 104 | - * |
|
| 105 | - * @since 2.4.0 |
|
| 106 | - * @return array |
|
| 107 | - */ |
|
| 108 | - protected function get_setup_steps() { |
|
| 109 | - |
|
| 110 | - $steps = array( |
|
| 111 | - |
|
| 112 | - 'introduction' => array( |
|
| 113 | - 'name' => __( 'Introduction', 'invoicing' ), |
|
| 114 | - 'view' => array( $this, 'setup_introduction' ), |
|
| 115 | - 'handler' => '', |
|
| 116 | - ), |
|
| 117 | - |
|
| 118 | - 'business_details' => array( |
|
| 119 | - 'name' => __( "Business Details", 'invoicing' ), |
|
| 120 | - 'view' => array( $this, 'setup_business' ), |
|
| 121 | - 'handler' => '', |
|
| 122 | - ), |
|
| 123 | - |
|
| 124 | - 'currency' => array( |
|
| 125 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 126 | - 'view' => array( $this, 'setup_currency' ), |
|
| 127 | - 'handler' => '', |
|
| 128 | - ), |
|
| 129 | - |
|
| 130 | - 'payments' => array( |
|
| 131 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 132 | - 'view' => array( $this, 'setup_payments' ), |
|
| 133 | - 'handler' => array( $this, 'setup_payments_save' ), |
|
| 134 | - ), |
|
| 135 | - |
|
| 136 | - 'recommend' => array( |
|
| 137 | - 'name' => __( 'Recommend', 'invoicing' ), |
|
| 138 | - 'view' => array( $this, 'setup_recommend' ), |
|
| 139 | - 'handler' => '', |
|
| 140 | - ), |
|
| 141 | - |
|
| 142 | - 'next_steps' => array( |
|
| 143 | - 'name' => __( 'Get Paid', 'invoicing' ), |
|
| 144 | - 'view' => array( $this, 'setup_ready' ), |
|
| 145 | - 'handler' => '', |
|
| 146 | - ), |
|
| 147 | - |
|
| 148 | - ); |
|
| 149 | - |
|
| 150 | - return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
| 151 | - |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Returns the current step. |
|
| 156 | - * |
|
| 157 | - * @since 2.4.0 |
|
| 158 | - * @return string |
|
| 159 | - */ |
|
| 160 | - protected function get_current_step() { |
|
| 161 | - $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
| 162 | - return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Returns the previous step. |
|
| 167 | - * |
|
| 168 | - * @since 2.4.0 |
|
| 169 | - * @return string|false |
|
| 170 | - */ |
|
| 171 | - protected function get_previous_step() { |
|
| 172 | - |
|
| 173 | - $previous = false; |
|
| 174 | - $current = $this->step; |
|
| 175 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
| 176 | - if ( $current === $step ) { |
|
| 177 | - return $previous; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - $previous = $step; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Returns the next step. |
|
| 188 | - * |
|
| 189 | - * @since 2.4.0 |
|
| 190 | - * @return string|false |
|
| 191 | - */ |
|
| 192 | - protected function get_next_step() { |
|
| 193 | - |
|
| 194 | - $on_current = false; |
|
| 195 | - $current = $this->step; |
|
| 196 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
| 197 | - |
|
| 198 | - if ( $on_current ) { |
|
| 199 | - return $step; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - if ( $current === $step ) { |
|
| 203 | - return $on_current = true; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Displays the setup wizard. |
|
| 213 | - * |
|
| 214 | - * @since 2.4.0 |
|
| 215 | - */ |
|
| 216 | - public function display_wizard() { |
|
| 217 | - $this->display_header(); |
|
| 218 | - $this->display_current_step(); |
|
| 219 | - $this->display_footer(); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Displays the Wizard Header. |
|
| 224 | - * |
|
| 225 | - * @since 2.0.0 |
|
| 226 | - */ |
|
| 227 | - public function display_header() { |
|
| 228 | - $steps = $this->steps; |
|
| 229 | - $current = $this->step; |
|
| 230 | - $next_step = $this->next_step; |
|
| 231 | - array_shift( $steps ); |
|
| 232 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Displays the content for the current step. |
|
| 237 | - * |
|
| 238 | - * @since 2.4.0 |
|
| 239 | - */ |
|
| 240 | - public function display_current_step() { |
|
| 241 | - ?> |
|
| 20 | + /** |
|
| 21 | + * @var string Current Step |
|
| 22 | + */ |
|
| 23 | + protected $step = ''; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string|false Previous Step |
|
| 27 | + */ |
|
| 28 | + protected $previous_step = ''; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var string|false Next Step |
|
| 32 | + */ |
|
| 33 | + protected $next_step = ''; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var array All available steps for the setup wizard |
|
| 37 | + */ |
|
| 38 | + protected $steps = array(); |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Class constructor. |
|
| 42 | + * |
|
| 43 | + * @since 2.4.0 |
|
| 44 | + */ |
|
| 45 | + public function __construct() { |
|
| 46 | + |
|
| 47 | + if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
| 48 | + add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
| 49 | + add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Add admin menus/screens. |
|
| 56 | + * |
|
| 57 | + * @since 2.4.0 |
|
| 58 | + */ |
|
| 59 | + public function add_menu() { |
|
| 60 | + add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Sets up the setup wizard. |
|
| 65 | + * |
|
| 66 | + * @since 2.4.0 |
|
| 67 | + */ |
|
| 68 | + public function setup_wizard() { |
|
| 69 | + |
|
| 70 | + if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
| 71 | + $this->setup_globals(); |
|
| 72 | + $this->maybe_save_current_step(); |
|
| 73 | + $this->display_wizard(); |
|
| 74 | + exit; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Sets up class variables. |
|
| 81 | + * |
|
| 82 | + * @since 2.4.0 |
|
| 83 | + */ |
|
| 84 | + protected function setup_globals() { |
|
| 85 | + $this->steps = $this->get_setup_steps(); |
|
| 86 | + $this->step = $this->get_current_step(); |
|
| 87 | + $this->previous_step = $this->get_previous_step(); |
|
| 88 | + $this->next_step = $this->get_next_step(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Saves the current step. |
|
| 93 | + * |
|
| 94 | + * @since 2.4.0 |
|
| 95 | + */ |
|
| 96 | + protected function maybe_save_current_step() { |
|
| 97 | + if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
| 98 | + call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Returns the setup steps. |
|
| 104 | + * |
|
| 105 | + * @since 2.4.0 |
|
| 106 | + * @return array |
|
| 107 | + */ |
|
| 108 | + protected function get_setup_steps() { |
|
| 109 | + |
|
| 110 | + $steps = array( |
|
| 111 | + |
|
| 112 | + 'introduction' => array( |
|
| 113 | + 'name' => __( 'Introduction', 'invoicing' ), |
|
| 114 | + 'view' => array( $this, 'setup_introduction' ), |
|
| 115 | + 'handler' => '', |
|
| 116 | + ), |
|
| 117 | + |
|
| 118 | + 'business_details' => array( |
|
| 119 | + 'name' => __( "Business Details", 'invoicing' ), |
|
| 120 | + 'view' => array( $this, 'setup_business' ), |
|
| 121 | + 'handler' => '', |
|
| 122 | + ), |
|
| 123 | + |
|
| 124 | + 'currency' => array( |
|
| 125 | + 'name' => __( 'Currency', 'invoicing' ), |
|
| 126 | + 'view' => array( $this, 'setup_currency' ), |
|
| 127 | + 'handler' => '', |
|
| 128 | + ), |
|
| 129 | + |
|
| 130 | + 'payments' => array( |
|
| 131 | + 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 132 | + 'view' => array( $this, 'setup_payments' ), |
|
| 133 | + 'handler' => array( $this, 'setup_payments_save' ), |
|
| 134 | + ), |
|
| 135 | + |
|
| 136 | + 'recommend' => array( |
|
| 137 | + 'name' => __( 'Recommend', 'invoicing' ), |
|
| 138 | + 'view' => array( $this, 'setup_recommend' ), |
|
| 139 | + 'handler' => '', |
|
| 140 | + ), |
|
| 141 | + |
|
| 142 | + 'next_steps' => array( |
|
| 143 | + 'name' => __( 'Get Paid', 'invoicing' ), |
|
| 144 | + 'view' => array( $this, 'setup_ready' ), |
|
| 145 | + 'handler' => '', |
|
| 146 | + ), |
|
| 147 | + |
|
| 148 | + ); |
|
| 149 | + |
|
| 150 | + return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
| 151 | + |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Returns the current step. |
|
| 156 | + * |
|
| 157 | + * @since 2.4.0 |
|
| 158 | + * @return string |
|
| 159 | + */ |
|
| 160 | + protected function get_current_step() { |
|
| 161 | + $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
| 162 | + return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Returns the previous step. |
|
| 167 | + * |
|
| 168 | + * @since 2.4.0 |
|
| 169 | + * @return string|false |
|
| 170 | + */ |
|
| 171 | + protected function get_previous_step() { |
|
| 172 | + |
|
| 173 | + $previous = false; |
|
| 174 | + $current = $this->step; |
|
| 175 | + foreach ( array_keys( $this->steps ) as $step ) { |
|
| 176 | + if ( $current === $step ) { |
|
| 177 | + return $previous; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + $previous = $step; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Returns the next step. |
|
| 188 | + * |
|
| 189 | + * @since 2.4.0 |
|
| 190 | + * @return string|false |
|
| 191 | + */ |
|
| 192 | + protected function get_next_step() { |
|
| 193 | + |
|
| 194 | + $on_current = false; |
|
| 195 | + $current = $this->step; |
|
| 196 | + foreach ( array_keys( $this->steps ) as $step ) { |
|
| 197 | + |
|
| 198 | + if ( $on_current ) { |
|
| 199 | + return $step; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + if ( $current === $step ) { |
|
| 203 | + return $on_current = true; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Displays the setup wizard. |
|
| 213 | + * |
|
| 214 | + * @since 2.4.0 |
|
| 215 | + */ |
|
| 216 | + public function display_wizard() { |
|
| 217 | + $this->display_header(); |
|
| 218 | + $this->display_current_step(); |
|
| 219 | + $this->display_footer(); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Displays the Wizard Header. |
|
| 224 | + * |
|
| 225 | + * @since 2.0.0 |
|
| 226 | + */ |
|
| 227 | + public function display_header() { |
|
| 228 | + $steps = $this->steps; |
|
| 229 | + $current = $this->step; |
|
| 230 | + $next_step = $this->next_step; |
|
| 231 | + array_shift( $steps ); |
|
| 232 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Displays the content for the current step. |
|
| 237 | + * |
|
| 238 | + * @since 2.4.0 |
|
| 239 | + */ |
|
| 240 | + public function display_current_step() { |
|
| 241 | + ?> |
|
| 242 | 242 | <div class="gp-setup-content rowx mw-100 text-center mb-3"> |
| 243 | 243 | <div class="col-12 col-md-5 m-auto"> |
| 244 | 244 | <?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?> |
| 245 | 245 | </div> |
| 246 | 246 | </div> |
| 247 | 247 | <?php |
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Setup Wizard Footer. |
|
| 252 | - * |
|
| 253 | - * @since 2.4.0 |
|
| 254 | - */ |
|
| 255 | - public function display_footer() { |
|
| 256 | - |
|
| 257 | - if ( isset( $_GET['step'] ) ) { |
|
| 258 | - $next_url = esc_url( $this->get_next_step_link() ); |
|
| 259 | - $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
| 260 | - |
|
| 261 | - echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>'; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - echo '</body></html>'; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Introduction step. |
|
| 269 | - * |
|
| 270 | - * @since 2.0.0 |
|
| 271 | - */ |
|
| 272 | - public function setup_introduction() { |
|
| 273 | - $next_url = $this->get_next_step_link(); |
|
| 274 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Get the URL for the next step's screen. |
|
| 279 | - * |
|
| 280 | - * @param string step slug (default: current step) |
|
| 281 | - * |
|
| 282 | - * @return string URL for next step if a next step exists. |
|
| 283 | - * Admin URL if it's the last step. |
|
| 284 | - * Empty string on failure. |
|
| 285 | - * @since 3.0.0 |
|
| 286 | - */ |
|
| 287 | - public function get_next_step_link( $step = '' ) { |
|
| 288 | - if ( ! $step ) { |
|
| 289 | - $step = $this->step; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - $keys = array_keys( $this->steps ); |
|
| 293 | - if ( end( $keys ) === $step ) { |
|
| 294 | - return admin_url(); |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - $step_index = array_search( $step, $keys ); |
|
| 298 | - if ( false === $step_index ) { |
|
| 299 | - return ''; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] )); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Setup maps api. |
|
| 307 | - * |
|
| 308 | - * @since 2.0.0 |
|
| 309 | - */ |
|
| 310 | - public function setup_business() { |
|
| 311 | - $next_url = $this->get_next_step_link(); |
|
| 312 | - $wizard = $this; |
|
| 313 | - $page = 'wpinv_settings_general_main'; |
|
| 314 | - $section = 'wpinv_settings_general_main'; |
|
| 315 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Default Location settings. |
|
| 320 | - * |
|
| 321 | - * @since 2.0.0 |
|
| 322 | - */ |
|
| 323 | - public function setup_currency() { |
|
| 324 | - $next_url = $this->get_next_step_link(); |
|
| 325 | - $wizard = $this; |
|
| 326 | - $page = 'wpinv_settings_general_currency_section'; |
|
| 327 | - $section = 'wpinv_settings_general_currency_section'; |
|
| 328 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Installation of recommended plugins. |
|
| 333 | - * |
|
| 334 | - * @since 1.0.0 |
|
| 335 | - */ |
|
| 336 | - public function setup_recommend() { |
|
| 337 | - $next_url = $this->get_next_step_link(); |
|
| 338 | - $recommended_plugins = self::get_recommend_wp_plugins(); |
|
| 339 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * A list of recommended wp.org plugins. |
|
| 344 | - * @return array |
|
| 345 | - */ |
|
| 346 | - public static function get_recommend_wp_plugins(){ |
|
| 347 | - return array( |
|
| 348 | - 'ayecode-connect' => array( |
|
| 349 | - 'file' => 'ayecode-connect/ayecode-connect.php', |
|
| 350 | - 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
|
| 351 | - 'slug' => 'ayecode-connect', |
|
| 352 | - 'name' => 'AyeCode Connect', |
|
| 353 | - 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
|
| 354 | - ), |
|
| 355 | - 'invoicing-quotes' => array( |
|
| 356 | - 'file' => 'invoicing-quotes/wpinv-quote.php', |
|
| 357 | - 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
|
| 358 | - 'slug' => 'invoicing-quotes', |
|
| 359 | - 'name' => 'Customer Quotes', |
|
| 360 | - 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'), |
|
| 361 | - ), |
|
| 362 | - 'userswp' => array( |
|
| 363 | - 'file' => 'userswp/userswp.php', |
|
| 364 | - 'url' => 'https://wordpress.org/plugins/userswp/', |
|
| 365 | - 'slug' => 'userswp', |
|
| 366 | - 'name' => 'UsersWP', |
|
| 367 | - 'desc' => __('Frontend user login and registration as well as slick profile pages.','geodirectory'), |
|
| 368 | - ), |
|
| 369 | - ); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Dummy Data setup. |
|
| 374 | - * |
|
| 375 | - * @since 2.4.0 |
|
| 376 | - */ |
|
| 377 | - public function setup_payments() { |
|
| 378 | - $next_url = $this->get_next_step_link(); |
|
| 379 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Dummy data save. |
|
| 384 | - * |
|
| 385 | - * This is done via ajax so we just pass onto the next step. |
|
| 386 | - * |
|
| 387 | - * @since 2.0.0 |
|
| 388 | - */ |
|
| 389 | - public function setup_payments_save() { |
|
| 390 | - check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
| 391 | - wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
| 392 | - wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
| 393 | - exit; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * Final step. |
|
| 398 | - * |
|
| 399 | - * @since 2.0.0 |
|
| 400 | - */ |
|
| 401 | - public function setup_ready() { |
|
| 402 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
| 403 | - } |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Setup Wizard Footer. |
|
| 252 | + * |
|
| 253 | + * @since 2.4.0 |
|
| 254 | + */ |
|
| 255 | + public function display_footer() { |
|
| 256 | + |
|
| 257 | + if ( isset( $_GET['step'] ) ) { |
|
| 258 | + $next_url = esc_url( $this->get_next_step_link() ); |
|
| 259 | + $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
| 260 | + |
|
| 261 | + echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>'; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + echo '</body></html>'; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Introduction step. |
|
| 269 | + * |
|
| 270 | + * @since 2.0.0 |
|
| 271 | + */ |
|
| 272 | + public function setup_introduction() { |
|
| 273 | + $next_url = $this->get_next_step_link(); |
|
| 274 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Get the URL for the next step's screen. |
|
| 279 | + * |
|
| 280 | + * @param string step slug (default: current step) |
|
| 281 | + * |
|
| 282 | + * @return string URL for next step if a next step exists. |
|
| 283 | + * Admin URL if it's the last step. |
|
| 284 | + * Empty string on failure. |
|
| 285 | + * @since 3.0.0 |
|
| 286 | + */ |
|
| 287 | + public function get_next_step_link( $step = '' ) { |
|
| 288 | + if ( ! $step ) { |
|
| 289 | + $step = $this->step; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + $keys = array_keys( $this->steps ); |
|
| 293 | + if ( end( $keys ) === $step ) { |
|
| 294 | + return admin_url(); |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + $step_index = array_search( $step, $keys ); |
|
| 298 | + if ( false === $step_index ) { |
|
| 299 | + return ''; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] )); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Setup maps api. |
|
| 307 | + * |
|
| 308 | + * @since 2.0.0 |
|
| 309 | + */ |
|
| 310 | + public function setup_business() { |
|
| 311 | + $next_url = $this->get_next_step_link(); |
|
| 312 | + $wizard = $this; |
|
| 313 | + $page = 'wpinv_settings_general_main'; |
|
| 314 | + $section = 'wpinv_settings_general_main'; |
|
| 315 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Default Location settings. |
|
| 320 | + * |
|
| 321 | + * @since 2.0.0 |
|
| 322 | + */ |
|
| 323 | + public function setup_currency() { |
|
| 324 | + $next_url = $this->get_next_step_link(); |
|
| 325 | + $wizard = $this; |
|
| 326 | + $page = 'wpinv_settings_general_currency_section'; |
|
| 327 | + $section = 'wpinv_settings_general_currency_section'; |
|
| 328 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Installation of recommended plugins. |
|
| 333 | + * |
|
| 334 | + * @since 1.0.0 |
|
| 335 | + */ |
|
| 336 | + public function setup_recommend() { |
|
| 337 | + $next_url = $this->get_next_step_link(); |
|
| 338 | + $recommended_plugins = self::get_recommend_wp_plugins(); |
|
| 339 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * A list of recommended wp.org plugins. |
|
| 344 | + * @return array |
|
| 345 | + */ |
|
| 346 | + public static function get_recommend_wp_plugins(){ |
|
| 347 | + return array( |
|
| 348 | + 'ayecode-connect' => array( |
|
| 349 | + 'file' => 'ayecode-connect/ayecode-connect.php', |
|
| 350 | + 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
|
| 351 | + 'slug' => 'ayecode-connect', |
|
| 352 | + 'name' => 'AyeCode Connect', |
|
| 353 | + 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
|
| 354 | + ), |
|
| 355 | + 'invoicing-quotes' => array( |
|
| 356 | + 'file' => 'invoicing-quotes/wpinv-quote.php', |
|
| 357 | + 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
|
| 358 | + 'slug' => 'invoicing-quotes', |
|
| 359 | + 'name' => 'Customer Quotes', |
|
| 360 | + 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'), |
|
| 361 | + ), |
|
| 362 | + 'userswp' => array( |
|
| 363 | + 'file' => 'userswp/userswp.php', |
|
| 364 | + 'url' => 'https://wordpress.org/plugins/userswp/', |
|
| 365 | + 'slug' => 'userswp', |
|
| 366 | + 'name' => 'UsersWP', |
|
| 367 | + 'desc' => __('Frontend user login and registration as well as slick profile pages.','geodirectory'), |
|
| 368 | + ), |
|
| 369 | + ); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Dummy Data setup. |
|
| 374 | + * |
|
| 375 | + * @since 2.4.0 |
|
| 376 | + */ |
|
| 377 | + public function setup_payments() { |
|
| 378 | + $next_url = $this->get_next_step_link(); |
|
| 379 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Dummy data save. |
|
| 384 | + * |
|
| 385 | + * This is done via ajax so we just pass onto the next step. |
|
| 386 | + * |
|
| 387 | + * @since 2.0.0 |
|
| 388 | + */ |
|
| 389 | + public function setup_payments_save() { |
|
| 390 | + check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
| 391 | + wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
| 392 | + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
| 393 | + exit; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * Final step. |
|
| 398 | + * |
|
| 399 | + * @since 2.0.0 |
|
| 400 | + */ |
|
| 401 | + public function setup_ready() { |
|
| 402 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | 405 | } |
| 406 | 406 | |