PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.3
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-actions-handler.php

class-mainwp-actions-handler.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.3, at class/class-mainwp-actions-handler.php

131 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle Dashboard Hooks Actions.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_Actions_Handler
12 */
13 class MainWP_Actions_Handler { //phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
14
15 /**
16 * Private static variable to hold the single instance of the class.
17 *
18 * @static
19 *
20 * @var mixed Default null
21 */
22 private static $instance = null;
23
24 /**
25 * Method instance()
26 *
27 * Create a public static instance.
28 *
29 * @static
30 * @return MainWP_Actions_Handler
31 */
32 public static function instance() {
33 if ( null === static::$instance ) {
34 static::$instance = new self();
35 }
36 return static::$instance;
37 }
38
39 /**
40 * Action mainwp_post_action.
41 *
42 * @param object $website website data.
43 * @param string $pAction post action.
44 * @param array $information post action information.
45 * @param int|false $postId post id.
46 * @param string $type post|page.
47 */
48 public function do_action_mainwp_post_action( $website, $pAction, $information, $postId, $type = '' ) {
49 if ( is_array( $information ) && isset( $information['status'] ) && ( 'SUCCESS' === $information['status'] ) ) {
50 $data = isset( $information['other_data']['post_action_data'] ) ? $information['other_data']['post_action_data'] : array();
51 /**
52 * Fires immediately after post action.
53 *
54 * @since 4.5.1.1
55 */
56 do_action( 'mainwp_post_action', $website, $pAction, $data, $postId, $type );
57 }
58 }
59
60 /**
61 * Action mainwp_install_actions.
62 *
63 * @param array $websites websites.
64 * @param string $pAction install action.
65 * @param mixed $output result.
66 * @param string $type action type.
67 * @param mixed $post_data post data (option).
68 * @param bool $upload true|false: install by upload (option).
69 */
70 public function do_action_mainwp_install_actions( $websites, $pAction, $output, $type, $post_data = array(), $upload = false ) {
71
72 if ( ! in_array( $pAction, array( 'install', 'updated' ), true ) ) {
73 return;
74 }
75
76 $website = is_array( $websites ) ? current( $websites ) : $websites;
77 if ( empty( $website ) ) {
78 return;
79 }
80
81 if ( ! is_array( $post_data ) ) {
82 $post_data = array();
83 }
84
85 $data = array();
86 if ( is_array( $output ) ) {
87 $data = $output;
88 } elseif ( is_object( $output ) ) {
89 if ( ! empty( $output->other_data ) && is_array( $output->other_data ) && isset( $output->other_data[ $website->id ]['install_items'] ) ) {
90 $data['install_items'] = $output->other_data[ $website->id ]['install_items'];
91 }
92 }
93
94 /**
95 * Fires immediately after install action.
96 *
97 * @since 4.5.1.1
98 */
99 do_action( 'mainwp_install_update_actions', $website, $pAction, $data, $type, $post_data, $upload );
100 }
101
102 /**
103 *
104 * Handle @action mainwp_fetch_url_authed.
105 *
106 * @param object $website website.
107 * @param array $information information result data.
108 * @param string $action action.
109 * @param array $params params input array.
110 * @param array $others others input array.
111 *
112 * @since 4.5.1.1
113 */
114 public function hook_mainwp_fetch_url_authed( $website, $information, $action, $params, $others ) {
115 if ( 'plugin_action' === $action ) {
116 $plugin_act = isset( $params['action'] ) ? $params['action'] : '';
117 if ( in_array( $plugin_act, array( 'activate', 'deactivate', 'delete' ) ) && isset( $information['other_data']['plugin_action_data'] ) ) {
118 do_action( 'mainwp_install_plugin_action', $website, $plugin_act, $params, $information['other_data']['plugin_action_data'], $others );
119 }
120 } elseif ( 'theme_action' === $action ) {
121 $theme_act = isset( $params['action'] ) ? $params['action'] : '';
122 if ( 'activate' === $theme_act && isset( $information['other_data']['theme_deactivate_data'] ) ) {
123 do_action( 'mainwp_install_theme_action', $website, 'deactivate', $params, $information['other_data']['theme_deactivate_data'], $others );
124 }
125 if ( in_array( $theme_act, array( 'activate', 'delete' ) ) && isset( $information['other_data']['theme_action_data'] ) ) {
126 do_action( 'mainwp_install_theme_action', $website, $theme_act, $params, $information['other_data']['theme_action_data'], $others );
127 }
128 }
129 }
130 }
131