PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.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 All 155 releases
← All changes | class/class-mainwp-hooks.php +64 -8 6.0.12 → 6.2.1 View file →
@@ -185,8 +185,14 @@
185 185 add_action( 'mainwp_render_plugin_details_modal', array( &$this, 'hook_render_plugin_details_modal' ), 10, 2 );
186 186 add_action( 'mainwp_render_updates', array( &$this, 'hook_render_updates' ), 10, 2 );
187 187 add_filter( 'mainwp_get_wp_client_by', array( &$this, 'hook_get_wp_client_by' ), 10, 4 );
188 188
189 + // Batch-preload uptime data to avoid per-row queries.
190 + add_filter( 'mainwp_sitestable_prepared_items', array( &$this, 'hook_uptime_preload_data' ), 10, 4 );
191 +
192 + // Intercept column rendering.
193 + add_filter( 'mainwp_sitestable_display_row_columns', array( &$this, 'hook_uptime_intercept_column' ), 10, 4 );
194 +
189 195 /**
190 196 * Filter: mainwp_get_tokens_values
191 197 *
192 198 * Get tokens values for reports.
@@ -215,8 +221,9 @@
215 221
216 222 add_filter( 'mainwp_encrypt_key_value', array( &$this, 'hook_encrypt_key_value' ), 10, 4 );
217 223 add_filter( 'mainwp_decrypt_key_value', array( &$this, 'hook_decrypt_key_value' ), 10, 3 );
218 224 add_action( 'mainwp_delete_key_file', array( &$this, 'hook_delete_key_file' ), 10, 1 );
225 + add_filter( 'mainwp_delete_key_file_result', array( &$this, 'hook_delete_key_file_result' ), 10, 2 );
219 226 add_filter( 'mainwp_verify_ping_nonce', array( MainWP_Utility::class, 'hook_verify_ping_nonce' ), 10, 3 );
220 227 add_action( 'mainwp_fetch_url_authed', array( MainWP_Actions_Handler::instance(), 'hook_mainwp_fetch_url_authed' ), 10, 5 );
221 228
222 229 add_filter( 'mainwp_get_lookup_items', array( &$this, 'hook_get_lookup_items' ), 10, 4 );
@@ -864,10 +871,10 @@
864 871 /**
865 872 * Method hook_get_all_posts()
866 873 * Hook to get posts from sites.
867 874 *
868 - * @param object $sites Child Sites object.
869 - * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type.
875 + * @param object|array $sites Child Sites object.
876 + * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type.
870 877 *
871 878 * @return \stdClass $output All posts data array.
872 879 *
873 880 * @since 3.4.4
@@ -875,9 +882,9 @@
875 882 * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
876 883 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
877 884 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
878 885 */
879 - public function hook_get_all_posts( $sites, $post_data = array() ) {
886 + public function hook_get_all_posts( $sites, $post_data = array() ) { // phpcs:ignore -- NOSONAR - complex.
880 887
881 888 $dbwebsites = array();
882 889
883 890 $data = MainWP_System_Utility::get_default_map_site_fields();
@@ -883,11 +890,21 @@
883 890 $data = MainWP_System_Utility::get_default_map_site_fields();
884 891 $data[] = 'verify_certificate';
885 892
886 893 if ( '' !== $sites ) {
887 - foreach ( $sites as $v ) {
888 - if ( MainWP_Utility::ctype_digit( $v ) ) {
889 - $website = MainWP_DB::instance()->get_website_by_id( $v );
894 + foreach ( $sites as $site ) {
895 + // Keep accepting the legacy list of scalar site IDs as well
896 + // as the mapped website objects used by REST v2.
897 + if ( is_object( $site ) ) {
898 + $site_id = isset( $site->id ) ? $site->id : '';
899 + } elseif ( is_array( $site ) ) {
900 + $site_id = isset( $site['id'] ) ? $site['id'] : '';
901 + } else {
902 + $site_id = $site;
903 + }
904 +
905 + if ( MainWP_Utility::ctype_digit( $site_id ) ) {
906 + $website = MainWP_DB::instance()->get_website_by_id( $site_id );
890 907 if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
891 908 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data );
892 909 }
893 910 }
@@ -1752,8 +1769,35 @@
1752 1769 return MainWP_DB_Client::instance()->get_wp_client_by( $by, $value, $obj, $params );
1753 1770 }
1754 1771
1755 1772 /**
1773 + * Method hook_uptime_preload_data().
1774 + *
1775 + * @param array $websites Websites array.
1776 + *
1777 + * @return void
1778 + */
1779 + public function hook_uptime_preload_data( $websites ) {
1780 + MainWP_Monitoring_Handler::preload_uptime_data( $websites );
1781 + }
1782 +
1783 + /**
1784 + * Method hook_uptime_intercept_column()
1785 + *
1786 + * Intercept column display in the sites table.
1787 + *
1788 + * @param string $content Column content.
1789 + * @param string $column_name Column name.
1790 + * @param array $website Website data.
1791 + *
1792 + * @return string $content Modified column content.
1793 + */
1794 + public function hook_uptime_intercept_column( $content, $column_name, $website ) {
1795 + // Implementation for intercepting column display.
1796 + return MainWP_Monitoring_Handler::intercept_column( $content, $column_name, $website );
1797 + }
1798 +
1799 + /**
1756 1800 * Method hook_get_activation_info()
1757 1801 *
1758 1802 * Get extension activation info.
1759 1803 *
@@ -1958,8 +2002,21 @@
1958 2002 return MainWP_Keys_Manager::instance()->delete_key_file( $key_file );
1959 2003 }
1960 2004
1961 2005 /**
2006 + * Delete one exact key file and return only read-verified truth.
2007 + *
2008 + * @param mixed $input_value Filter-chain initial value.
2009 + * @param string $key_file Key file name.
2010 + *
2011 + * @return bool Whether exact absence was proved.
2012 + */
2013 + public function hook_delete_key_file_result( $input_value, $key_file ) {
2014 + unset( $input_value );
2015 + return MainWP_Keys_Manager::instance()->delete_key_file_with_result( $key_file );
2016 + }
2017 +
2018 + /**
1962 2019 * Method hook_get_lookup_items().
1963 2020 *
1964 2021 * @param bool $false_val false value.
1965 2022 * @param string $item_name item name.
@@ -2047,9 +2104,9 @@
2047 2104
2048 2105 /**
2049 2106 * Method hook_get_primary_backup_method.
2050 2107 *
2051 - * @param mixed $inpval Hook input value.
2108 + * @param mixed $inpval Hook input value.
2052 2109 * @param int|false $siteid Optional Site ID; false for global method.
2053 2110 *
2054 2111 * @since 6.0.10.
2055 2112 *
@@ -2070,6 +2127,5 @@
2070 2127 }
2071 2128 }
2072 2129 return $primaryBackup;
2073 2130 }
2074 -
2075 2131 }