PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.2.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.2.1
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / admin-core / ajax / ajax-errors.php

ajax-errors.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.2.1, at admin-core/ajax/ajax-errors.php

91 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 * CartFlows Ajax Errors.
4 *
5 * @package CartFlows
6 */
7
8 namespace CartflowsAdmin\AdminCore\Ajax;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class AjaxErrors
17 */
18 class AjaxErrors {
19
20 /**
21 * Instance
22 *
23 * @access private
24 * @var object Class object.
25 * @since 1.0.0
26 */
27 private static $instance;
28
29 /**
30 * Errors
31 *
32 * @access private
33 * @var array Errors strings.
34 * @since 1.0.0
35 */
36 private static $errors = array();
37
38 /**
39 * Initiator
40 *
41 * @since 1.0.0
42 * @return object initialized object of class.
43 */
44 public static function get_instance() {
45 if ( ! isset( self::$instance ) ) {
46 self::$instance = new self();
47 }
48 return self::$instance;
49 }
50
51 /**
52 * Constructor
53 *
54 * @since 1.0.0
55 */
56 public function __construct() {
57 add_action( 'init', array( $this, 'prepare_ajax_errors' ) );
58 }
59
60 /**
61 * Prepare Ajax Error Messages
62 *
63 * @return void
64 */
65 public function prepare_ajax_errors() {
66 self::$errors = array(
67 'permission' => __( 'Sorry, you are not allowed to do this operation.', 'cartflows' ),
68 'nonce' => __( 'Nonce validation failed', 'cartflows' ),
69 'default' => __( 'Sorry, something went wrong.', 'cartflows' ),
70 'parameter' => __( 'Required parameter is missing from the posted data.', 'cartflows' ),
71 );
72 }
73
74 /**
75 * Get error message.
76 *
77 * @param string $type Message type.
78 * @return string
79 */
80 public function get_error_msg( $type ) {
81
82 if ( ! isset( self::$errors[ $type ] ) ) {
83 $type = 'default';
84 }
85
86 return self::$errors[ $type ];
87 }
88 }
89
90 AjaxErrors::get_instance();
91