PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.1.1
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-stack-helper.php

class-mainwp-stack-helper.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.1.1, at class/class-mainwp-stack-helper.php

98 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Utility Helper.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 // phpcs:disable WordPress.DB.RestrictedFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.NoSilencedErrors, Generic.Metrics.CyclomaticComplexity -- Using cURL functions.
16
17 /**
18 * Class MainWP_Stack_Helper
19 *
20 * @package MainWP\Dashboard
21 */
22 class MainWP_Stack_Helper { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
23
24 /**
25 * Working stack.
26 *
27 * @var array $working_stack Working stack.
28 */
29 private static $working_stack = array();
30
31 /**
32 * Stack push
33 *
34 * @param mixed $action
35 * @return void
36 */
37 public static function stack_push( $action ) {
38 self::$working_stack[] = $action;
39 }
40
41 /**
42 * Stack pop
43 *
44 * @return void
45 */
46 public static function stack_pop() {
47 return array_pop( self::$working_stack );
48 }
49
50 /**
51 * Stack current
52 *
53 * @return void
54 */
55 public static function stack_current() {
56 return self::$working_stack ? end( self::$working_stack ) : null;
57 }
58
59 /**
60 * Stack all
61 *
62 * @return void
63 */
64 public static function stack_all() {
65 return self::$working_stack;
66 }
67
68 /**
69 * Stack clear
70 *
71 * @return void
72 */
73 public static function stack_clear() {
74 self::$stack = array();
75 }
76
77 /**
78 * In stack
79 *
80 * @param mixed $action
81 * @return void
82 */
83 public static function in_stack( $action ) {
84 return in_array( $action, self::$working_stack, true );
85 }
86
87 /**
88 * is_current_stack
89 *
90 * @param mixed $action
91 * @return void
92 */
93 public static function is_current_stack( $action ) {
94 return self::stack_current() === $action;
95 }
96
97 }
98