PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.4.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.4.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
← All changes | class/class-mainwp-hooks.php +1434 -1770 5.2.24.4.1 View file →
@@ -13,1928 +13,1592 @@
13 13 * Class MainWP_Hooks
14 14 *
15 15 * @package MainWP\Dashboard
16 16 */
17 -class MainWP_Hooks { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
18 - /**
19 - * MainWP_Hooks constructor.
20 - *
21 - * Initialize MainWP_Hooks actions/filters upon creation of the object.
22 - *
23 - * @deprecated 4.0.7. Hook deprecation - Please use filter `mainwp_get_error_message` instead of `mainwp_getErrorMessage`.
24 - *
25 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_class_name()
26 - * @uses \MainWP\Dashboard\MainWP_UI::get_class_name()
27 - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_class_name()
28 - * @uses \MainWP\Dashboard\MainWP_Install_Bulk::get_class_name()
29 - */
30 - public function __construct() {
31 - add_filter( 'mainwp_getspecificdir', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_dir' ), 10, 1 );
32 - add_filter( 'mainwp_getmainwpdir', array( &$this, 'hook_get_mainwp_dir' ), 10, 3 );
33 - add_filter( 'mainwp_is_multi_user', array( &$this, 'is_multi_user' ) );
34 - add_filter( 'mainwp_qq2fileuploader', array( &$this, 'filter_qq2_file_uploader' ), 10, 2 );
35 - add_action( 'mainwp_select_sites_box', array( &$this, 'hook_select_sites_box' ), 10, 12 );
36 - add_action( 'mainwp_add_categories_box', array( &$this, 'hook_add_categories_box' ), 10, 1 );
37 - add_action( 'mainwp_prepareinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'prepare_install' ) );
38 - add_action( 'mainwp_performinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'perform_install' ) );
39 - add_filter( 'mainwp_getwpfilesystem', array( MainWP_System_Utility::get_class_name(), 'get_wp_file_system' ) );
40 - add_filter( 'mainwp_getspecificurl', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_url' ), 10, 1 );
41 - add_filter( 'mainwp_getdownloadurl', array( MainWP_System_Utility::get_class_name(), 'get_download_url' ), 10, 2 );
42 - add_action( 'mainwp_renderHeader', array( MainWP_UI::get_class_name(), 'render_header' ), 10, 2 );
43 - add_action( 'mainwp_renderFooter', array( MainWP_UI::get_class_name(), 'render_footer' ), 10, 0 );
17 +class MainWP_Hooks {
44 18
45 - add_action( 'mainwp_notify_user', array( &$this, 'hook_notify_user' ), 10, 3 );
46 - add_filter( 'mainwp_is_mainwp_page', array( MainWP_System::class, 'is_mainwp_pages' ) );
19 + /**
20 + * MainWP_Hooks constructor.
21 + *
22 + * Initialize MainWP_Hooks actions/filters upon creation of the object.
23 + *
24 + * @deprecated 4.0.7. Hook deprecation - Please use filter `mainwp_get_error_message` instead of `mainwp_getErrorMessage`.
25 + *
26 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_class_name()
27 + * @uses \MainWP\Dashboard\MainWP_UI::get_class_name()
28 + * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_class_name()
29 + * @uses \MainWP\Dashboard\MainWP_Install_Bulk::get_class_name()
30 + */
31 + public function __construct() {
32 + add_filter( 'mainwp_getspecificdir', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_dir' ), 10, 1 );
33 + add_filter( 'mainwp_getmainwpdir', array( &$this, 'hook_get_mainwp_dir' ), 10, 3 );
34 + add_filter( 'mainwp_is_multi_user', array( &$this, 'is_multi_user' ) );
35 + add_filter( 'mainwp_qq2fileuploader', array( &$this, 'filter_qq2_file_uploader' ), 10, 2 );
36 + add_action( 'mainwp_select_sites_box', array( &$this, 'select_sites_box' ), 10, 11 );
37 + add_action( 'mainwp_add_categories_box', array( &$this, 'hook_add_categories_box' ), 10, 1 );
38 + add_action( 'mainwp_prepareinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'prepare_install' ) );
39 + add_action( 'mainwp_performinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'perform_install' ) );
40 + add_filter( 'mainwp_getwpfilesystem', array( MainWP_System_Utility::get_class_name(), 'get_wp_file_system' ) );
41 + add_filter( 'mainwp_getspecificurl', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_url' ), 10, 1 );
42 + add_filter( 'mainwp_getdownloadurl', array( MainWP_System_Utility::get_class_name(), 'get_download_url' ), 10, 2 );
43 + add_action( 'mainwp_renderHeader', array( MainWP_UI::get_class_name(), 'render_header' ), 10, 2 );
44 + add_action( 'mainwp_renderFooter', array( MainWP_UI::get_class_name(), 'render_footer' ), 10, 0 );
47 45
48 - /**
49 - * The actions has been deprecated.
50 - *
51 - * @deprecated 4.3 Please use actions: mainwp_action_activeplugin, mainwp_action_deactiveplugin ....
52 - */
53 - add_action( 'mainwp_activePlugin', array( &$this, 'active_plugin' ), 10, 0 );
54 - add_action( 'mainwp_deactivePlugin', array( &$this, 'deactive_plugin' ), 10, 0 );
55 - add_action( 'mainwp_upgradePluginTheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 );
56 - add_action( 'mainwp_deletePlugin', array( &$this, 'delete_plugin' ), 10, 0 );
57 - add_action( 'mainwp_deleteTheme', array( &$this, 'delete_theme' ), 10, 0 );
58 - // End.
46 + add_action( 'mainwp_notify_user', array( &$this, 'hook_notify_user' ), 10, 3 );
59 47
60 - /**
61 - * Plugins/themes/core actions.
62 - *
63 - * @since 4.3
64 - */
65 - add_action( 'mainwp_action_activeplugin', array( &$this, 'active_plugin' ), 10, 0 );
66 - add_action( 'mainwp_action_deactiveplugin', array( &$this, 'deactive_plugin' ), 10, 0 );
67 - add_action( 'mainwp_action_upgradeplugintheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 );
68 - add_action( 'mainwp_action_deleteplugin', array( &$this, 'delete_plugin' ), 10, 0 );
69 - add_action( 'mainwp_action_deletetheme', array( &$this, 'delete_theme' ), 10, 0 );
70 - add_action( 'mainwp_upgrade_wp', array( &$this, 'upgrade_wp' ), 10, 0 );
71 - // End.
48 + /**
49 + * The actions has been deprecated.
50 + *
51 + * @deprecated 4.3 Please use actions: mainwp_action_activeplugin, mainwp_action_deactiveplugin ....
52 + */
53 + add_action( 'mainwp_activePlugin', array( &$this, 'active_plugin' ), 10, 0 );
54 + add_action( 'mainwp_deactivePlugin', array( &$this, 'deactive_plugin' ), 10, 0 );
55 + add_action( 'mainwp_upgradePluginTheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 );
56 + add_action( 'mainwp_deletePlugin', array( &$this, 'delete_plugin' ), 10, 0 );
57 + add_action( 'mainwp_deleteTheme', array( &$this, 'delete_theme' ), 10, 0 );
58 + // End.
72 59
73 - add_filter( 'mainwp_get_user_extension', array( &$this, 'hook_get_user_extension' ), 10, 2 );
74 - add_filter( 'mainwp_update_user_extension', array( &$this, 'update_user_extension' ), 10, 3 );
75 - add_filter( 'mainwp_getwebsitesbyurl', array( &$this, 'get_websites_by_url' ) );
76 - add_filter( 'mainwp_getWebsitesByUrl', array( &$this, 'get_websites_by_url' ) );
77 - add_action( 'mainwp_manage_posts_get_edit', array( &$this, 'hook_posts_get_edit' ), 10, 2 );
78 - add_action( 'mainwp_manage_posts_bulk_posting', array( &$this, 'hook_posts_bulk_posting' ), 10, 2 );
60 + /**
61 + * Plugins/themes/core actions.
62 + *
63 + * @since 4.3
64 + */
65 + add_action( 'mainwp_action_activeplugin', array( &$this, 'active_plugin' ), 10, 0 );
66 + add_action( 'mainwp_action_deactiveplugin', array( &$this, 'deactive_plugin' ), 10, 0 );
67 + add_action( 'mainwp_action_upgradeplugintheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 );
68 + add_action( 'mainwp_action_deleteplugin', array( &$this, 'delete_plugin' ), 10, 0 );
69 + add_action( 'mainwp_action_deletetheme', array( &$this, 'delete_theme' ), 10, 0 );
70 + add_action( 'mainwp_upgrade_wp', array( &$this, 'upgrade_wp' ), 10, 0 );
71 + // End.
79 72
80 - /**
81 - * The mainwp_getErrorMessage filter has been deprecated.
82 - *
83 - * @deprecated 4.0.7. Please use filter mainwp_get_error_message.
84 - */
85 - add_filter( 'mainwp_getErrorMessage', array( &$this, 'get_error_message' ), 10, 2 );
86 - add_filter( 'mainwp_get_error_message', array( &$this, 'get_error_message' ), 10, 2 );
73 + add_filter( 'mainwp_get_user_extension', array( &$this, 'hook_get_user_extension' ), 10, 2 );
74 + add_filter( 'mainwp_update_user_extension', array( &$this, 'update_user_extension' ), 10, 3 );
75 + add_filter( 'mainwp_getwebsitesbyurl', array( &$this, 'get_websites_by_url' ) );
76 + add_filter( 'mainwp_getWebsitesByUrl', array( &$this, 'get_websites_by_url' ) );
77 + add_action( 'mainwp_manage_posts_get_edit', array( &$this, 'hook_posts_get_edit' ), 10, 2 );
78 + add_action( 'mainwp_manage_posts_bulk_posting', array( &$this, 'hook_posts_bulk_posting' ), 10, 2 );
87 79
88 - add_filter( 'mainwp_getwebsitesbygroupids', array( &$this, 'hook_get_websites_by_group_ids' ), 10, 2 );
80 + /**
81 + * The mainwp_getErrorMessage filter has been deprecated.
82 + *
83 + * @deprecated 4.0.7. Please use filter mainwp_get_error_message.
84 + */
85 + add_filter( 'mainwp_getErrorMessage', array( &$this, 'get_error_message' ), 10, 2 );
86 + add_filter( 'mainwp_get_error_message', array( &$this, 'get_error_message' ), 10, 2 );
89 87
90 - add_filter( 'mainwp_cache_getcontext', array( &$this, 'cache_getcontext' ) );
91 - add_action( 'mainwp_cache_echo_body', array( &$this, 'cache_echo_body' ) );
92 - add_action( 'mainwp_cache_init', array( &$this, 'cache_init' ) );
93 - add_action( 'mainwp_cache_add_context', array( &$this, 'cache_add_context' ), 10, 2 );
94 - add_action( 'mainwp_cache_add_body', array( &$this, 'cache_add_body' ), 10, 2 );
88 + add_filter( 'mainwp_getwebsitesbygroupids', array( &$this, 'hook_get_websites_by_group_ids' ), 10, 2 );
95 89
96 - add_filter( 'mainwp_get_metaboxes_post', array( &$this, 'get_metaboxes_post' ), 10, 0 );
97 - add_filter( 'mainwp_getnotificationemail', array( &$this, 'hook_notification_email' ), 10, 1 );
98 - add_filter( 'mainwp_getformatemail', array( &$this, 'get_formated_email' ), 10, 3 );
99 - add_filter( 'mainwp-extension-available-check', array( MainWP_Extensions_Handler::get_class_name(), 'is_extension_available' ) );
100 - add_filter( 'mainwp_extension_is_activated', array( &$this, 'is_extension_activated' ), 10, 2 );
101 - add_filter( 'mainwp_extension_is_pro_member', array( &$this, 'is_pro_member' ), 10, 1 );
90 + add_filter( 'mainwp_cache_getcontext', array( &$this, 'cache_getcontext' ) );
91 + add_action( 'mainwp_cache_echo_body', array( &$this, 'cache_echo_body' ) );
92 + add_action( 'mainwp_cache_init', array( &$this, 'cache_init' ) );
93 + add_action( 'mainwp_cache_add_context', array( &$this, 'cache_add_context' ), 10, 2 );
94 + add_action( 'mainwp_cache_add_body', array( &$this, 'cache_add_body' ), 10, 2 );
102 95
103 - /**
104 - * Logging debug actions.
105 - */
106 - add_action( 'mainwp_log_debug', array( &$this, 'mainwp_log_debug' ), 10, 1 );
107 - add_action( 'mainwp_log_info', array( &$this, 'mainwp_log_info' ), 10, 1 );
108 - add_action( 'mainwp_log_warning', array( &$this, 'mainwp_log_warning' ), 10, 1 );
109 - add_action( 'mainwp_log_action', array( &$this, 'mainwp_log_action' ), 10, 4 );
110 - add_action( 'mainwp_log_execution_time', array( &$this, 'mainwp_log_execution_time' ), 10, 1 );
111 - // END.
96 + add_filter( 'mainwp_get_metaboxes_post', array( &$this, 'get_metaboxes_post' ), 10, 0 );
97 + add_filter( 'mainwp_getnotificationemail', array( &$this, 'hook_notification_email' ), 10, 1 );
98 + add_filter( 'mainwp_getformatemail', array( &$this, 'get_formated_email' ), 10, 3 );
99 + add_filter( 'mainwp-extension-available-check', array( MainWP_Extensions_Handler::get_class_name(), 'is_extension_available' ) );
100 + add_filter( 'mainwp_extension_is_activated', array( &$this, 'is_extension_activated' ), 10, 2 );
101 + add_filter( 'mainwp_extension_is_pro_member', array( &$this, 'is_pro_member' ), 10, 1 );
112 102
113 - add_filter( 'mainwp_getactivateextensionnotice', array( &$this, 'get_activate_extension_notice' ), 10, 1 );
114 - add_action( 'mainwp_enqueue_meta_boxes_scripts', array( &$this, 'enqueue_meta_boxes_scripts' ), 10, 1 );
115 - add_filter( 'mainwp_addsite', array( &$this, 'mainwp_add_site' ), 10, 1 );
116 - add_filter( 'mainwp_deletesite', array( &$this, 'hook_delete_site' ), 10, 1 );
117 - add_filter( 'mainwp_clonesite', array( &$this, 'filter_clone_site' ), 10, 6 );
118 - add_filter( 'mainwp_delete_clonesite', array( &$this, 'filter_delete_clone_site' ), 10, 4 );
119 - add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 );
120 - add_action( 'mainwp_add_sub_leftmenu', array( &$this, 'hook_add_sub_left_menu' ), 10, 6 );
121 - add_filter( 'mainwp_getwebsiteoptions', array( &$this, 'hook_get_site_options' ), 10, 3 );
122 - add_filter( 'mainwp_updatewebsiteoptions', array( &$this, 'hook_update_site_options' ), 10, 4 );
103 + /**
104 + * Logging debug actions.
105 + */
106 + add_action( 'mainwp_log_debug', array( &$this, 'mainwp_log_debug' ), 10, 1 );
107 + add_action( 'mainwp_log_info', array( &$this, 'mainwp_log_info' ), 10, 1 );
108 + add_action( 'mainwp_log_warning', array( &$this, 'mainwp_log_warning' ), 10, 1 );
109 + add_action( 'mainwp_log_action', array( &$this, 'mainwp_log_action' ), 10, 4 );
110 + add_action( 'mainwp_log_execution_time', array( &$this, 'mainwp_log_execution_time' ), 10, 1 );
111 + // END.
123 112
124 - add_filter( 'mainwp_getwebsitesbyuserid', array( &$this, 'hook_get_websites_by_user_id' ), 10, 5 );
125 - add_filter( 'mainwp_getwebsite_by_id', array( &$this, 'hook_get_website_by_id' ), 10, 4 );
113 + add_filter( 'mainwp_getactivateextensionnotice', array( &$this, 'get_activate_extension_notice' ), 10, 1 );
114 + add_action( 'mainwp_enqueue_meta_boxes_scripts', array( &$this, 'enqueue_meta_boxes_scripts' ), 10, 1 );
115 + add_filter( 'mainwp_addsite', array( &$this, 'mainwp_add_site' ), 10, 1 );
116 + add_filter( 'mainwp_deletesite', array( &$this, 'hook_delete_site' ), 10, 1 );
117 + add_filter( 'mainwp_clonesite', array( &$this, 'filter_clone_site' ), 10, 6 );
118 + add_filter( 'mainwp_delete_clonesite', array( &$this, 'filter_delete_clone_site' ), 10, 4 );
119 + add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 );
120 + add_action( 'mainwp_add_sub_leftmenu', array( &$this, 'hook_add_sub_left_menu' ), 10, 6 );
121 + add_filter( 'mainwp_getwebsiteoptions', array( &$this, 'hook_get_site_options' ), 10, 3 );
122 + add_filter( 'mainwp_updatewebsiteoptions', array( &$this, 'hook_update_site_options' ), 10, 4 );
126 123
127 - add_filter( 'mainwp_addgroup', array( MainWP_Extensions_Handler::get_class_name(), 'hook_add_group' ), 10, 3 );
128 - add_filter( 'mainwp_getallposts', array( &$this, 'hook_get_all_posts' ), 10, 2 );
129 - add_filter( 'mainwp_check_current_user_can', array( &$this, 'hook_current_user_can' ), 10, 3 );
130 - add_filter( 'mainwp_escape_response_data', array( &$this, 'hook_escape_response' ), 10, 3 );
131 - add_filter( 'mainwp_escape_content', array( &$this, 'hook_escape_content' ), 10, 3 );
124 + add_filter( 'mainwp_getwebsitesbyuserid', array( &$this, 'hook_get_websites_by_user_id' ), 10, 5 );
125 + add_filter( 'mainwp_getwebsite_by_id', array( &$this, 'hook_get_website_by_id' ), 10, 4 );
132 126
133 - add_filter( 'mainwp_db_query', array( &$this, 'hook_db_query' ), 10, 2 );
134 - add_filter( 'mainwp_db_fetch_object', array( &$this, 'db_fetch_object' ), 10, 2 );
135 - add_filter( 'mainwp_db_fetch_array', array( &$this, 'db_fetch_array' ), 10, 2 );
136 - add_action( 'mainwp_db_data_seek', array( &$this, 'hook_db_data_seek' ), 10, 2 );
137 - add_filter( 'mainwp_db_free_result', array( &$this, 'db_free_result' ), 10, 2 );
138 - add_filter( 'mainwp_db_num_rows', array( &$this, 'db_num_rows' ), 10, 2 );
139 - add_filter( 'mainwp_db_get_websites_for_current_user', array( &$this, 'db_get_websites_for_current_user' ), 10, 2 );
127 + add_filter( 'mainwp_addgroup', array( MainWP_Extensions_Handler::get_class_name(), 'hook_add_group' ), 10, 3 );
128 + add_filter( 'mainwp_getallposts', array( &$this, 'hook_get_all_posts' ), 10, 2 );
129 + add_filter( 'mainwp_check_current_user_can', array( &$this, 'hook_current_user_can' ), 10, 3 );
130 + add_filter( 'mainwp_escape_response_data', array( &$this, 'hook_escape_response' ), 10, 3 );
131 + add_filter( 'mainwp_escape_content', array( &$this, 'hook_escape_content' ), 10, 3 );
140 132
141 - // Sync website.
142 - add_filter( 'mainwp_sync_website', array( &$this, 'hook_sync_website' ), 10, 3 );
133 + add_filter( 'mainwp_db_query', array( &$this, 'hook_db_query' ), 10, 2 );
134 + add_filter( 'mainwp_db_fetch_object', array( &$this, 'db_fetch_object' ), 10, 2 );
135 + add_filter( 'mainwp_db_fetch_array', array( &$this, 'db_fetch_array' ), 10, 2 );
136 + add_action( 'mainwp_db_data_seek', array( &$this, 'hook_db_data_seek' ), 10, 2 );
137 + add_filter( 'mainwp_db_free_result', array( &$this, 'db_free_result' ), 10, 2 );
138 + add_filter( 'mainwp_db_num_rows', array( &$this, 'db_num_rows' ), 10, 2 );
139 + add_filter( 'mainwp_db_get_websites_for_current_user', array( &$this, 'db_get_websites_for_current_user' ), 10, 2 );
143 140
144 - add_action( 'mainwp_secure_request', array( &$this, 'hook_secure_request' ), 10, 2 );
145 - add_filter( 'mainwp_check_security_request', array( &$this, 'hook_check_security_request' ), 10, 3 );
146 - add_filter( 'mainwp_notification_get_settings', array( &$this, 'get_notification_settings' ), 10, 2 );
141 + // Sync website.
142 + add_filter( 'mainwp_sync_website', array( &$this, 'hook_sync_website' ), 10, 3 );
147 143
148 - add_filter( 'mainwp_send_wp_mail', array( &$this, 'hook_send_wp_mail' ), 10, 5 );
149 - add_filter( 'mainwp_notification_get_template_content', array( &$this, 'hook_get_template_html' ), 10, 3 );
150 - add_filter( 'mainwp_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 );
151 - add_filter( 'mainwp_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 );
152 - add_filter( 'mainwp_monitoring_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 );
153 - add_filter( 'mainwp_monitoring_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 );
154 - add_filter( 'mainwp_clients_get_website_client_tokens', array( &$this, 'hook_get_website_client_tokens' ), 10, 2 );
155 - add_filter( 'mainwp_secure_get_download_sig', array( &$this, 'hook_get_download_sig' ), 10, 2 );
156 - add_action( 'mainwp_secure_download', array( &$this, 'hook_secure_download' ), 10, 3 );
157 - add_action( 'mainwp_ajax_add_action', array( &$this, 'hook_ajax_add_action' ), 10, 2 );
158 - add_filter( 'mainwp_get_plugin_icon', array( &$this, 'hook_get_plugin_icon' ), 10, 2 );
159 - add_filter( 'mainwp_get_theme_icon', array( &$this, 'hook_get_theme_icon' ), 10, 2 );
160 - add_filter( 'mainwp_get_dir_slug', array( &$this, 'hook_get_dir_slug' ), 10, 2 );
161 - add_action( 'mainwp_do_widget_boxes', array( &$this, 'hook_do_widget_boxes' ), 10, 3 );
162 - add_action( 'mainwp_add_widget_box', array( &$this, 'hook_add_widget_box' ), 10, 6 );
163 - add_action( 'mainwp_render_modal_upload_icon', array( &$this, 'hook_render_modal_upload_icon' ), 10, 2 );
164 - add_action( 'mainwp_render_plugin_details_modal', array( &$this, 'hook_render_plugin_details_modal' ), 10, 2 );
165 - add_action( 'mainwp_render_updates', array( &$this, 'hook_render_updates' ), 10, 2 );
166 - add_filter( 'mainwp_get_wp_client_by', array( &$this, 'hook_get_wp_client_by' ), 10, 4 );
144 + add_action( 'mainwp_secure_request', array( &$this, 'hook_secure_request' ), 10, 2 );
145 + add_filter( 'mainwp_check_security_request', array( &$this, 'hook_check_security_request' ), 10, 3 );
146 + add_filter( 'mainwp_notification_get_settings', array( &$this, 'get_notification_settings' ), 10, 2 );
167 147
168 - /**
169 - * Filter: mainwp_get_tokens_values
170 - *
171 - * Get tokens values for reports.
172 - *
173 - * @since 4.3.
174 - */
175 - add_filter( 'mainwp_get_reports_group_values_website', array( MainWP_Reports_Helper::get_instance(), 'hook_get_reports_group_values' ), 10, 6 );
148 + add_filter( 'mainwp_send_wp_mail', array( &$this, 'hook_send_wp_mail' ), 10, 5 );
149 + add_filter( 'mainwp_notification_get_template_content', array( &$this, 'hook_get_template_html' ), 10, 3 );
150 + add_filter( 'mainwp_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 );
151 + add_filter( 'mainwp_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 );
152 + add_filter( 'mainwp_monitoring_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 );
153 + add_filter( 'mainwp_monitoring_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 );
154 + add_filter( 'mainwp_clients_get_website_client_tokens', array( &$this, 'hook_get_website_client_tokens' ), 10, 2 );
155 + add_filter( 'mainwp_secure_get_download_sig', array( &$this, 'hook_get_download_sig' ), 10, 2 );
156 + add_action( 'mainwp_secure_download', array( &$this, 'hook_secure_download' ), 10, 2 );
157 + add_action( 'mainwp_ajax_add_action', array( &$this, 'hook_ajax_add_action' ), 10, 2 );
158 + add_filter( 'mainwp_get_plugin_icon', array( &$this, 'hook_get_plugin_icon' ), 10, 2 );
159 + add_filter( 'mainwp_get_theme_icon', array( &$this, 'hook_get_theme_icon' ), 10, 2 );
160 + add_filter( 'mainwp_get_dir_slug', array( &$this, 'hook_get_dir_slug' ), 10, 2 );
161 + add_action( 'mainwp_do_widget_boxes', array( &$this, 'hook_do_widget_boxes' ), 10, 3 );
162 + add_action( 'mainwp_add_widget_box', array( &$this, 'hook_add_widget_box' ), 10, 6 );
163 + add_action( 'mainwp_render_modal_upload_icon', array( &$this, 'hook_render_modal_upload_icon' ), 10, 2 );
164 + add_action( 'mainwp_render_plugin_details_modal', array( &$this, 'hook_render_plugin_details_modal' ), 10, 2 );
165 + add_action( 'mainwp_render_updates', array( &$this, 'hook_render_updates' ), 10, 2 );
176 166
177 - /**
178 - * MainWP API hooks.
179 - *
180 - * @since 4.5.
181 - */
182 - add_filter( 'mainwp_extension_get_activation_info', array( &$this, 'hook_get_activation_info' ), 10, 2 );
183 - add_filter( 'mainwp_get_api_url', array( &$this, 'hook_get_api_url' ), 10, 1 );
184 - add_filter( 'mainwp_hook_run_dashboard_action', array( &$this, 'hook_run_dashboard_action' ), 10, 2 );
167 + /**
168 + * Filter: mainwp_get_tokens_values
169 + *
170 + * Get tokens values for reports.
171 + *
172 + * @since 4.3.
173 + */
174 + add_filter( 'mainwp_get_reports_group_values_website', array( MainWP_Reports_Helper::get_instance(), 'hook_get_reports_group_values' ), 10, 6 );
175 + }
185 176
186 - /**
187 - * Key encrypt hooks.
188 - *
189 - * @since 4.5.
190 - */
191 - add_filter( 'mainwp_get_key_value', array( &$this, 'hook_get_key_value' ), 10, 3 );
192 - add_filter( 'mainwp_update_key_value', array( &$this, 'hook_update_key_value' ), 10, 4 );
193 - add_action( 'mainwp_delete_key_value', array( &$this, 'hook_delete_key_value' ), 10, 1 );
177 + /**
178 + * Method mainwp_log_debug()
179 + *
180 + * MainWP debug log.
181 + *
182 + * @param string $text Debug text.
183 + *
184 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
185 + */
186 + public function mainwp_log_debug( $text ) {
187 + MainWP_Logger::instance()->debug( $text );
188 + }
194 189
195 - add_filter( 'mainwp_encrypt_key_value', array( &$this, 'hook_encrypt_key_value' ), 10, 4 );
196 - add_filter( 'mainwp_decrypt_key_value', array( &$this, 'hook_decrypt_key_value' ), 10, 3 );
197 - add_action( 'mainwp_delete_key_file', array( &$this, 'hook_delete_key_file' ), 10, 1 );
198 - add_filter( 'mainwp_verify_ping_nonce', array( MainWP_Utility::class, 'hook_verify_ping_nonce' ), 10, 3 );
199 - add_action( 'mainwp_fetch_url_authed', array( MainWP_Actions_Handler::instance(), 'hook_mainwp_fetch_url_authed' ), 10, 5 );
190 + /**
191 + * Method mainwp_log_info()
192 + *
193 + * MainWP log info.
194 + *
195 + * @param string $text Info Text.
196 + *
197 + * @uses \MainWP\Dashboard\MainWP_Logger::info()
198 + */
199 + public function mainwp_log_info( $text ) {
200 + MainWP_Logger::instance()->info( $text );
201 + }
200 202
201 - add_filter( 'mainwp_get_lookup_items', array( &$this, 'hook_get_lookup_items' ), 10, 4 );
202 - add_filter( 'mainwp_insert_lookup_item', array( &$this, 'hook_insert_lookup_item' ), 10, 5 );
203 - add_filter( 'mainwp_delete_lookup_items', array( &$this, 'hook_delete_lookup_items' ), 10, 3 );
204 - add_filter( 'mainwp_get_indicator', array( &$this, 'hook_get_indicator' ), 10, 4 );
205 - }
203 + /**
204 + * Method mainwp_log_warning()
205 + *
206 + * MainWP log warning.
207 + *
208 + * @param string $text Warning text.
209 + *
210 + * @uses \MainWP\Dashboard\MainWP_Logger::warning()
211 + */
212 + public function mainwp_log_warning( $text ) {
213 + MainWP_Logger::instance()->warning( $text );
214 + }
206 215
207 - /**
208 - * Method get_instance().
209 - */
210 - public static function get_instance() {
211 - return new self();
212 - }
216 + /**
217 + * Method mainwp_log_action()
218 + *
219 + * MainWP log action.
220 + *
221 + * @param string $text Debug text.
222 + * @param int $priority priority.
223 + * @param int $log_color Set color: 0 - LOG, 1 - WARNING, 2 - INFO, 3- DEBUG.
224 + * @param bool $forced forced logging.
225 + *
226 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
227 + */
228 + public function mainwp_log_action( $text, $priority = 0, $log_color = 0, $forced = false ) {
229 + if ( ! empty( $priority ) ) {
230 + MainWP_Logger::instance()->log_action( $text, $priority, $log_color, $forced );
231 + }
232 + }
213 233
214 - /**
215 - * Method mainwp_log_debug()
216 - *
217 - * MainWP debug log.
218 - *
219 - * @param string $text Debug text.
220 - *
221 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
222 - */
223 - public function mainwp_log_debug( $text ) {
224 - MainWP_Logger::instance()->debug( $text );
225 - }
234 + /**
235 + * Method mainwp_log_execution_time()
236 + *
237 + * MainWP log execution time.
238 + *
239 + * @param string $text Debug text.
240 + *
241 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
242 + */
243 + public function mainwp_log_execution_time( $text = '' ) {
244 + MainWP_Logger::instance()->log_execution_time( $text );
245 + }
226 246
227 - /**
228 - * Method mainwp_log_info()
229 - *
230 - * MainWP log info.
231 - *
232 - * @param string $text Info Text.
233 - *
234 - * @uses \MainWP\Dashboard\MainWP_Logger::info()
235 - */
236 - public function mainwp_log_info( $text ) {
237 - MainWP_Logger::instance()->info( $text );
238 - }
247 + /**
248 + * Method enqueue_meta_boxes_scripts()
249 + *
250 + * Enqueue Scripts for all Meta boxes.
251 + *
252 + * @uses \MainWP\Dashboard\MainWP_System::enqueue_postbox_scripts()
253 + */
254 + public function enqueue_meta_boxes_scripts() {
255 + MainWP_System::enqueue_postbox_scripts();
256 + }
239 257
240 - /**
241 - * Method mainwp_log_warning()
242 - *
243 - * MainWP log warning.
244 - *
245 - * @param string $text Warning text.
246 - *
247 - * @uses \MainWP\Dashboard\MainWP_Logger::warning()
248 - */
249 - public function mainwp_log_warning( $text ) {
250 - MainWP_Logger::instance()->warning( $text );
251 - }
258 + /**
259 + * Method mainwp_add_site()
260 + *
261 + * Hook to add Child Site.
262 + *
263 + * @param array $params site data fields: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version,
264 + * http_user, http_pass, websiteid - if edit site.
265 + *
266 + * @return array $ret data fields: response, siteid.
267 + *
268 + * @throws \Exception Exception message.
269 + *
270 + * @since 3.2.2
271 + *
272 + * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site()
273 + * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::add_wp_site()
274 + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
275 + */
276 + public function mainwp_add_site( $params ) {
277 + $ret = array();
252 278
253 - /**
254 - * Method mainwp_log_action()
255 - *
256 - * MainWP log action.
257 - *
258 - * @param string $text Debug text.
259 - * @param int $priority priority: -1 disabled, 0 - log, 1 - warning, 2 - info, 3 - debug.
260 - * @param int $log_color Set color: 0 - LOG, 1 - WARNING, 2 - INFO, 3- DEBUG.
261 - * @param bool $forced forced logging.
262 - *
263 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
264 - */
265 - public function mainwp_log_action( $text, $priority = 0, $log_color = 0, $forced = false ) {
266 - if ( ! empty( $priority ) ) {
267 - MainWP_Logger::instance()->log_action( $text, $priority, $log_color, $forced );
268 - }
269 - }
279 + if ( is_array( $params ) ) {
280 + if ( isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) {
281 + $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params );
282 + return $ret;
283 + } elseif ( isset( $params['url'] ) && isset( $params['wpadmin'] ) ) {
284 + $website = MainWP_DB::instance()->get_websites_by_url( $params['url'] );
285 + list( $message, $error, $site_id ) = MainWP_Manage_Sites_View::add_wp_site( $website, $params );
270 286
271 - /**
272 - * Method mainwp_log_execution_time()
273 - *
274 - * MainWP log execution time.
275 - *
276 - * @param string $text Debug text.
277 - *
278 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
279 - */
280 - public function mainwp_log_execution_time( $text = '' ) {
281 - MainWP_Logger::instance()->log_execution_time( $text );
282 - }
287 + if ( '' !== $error ) {
288 + return array( 'error' => $error );
289 + }
290 + $ret['response'] = $message;
291 + $ret['siteid'] = $site_id;
292 + }
293 + }
283 294
284 - /**
285 - * Method enqueue_meta_boxes_scripts()
286 - *
287 - * Enqueue Scripts for all Meta boxes.
288 - *
289 - * @uses \MainWP\Dashboard\MainWP_System::enqueue_postbox_scripts()
290 - */
291 - public function enqueue_meta_boxes_scripts() {
292 - MainWP_System::enqueue_postbox_scripts();
293 - }
295 + return $ret;
296 + }
294 297
295 - /**
296 - * Method mainwp_add_site()
297 - *
298 - * Hook to add Child Site.
299 - *
300 - * @param array $params site data fields: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version,
301 - * http_user, http_pass, websiteid - if edit site.
302 - *
303 - * @return array $ret data fields: response, siteid.
304 - *
305 - * @throws \MainWP_Exception Exception message.
306 - *
307 - * @since 3.2.2
308 - *
309 - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site()
310 - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::add_wp_site()
311 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
312 - */
313 - public function mainwp_add_site( $params ) {
314 - $ret = array();
298 + /**
299 + * Method hook_delete_site()
300 + *
301 + * Hook to delete Child Site.
302 + *
303 + * @param bool $site_id Child site ID.
304 + *
305 + * @return bool|array Return false if empty and return array error - Site not found | result - SUCCESS.
306 + *
307 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
308 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_icons_dir()
309 + */
310 + public function hook_delete_site( $site_id = false ) {
315 311
316 - if ( is_array( $params ) ) {
317 - if ( isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) {
318 - $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params );
319 - return $ret;
320 - } elseif ( isset( $params['url'] ) && isset( $params['wpadmin'] ) ) {
321 - $website = MainWP_DB::instance()->get_websites_by_url( $params['url'] );
322 - list( $message, $error, $site_id ) = MainWP_Manage_Sites_View::add_wp_site( $website, $params );
312 + if ( empty( $site_id ) ) {
313 + return false;
314 + }
323 315
324 - if ( '' !== $error ) {
325 - return array( 'error' => $error );
326 - }
327 - $ret['response'] = $message;
328 - $ret['siteid'] = $site_id;
329 - }
330 - }
316 + $sql = MainWP_DB::instance()->get_sql_website_by_id( $site_id );
317 + $websites = MainWP_DB::instance()->query( $sql );
318 + $site = MainWP_DB::fetch_object( $websites );
331 319
332 - return $ret;
333 - }
320 + if ( empty( $site ) ) {
321 + return array( 'error' => esc_html__( 'Not found the website', 'mainwp' ) );
322 + }
323 + $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system();
334 324
335 - /**
336 - * Method is_pro_member()
337 - *
338 - * Check for inactive MainWP Extensions.
339 - *
340 - * @param mixed $input Input value.
341 - *
342 - * @return bool Activation notice.
343 - */
344 - public static function is_pro_member( $input = false ) {
345 - $info = get_option( 'mainwp_extensions_plan_info' );
346 - if ( ! empty( $info ) ) {
347 - $info = json_decode( $info, true );
348 - if ( is_array( $info ) && isset( $info['plan_purchased'] ) && isset( $info['plan_status'] ) && 'active' === $info['plan_status'] && in_array( $info['plan_purchased'], array( 'monthly', 'yearly', 'lifetime' ) ) ) {
349 - return true;
350 - }
351 - }
352 - return $input;
353 - }
325 + /**
326 + * WordPress files system object.
327 + *
328 + * @global object
329 + */
330 + global $wp_filesystem;
354 331
332 + if ( $hasWPFileSystem ) {
333 + $favi = MainWP_DB::instance()->get_website_option( $site, 'favi_icon', '' );
334 + if ( ! empty( $favi ) && ( false !== strpos( $favi, 'favi-' . $site->id . '-' ) ) ) {
335 + $dirs = MainWP_System_Utility::get_icons_dir();
336 + if ( $wp_filesystem->exists( $dirs[0] . $favi ) ) {
337 + $wp_filesystem->delete( $dirs[0] . $favi );
338 + }
339 + }
340 + }
355 341
356 - /**
357 - * Method hook_delete_site()
358 - *
359 - * Hook to delete Child Site.
360 - *
361 - * @param bool $site_id Child site ID.
362 - *
363 - * @return bool|array Return false if empty and return array error - Site not found | result - SUCCESS.
364 - *
365 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
366 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_icons_dir()
367 - */
368 - public function hook_delete_site( $site_id = false ) {
342 + MainWP_DB::instance()->remove_website( $site->id );
369 343
370 - if ( empty( $site_id ) ) {
371 - return false;
372 - }
344 + /** This action is documented in pages\page-mainwp-manage-sites-handler.php */
345 + do_action( 'mainwp_delete_site', $site );
346 + return array( 'result' => 'SUCCESS' );
347 + }
373 348
374 - $sql = MainWP_DB::instance()->get_sql_website_by_id( $site_id );
375 - $websites = MainWP_DB::instance()->query( $sql );
376 - $site = MainWP_DB::fetch_object( $websites );
349 + /**
350 + * Method filter_clone_site()
351 + *
352 + * Hook to clone site.
353 + *
354 + * @since 3.4.4
355 + * @param mixed $pluginFile Plugin file.
356 + * @param mixed $key Key.
357 + * @param mixed $websiteid Child site ID.
358 + * @param mixed $cloneid Clone site ID.
359 + * @param mixed $clone_url Clone site URL.
360 + * @param bool $force_update Force the update, true|false, Default: false.
361 + *
362 + * @return array Site array to clone.
363 + *
364 + * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_clone_site()
365 + */
366 + public function filter_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update = false ) {
367 + return MainWP_Extensions_Handler::hook_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update );
368 + }
377 369
378 - if ( empty( $site ) ) {
379 - return array( 'error' => esc_html__( 'Not found the website', 'mainwp' ) );
380 - }
381 - $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system();
370 + /**
371 + * Method filter_delete_clone_site()
372 + *
373 + * Hook to delete cloaned Child Site.
374 + *
375 + * @param mixed $pluginFile Plugin file.
376 + * @param mixed $key Key.
377 + * @param string $clone_url Clone site URL.
378 + * @param bool $clone_site_id Clone site ID.
379 + *
380 + * @return array Site array to delete.
381 + *
382 + * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_delete_clone_site()
383 + */
384 + public function filter_delete_clone_site( $pluginFile, $key, $clone_url = '', $clone_site_id = false ) {
385 + return MainWP_Extensions_Handler::hook_delete_clone_site( $pluginFile, $key, $clone_url, $clone_site_id );
386 + }
382 387
383 - /**
384 - * WordPress files system object.
385 - *
386 - * @global object
387 - */
388 - global $wp_filesystem;
388 + /**
389 + * Method mainwp_edit_site()
390 + *
391 + * Hook to edit Child Site.
392 + *
393 + * @param array $params site data fields: websiteid, name, wpadmin, unique_id.
394 + *
395 + * @return array $ret Child site ID.
396 + *
397 + * @throws \Exception Exception message.
398 + *
399 + * @since 3.2.2
400 + *
401 + * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site()
402 + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
403 + */
404 + public function mainwp_edit_site( $params ) {
405 + $ret = array();
406 + if ( is_array( $params ) ) {
407 + if ( isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) {
408 + $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params );
409 + return $ret;
410 + }
411 + }
412 + return $ret;
413 + }
389 414
390 - if ( $hasWPFileSystem ) {
391 - $favi = MainWP_DB::instance()->get_website_option( $site, 'favi_icon', '' );
392 - if ( ! empty( $favi ) && ( false !== strpos( $favi, 'favi-' . $site->id . '-' ) ) ) {
393 - $dirs = MainWP_System_Utility::get_icons_dir();
394 - if ( $wp_filesystem->exists( $dirs[0] . $favi ) ) {
395 - $wp_filesystem->delete( $dirs[0] . $favi );
396 - }
397 - }
398 - }
415 + /**
416 + * Method hook_add_sub_left_menu()
417 + *
418 + * Hook to add MainWP Left Menu item.
419 + *
420 + * @param string $title Menu title.
421 + * @param string $slug Menu slug.
422 + * @param string $href Menu link.
423 + * @param integer $level Menu level.
424 + * @param string $parent_key Parent menu.
425 + *
426 + * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
427 + */
428 + public function hook_add_sub_left_menu( $title, $slug, $href, $level = 1, $parent_key = 'mainwp_tab' ) {
429 + $item = array(
430 + 'title' => $title,
431 + 'parent_key' => $parent_key,
432 + 'slug' => $slug,
433 + 'href' => $href,
434 + );
435 + MainWP_Menu::add_left_menu( $item, $level );
436 + }
399 437
400 - MainWP_DB::instance()->remove_website( $site->id );
438 + /**
439 + * Method is_extension_activated()
440 + *
441 + * Check for inactive MainWP Extensions.
442 + *
443 + * @param mixed $input Input value.
444 + * @param mixed $slug MainWP Extension to check.
445 + *
446 + * @return bool Activation notice.
447 + */
448 + public function is_extension_activated( $input, $slug ) {
449 + return MainWP_Extensions_Handler::is_extension_activated( $slug );
450 + }
401 451
402 - /** This action is documented in pages\page-mainwp-manage-sites-handler.php */
403 - do_action( 'mainwp_delete_site', $site );
404 - return array( 'result' => 'SUCCESS' );
405 - }
452 + /**
453 + * Method is_pro_member()
454 + *
455 + * Check for inactive MainWP Extensions.
456 + *
457 + * @param mixed $input Input value.
458 + *
459 + * @return bool Activation notice.
460 + */
461 + public function is_pro_member( $input = false ) {
462 + $info = get_option( 'mainwp_extensions_plan_info' );
463 + if ( ! empty( $info ) ) {
464 + $info = json_decode( $info, true );
465 + if ( is_array( $info ) && isset( $info['plan_purchased'] ) && isset( $info['plan_status'] ) ) {
466 + if ( 'active' === $info['plan_status'] && in_array( $info['plan_purchased'], array( 'monthly', 'yearly', 'lifetime' ) ) ) {
467 + return true;
468 + }
469 + }
470 + }
471 + return false;
472 + }
406 473
407 - /**
408 - * Method filter_clone_site()
409 - *
410 - * Hook to clone site.
411 - *
412 - * @since 3.4.4
413 - * @param mixed $pluginFile Plugin file.
414 - * @param mixed $key Key.
415 - * @param mixed $websiteid Child site ID.
416 - * @param mixed $cloneid Clone site ID.
417 - * @param mixed $clone_url Clone site URL.
418 - * @param bool $force_update Force the update, true|false, Default: false.
419 - *
420 - * @return array Site array to clone.
421 - *
422 - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_clone_site()
423 - */
424 - public function filter_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update = false ) {
425 - return MainWP_Extensions_Handler::hook_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update );
426 - }
427 474
428 - /**
429 - * Method filter_delete_clone_site()
430 - *
431 - * Hook to delete cloaned Child Site.
432 - *
433 - * @param mixed $pluginFile Plugin file.
434 - * @param mixed $key Key.
435 - * @param string $clone_url Clone site URL.
436 - * @param bool $clone_site_id Clone site ID.
437 - *
438 - * @return array Site array to delete.
439 - *
440 - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_delete_clone_site()
441 - */
442 - public function filter_delete_clone_site( $pluginFile, $key, $clone_url = '', $clone_site_id = false ) {
443 - return MainWP_Extensions_Handler::hook_delete_clone_site( $pluginFile, $key, $clone_url, $clone_site_id );
444 - }
475 + /**
476 + * Method get_activate_extension_notice()
477 + *
478 + * Check for inactive MainWP Extensions &
479 + * return an activation warning message.
480 + *
481 + * @param mixed $pluginFile MainWP Extension to check.
482 + *
483 + * @return string Activation notice.
484 + *
485 + * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::is_extension_activated()
486 + */
487 + public function get_activate_extension_notice( $pluginFile ) {
488 + $active = MainWP_Extensions_Handler::is_extension_activated( $pluginFile );
489 + if ( $active ) {
490 + return false;
491 + }
445 492
446 - /**
447 - * Method mainwp_edit_site()
448 - *
449 - * Hook to edit Child Site.
450 - *
451 - * @param array $params site data fields: websiteid, name, wpadmin, unique_id.
452 - *
453 - * @return array $ret Child site ID.
454 - *
455 - * @throws \MainWP_Exception Exception message.
456 - *
457 - * @since 3.2.2
458 - *
459 - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site()
460 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
461 - */
462 - public function mainwp_edit_site( $params ) {
463 - $ret = array();
464 - if ( is_array( $params ) && isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) {
465 - $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params );
466 - return $ret;
467 - }
468 - return $ret;
469 - }
493 + $activate_notices = get_user_option( 'mainwp_hide_activate_notices' );
494 + if ( is_array( $activate_notices ) ) {
495 + $slug = basename( $pluginFile, '.php' );
496 + if ( isset( $activate_notices[ $slug ] ) ) {
497 + return false;
498 + }
499 + }
470 500
471 - /**
472 - * Method hook_add_sub_left_menu()
473 - *
474 - * Hook to add MainWP Left Menu item.
475 - *
476 - * @param string $title Menu title.
477 - * @param string $slug Menu slug.
478 - * @param string $href Menu link.
479 - * @param integer $level Menu level.
480 - * @param string $parent_key Parent menu.
481 - *
482 - * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
483 - */
484 - public function hook_add_sub_left_menu( $title, $slug, $href, $level = 1, $parent_key = 'mainwp_tab' ) {
485 - $item = array(
486 - 'title' => $title,
487 - 'parent_key' => $parent_key,
488 - 'slug' => $slug,
489 - 'href' => $href,
490 - );
491 - MainWP_Menu::add_left_menu( $item, $level );
492 - }
501 + return sprintf( esc_html__( 'You have a MainWP extension that does not have an active API entered. This means you will not receive updates or support. Please visit the %1$sExtensions%2$s page and enter your API key.', 'mainwp' ), '<a href="admin.php?page=Extensions">', '</a>' );
502 + }
493 503
494 - /**
495 - * Method is_extension_activated()
496 - *
497 - * Check for inactive MainWP Extensions.
498 - *
499 - * @param mixed $input Input value.
500 - * @param mixed $slug MainWP Extension to check.
501 - *
502 - * @return bool Activation notice.
503 - */
504 - public function is_extension_activated( $input, $slug ) {
505 - unset( $input );
506 - return MainWP_Extensions_Handler::is_extension_activated( $slug );
507 - }
504 + /**
505 + * Method cache_getcontext()
506 + *
507 + * Get cached search context for given page.
508 + *
509 + * @param string $page Current MainWP Page.
510 + *
511 + * @return array Cached Search Array.
512 + */
513 + public function cache_getcontext( $page ) {
514 + return MainWP_Cache::get_cached_context( $page );
515 + }
508 516
517 + /**
518 + * Method cache_echo_body()
519 + *
520 + * Echo Cached Search Body.
521 + *
522 + * @param string $page Current MainWP Page.
523 + */
524 + public function cache_echo_body( $page ) {
525 + MainWP_Cache::echo_body( $page );
526 + }
509 527
510 - /**
511 - * Method get_activate_extension_notice()
512 - *
513 - * Check for inactive MainWP Extensions &
514 - * return an activation warning message.
515 - *
516 - * @param mixed $pluginFile MainWP Extension to check.
517 - *
518 - * @return string Activation notice.
519 - *
520 - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::is_extension_activated()
521 - */
522 - public function get_activate_extension_notice( $pluginFile ) {
523 - $active = MainWP_Extensions_Handler::is_extension_activated( $pluginFile );
524 - if ( $active ) {
525 - return false;
526 - }
528 + /**
529 + * Method cache_init()
530 + *
531 + * Initiate search session variables for the current page.
532 + *
533 + * @param string $page Current MainWP Page.
534 + */
535 + public function cache_init( $page ) {
536 + MainWP_Cache::init_cache( $page );
537 + }
527 538
528 - $activate_notices = get_user_option( 'mainwp_hide_activate_notices' );
529 - if ( is_array( $activate_notices ) ) {
530 - $slug = basename( $pluginFile, '.php' );
531 - if ( isset( $activate_notices[ $slug ] ) ) {
532 - return false;
533 - }
534 - }
539 + /**
540 + * Method cache_add_context()
541 + *
542 + * Hook to add time & Search Context session variable.
543 + *
544 + * @param string $page Current MainWP Page.
545 + * @param mixed $context Time of search.
546 + */
547 + public function cache_add_context( $page, $context ) {
548 + MainWP_Cache::add_context( $page, $context );
549 + }
535 550
536 - return sprintf( esc_html__( 'You have a MainWP extension that does not have an active API entered. This means you will not receive updates or support. Please visit the %1$sExtensions%2$s page and enter your API key.', 'mainwp' ), '<a href="admin.php?page=Extensions">', '</a>' );
537 - }
551 + /**
552 + * Method cache_add_body()
553 + *
554 + * Hook to add Search Body Session variable.
555 + *
556 + * @param string $page Current MainWP Page.
557 + * @param mixed $body Search body.
558 + */
559 + public function cache_add_body( $page, $body ) {
560 + MainWP_Cache::add_body( $page, $body );
561 + }
538 562
539 - /**
540 - * Method cache_getcontext()
541 - *
542 - * Get cached search context for given page.
543 - *
544 - * @param string $page Current MainWP Page.
545 - *
546 - * @return array Cached Search Array.
547 - */
548 - public function cache_getcontext( $page ) {
549 - return MainWP_Cache::get_cached_context( $page );
550 - }
563 + /**
564 + * Method select_sites_box()
565 + *
566 + * Hook to select sites box.
567 + *
568 + * @param string $title Input title.
569 + * @param string $type Input type, radio.
570 + * @param bool $show_group Whether or not to show group, Default: true.
571 + * @param bool $show_select_all Whether to show select all.
572 + * @param string $class Default = ''.
573 + * @param string $style Default = ''.
574 + * @param array $selected_websites Selected Child Sites.
575 + * @param array $selected_groups Selected Groups.
576 + * @param bool $show_client Show Clients.
577 + * @param array $selected_clients Selected Clients.
578 + * @param mixed $post_id post ID.
579 + */
580 + public function select_sites_box( $title = '', $type = 'checkbox', $show_group = true, $show_select_all = true, $class = '', $style = '', $selected_websites = array(), $selected_groups = array(), $show_client = false, $selected_clients = array(), $post_id = false ) {
581 + $sel_params = array(
582 + 'type' => $type,
583 + 'show_group' => $show_group,
584 + 'show_select_all' => $show_select_all,
585 + 'class' => $class,
586 + 'style' => $style,
587 + 'selected_sites' => $selected_websites,
588 + 'selected_groups' => $selected_groups,
589 + 'show_client' => $show_client,
590 + 'selected_clients' => $selected_clients,
591 + 'post_id' => $post_id,
592 + );
593 + MainWP_UI_Select_Sites::select_sites_box( $sel_params );
594 + }
551 595
552 - /**
553 - * Method cache_echo_body()
554 - *
555 - * Echo Cached Search Body.
556 - *
557 - * @param string $page Current MainWP Page.
558 - */
559 - public function cache_echo_body( $page ) {
560 - MainWP_Cache::echo_body( $page );
561 - }
596 + /**
597 + * Method hook_add_categories_box()
598 + *
599 + * General categories box.
600 + *
601 + * @param int $post_id Post ID.
602 + */
603 + public function hook_add_categories_box( $post_id = false ) {
604 + MainWP_System::instance()->metaboxes->add_categories( $post_id );
605 + }
562 606
563 - /**
564 - * Method cache_init()
565 - *
566 - * Initiate search session variables for the current page.
567 - *
568 - * @param string $page Current MainWP Page.
569 - */
570 - public function cache_init( $page ) {
571 - MainWP_Cache::init_cache( $page );
572 - }
607 + /**
608 + * Method hook_notify_user()
609 + *
610 + * Hook to send user a notification.
611 + *
612 + * @param int $userId User ID.
613 + * @param string $subject Email Subject.
614 + * @param string $content Email Content.
615 + *
616 + * @uses \MainWP\Dashboard\MainWP_Notification::send_notify_user()
617 + */
618 + public function hook_notify_user( $userId, $subject, $content ) {
619 + MainWP_Notification::send_notify_user( $userId, $subject, $content );
620 + }
573 621
574 - /**
575 - * Method cache_add_context()
576 - *
577 - * Hook to add time & Search Context session variable.
578 - *
579 - * @param string $page Current MainWP Page.
580 - * @param mixed $context Time of search.
581 - */
582 - public function cache_add_context( $page, $context ) {
583 - MainWP_Cache::add_context( $page, $context );
584 - }
622 + /**
623 + * Method get_error_message()
624 + *
625 + * Hook to get error message.
626 + *
627 + * @param object $msg Error message.
628 + * @param object $extra HTTP error message.
629 + *
630 + * @return string Error message.
631 + *
632 + * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
633 + */
634 + public function get_error_message( $msg, $extra ) {
635 + return MainWP_Error_Helper::get_error_message( new MainWP_Exception( $msg, $extra ) );
636 + }
585 637
586 - /**
587 - * Method cache_add_body()
588 - *
589 - * Hook to add Search Body Session variable.
590 - *
591 - * @param string $page Current MainWP Page.
592 - * @param mixed $body Search body.
593 - */
594 - public function cache_add_body( $page, $body ) {
595 - MainWP_Cache::add_body( $page, $body );
596 - }
638 + /**
639 + * Method hook_get_user_extension()
640 + *
641 + * Hook to get user extension.
642 + *
643 + * @return object $row User extension.
644 + */
645 + public function hook_get_user_extension() {
646 + return MainWP_DB_Common::instance()->get_user_extension();
647 + }
597 648
598 - /**
599 - * Method hook_select_sites_box()
600 - *
601 - * Hook to select sites box.
602 - *
603 - * @param string $title Input title.
604 - * @param string $type Input type, radio.
605 - * @param bool $show_group Whether or not to show group, Default: true.
606 - * @param bool $show_select_all Whether to show select all.
607 - * @param string $class_style Default = ''.
608 - * @param string $style Default = ''.
609 - * @param array $selected_websites Selected Child Sites.
610 - * @param array $selected_groups Selected Groups.
611 - * @param bool $show_client Show Clients.
612 - * @param array $selected_clients Selected Clients.
613 - * @param mixed $post_id post ID.
614 - * @param bool $show_create_tag Show create tag button.
615 - */
616 - public function hook_select_sites_box( $title = '', $type = 'checkbox', $show_group = true, $show_select_all = true, $class_style = '', $style = '', $selected_websites = array(), $selected_groups = array(), $show_client = false, $selected_clients = array(), $post_id = false, $show_create_tag = true ) { //phpcs:ignore -- NOSONAR - compatible.
617 - unset( $title );
618 - $sel_params = array(
619 - 'type' => $type,
620 - 'show_group' => $show_group,
621 - 'show_select_all' => $show_select_all,
622 - 'class' => $class_style,
623 - 'style' => $style,
624 - 'selected_sites' => $selected_websites,
625 - 'selected_groups' => $selected_groups,
626 - 'show_client' => $show_client,
627 - 'selected_clients' => $selected_clients,
628 - 'post_id' => $post_id,
629 - 'show_create_tag' => $show_create_tag,
630 - );
631 - MainWP_UI_Select_Sites::select_sites_box( $sel_params );
632 - }
649 + /**
650 + * Method update_user_extension()
651 + *
652 + * Hook to update user extension.
653 + *
654 + * @param bool $false input filter value.
655 + * @param string $option_name option name.
656 + * @param mixed $option_value option value.
657 + *
658 + * @return bool true.
659 + */
660 + public function update_user_extension( $false, $option_name, $option_value ) {
661 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
662 + $userExtension->{$option_name} = wp_json_encode( $option_value );
663 + MainWP_DB_Common::instance()->update_user_extension( $userExtension );
664 + return true;
665 + }
633 666
634 - /**
635 - * Method hook_add_categories_box()
636 - *
637 - * General categories box.
638 - *
639 - * @param int $post_id Post ID.
640 - */
641 - public function hook_add_categories_box( $post_id = false ) {
642 - MainWP_System::instance()->metaboxes->add_categories( $post_id );
643 - }
667 + /**
668 + * Method hook_get_site_options()
669 + *
670 + * Hook to get Child site options.
671 + *
672 + * @param mixed $boolean Boolean check.
673 + * @param object $website Child site object.
674 + * @param string|array $options Option table name.
675 + *
676 + * @return string|null Database query result (as string), or null on failure
677 + */
678 + public function hook_get_site_options( $boolean, $website, $options = '' ) {
644 679
645 - /**
646 - * Method hook_notify_user()
647 - *
648 - * Hook to send user a notification.
649 - *
650 - * @param int $userId User ID.
651 - * @param string $subject Email Subject.
652 - * @param string $content Email Content.
653 - *
654 - * @uses \MainWP\Dashboard\MainWP_Notification::send_notify_user()
655 - */
656 - public function hook_notify_user( $userId, $subject, $content ) {
657 - MainWP_Notification::send_notify_user( $userId, $subject, $content );
658 - }
680 + if ( empty( $options ) ) {
681 + return $boolean;
682 + }
659 683
660 - /**
661 - * Method get_error_message()
662 - *
663 - * Hook to get error message.
664 - *
665 - * @param object $msg Error message.
666 - * @param object $extra HTTP error message.
667 - *
668 - * @return string Error message.
669 - *
670 - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
671 - */
672 - public function get_error_message( $msg, $extra ) {
673 - return MainWP_Error_Helper::get_error_message( new MainWP_Exception( $msg, $extra ) );
674 - }
684 + if ( is_string( $options ) ) {
685 + return MainWP_DB::instance()->get_website_option( $website, $options );
686 + } elseif ( is_array( $options ) ) {
687 + return MainWP_DB::instance()->get_website_options_array( $website, $options );
688 + }
689 + return $boolean;
690 + }
675 691
676 - /**
677 - * Method hook_get_user_extension()
678 - *
679 - * Hook to get user extension.
680 - *
681 - * @return object $row User extension.
682 - */
683 - public function hook_get_user_extension() {
684 - return MainWP_DB_Common::instance()->get_user_extension();
685 - }
692 + /**
693 + * Method hook_update_site_options()
694 + *
695 + * Hook to get Child site options.
696 + *
697 + * @param mixed $boolean Boolean check.
698 + * @param object $website Child site object.
699 + * @param string $option Option name.
700 + * @param string $value Option value.
701 + *
702 + * @return string|null Database query result (as string), or null on failure
703 + */
704 + public function hook_update_site_options( $boolean, $website, $option, $value ) {
705 + if ( is_numeric( $website ) ) {
706 + $obj = new \stdClass();
707 + $obj->id = intval( $website );
708 + $website = $obj;
709 + } elseif ( ! is_object( $website ) || ! property_exists( $website, 'id' ) ) {
710 + return false;
711 + }
712 + return MainWP_DB::instance()->update_website_option( $website, $option, $value );
713 + }
686 714
687 - /**
688 - * Method update_user_extension()
689 - *
690 - * Hook to update user extension.
691 - *
692 - * @param bool $input_value input filter value.
693 - * @param string $option_name option name.
694 - * @param mixed $option_value option value.
695 - *
696 - * @return bool true.
697 - */
698 - public function update_user_extension( $input_value, $option_name, $option_value ) {
699 - unset( $input_value );
700 - $userExtension = MainWP_DB_Common::instance()->get_user_extension();
701 - $userExtension->{$option_name} = wp_json_encode( $option_value );
702 - MainWP_DB_Common::instance()->update_user_extension( $userExtension );
703 - return true;
704 - }
715 + /**
716 + * Get sites by user ID.
717 + *
718 + * @param mixed $boolean Boolean check.
719 + * @param int $userid User ID.
720 + * @param bool $selectgroups Selected groups.
721 + * @param null $search_site Site search field value.
722 + * @param string $orderBy Order list by. Default: URL.
723 + *
724 + * @return object|null Database query results or null on failure.
725 + */
726 + public function hook_get_websites_by_user_id( $boolean, $userid, $selectgroups = false, $search_site = null, $orderBy = 'wp.url' ) {
727 + return MainWP_DB::instance()->get_websites_by_user_id( $userid, $selectgroups, $search_site, $orderBy );
728 + }
705 729
706 - /**
707 - * Method hook_get_site_options()
708 - *
709 - * Hook to get Child site options.
710 - *
711 - * @param mixed $boolean Boolean check.
712 - * @param object $website Child site object.
713 - * @param string|array $options Option table name.
714 - *
715 - * @return string|null Database query result (as string), or null on failure
716 - */
717 - public function hook_get_site_options( $boolean, $website, $options = '' ) {
730 + /**
731 + * Get sites by website ID.
732 + *
733 + * @param mixed $boolean Boolean check.
734 + * @param int $website_id User ID.
735 + * @param bool $selectGroups Select groups.
736 + * @param array $extra_view get extra option fields.
737 + *
738 + * @return object|null Database query results or null on failure.
739 + */
740 + public function hook_get_website_by_id( $boolean, $website_id, $selectGroups = false, $extra_view = array() ) {
718 741
719 - if ( empty( $options ) ) {
720 - return $boolean;
721 - }
742 + if ( empty( $website_id ) ) {
743 + return false;
744 + }
722 745
723 - if ( is_string( $options ) ) {
724 - return MainWP_DB::instance()->get_website_option( $website, $options );
725 - } elseif ( is_array( $options ) ) {
726 - return MainWP_DB::instance()->get_website_options_array( $website, $options );
727 - }
728 - return $boolean;
729 - }
746 + $website = MainWP_DB::instance()->get_website_by_id( $website_id, $selectGroups, $extra_view );
730 747
731 - /**
732 - * Method hook_update_site_options()
733 - *
734 - * Hook to get Child site options.
735 - *
736 - * @param mixed $boolean Boolean check.
737 - * @param object $website Child site object.
738 - * @param string $option Option name.
739 - * @param string $value Option value.
740 - *
741 - * @return string|null Database query result (as string), or null on failure
742 - */
743 - public function hook_update_site_options( $boolean, $website, $option, $value ) {
744 - unset( $boolean );
748 + if ( ! empty( $website ) && property_exists( $website, 'privkey' ) ) {
749 + unset( $website->privkey );
750 + }
745 751
746 - if ( is_numeric( $website ) ) {
747 - $obj = new \stdClass();
748 - $obj->id = intval( $website );
749 - $website = $obj;
750 - } elseif ( ! is_object( $website ) || ! property_exists( $website, 'id' ) ) {
751 - return false;
752 - }
753 - return MainWP_DB::instance()->update_website_option( $website, $option, $value );
754 - }
752 + if ( ! empty( $website ) && property_exists( $website, 'nosslkey' ) ) {
753 + unset( $website->nosslkey );
754 + }
755 755
756 - /**
757 - * Get sites by user ID.
758 - *
759 - * @param mixed $boolean Boolean check.
760 - * @param int $userid User ID.
761 - * @param bool $selectgroups Selected groups.
762 - * @param null $search_site Site search field value.
763 - * @param string $orderBy Order list by. Default: URL.
764 - *
765 - * @return object|null Database query results or null on failure.
766 - */
767 - public function hook_get_websites_by_user_id( $boolean, $userid, $selectgroups = false, $search_site = null, $orderBy = 'wp.url' ) {
768 - unset( $boolean );
769 - return MainWP_DB::instance()->get_websites_by_user_id( $userid, $selectgroups, $search_site, $orderBy );
770 - }
756 + return $website;
757 + }
771 758
772 - /**
773 - * Get sites by website ID.
774 - *
775 - * @param mixed $boolean Boolean check.
776 - * @param int $website_id User ID.
777 - * @param bool $selectGroups Select groups.
778 - * @param array $extra_view get extra option fields.
779 - *
780 - * @return object|null Database query results or null on failure.
781 - */
782 - public function hook_get_website_by_id( $boolean, $website_id, $selectGroups = false, $extra_view = array() ) {
783 - unset( $boolean );
784 - if ( empty( $website_id ) ) {
785 - return false;
786 - }
787 759
788 - $website = MainWP_DB::instance()->get_website_by_id( $website_id, $selectGroups, $extra_view );
760 + /**
761 + * Method get_websites_by_url()
762 + *
763 + * Hook to get Child Site by URL.
764 + *
765 + * @param string $url Child Site URL.
766 + *
767 + * @return array|object|null Database query results.
768 + */
769 + public function get_websites_by_url( $url ) {
770 + return MainWP_DB::instance()->get_websites_by_url( $url );
771 + }
789 772
790 - if ( ! empty( $website ) && property_exists( $website, 'privkey' ) ) {
791 - unset( $website->privkey );
792 - }
773 + /**
774 + * Method hook_get_all_posts()
775 + * Hook to get posts from sites.
776 + *
777 + * @param object $sites Child Sites object.
778 + * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type.
779 + *
780 + * @return \stdClass $output All posts data array.
781 + *
782 + * @since 3.4.4
783 + *
784 + * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
785 + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
786 + * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
787 + */
788 + public function hook_get_all_posts( $sites, $post_data = array() ) {
793 789
794 - return $website;
795 - }
790 + $dbwebsites = array();
791 + $data = array( 'id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey', 'verify_certificate', 'http_user', 'http_pass', 'ssl_version' );
796 792
793 + if ( '' !== $sites ) {
794 + foreach ( $sites as $k => $v ) {
795 + if ( MainWP_Utility::ctype_digit( $v ) ) {
796 + $website = MainWP_DB::instance()->get_website_by_id( $v );
797 + if ( '' == $website->sync_errors && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
798 + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data );
799 + }
800 + }
801 + }
802 + }
797 803
798 - /**
799 - * Method get_websites_by_url()
800 - *
801 - * Hook to get Child Site by URL.
802 - *
803 - * @param string $url Child Site URL.
804 - *
805 - * @return array|object|null Database query results.
806 - */
807 - public function get_websites_by_url( $url ) {
808 - return MainWP_DB::instance()->get_websites_by_url( $url );
809 - }
804 + $default_data = array(
805 + 'post_type' => 'post',
806 + 'status' => 'publish',
807 + 'maxRecords' => 10,
808 + );
810 809
811 - /**
812 - * Method hook_get_all_posts()
813 - * Hook to get posts from sites.
814 - *
815 - * @param object $sites Child Sites object.
816 - * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type.
817 - *
818 - * @return \stdClass $output All posts data array.
819 - *
820 - * @since 3.4.4
821 - *
822 - * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
823 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
824 - * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
825 - */
826 - public function hook_get_all_posts( $sites, $post_data = array() ) {
810 + $post_data = array_merge( $default_data, $post_data );
827 811
828 - $dbwebsites = array();
812 + $output = new \stdClass();
813 + $output->results = array();
814 + if ( $dbwebsites ) {
815 + MainWP_Connect::fetch_urls_authed(
816 + $dbwebsites,
817 + 'get_all_posts',
818 + $post_data,
819 + array(
820 + MainWP_Post::get_class_name(),
821 + 'hook_posts_search_handler',
822 + ),
823 + $output,
824 + $is_external_hook = true
825 + );
826 + }
827 + return $output;
828 + }
829 829
830 - $data = MainWP_System_Utility::get_default_map_site_fields();
831 - $data[] = 'verify_certificate';
830 + /**
831 + * Method mainwp_current_user_have_right()
832 + *
833 + * Check permission level by hook mainwp_currentusercan of Team Control extension
834 + *
835 + * @param mixed $input Return value holder.
836 + * @param string $can_type group or type of capabilities.
837 + * @param string $which Which function to perform.
838 + *
839 + * @return bool $input Return true if the user can and false if they can not.
840 + */
841 + public function hook_current_user_can( $input, $can_type, $which ) {
832 842
833 - if ( '' !== $sites ) {
834 - foreach ( $sites as $v ) {
835 - if ( MainWP_Utility::ctype_digit( $v ) ) {
836 - $website = MainWP_DB::instance()->get_website_by_id( $v );
837 - if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
838 - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data );
839 - }
840 - }
841 - }
842 - }
843 + if ( function_exists( 'mainwp_current_user_have_right' ) ) {
844 + return mainwp_current_user_have_right( $can_type, $which );
845 + }
843 846
844 - $default_data = array(
845 - 'post_type' => 'post',
846 - 'status' => 'publish',
847 - 'maxRecords' => 10,
848 - );
847 + return $input;
848 + }
849 849
850 - $post_data = array_merge( $default_data, $post_data );
850 + /**
851 + * Method hook_escape_response()
852 + *
853 + * To escape response data.
854 + *
855 + * @param mixed $response response data.
856 + * @param bool $fields fields of response data - option.
857 + * @param array $more_allowed input allowed tags - option.
858 + *
859 + * @return mixed $response valid response data.
860 + * @throws \Exception Exception message.
861 + *
862 + * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
863 + * @uses \MainWP\Dashboard\MainWP_Utility::esc_mixed_content()
864 + */
865 + public function hook_escape_response( $response, $fields = false, $more_allowed = array() ) {
851 866
852 - $output = new \stdClass();
853 - $output->results = array();
854 - if ( $dbwebsites ) {
855 - MainWP_Connect::fetch_urls_authed(
856 - $dbwebsites,
857 - 'get_all_posts',
858 - $post_data,
859 - array(
860 - MainWP_Post::get_class_name(),
861 - 'hook_posts_search_handler',
862 - ),
863 - $output
864 - );
865 - }
866 - return $output;
867 - }
867 + if ( false === $fields || is_string( $response ) ) {
868 + return MainWP_Utility::esc_content( $response );
869 + }
868 870
869 - /**
870 - * Method mainwp_current_user_have_right()
871 - *
872 - * Check permission level by hook mainwp_currentusercan of Team Control extension
873 - *
874 - * @param mixed $input Return value holder.
875 - * @param string $can_type group or type of capabilities.
876 - * @param string $which Which function to perform.
877 - *
878 - * @return bool $input Return true if the user can and false if they can not.
879 - */
880 - public function hook_current_user_can( $input, $can_type, $which ) {
871 + if ( ! is_array( $fields ) ) {
872 + return $response;
873 + }
881 874
882 - if ( function_exists( 'mainwp_current_user_have_right' ) ) {
883 - return mainwp_current_user_have_right( $can_type, $which );
884 - }
875 + if ( ! in_array( 'error', $fields ) ) {
876 + $fields[] = 'error'; // to sure to valid 'error' field, if that existed.
877 + }
885 878
886 - return $input;
887 - }
879 + if ( ! in_array( 'message', $fields ) ) {
880 + $fields[] = 'message'; // to sure to valid 'message' field, if that existed.
881 + }
888 882
889 - /**
890 - * Method hook_escape_response()
891 - *
892 - * To escape response data.
893 - *
894 - * @param mixed $response response data.
895 - * @param bool $fields fields of response data - option.
896 - * @param array $more_allowed input allowed tags - option.
897 - *
898 - * @return mixed $response valid response data.
899 - * @throws \MainWP_Exception Exception message.
900 - *
901 - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
902 - * @uses \MainWP\Dashboard\MainWP_Utility::esc_mixed_content()
903 - */
904 - public function hook_escape_response( $response, $fields = false, $more_allowed = array() ) {
883 + $depth = 10;
905 884
906 - if ( false === $fields || is_string( $response ) ) {
907 - return MainWP_Utility::esc_content( $response );
908 - }
885 + foreach ( $fields as $field ) {
886 + if ( isset( $response[ $field ] ) ) {
887 + $response[ $field ] = MainWP_Utility::esc_mixed_content( $response[ $field ], $depth, $more_allowed );
888 + }
889 + }
890 + return $response;
891 + }
909 892
910 - if ( ! is_array( $fields ) ) {
911 - return $response;
912 - }
893 + /**
894 + * Method hook_escape_content()
895 + *
896 + * To escape content.
897 + *
898 + * @param mixed $content response data.
899 + * @param string $type content type for escape.
900 + * @param array $more_allowed input allowed tags - option.
901 + *
902 + * @return mixed $response valid response data.
903 + * @throws \Exception Exception message.
904 + *
905 + * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
906 + */
907 + public function hook_escape_content( $content, $type = 'note', $more_allowed = array() ) {
908 + return MainWP_Utility::esc_content( $content, $type, $more_allowed );
909 + }
913 910
914 - if ( ! in_array( 'error', $fields ) ) {
915 - $fields[] = 'error'; // to sure to valid 'error' field, if that existed.
916 - }
917 911
918 - if ( ! in_array( 'message', $fields ) ) {
919 - $fields[] = 'message'; // to sure to valid 'message' field, if that existed.
920 - }
912 + /**
913 + * Method db_free_result()
914 + *
915 + * To escape response data.
916 + *
917 + * @param mixed $false input value.
918 + * @param mixed $result result data.
919 + *
920 + * @return bool true.
921 + */
922 + public function db_free_result( $false, $result ) {
923 + MainWP_DB::free_result( $result );
924 + return true;
925 + }
921 926
922 - $depth = 10;
927 + /**
928 + * Method db_num_rows()
929 + *
930 + * To escape response data.
931 + *
932 + * @param mixed $false input value.
933 + * @param mixed $result result data.
934 + *
935 + * @return bool true.
936 + */
937 + public function db_num_rows( $false, $result ) {
938 + return MainWP_DB::num_rows( $result );
939 + }
923 940
924 - foreach ( $fields as $field ) {
925 - if ( isset( $response[ $field ] ) ) {
926 - $response[ $field ] = MainWP_Utility::esc_mixed_content( $response[ $field ], $depth, $more_allowed );
927 - }
928 - }
929 - return $response;
930 - }
931 941
932 - /**
933 - * Method hook_escape_content()
934 - *
935 - * To escape content.
936 - *
937 - * @param mixed $content response data.
938 - * @param string $type content type for escape.
939 - * @param array $more_allowed input allowed tags - option.
940 - *
941 - * @return mixed $response valid response data.
942 - * @throws \MainWP_Exception Exception message.
943 - *
944 - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
945 - */
946 - public function hook_escape_content( $content, $type = 'note', $more_allowed = array() ) {
947 - return MainWP_Utility::esc_content( $content, $type, $more_allowed );
948 - }
942 + /**
943 + * Method db_get_websites_for_current_user()
944 + *
945 + * To escape response data.
946 + *
947 + * @param mixed $false input value.
948 + * @param array $params params data.
949 + *
950 + * @return mixed websites.
951 + */
952 + public function db_get_websites_for_current_user( $false = false, $params = array() ) {
953 + if ( ! is_array( $params ) ) {
954 + $params = array();
955 + }
949 956
957 + $orderBy = isset( $params['orderby'] ) ? MainWP_DB::instance()->escape( $params['orderby'] ) : 'wp.url';
958 + $extra_view = isset( $params['extra_view'] ) ? $params['extra_view'] : array( 'favi_icon' );
950 959
951 - /**
952 - * Method db_free_result()
953 - *
954 - * To escape response data.
955 - *
956 - * @param mixed $input_value input value.
957 - * @param mixed $result result data.
958 - *
959 - * @return bool true.
960 - */
961 - public function db_free_result( $input_value, $result ) {
962 - unset( $input_value );
963 - MainWP_DB::free_result( $result );
964 - return true;
965 - }
960 + if ( ! is_array( $extra_view ) ) {
961 + $extra_view = array( 'favi_icon' );
962 + }
963 + return MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, $orderBy, false, false, null, false, $extra_view ) );
964 + }
966 965
967 - /**
968 - * Method db_num_rows()
969 - *
970 - * To escape response data.
971 - *
972 - * @param mixed $input_value input value.
973 - * @param mixed $result result data.
974 - *
975 - * @return bool true.
976 - */
977 - public function db_num_rows( $input_value, $result ) {
978 - unset( $input_value );
979 - return MainWP_DB::num_rows( $result );
980 - }
981 966
967 + /**
968 + * Method hook_sync_website()
969 + *
970 + * To escape response data.
971 + *
972 + * @param mixed $false input value.
973 + * @param int $website_id Website ID.
974 + * @param bool $fire_end_session to run the ending session or not.
975 + *
976 + * @return mixed websites.
977 + */
978 + public function hook_sync_website( $false, $website_id, $fire_end_session = true ) {
979 + if ( empty( $website_id ) ) {
980 + return $false;
981 + }
982 + $website = MainWP_DB::instance()->get_website_by_id( $website_id );
983 + if ( empty( $website ) ) {
984 + return $false;
985 + }
986 + return MainWP_Sync::sync_website( $website, $fire_end_session );
987 + }
982 988
983 - /**
984 - * Method db_get_websites_for_current_user()
985 - *
986 - * To escape response data.
987 - *
988 - * @param mixed $input_value input value.
989 - * @param array $params params data.
990 - *
991 - * @return mixed websites.
992 - */
993 - public function db_get_websites_for_current_user( $input_value = false, $params = array() ) {
994 - unset( $input_value );
995 - if ( ! is_array( $params ) ) {
996 - $params = array();
997 - }
989 + /**
990 + * Method hook_db_data_seek()
991 + *
992 + * To escape response data.
993 + *
994 + * @param mixed $result result data.
995 + * @param int $offset offset of data.
996 + */
997 + public function hook_db_data_seek( $result, $offset = 0 ) {
998 + MainWP_DB::data_seek( $result, $offset );
999 + }
998 1000
999 - $orderBy = isset( $params['orderby'] ) ? MainWP_DB::instance()->escape( $params['orderby'] ) : 'wp.url';
1000 - $extra_view = isset( $params['extra_view'] ) ? $params['extra_view'] : array( 'favi_icon' );
1001 1001
1002 - if ( ! is_array( $extra_view ) ) {
1003 - $extra_view = array( 'favi_icon' );
1004 - }
1005 - return MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, $orderBy, false, false, null, false, $extra_view ) );
1006 - }
1002 + /**
1003 + * Method hook_db_query()
1004 + *
1005 + * To query db.
1006 + *
1007 + * @param mixed $false filter input value.
1008 + * @param string $sql result data.
1009 + *
1010 + * @return bool true.
1011 + */
1012 + public function hook_db_query( $false, $sql ) {
1013 + return MainWP_DB::instance()->query( $sql );
1014 + }
1007 1015
1016 + /**
1017 + * Method db_fetch_object()
1018 + *
1019 + * To escape response data.
1020 + *
1021 + * @param mixed $false input value.
1022 + * @param mixed $result result data.
1023 + *
1024 + * @return bool true.
1025 + */
1026 + public function db_fetch_object( $false, $result ) {
1027 + return MainWP_DB::fetch_object( $result );
1028 + }
1008 1029
1009 - /**
1010 - * Method hook_sync_website()
1011 - *
1012 - * To escape response data.
1013 - *
1014 - * @param mixed $input_value input value.
1015 - * @param int $website_id Website ID.
1016 - * @param bool $fire_end_session to run the ending session or not.
1017 - *
1018 - * @return mixed websites.
1019 - */
1020 - public function hook_sync_website( $input_value, $website_id, $fire_end_session = true ) {
1021 - if ( empty( $website_id ) ) {
1022 - return $input_value;
1023 - }
1024 - $website = MainWP_DB::instance()->get_website_by_id( $website_id );
1025 - if ( empty( $website ) ) {
1026 - return $input_value;
1027 - }
1028 - return MainWP_Sync::sync_website( $website, $fire_end_session );
1029 - }
1030 1030
1031 + /**
1032 + * Method db_fetch_array()
1033 + *
1034 + * To escape response data.
1035 + *
1036 + * @param mixed $false input value.
1037 + * @param mixed $result result data.
1038 + *
1039 + * @return bool true.
1040 + */
1041 + public function db_fetch_array( $false, $result ) {
1042 + return MainWP_DB::fetch_array( $result );
1043 + }
1031 1044
1032 - /**
1033 - * Method hook_db_data_seek()
1034 - *
1035 - * To escape response data.
1036 - *
1037 - * @param mixed $result result data.
1038 - * @param int $offset offset of data.
1039 - */
1040 - public function hook_db_data_seek( $result, $offset = 0 ) {
1041 - MainWP_DB::data_seek( $result, $offset );
1042 - }
1043 1045
1046 + /**
1047 + * Get notification email settings.
1048 + *
1049 + * @param string $settings hook settings input value.
1050 + * @param string $type Notification type.
1051 + *
1052 + * @return array $gen_email_settings email settings.
1053 + */
1054 + public function get_notification_settings( $settings, $type ) {
1055 + $gen_email_settings = MainWP_Notification_Settings::get_general_email_settings( $type );
1056 + return $gen_email_settings;
1057 + }
1044 1058
1045 - /**
1046 - * Method hook_db_query()
1047 - *
1048 - * To query db.
1049 - *
1050 - * @param mixed $input_value filter input value.
1051 - * @param string $sql result data.
1052 - *
1053 - * @return bool true.
1054 - */
1055 - public function hook_db_query( $input_value, $sql ) {
1056 - unset( $input_value );
1057 - return MainWP_DB::instance()->query( $sql );
1058 - }
1059 + /**
1060 + * Hook send_wp_mail().
1061 + *
1062 + * Send email via wp_mail().
1063 + *
1064 + * @param string $input hook input value.
1065 + * @param string $email send to email.
1066 + * @param string $subject email content.
1067 + * @param bool $formated_content email content.
1068 + * @param string $content_type Text format.
1069 + */
1070 + public function hook_send_wp_mail( $input, $email, $subject, $formated_content, $content_type = '' ) {
1071 + return MainWP_Notification::send_wp_mail(
1072 + $email,
1073 + $subject,
1074 + $formated_content,
1075 + $content_type
1076 + );
1077 + }
1059 1078
1060 - /**
1061 - * Method db_fetch_object()
1062 - *
1063 - * To escape response data.
1064 - *
1065 - * @param mixed $input_value input value.
1066 - * @param mixed $result result data.
1067 - *
1068 - * @return bool true.
1069 - */
1070 - public function db_fetch_object( $input_value, $result ) {
1071 - unset( $input_value );
1072 - return MainWP_DB::fetch_object( $result );
1073 - }
1079 + /**
1080 + * Hook get template HTML content.
1081 + *
1082 + * @param string $input hooks input value.
1083 + * @param string $template_name Template name.
1084 + * @param array $args Arguments. (default: array).
1085 + *
1086 + * @return string
1087 + */
1088 + public function hook_get_template_html( $input, $template_name, $args = array() ) {
1089 + $mail_content = MainWP_Notification_Template::instance()->get_template_html(
1090 + $template_name,
1091 + $args
1092 + );
1093 + return $mail_content;
1094 + }
1074 1095
1096 + /**
1097 + * Method hook_secure_request()
1098 + *
1099 + * Security check to request parameter
1100 + *
1101 + * @param string $action Action to perform.
1102 + * @param string $query_arg Query argument.
1103 + *
1104 + * @uses \MainWP\Dashboard\MainWP_Post_Handler::secure_request()
1105 + */
1106 + public function hook_secure_request( $action = '', $query_arg = 'security' ) {
1107 + MainWP_Post_Handler::instance()->secure_request( $action, $query_arg );
1108 + }
1075 1109
1076 - /**
1077 - * Method db_fetch_array()
1078 - *
1079 - * To escape response data.
1080 - *
1081 - * @param mixed $input_value input value.
1082 - * @param mixed $result result data.
1083 - *
1084 - * @return bool true.
1085 - */
1086 - public function db_fetch_array( $input_value, $result ) {
1087 - unset( $input_value );
1088 - return MainWP_DB::fetch_array( $result );
1089 - }
1110 + /**
1111 + * Method hook_check_security_request()
1112 + *
1113 + * Security check to request parameter
1114 + *
1115 + * @param bool $false Input value.
1116 + * @param string $action Action to perform.
1117 + * @param string $query_arg Query argument.
1118 + */
1119 + public function hook_check_security_request( $false, $action = '', $query_arg = '' ) {
1120 + if ( empty( $query_arg ) ) {
1121 + $query_arg = $action; // to check wp_verify_nonce - sanitize_key( $_REQUEST[ $query_arg ] ) - $action.
1122 + }
1123 + return MainWP_Post_Handler::instance()->check_security( $action, $query_arg, false );
1124 + }
1090 1125
1126 + /**
1127 + * Method hook_get_mainwp_dir()
1128 + *
1129 + * Hook to get MainWP Directory.
1130 + *
1131 + * @param bool $false False.
1132 + * @param null $dir WP files system diectories.
1133 + * @param bool $direct_access Return true if Direct access file system. Default: false.
1134 + *
1135 + * @return array $newdir, $url.
1136 + *
1137 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
1138 + */
1139 + public function hook_get_mainwp_dir( $false = false, $dir = null, $direct_access = false ) {
1140 + return MainWP_System_Utility::get_mainwp_dir( $dir, $direct_access );
1141 + }
1091 1142
1092 - /**
1093 - * Get notification email settings.
1094 - *
1095 - * @param string $settings hook settings input value.
1096 - * @param string $type Notification type.
1097 - *
1098 - * @return array $gen_email_settings email settings.
1099 - */
1100 - public function get_notification_settings( $settings, $type ) {
1101 - unset( $settings );
1102 - return MainWP_Notification_Settings::get_general_email_settings( $type );
1103 - }
1104 1143
1105 - /**
1106 - * Hook send_wp_mail().
1107 - *
1108 - * Send email via wp_mail().
1109 - *
1110 - * @param string $input hook input value.
1111 - * @param string $email send to email.
1112 - * @param string $subject email content.
1113 - * @param bool $formated_content email content.
1114 - * @param string $content_type Text format.
1115 - */
1116 - public function hook_send_wp_mail( $input, $email, $subject, $formated_content, $content_type = '' ) {
1117 - unset( $input );
1118 - return MainWP_Notification::send_wp_mail(
1119 - $email,
1120 - $subject,
1121 - $formated_content,
1122 - $content_type
1123 - );
1124 - }
1144 + /**
1145 + * Method is_multi_user()
1146 + *
1147 + * Hook to check if multi user.
1148 + *
1149 + * @return bool true|false.
1150 + *
1151 + * @uses \MainWP\Dashboard\MainWP_System::is_multi_user()
1152 + */
1153 + public function is_multi_user() {
1154 + return MainWP_System::instance()->is_multi_user();
1155 + }
1125 1156
1126 - /**
1127 - * Hook get template HTML content.
1128 - *
1129 - * @param string $input hooks input value.
1130 - * @param string $template_name Template name.
1131 - * @param array $args Arguments. (default: array).
1132 - *
1133 - * @return string
1134 - */
1135 - public function hook_get_template_html( $input, $template_name, $args = array() ) {
1136 - unset( $input );
1137 - return MainWP_Notification_Template::instance()->get_template_html(
1138 - $template_name,
1139 - $args
1140 - );
1141 - }
1157 + /**
1158 + * Method filter_qq2_file_uploader()
1159 + *
1160 + * Hook to create new MainWP_QQ2_File_Uploader() class.
1161 + *
1162 + * @param mixed $allowedExtensions Allowed files extentions.
1163 + * @param mixed $sizeLimit Maximum file size allowed to be uploaded.
1164 + *
1165 + * @return MainWP_QQ2_File_Uploader Return instance of MainWP_QQ2_File_Uploader
1166 + *
1167 + * @uses \MainWP\Dashboard\MainWP_QQ2_File_Uploader
1168 + */
1169 + public function filter_qq2_file_uploader( $allowedExtensions, $sizeLimit ) {
1170 + return new MainWP_QQ2_File_Uploader( $allowedExtensions, $sizeLimit );
1171 + }
1142 1172
1143 - /**
1144 - * Method hook_secure_request()
1145 - *
1146 - * Security check to request parameter
1147 - *
1148 - * @param string $action Action to perform.
1149 - * @param string $query_arg Query argument.
1150 - *
1151 - * @uses \MainWP\Dashboard\MainWP_Post_Handler::secure_request()
1152 - */
1153 - public function hook_secure_request( $action = '', $query_arg = 'security' ) {
1154 - MainWP_Post_Handler::instance()->secure_request( $action, $query_arg );
1155 - }
1173 + /**
1174 + * Method get_metaboxes_post()
1175 + *
1176 + * Hook to get meta boxes.
1177 + *
1178 + * @return string|bool Return error or true.
1179 + *
1180 + * @uses \MainWP\Dashboard\MainWP_System::$metaboxes
1181 + */
1182 + public function get_metaboxes_post() {
1183 + return MainWP_System::instance()->metaboxes;
1184 + }
1156 1185
1157 - /**
1158 - * Method hook_check_security_request()
1159 - *
1160 - * Security check to request parameter
1161 - *
1162 - * @param bool $input_value Input value.
1163 - * @param string $action Action to perform.
1164 - * @param string $query_arg Query argument.
1165 - */
1166 - public function hook_check_security_request( $input_value, $action = '', $query_arg = '' ) {
1167 - unset( $input_value );
1168 - if ( empty( $query_arg ) ) {
1169 - //phpcs:ignore Squiz.PHP.CommentedOutCode.Found
1170 - // to do, $query_arg = 'security'.
1171 - $query_arg = $action; // to check wp_verify_nonce - sanitize_key( $_REQUEST[ $query_arg ] ) - $action.
1172 - }
1173 - return MainWP_Post_Handler::instance()->check_security( $action, $query_arg, false );
1174 - }
1186 + /**
1187 + * Method hook_notification_email()
1188 + *
1189 + * Hook to get notification email.
1190 + *
1191 + * @return string Return email.
1192 + */
1193 + public function hook_notification_email() {
1194 + return MainWP_Notification_Settings::get_general_email();
1195 + }
1175 1196
1176 - /**
1177 - * Method hook_get_mainwp_dir()
1178 - *
1179 - * Hook to get MainWP Directory.
1180 - *
1181 - * @param bool $input_value False.
1182 - * @param null $dir WP files system diectories.
1183 - * @param bool $direct_access Return true if Direct access file system. Default: false.
1184 - *
1185 - * @return array $newdir, $url.
1186 - *
1187 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
1188 - */
1189 - public function hook_get_mainwp_dir( $input_value = false, $dir = null, $direct_access = false ) {
1190 - unset( $input_value );
1191 - return MainWP_System_Utility::get_mainwp_dir( $dir, $direct_access );
1192 - }
1197 + /**
1198 + * Method get_formated_email()
1199 + *
1200 + * Hook to format email.
1201 + *
1202 + * @param mixed $body Email body.
1203 + * @param mixed $email Email address.
1204 + * @param string $title Email title.
1205 + *
1206 + * @return string|bool Return error or true.
1207 + *
1208 + * @uses \MainWP\Dashboard\MainWP_Format::format_email()
1209 + */
1210 + public function get_formated_email( $body, $email, $title = '' ) {
1211 + return MainWP_Format::format_email( $email, $body, $title );
1212 + }
1193 1213
1214 + /**
1215 + * Method active_plugin()
1216 + *
1217 + * Hook to activate plugins.
1218 + *
1219 + * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::activate_plugins()
1220 + */
1221 + public function active_plugin() {
1222 + MainWP_Plugins_Handler::activate_plugins();
1223 + die();
1224 + }
1194 1225
1195 - /**
1196 - * Method is_multi_user()
1197 - *
1198 - * Hook to check if multi user.
1199 - *
1200 - * @return bool true|false.
1201 - *
1202 - * @uses \MainWP\Dashboard\MainWP_System::is_multi_user()
1203 - */
1204 - public function is_multi_user() {
1205 - return MainWP_System::instance()->is_multi_user();
1206 - }
1226 + /**
1227 + * Method deactive_plugin()
1228 + *
1229 + * Hook to deactivate plugins.
1230 + *
1231 + * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::deactivate_plugins()
1232 + */
1233 + public function deactive_plugin() {
1234 + MainWP_Plugins_Handler::deactivate_plugins();
1235 + die();
1236 + }
1207 1237
1208 - /**
1209 - * Method filter_qq2_file_uploader()
1210 - *
1211 - * Hook to create new MainWP_QQ2_File_Uploader() class.
1212 - *
1213 - * @param mixed $allowedExtensions Allowed files extentions.
1214 - * @param mixed $sizeLimit Maximum file size allowed to be uploaded.
1215 - *
1216 - * @return MainWP_QQ2_File_Uploader Return instance of MainWP_QQ2_File_Uploader
1217 - *
1218 - * @uses \MainWP\Dashboard\MainWP_QQ2_File_Uploader
1219 - */
1220 - public function filter_qq2_file_uploader( $allowedExtensions, $sizeLimit ) {
1221 - return new MainWP_QQ2_File_Uploader( $allowedExtensions, $sizeLimit );
1222 - }
1238 + /**
1239 + * Method delete_plugin()
1240 + *
1241 + * Hook to delete plugins.
1242 + *
1243 + * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::delete_plugins()
1244 + */
1245 + public function delete_plugin() {
1246 + MainWP_Plugins_Handler::delete_plugins();
1247 + die();
1248 + }
1223 1249
1224 - /**
1225 - * Method get_metaboxes_post()
1226 - *
1227 - * Hook to get meta boxes.
1228 - *
1229 - * @return string|bool Return error or true.
1230 - *
1231 - * @uses \MainWP\Dashboard\MainWP_System::$metaboxes
1232 - */
1233 - public function get_metaboxes_post() {
1234 - return MainWP_System::instance()->metaboxes;
1235 - }
1250 + /**
1251 + * Method delete_theme()
1252 + *
1253 + * Hook to delete theme()
1254 + *
1255 + * @uses \MainWP\Dashboard\MainWP_Themes_Handler::delete_themes()
1256 + */
1257 + public function delete_theme() {
1258 + MainWP_Themes_Handler::delete_themes();
1259 + die();
1260 + }
1236 1261
1237 - /**
1238 - * Method hook_notification_email()
1239 - *
1240 - * Hook to get notification email.
1241 - *
1242 - * @return string Return email.
1243 - */
1244 - public function hook_notification_email() {
1245 - return MainWP_Notification_Settings::get_general_email();
1246 - }
1262 + /**
1263 + * Method upgrade_wp()
1264 + *
1265 + * Hook to upgrade WP.
1266 + */
1267 + public function upgrade_wp() {
1247 1268
1248 - /**
1249 - * Method get_formated_email()
1250 - *
1251 - * Hook to format email.
1252 - *
1253 - * @param mixed $body Email body.
1254 - * @param mixed $email Email address.
1255 - * @param string $title Email title.
1256 - *
1257 - * @return string|bool Return error or true.
1258 - *
1259 - * @uses \MainWP\Dashboard\MainWP_Format::format_email()
1260 - */
1261 - public function get_formated_email( $body, $email, $title = '' ) {
1262 - return MainWP_Format::format_email( $email, $body, $title );
1263 - }
1269 + if ( ! mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ) ) {
1270 + die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), $echo = false ) ) ) );
1271 + }
1264 1272
1265 - /**
1266 - * Method active_plugin()
1267 - *
1268 - * Hook to activate plugins.
1269 - *
1270 - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::activate_plugins()
1271 - */
1272 - public function active_plugin() {
1273 - MainWP_Plugins_Handler::activate_plugins();
1274 - die();
1275 - }
1273 + try {
1274 + $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false;
1275 + die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::upgrade_site( $id ) ) ) ); // ok.
1276 + } catch ( MainWP_Exception $e ) {
1277 + die(
1278 + wp_json_encode(
1279 + array(
1280 + 'error' => array(
1281 + 'message' => $e->getMessage(),
1282 + 'extra' => $e->get_message_extra(),
1283 + ),
1284 + )
1285 + )
1286 + );
1287 + }
1276 1288
1277 - /**
1278 - * Method deactive_plugin()
1279 - *
1280 - * Hook to deactivate plugins.
1281 - *
1282 - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::deactivate_plugins()
1283 - */
1284 - public function deactive_plugin() {
1285 - MainWP_Plugins_Handler::deactivate_plugins();
1286 - die();
1287 - }
1289 + die();
1290 + }
1288 1291
1289 - /**
1290 - * Method delete_plugin()
1291 - *
1292 - * Hook to delete plugins.
1293 - *
1294 - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::delete_plugins()
1295 - */
1296 - public function delete_plugin() {
1297 - MainWP_Plugins_Handler::delete_plugins();
1298 - die();
1299 - }
1292 + /**
1293 + * Method upgrade_plugin_theme()
1294 + *
1295 + * Hook to update theme.
1296 + *
1297 + * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
1298 + * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website()
1299 + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
1300 + */
1301 + public function upgrade_plugin_theme() {
1302 + try {
1303 + $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : null;
1304 + $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : null;
1305 + $slugs = isset( $_POST['slugs'] ) && is_array( $_POST['slugs'] ) ? wp_unslash( $_POST['slugs'] ) : array();
1306 + $error = '';
1307 + $erCode = '';
1300 1308
1301 - /**
1302 - * Method delete_theme()
1303 - *
1304 - * Hook to delete theme()
1305 - *
1306 - * @uses \MainWP\Dashboard\MainWP_Themes_Handler::delete_themes()
1307 - */
1308 - public function delete_theme() {
1309 - MainWP_Themes_Handler::delete_themes();
1310 - die();
1311 - }
1309 + if ( 'plugin' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_plugins' ) ) {
1310 + $error = mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false );
1311 + } elseif ( 'theme' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_themes' ) ) {
1312 + $error = mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false );
1313 + }
1312 1314
1313 - /**
1314 - * Method upgrade_wp()
1315 - *
1316 - * Hook to upgrade WP.
1317 - */
1318 - public function upgrade_wp() {
1315 + $website = MainWP_DB::instance()->get_website_by_id( $websiteId );
1319 1316
1320 - if ( ! mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ) ) {
1321 - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) );
1322 - }
1317 + if ( MainWP_System_Utility::is_suspended_site( $website ) ) {
1318 + $error = esc_html__( 'Suspended site.', 'mainwp' );
1319 + $erCode = 'SUSPENDED_SITE';
1320 + }
1323 1321
1324 - try {
1325 - $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1326 - die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::upgrade_site( $id ) ) ) ); // ok.
1327 - } catch ( MainWP_Exception $e ) {
1328 - die(
1329 - wp_json_encode(
1330 - array(
1331 - 'error' => array(
1332 - 'message' => $e->getMessage(),
1333 - 'extra' => $e->get_message_extra(),
1334 - ),
1335 - )
1336 - )
1337 - );
1338 - }
1322 + if ( ! empty( $error ) ) {
1323 + wp_send_json(
1324 + array(
1325 + 'error' => $error,
1326 + 'errorCode' => $erCode,
1327 + )
1328 + );
1329 + }
1339 1330
1340 - die();
1341 - }
1331 + if ( MainWP_Utility::ctype_digit( $websiteId ) ) {
1332 + if ( MainWP_System_Utility::can_edit_website( $website ) ) {
1333 + /**
1334 + * Action: mainwp_before_plugin_theme_translation_update
1335 + *
1336 + * Fires before plugin/theme/translation update actions.
1337 + *
1338 + * @since 4.1
1339 + */
1340 + do_action( 'mainwp_before_plugin_theme_translation_update', $type, implode( ',', $slugs ), $website );
1342 1341
1343 - /**
1344 - * Method upgrade_plugin_theme()
1345 - *
1346 - * Hook to update theme.
1347 - *
1348 - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
1349 - * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website()
1350 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
1351 - */
1352 - public function upgrade_plugin_theme() { // phpcs:ignore -- NOSONAR - complex.
1353 - try {
1354 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1355 - $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : null;
1356 - $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : null;
1357 - $slugs = isset( $_POST['slugs'] ) && is_array( $_POST['slugs'] ) ? wp_unslash( $_POST['slugs'] ) : array();
1358 - $error = '';
1359 - $erCode = '';
1360 - // phpcs:enable
1342 + $information = MainWP_Connect::fetch_url_authed(
1343 + $website,
1344 + 'upgradeplugintheme',
1345 + array(
1346 + 'type' => $type,
1347 + 'list' => urldecode( implode( ',', $slugs ) ),
1348 + )
1349 + );
1361 1350
1362 - if ( 'plugin' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_plugins' ) ) {
1363 - $error = mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false );
1364 - } elseif ( 'theme' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_themes' ) ) {
1365 - $error = mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false );
1366 - }
1351 + /**
1352 + * Action: mainwp_after_plugin_theme_translation_update
1353 + *
1354 + * Fires before plugin/theme/translation update actions.
1355 + *
1356 + * @since 4.1
1357 + */
1358 + do_action( 'mainwp_after_plugin_theme_translation_update', $information, $type, implode( ',', $slugs ), $website );
1367 1359
1368 - $website = MainWP_DB::instance()->get_website_by_id( $websiteId );
1360 + if ( isset( $information['sync'] ) ) {
1361 + unset( $information['sync'] );
1362 + }
1369 1363
1370 - if ( MainWP_System_Utility::is_suspended_site( $website ) ) {
1371 - $error = esc_html__( 'Suspended site.', 'mainwp' );
1372 - $erCode = 'SUSPENDED_SITE';
1373 - }
1364 + wp_send_json( $information );
1365 + }
1366 + }
1367 + } catch ( MainWP_Exception $e ) {
1368 + die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) );
1369 + }
1374 1370
1375 - if ( ! empty( $error ) ) {
1376 - wp_send_json(
1377 - array(
1378 - 'error' => $error,
1379 - 'errorCode' => $erCode,
1380 - )
1381 - );
1382 - }
1371 + die();
1372 + }
1383 1373
1384 - if ( MainWP_Utility::ctype_digit( $websiteId ) && MainWP_System_Utility::can_edit_website( $website ) ) {
1385 - /**
1386 - * Action: mainwp_before_plugin_theme_translation_update
1387 - *
1388 - * Fires before plugin/theme/translation update actions.
1389 - *
1390 - * @since 4.1
1391 - */
1392 - do_action( 'mainwp_before_plugin_theme_translation_update', $type, implode( ',', $slugs ), $website );
1374 + /**
1375 + * Method hook_get_websites_by_group_ids()
1376 + *
1377 + * Hook to get Child Sites by group ID.
1378 + *
1379 + * @param mixed $ids Group IDs.
1380 + * @param null $userId Current user ID.
1381 + *
1382 + * @return (object|null) Database query result for get Child Sites by group ID or null on failure.
1383 + */
1384 + public function hook_get_websites_by_group_ids( $ids, $userId = null ) {
1385 + return MainWP_DB::instance()->get_websites_by_group_ids( $ids, $userId );
1386 + }
1393 1387
1394 - $information = MainWP_Connect::fetch_url_authed(
1395 - $website,
1396 - 'upgradeplugintheme',
1397 - array(
1398 - 'type' => $type,
1399 - 'list' => urldecode( implode( ',', $slugs ) ),
1400 - )
1401 - );
1388 + /**
1389 + * Method hook_posts_get_edit()
1390 + *
1391 + * Get and create post to edit.
1392 + *
1393 + * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post()
1394 + */
1395 + public function hook_posts_get_edit() {
1396 + MainWP_Post_Page_Handler::get_post();
1397 + die();
1398 + }
1402 1399
1403 - /**
1404 - * Action: mainwp_after_plugin_theme_translation_update
1405 - *
1406 - * Fires before plugin/theme/translation update actions.
1407 - *
1408 - * @since 4.1
1409 - */
1410 - do_action( 'mainwp_after_plugin_theme_translation_update', $information, $type, implode( ',', $slugs ), $website );
1400 + /**
1401 + * Method hook_posts_bulk_posting()
1402 + *
1403 + * Post Bulk posting.
1404 + *
1405 + * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post()
1406 + */
1407 + public function hook_posts_bulk_posting() {
1408 + $post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] ? intval( $_POST['post_id'] ) : false;
1409 + if ( $post_id ) {
1410 + MainWP_Post_Page_Handler::posting_posts( $post_id, 'ajax_posting' );
1411 + }
1412 + die();
1413 + }
1411 1414
1412 - if ( isset( $information['sync'] ) ) {
1413 - unset( $information['sync'] );
1414 - }
1415 - wp_send_json( $information );
1416 - }
1417 - } catch ( MainWP_Exception $e ) {
1418 - die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) );
1419 - }
1415 + /**
1416 + * Method hook_atarim_default_sitestable_column()
1417 + *
1418 + * @param mixed $columns columns data.
1419 + *
1420 + * Hook Atarim default column.
1421 + */
1422 + public function hook_atarim_default_sitestable_column( $columns ) {
1423 + if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) ) {
1424 + $columns['atarim_tasks'] = esc_html__( 'Atarim', 'mainwp-atarim-extension' );
1425 + }
1426 + return $columns;
1427 + }
1420 1428
1421 - die();
1422 - }
1429 + /**
1430 + * Method hook_atarim_manage_sites_default_item()
1431 + *
1432 + * @param mixed $item item row data.
1433 + *
1434 + * Hook Atarim manage sites default item.
1435 + */
1436 + public function hook_atarim_manage_sites_default_item( $item ) {
1437 + if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) ) {
1438 + if ( is_array( $item ) && isset( $item['url'] ) ) {
1439 + $collaborate_link = 'https://app.atarim.io/fetching/?_from=mainwp&url=' . $item['url'];
1440 + $item['atarim_tasks'] = '<a href="' . $collaborate_link . '" target="_balnk" data-tooltip="Collaborate on this website." data-inverted="" data-position="left center"><span class="ui blue icon label"><i class="comments icon"></i></span></a>';
1441 + }
1442 + }
1443 + return $item;
1444 + }
1423 1445
1424 - /**
1425 - * Method hook_get_websites_by_group_ids()
1426 - *
1427 - * Hook to get Child Sites by group ID.
1428 - *
1429 - * @param mixed $ids Group IDs.
1430 - * @param null $userId Current user ID.
1431 - *
1432 - * @return (object|null) Database query result for get Child Sites by group ID or null on failure.
1433 - */
1434 - public function hook_get_websites_by_group_ids( $ids, $userId = null ) {
1435 - return MainWP_DB::instance()->get_websites_by_group_ids( $ids, $userId );
1436 - }
1446 + /**
1447 + * Method hook_get_website_client_tokens()
1448 + *
1449 + * Hook get client tokens.
1450 + *
1451 + * @param mixed $false input filter value.
1452 + * @param int $websiteid Website ID.
1453 + *
1454 + * @return mixed $result Result of tokens.
1455 + */
1456 + public function hook_get_website_client_tokens( $false, $websiteid = false ) {
1457 + $client_tokens = MainWP_Client_Handler::instance()->get_website_client_tokens_data( $websiteid );
1437 1458
1438 - /**
1439 - * Method hook_posts_get_edit()
1440 - *
1441 - * Get and create post to edit.
1442 - *
1443 - * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post()
1444 - */
1445 - public function hook_posts_get_edit() {
1446 - MainWP_Post_Page_Handler::get_post();
1447 - die();
1448 - }
1459 + if ( false === $client_tokens ) {
1460 + return $false;
1461 + }
1449 1462
1450 - /**
1451 - * Method hook_posts_bulk_posting()
1452 - *
1453 - * Post Bulk posting.
1454 - *
1455 - * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post()
1456 - */
1457 - public function hook_posts_bulk_posting() {
1458 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1459 - $post_id = isset( $_POST['post_id'] ) && ! empty( $_POST['post_id'] ) ? intval( wp_unslash( $_POST['post_id'] ) ) : false;
1460 - if ( $post_id ) {
1461 - MainWP_Post_Page_Handler::posting_posts( $post_id, 'ajax_posting' );
1462 - }
1463 - // phpcs:enable
1464 - die();
1465 - }
1463 + return $client_tokens;
1464 + }
1466 1465
1467 - /**
1468 - * Method hook_atarim_default_sitestable_column()
1469 - *
1470 - * @param mixed $columns columns data.
1471 - *
1472 - * Hook Atarim default column.
1473 - */
1474 - public function hook_atarim_default_sitestable_column( $columns ) {
1475 - if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) ) {
1476 - $columns['atarim_tasks'] = esc_html__( 'Atarim', 'mainwp-atarim-extension' );
1477 - }
1478 - return $columns;
1479 - }
1466 + /**
1467 + * Method hook_get_download_sig()
1468 + *
1469 + * Hook get download sig.
1470 + *
1471 + * @param string $false Input value.
1472 + * @param string $fullfile Full file path.
1473 + *
1474 + * @return string
1475 + */
1476 + public function hook_get_download_sig( $false, $fullfile ) {
1477 + return MainWP_System_Utility::get_download_sig( $fullfile );
1478 + }
1480 1479
1481 - /**
1482 - * Method hook_atarim_manage_sites_default_item()
1483 - *
1484 - * @param mixed $item item row data.
1485 - *
1486 - * Hook Atarim manage sites default item.
1487 - */
1488 - public function hook_atarim_manage_sites_default_item( $item ) {
1489 - if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) && is_array( $item ) && isset( $item['url'] ) ) {
1490 - $collaborate_link = 'https://app.atarim.io/fetching/?_from=mainwp&url=' . $item['url'];
1491 - $item['atarim_tasks'] = '<a href="' . $collaborate_link . '" target="_balnk" data-tooltip="Collaborate on this website." data-inverted="" data-position="left center"><span class="ui blue icon label"><i class="comments icon"></i></span></a>';
1492 - }
1493 - return $item;
1494 - }
1480 + /**
1481 + * Method hook_download_valid_sig().
1482 + *
1483 + * Hook get download sig.
1484 + *
1485 + * @param string $fullfile Full file path.
1486 + * @param string $sig sig value.
1487 + */
1488 + public function hook_secure_download( $fullfile, $sig ) {
1489 + $valid = MainWP_System_Utility::valid_download_sig( $fullfile, $sig );
1490 + if ( ! $valid ) {
1491 + wp_die( 'Invalid download.' );
1492 + }
1493 + }
1495 1494
1496 - /**
1497 - * Method hook_get_website_client_tokens()
1498 - *
1499 - * Hook get client tokens.
1500 - *
1501 - * @param mixed $input_value input filter value.
1502 - * @param int $websiteid Website ID.
1503 - *
1504 - * @return mixed $result Result of tokens.
1505 - */
1506 - public function hook_get_website_client_tokens( $input_value, $websiteid = false ) {
1507 - $client_tokens = MainWP_Client_Handler::instance()->get_website_client_tokens_data( $websiteid );
1495 + /**
1496 + * Method hook_ajax_add_action().
1497 + *
1498 + * Hook add ajax action.
1499 + *
1500 + * @param string $action action name.
1501 + * @param string $callback callback function.
1502 + */
1503 + public function hook_ajax_add_action( $action, $callback ) {
1504 + MainWP_Post_Handler::instance()->add_action( $action, $callback );
1505 + }
1508 1506
1509 - if ( false === $client_tokens ) {
1510 - return $input_value;
1511 - }
1507 + /**
1508 + * Method hook_get_plugin_icon().
1509 + *
1510 + * Hook get plugin icon.
1511 + *
1512 + * @param mixed $icon input icon.
1513 + * @param string $slug Plugin slug.
1514 + */
1515 + public function hook_get_plugin_icon( $icon, $slug ) {
1516 + return MainWP_System_Utility::get_plugin_icon( $slug );
1517 + }
1512 1518
1513 - return $client_tokens;
1514 - }
1519 + /**
1520 + * Method hook_get_theme_icon().
1521 + *
1522 + * Hook get theme icon.
1523 + *
1524 + * @param mixed $icon input icon.
1525 + * @param string $slug Theme slug.
1526 + */
1527 + public function hook_get_theme_icon( $icon, $slug ) {
1528 + return MainWP_System_Utility::get_theme_icon( $slug );
1529 + }
1530 + /**
1531 + * Method hook_get_dir_slug().
1532 + *
1533 + * Hook get dir slug of plugin/theme.
1534 + *
1535 + * @param mixed $input input value.
1536 + * @param string $slug Plugin/Theme slug.
1537 + */
1538 + public function hook_get_dir_slug( $input, $slug ) {
1539 + return MainWP_Utility::get_dir_slug( $slug );
1540 + }
1515 1541
1516 - /**
1517 - * Method hook_get_download_sig()
1518 - *
1519 - * Hook get download sig.
1520 - *
1521 - * @param string $input_value Input value.
1522 - * @param string $fullfile Full file path.
1523 - *
1524 - * @return string
1525 - */
1526 - public function hook_get_download_sig( $input_value, $fullfile ) {
1527 - unset( $input_value );
1528 - return MainWP_System_Utility::get_download_sig( $fullfile );
1529 - }
1542 + /**
1543 + * Method hook_do_widget_boxes()
1544 + *
1545 + * Customize WordPress do_meta_boxes() function.
1546 + *
1547 + * @param mixed $screen Current page.
1548 + * @param string|null $context right|null. If 3 columns then = 'middle'.
1549 + * @param string $object Empty string.
1550 + *
1551 + * @return void Renders widget container box.
1552 + */
1553 + public function hook_do_widget_boxes( $screen, $context = null, $object = '' ) {
1554 + MainWP_UI::do_widget_boxes( $screen, $context, $object );
1555 + }
1530 1556
1531 - /**
1532 - * Method hook_download_valid_sig().
1533 - *
1534 - * Hook get download sig.
1535 - *
1536 - * @param string $false_value false value.
1537 - * @param string $fullfile Full file path.
1538 - * @param string $sig sig value.
1539 - */
1540 - public function hook_secure_download( $false_value, $fullfile, $sig ) {
1541 - unset( $false_value );
1542 - return MainWP_System_Utility::valid_download_sig( $fullfile, $sig );
1543 - }
1544 1557
1545 - /**
1546 - * Method hook_ajax_add_action().
1547 - *
1548 - * Hook add ajax action.
1549 - *
1550 - * @param string $action action name.
1551 - * @param string $callback callback function.
1552 - * @param int $priority priority action.
1553 - * @param int $accepted number args.
1554 - */
1555 - public function hook_ajax_add_action( $action, $callback, $priority = 10, $accepted = 2 ) {
1556 - MainWP_Post_Handler::instance()->add_action( $action, $callback, $priority, $accepted );
1557 - }
1558 + /**
1559 + * Method hook_add_widget_box()
1560 + *
1561 + * Hook add MainWP meta box.
1562 + *
1563 + * @param mixed $id Widget ID parameter.
1564 + * @param mixed $callback Callback function.
1565 + * @param null $screen Current page.
1566 + * @param string|null $context right|null. If 3 columns then = 'middle'.
1567 + * @param null $title Widget title.
1568 + * @param string $priority high|core|default|low, Default: default.
1569 + *
1570 + * @return void Sets Global $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ].
1571 + *
1572 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1573 + */
1574 + public function hook_add_widget_box( $id, $callback, $screen = null, $context = null, $title = null, $priority = 'default' ) {
1575 + MainWP_UI::add_widget_box( $id, $callback, $screen, $context, $title, $priority );
1576 + }
1558 1577
1559 - /**
1560 - * Method hook_get_plugin_icon().
1561 - *
1562 - * Hook get plugin icon.
1563 - *
1564 - * @param mixed $icon input icon.
1565 - * @param string $slug Plugin slug.
1566 - */
1567 - public function hook_get_plugin_icon( $icon, $slug ) {
1568 - unset( $icon );
1569 - return MainWP_System_Utility::get_plugin_icon( $slug );
1570 - }
1578 + /**
1579 + * Method hook_render_modal_upload_icon()
1580 + *
1581 + * Render modal window for upload plugins & themes icon.
1582 + */
1583 + public function hook_render_modal_upload_icon() {
1584 + MainWP_UI::render_modal_upload_icon();
1585 + }
1571 1586
1572 - /**
1573 - * Method hook_get_theme_icon().
1574 - *
1575 - * Hook get theme icon.
1576 - *
1577 - * @param mixed $icon input icon.
1578 - * @param string $slug Theme slug.
1579 - */
1580 - public function hook_get_theme_icon( $icon, $slug ) {
1581 - unset( $icon );
1582 - return MainWP_System_Utility::get_theme_icon( $slug );
1583 - }
1584 - /**
1585 - * Method hook_get_dir_slug().
1586 - *
1587 - * Hook get dir slug of plugin/theme.
1588 - *
1589 - * @param mixed $input input value.
1590 - * @param string $slug Plugin/Theme slug.
1591 - */
1592 - public function hook_get_dir_slug( $input, $slug ) {
1593 - unset( $input );
1594 - return MainWP_Utility::get_dir_slug( $slug );
1595 - }
1587 + /**
1588 + * Method hook_render_plugin_details_modal()
1589 + *
1590 + * Render modal window plugin details.
1591 + */
1592 + public function hook_render_plugin_details_modal() {
1593 + MainWP_Updates::render_plugin_details_modal();
1594 + }
1596 1595
1597 - /**
1598 - * Method hook_do_widget_boxes()
1599 - *
1600 - * Customize WordPress do_meta_boxes() function.
1601 - *
1602 - * @param mixed $screen_id Current page ID.
1603 - * @param string|null $context right|null. If 3 columns then = 'middle'.
1604 - * @param string $input_obj Empty string.
1605 - *
1606 - * @return void Renders widget container box.
1607 - */
1608 - public function hook_do_widget_boxes( $screen_id, $context = null, $input_obj = '' ) {
1609 - MainWP_UI::do_widget_boxes( $screen_id, $context, $input_obj );
1610 - }
1611 -
1612 -
1613 - /**
1614 - * Method hook_add_widget_box()
1615 - *
1616 - * Hook add MainWP meta box.
1617 - *
1618 - * @param mixed $id Widget ID parameter.
1619 - * @param mixed $callback Callback function.
1620 - * @param null $screen Current page.
1621 - * @param string|null $layout widget's layout .
1622 - *
1623 - * @return void Sets Global $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ].
1624 - */
1625 - public function hook_add_widget_box( $id, $callback, $screen = null, $layout = null ) {
1626 - if ( ! is_array( $layout ) ) {
1627 - $layout = array();
1628 - }
1629 - MainWP_UI::add_widget_box( $id, $callback, $screen, $layout );
1630 - }
1631 -
1632 - /**
1633 - * Method hook_render_modal_upload_icon()
1634 - *
1635 - * Render modal window for upload plugins & themes icon.
1636 - */
1637 - public function hook_render_modal_upload_icon() {
1638 - MainWP_UI::render_modal_upload_icon();
1639 - }
1640 -
1641 - /**
1642 - * Method hook_render_plugin_details_modal()
1643 - *
1644 - * Render modal window plugin details.
1645 - */
1646 - public function hook_render_plugin_details_modal() {
1647 - MainWP_Updates::render_plugin_details_modal();
1648 - }
1649 -
1650 - /**
1651 - * Method hook_render_updates()
1652 - *
1653 - * Render modal window updates details.
1654 - */
1655 - public function hook_render_updates() {
1656 - MainWP_Updates::render();
1657 - }
1658 -
1659 - /**
1660 - * Method hook_get_wp_client_by()
1661 - *
1662 - * Handle get wp client by.
1663 - *
1664 - * @param string $by by.
1665 - * @param mixed $value by value.
1666 - * @param mixed $obj Format data.
1667 - * @param bool $params Others params.
1668 - *
1669 - * @return mixed $result results.
1670 - */
1671 - public function hook_get_wp_client_by( $by = 'client_id', $value = null, $obj = OBJECT, $params = array() ) {
1672 - return MainWP_DB_Client::instance()->get_wp_client_by( $by, $value, $obj, $params );
1673 - }
1674 -
1675 - /**
1676 - * Method hook_get_activation_info()
1677 - *
1678 - * Get extension activation info.
1679 - *
1680 - * @param bool $boolean Input bool value.
1681 - * @param string $ext_slug extension api slug.
1682 - */
1683 - public function hook_get_activation_info( $boolean, $ext_slug ) {
1684 - unset( $boolean );
1685 - $data = MainWP_Api_Manager::instance()->get_activation_info( $ext_slug );
1686 -
1687 - $info = array();
1688 -
1689 - if ( is_array( $data ) && ! empty( $data['api_key'] ) ) {
1690 - $info['api_key'] = $data['api_key'];
1691 - $info['product_id'] = isset( $data['product_id'] ) ? $data['product_id'] : '';
1692 - $info['instance'] = isset( $data['instance_id'] ) ? $data['instance_id'] : '';
1693 - $info['software_version'] = isset( $data['software_version'] ) ? $data['software_version'] : '';
1694 - $info['object'] = MainWP_Api_Manager::instance()->get_domain();
1695 - if ( isset( $data['product_item_id'] ) ) {
1696 - $info['product_item_id'] = $data['product_item_id'];
1697 - }
1698 - } else {
1699 - $info['activated_key'] = 'Deactivated';
1700 - }
1701 -
1702 - return $info;
1703 - }
1704 -
1705 - /**
1706 - * Method hook_get_api_url()
1707 - *
1708 - * Get MainWP API Url.
1709 - */
1710 - public function hook_get_api_url() {
1711 - return MainWP_Api_Manager::instance()->get_upgrade_url();
1712 - }
1713 -
1714 - /**
1715 - * Method hook_run_dashboard_action().
1716 - *
1717 - * Handle run dashboard action.
1718 - *
1719 - * @param bool $boolean Input bool value.
1720 - * @param string $action The action to run.
1721 - * @param bool $out_die The function die or return.
1722 - *
1723 - * @return mixed $return result.
1724 - */
1725 - public function hook_run_dashboard_action( $boolean, $action, $out_die = false ) {
1726 - unset( $boolean );
1727 - if ( ! isset( $action ) ) {
1728 - return false;
1729 - }
1730 -
1731 - if ( 'master_api_key_check' === $action ) {
1732 - $return = $this->hook_master_api_key_check();
1733 - } else {
1734 - return false;
1735 - }
1736 -
1737 - if ( $out_die ) {
1738 - wp_send_json( $return );
1739 - }
1740 -
1741 - return $return;
1742 - }
1743 -
1744 -
1745 -
1746 - /**
1747 - * Method hook_master_api_key_check().
1748 - *
1749 - * Handle to valid MainWP API key.
1750 - *
1751 - * @return array $return Data.
1752 - */
1753 - public function hook_master_api_key_check() {
1754 - $api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
1755 - $return = array();
1756 - $error = '';
1757 - if ( ! empty( $api_key ) ) {
1758 - $result = array();
1759 - try {
1760 - $test = MainWP_Api_Manager::instance()->verify_mainwp_api( $api_key );
1761 - $result = json_decode( $test, true );
1762 - if ( is_array( $result ) ) {
1763 - if ( isset( $result['success'] ) && $result['success'] ) {
1764 - $return['success'] = true;
1765 - } elseif ( isset( $result['error'] ) ) {
1766 - $error = $result['error'];
1767 - }
1768 - }
1769 - } catch ( \Exception $e ) {
1770 - $error = $e->getMessage();
1771 - }
1772 - } else {
1773 - $error = esc_html__( 'MainWP API key are required.', 'mainwp' );
1774 - }
1775 -
1776 - if ( ! empty( $error ) ) {
1777 - $return['error'] = $error;
1778 - }
1779 -
1780 - if ( ! isset( $return['success'] ) ) {
1781 - $return['success'] = false;
1782 - }
1783 -
1784 - return $return;
1785 - }
1786 -
1787 - /**
1788 - * Method hook_get_key_value().
1789 - *
1790 - * Handle get key value.
1791 - *
1792 - * @param bool $input_value Boolean value, it should always be FALSE.
1793 - * @param string $name Key option name.
1794 - * @param mixed $default_value default value.
1795 - *
1796 - * @return array $return Decrypted Key value.
1797 - */
1798 - public function hook_get_key_value( $input_value, $name, $default_value = false ) {
1799 - unset( $input_value );
1800 - return MainWP_Keys_Manager::instance()->get_keys_value( $name, $default_value );
1801 - }
1802 -
1803 - /**
1804 - * Method hook_update_key_value().
1805 - *
1806 - * Handle update key value.
1807 - *
1808 - * @param bool $input_value Boolean value, it should always be FALSE.
1809 - * @param string $name Key option name.
1810 - * @param mixed $value Key value.
1811 - * @param string $prefix prefix of key file name.
1812 - *
1813 - * @return array $return Decrypted Key value.
1814 - */
1815 - public function hook_update_key_value( $input_value, $name, $value = false, $prefix = 'ext_' ) {
1816 - unset( $input_value );
1817 - return MainWP_Keys_Manager::instance()->update_key_value( $name, $value, $prefix );
1818 - }
1819 -
1820 -
1821 - /**
1822 - * Method hook_delete_key_value().
1823 - *
1824 - * Handle delete key value.
1825 - *
1826 - * @param string $name Key option name.
1827 - *
1828 - * @return mixed Return Result.
1829 - */
1830 - public function hook_delete_key_value( $name ) {
1831 - return MainWP_Keys_Manager::instance()->update_key_value( $name, false ); // false: to delete.
1832 - }
1833 -
1834 - /**
1835 - * Method hook_encrypt_key_value().
1836 - *
1837 - * Handle get key value.
1838 - *
1839 - * @param bool $input_value Boolean value, it should always be FALSE.
1840 - * @param array $data Encrypted data.
1841 - * @param mixed $prefix prefix value.
1842 - * @param mixed $key_file Key file value.
1843 - *
1844 - * @return array $return Decrypted Key value.
1845 - */
1846 - public function hook_encrypt_key_value( $input_value, $data, $prefix = 'ext_', $key_file = false ) {
1847 - unset( $input_value );
1848 - return MainWP_Keys_Manager::instance()->encrypt_keys_data( $data, $prefix, $key_file );
1849 - }
1850 -
1851 - /**
1852 - * Method hook_decrypt_key_value().
1853 - *
1854 - * Handle get key value.
1855 - *
1856 - * @param bool $input_value Boolean value, it should always be FALSE.
1857 - * @param array $encrypted_data Encrypted data.
1858 - * @param mixed $default_value default value.
1859 - *
1860 - * @return array $return Decrypted Key value.
1861 - */
1862 - public function hook_decrypt_key_value( $input_value, $encrypted_data, $default_value = false ) {
1863 - unset( $input_value );
1864 - return MainWP_Keys_Manager::instance()->decrypt_keys_data( $encrypted_data, $default_value );
1865 - }
1866 -
1867 -
1868 - /**
1869 - * Method hook_delete_key_file().
1870 - *
1871 - * Handle delete key value.
1872 - *
1873 - * @param string $key_file Key file name.
1874 - *
1875 - * @return array $return Decrypted Key value.
1876 - */
1877 - public function hook_delete_key_file( $key_file ) {
1878 - return MainWP_Keys_Manager::instance()->delete_key_file( $key_file );
1879 - }
1880 -
1881 - /**
1882 - * Method hook_get_lookup_items().
1883 - *
1884 - * @param bool $false_val false value.
1885 - * @param string $item_name item name.
1886 - * @param int $item_id item id.
1887 - * @param string $obj_name object name.
1888 - *
1889 - * @return array Lookup items.
1890 - */
1891 - public function hook_get_lookup_items( $false_val, $item_name, $item_id, $obj_name ) {
1892 - unset( $false_val );
1893 - return MainWP_DB::instance()->get_lookup_items( $item_name, $item_id, $obj_name );
1894 - }
1895 -
1896 - /**
1897 - * Method hook_insert_lookup_item().
1898 - *
1899 - * @param bool $false_val false value.
1900 - * @param string $item_name item name.
1901 - * @param int $item_id item id.
1902 - * @param string $obj_name object name.
1903 - * @param int $obj_id object id.
1904 - *
1905 - * @return array Lookup items.
1906 - */
1907 - public function hook_insert_lookup_item( $false_val, $item_name, $item_id, $obj_name, $obj_id ) {
1908 - unset( $false_val );
1909 - return MainWP_DB::instance()->insert_lookup_item( $item_name, $item_id, $obj_name, $obj_id );
1910 - }
1911 -
1912 - /**
1913 - * Method hook_delete_lookup_items().
1914 - *
1915 - * @param bool $false_val false value.
1916 - * @param string $by Delete by.
1917 - * @param array $params params.
1918 - *
1919 - * @return mixed results.
1920 - */
1921 - public function hook_delete_lookup_items( $false_val, $by = 'lookup_id', $params = array() ) {
1922 - unset( $false_val );
1923 - return MainWP_DB::instance()->delete_lookup_items( $by, $params );
1924 - }
1925 -
1926 - /**
1927 - * Method hook_get_indicator().
1928 - *
1929 - * @param bool $def_value default input value.
1930 - * @param bool $indi_type Indicator type.
1931 - * @param bool $wrapper_cls field wrapper class.
1932 - * @param bool $visible Current indicator status.
1933 - *
1934 - * @return mixed indicator results.
1935 - */
1936 - public function hook_get_indicator( $def_value, $indi_type = 'field', $wrapper_cls = '', $visible = true ) {
1937 - unset( $def_value );
1938 - return MainWP_Settings_Indicator::get_indicator( $indi_type, $wrapper_cls, $visible );
1939 - }
1596 + /**
1597 + * Method hook_render_plugin_details_modal()
1598 + *
1599 + * Render modal window plugin details.
1600 + */
1601 + public function hook_render_updates() {
1602 + MainWP_Updates::render();
1603 + }
1940 1604 }