| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | // phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity. |
| 11 | 16 | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Hooks |
| @@ -100,8 +105,22 @@ | ||
| 100 | 105 | add_filter( 'mainwp_extension_is_activated', array( &$this, 'is_extension_activated' ), 10, 2 ); |
| 101 | 106 | add_filter( 'mainwp_extension_is_pro_member', array( &$this, 'is_pro_member' ), 10, 1 ); |
| 102 | 107 | |
| 103 | 108 | /** |
| 109 | + * Handle get avaiable add-ons. | |
| 110 | + * | |
| 111 | + * @since 6.0 | |
| 112 | + */ | |
| 113 | + add_filter( | |
| 114 | + 'mainwp_get_avaiable_add_ons', | |
| 115 | + function () { | |
| 116 | + return MainWP_Extensions_View::get_available_extensions( 'all' ); | |
| 117 | + }, | |
| 118 | + 10, | |
| 119 | + 1 | |
| 120 | + ); | |
| 121 | + | |
| 122 | + /** | |
| 104 | 123 | * Logging debug actions. |
| 105 | 124 | */ |
| 106 | 125 | add_action( 'mainwp_log_debug', array( &$this, 'mainwp_log_debug' ), 10, 1 ); |
| 107 | 126 | add_action( 'mainwp_log_info', array( &$this, 'mainwp_log_info' ), 10, 1 ); |
| @@ -111,9 +130,9 @@ | ||
| 111 | 130 | // END. |
| 112 | 131 | |
| 113 | 132 | add_filter( 'mainwp_getactivateextensionnotice', array( &$this, 'get_activate_extension_notice' ), 10, 1 ); |
| 114 | 133 | 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 ); | |
| 134 | + add_filter( 'mainwp_addsite', array( &$this, 'hook_add_site' ), 10, 1 ); | |
| 116 | 135 | add_filter( 'mainwp_deletesite', array( &$this, 'hook_delete_site' ), 10, 1 ); |
| 117 | 136 | add_filter( 'mainwp_clonesite', array( &$this, 'filter_clone_site' ), 10, 6 ); |
| 118 | 137 | add_filter( 'mainwp_delete_clonesite', array( &$this, 'filter_delete_clone_site' ), 10, 4 ); |
| 119 | 138 | add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 ); |
| @@ -119,8 +138,9 @@ | ||
| 119 | 138 | add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 ); |
| 120 | 139 | add_action( 'mainwp_add_sub_leftmenu', array( &$this, 'hook_add_sub_left_menu' ), 10, 6 ); |
| 121 | 140 | add_filter( 'mainwp_getwebsiteoptions', array( &$this, 'hook_get_site_options' ), 10, 3 ); |
| 122 | 141 | add_filter( 'mainwp_updatewebsiteoptions', array( &$this, 'hook_update_site_options' ), 10, 4 ); |
| 142 | + add_filter( 'mainwp_deletewebsiteoptions', array( &$this, 'hook_delete_site_options' ), 10, 2 ); | |
| 123 | 143 | |
| 124 | 144 | add_filter( 'mainwp_getwebsitesbyuserid', array( &$this, 'hook_get_websites_by_user_id' ), 10, 5 ); |
| 125 | 145 | add_filter( 'mainwp_getwebsite_by_id', array( &$this, 'hook_get_website_by_id' ), 10, 4 ); |
| 126 | 146 | |
| @@ -136,8 +156,9 @@ | ||
| 136 | 156 | add_action( 'mainwp_db_data_seek', array( &$this, 'hook_db_data_seek' ), 10, 2 ); |
| 137 | 157 | add_filter( 'mainwp_db_free_result', array( &$this, 'db_free_result' ), 10, 2 ); |
| 138 | 158 | add_filter( 'mainwp_db_num_rows', array( &$this, 'db_num_rows' ), 10, 2 ); |
| 139 | 159 | add_filter( 'mainwp_db_get_websites_for_current_user', array( &$this, 'db_get_websites_for_current_user' ), 10, 2 ); |
| 160 | + add_filter( 'mainwp_db_get_sql_websites_for_current_user', array( &$this, 'hook_get_sql_websites_by_params' ), 10, 2 ); | |
| 140 | 161 | |
| 141 | 162 | // Sync website. |
| 142 | 163 | add_filter( 'mainwp_sync_website', array( &$this, 'hook_sync_website' ), 10, 3 ); |
| 143 | 164 | |
| @@ -164,8 +185,14 @@ | ||
| 164 | 185 | add_action( 'mainwp_render_plugin_details_modal', array( &$this, 'hook_render_plugin_details_modal' ), 10, 2 ); |
| 165 | 186 | add_action( 'mainwp_render_updates', array( &$this, 'hook_render_updates' ), 10, 2 ); |
| 166 | 187 | add_filter( 'mainwp_get_wp_client_by', array( &$this, 'hook_get_wp_client_by' ), 10, 4 ); |
| 167 | 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 | + | |
| 168 | 195 | /** |
| 169 | 196 | * Filter: mainwp_get_tokens_values |
| 170 | 197 | * |
| 171 | 198 | * Get tokens values for reports. |
| @@ -194,8 +221,9 @@ | ||
| 194 | 221 | |
| 195 | 222 | add_filter( 'mainwp_encrypt_key_value', array( &$this, 'hook_encrypt_key_value' ), 10, 4 ); |
| 196 | 223 | add_filter( 'mainwp_decrypt_key_value', array( &$this, 'hook_decrypt_key_value' ), 10, 3 ); |
| 197 | 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 ); | |
| 198 | 226 | add_filter( 'mainwp_verify_ping_nonce', array( MainWP_Utility::class, 'hook_verify_ping_nonce' ), 10, 3 ); |
| 199 | 227 | add_action( 'mainwp_fetch_url_authed', array( MainWP_Actions_Handler::instance(), 'hook_mainwp_fetch_url_authed' ), 10, 5 ); |
| 200 | 228 | |
| 201 | 229 | add_filter( 'mainwp_get_lookup_items', array( &$this, 'hook_get_lookup_items' ), 10, 4 ); |
| @@ -201,8 +229,15 @@ | ||
| 201 | 229 | add_filter( 'mainwp_get_lookup_items', array( &$this, 'hook_get_lookup_items' ), 10, 4 ); |
| 202 | 230 | add_filter( 'mainwp_insert_lookup_item', array( &$this, 'hook_insert_lookup_item' ), 10, 5 ); |
| 203 | 231 | add_filter( 'mainwp_delete_lookup_items', array( &$this, 'hook_delete_lookup_items' ), 10, 3 ); |
| 204 | 232 | add_filter( 'mainwp_get_indicator', array( &$this, 'hook_get_indicator' ), 10, 4 ); |
| 233 | + add_filter( 'mainwp_get_time_elapsed_string', array( &$this, 'hook_get_time_elapsed_string' ), 10, 2 ); | |
| 234 | + | |
| 235 | + add_action( 'mainwp_general_process_update', array( MainWP_DB::instance(), 'update_regular_process' ), 10, 1 ); | |
| 236 | + add_action( 'mainwp_general_process_delete', array( MainWP_DB::instance(), 'delete_regular_process' ), 10, 4 ); | |
| 237 | + add_filter( 'mainwp_general_process_get_process_by', array( &$this, 'hook_get_regular_process_by' ), 10, 4 ); | |
| 238 | + | |
| 239 | + add_filter( 'mainwp_get_primary_backup_method', array( $this, 'hook_get_primary_backup_method' ), 10, 2 ); | |
| 205 | 240 | } |
| 206 | 241 | |
| 207 | 242 | /** |
| 208 | 243 | * Method get_instance(). |
| @@ -292,9 +327,9 @@ | ||
| 292 | 327 | MainWP_System::enqueue_postbox_scripts(); |
| 293 | 328 | } |
| 294 | 329 | |
| 295 | 330 | /** |
| 296 | - * Method mainwp_add_site() | |
| 331 | + * Method hook_add_site() | |
| 297 | 332 | * |
| 298 | 333 | * Hook to add Child Site. |
| 299 | 334 | * |
| 300 | 335 | * @param array $params site data fields: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version, |
| @@ -309,9 +344,9 @@ | ||
| 309 | 344 | * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site() |
| 310 | 345 | * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::add_wp_site() |
| 311 | 346 | * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() |
| 312 | 347 | */ |
| 313 | - public function mainwp_add_site( $params ) { | |
| 348 | + public function hook_add_site( $params ) { | |
| 314 | 349 | $ret = array(); |
| 315 | 350 | |
| 316 | 351 | if ( is_array( $params ) ) { |
| 317 | 352 | if ( isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) { |
| @@ -531,9 +566,9 @@ | ||
| 531 | 566 | if ( isset( $activate_notices[ $slug ] ) ) { |
| 532 | 567 | return false; |
| 533 | 568 | } |
| 534 | 569 | } |
| 535 | - | |
| 570 | + // translators: 1: Opening anchor tag, 2: Closing anchor tag. | |
| 536 | 571 | 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 | 572 | } |
| 538 | 573 | |
| 539 | 574 | /** |
| @@ -752,9 +787,34 @@ | ||
| 752 | 787 | } |
| 753 | 788 | return MainWP_DB::instance()->update_website_option( $website, $option, $value ); |
| 754 | 789 | } |
| 755 | 790 | |
| 791 | + | |
| 756 | 792 | /** |
| 793 | + * Method hook_delete_site_options() | |
| 794 | + * | |
| 795 | + * Hook to remove Child site options. | |
| 796 | + * | |
| 797 | + * @since 5.4 | |
| 798 | + * @param object $website Child site object. | |
| 799 | + * @param string $options Option name. | |
| 800 | + * | |
| 801 | + * @return string|null Database query result (as string), or null on failure | |
| 802 | + */ | |
| 803 | + public function hook_delete_site_options( $website, $options ) { | |
| 804 | + if ( is_numeric( $website ) ) { | |
| 805 | + $obj = new \stdClass(); | |
| 806 | + $obj->id = intval( $website ); | |
| 807 | + $website = $obj; | |
| 808 | + } elseif ( ! is_object( $website ) || ! property_exists( $website, 'id' ) ) { | |
| 809 | + return false; | |
| 810 | + } | |
| 811 | + | |
| 812 | + return MainWP_DB::instance()->remove_website_option( $website, $options ); | |
| 813 | + } | |
| 814 | + | |
| 815 | + | |
| 816 | + /** | |
| 757 | 817 | * Get sites by user ID. |
| 758 | 818 | * |
| 759 | 819 | * @param mixed $boolean Boolean check. |
| 760 | 820 | * @param int $userid User ID. |
| @@ -811,10 +871,10 @@ | ||
| 811 | 871 | /** |
| 812 | 872 | * Method hook_get_all_posts() |
| 813 | 873 | * Hook to get posts from sites. |
| 814 | 874 | * |
| 815 | - * @param object $sites Child Sites object. | |
| 816 | - * @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. | |
| 817 | 877 | * |
| 818 | 878 | * @return \stdClass $output All posts data array. |
| 819 | 879 | * |
| 820 | 880 | * @since 3.4.4 |
| @@ -822,9 +882,9 @@ | ||
| 822 | 882 | * @uses \MainWP\Dashboard\MainWP_Post::get_class_name() |
| 823 | 883 | * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() |
| 824 | 884 | * @uses \MainWP\Dashboard\MainWP_Utility::map_site() |
| 825 | 885 | */ |
| 826 | - 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. | |
| 827 | 887 | |
| 828 | 888 | $dbwebsites = array(); |
| 829 | 889 | |
| 830 | 890 | $data = MainWP_System_Utility::get_default_map_site_fields(); |
| @@ -830,11 +890,21 @@ | ||
| 830 | 890 | $data = MainWP_System_Utility::get_default_map_site_fields(); |
| 831 | 891 | $data[] = 'verify_certificate'; |
| 832 | 892 | |
| 833 | 893 | if ( '' !== $sites ) { |
| 834 | - foreach ( $sites as $v ) { | |
| 835 | - if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 836 | - $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 ); | |
| 837 | 907 | if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { |
| 838 | 908 | $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data ); |
| 839 | 909 | } |
| 840 | 910 | } |
| @@ -866,9 +936,9 @@ | ||
| 866 | 936 | return $output; |
| 867 | 937 | } |
| 868 | 938 | |
| 869 | 939 | /** |
| 870 | - * Method mainwp_current_user_have_right() | |
| 940 | + * Method \mainwp_current_user_can() | |
| 871 | 941 | * |
| 872 | 942 | * Check permission level by hook mainwp_currentusercan of Team Control extension |
| 873 | 943 | * |
| 874 | 944 | * @param mixed $input Return value holder. |
| @@ -878,10 +948,10 @@ | ||
| 878 | 948 | * @return bool $input Return true if the user can and false if they can not. |
| 879 | 949 | */ |
| 880 | 950 | public function hook_current_user_can( $input, $can_type, $which ) { |
| 881 | 951 | |
| 882 | - if ( function_exists( 'mainwp_current_user_have_right' ) ) { | |
| 883 | - return mainwp_current_user_have_right( $can_type, $which ); | |
| 952 | + if ( function_exists( '\mainwp_current_user_can' ) ) { | |
| 953 | + return \mainwp_current_user_can( $can_type, $which ); | |
| 884 | 954 | } |
| 885 | 955 | |
| 886 | 956 | return $input; |
| 887 | 957 | } |
| @@ -982,10 +1052,8 @@ | ||
| 982 | 1052 | |
| 983 | 1053 | /** |
| 984 | 1054 | * Method db_get_websites_for_current_user() |
| 985 | 1055 | * |
| 986 | - * To escape response data. | |
| 987 | - * | |
| 988 | 1056 | * @param mixed $input_value input value. |
| 989 | 1057 | * @param array $params params data. |
| 990 | 1058 | * |
| 991 | 1059 | * @return mixed websites. |
| @@ -1001,12 +1069,44 @@ | ||
| 1001 | 1069 | |
| 1002 | 1070 | if ( ! is_array( $extra_view ) ) { |
| 1003 | 1071 | $extra_view = array( 'favi_icon' ); |
| 1004 | 1072 | } |
| 1005 | - return MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, $orderBy, false, false, null, false, $extra_view ) ); | |
| 1073 | + | |
| 1074 | + // Prevent conflicts in wp_options query conditions. | |
| 1075 | + // If use_join_wp_options is not enabled, | |
| 1076 | + // force the use of a compatible subquery approach to ensure the query remains correct. | |
| 1077 | + if ( is_array( $params ) && empty( $params['use_join_wp_options'] ) ) { | |
| 1078 | + $params['use_compatible_subquery'] = 1; | |
| 1079 | + } | |
| 1080 | + | |
| 1081 | + return MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, $orderBy, false, false, null, false, $extra_view, 'no', $params ) ); | |
| 1006 | 1082 | } |
| 1007 | 1083 | |
| 1084 | + /** | |
| 1085 | + * Method hook_get_sql_websites_by_params() | |
| 1086 | + * | |
| 1087 | + * @param mixed $in_val input value. | |
| 1088 | + * @param array $params params data. | |
| 1089 | + * | |
| 1090 | + * @return mixed websites. | |
| 1091 | + */ | |
| 1092 | + public function hook_get_sql_websites_by_params( $in_val = false, $params = array() ) { | |
| 1093 | + unset( $in_val ); | |
| 1094 | + if ( ! is_array( $params ) ) { | |
| 1095 | + $params = array(); | |
| 1096 | + } | |
| 1008 | 1097 | |
| 1098 | + // Prevent conflicts in wp_options query conditions. | |
| 1099 | + // If use_join_wp_options is not enabled, | |
| 1100 | + // force the use of a compatible subquery approach to ensure the query remains correct. | |
| 1101 | + if ( is_array( $params ) && empty( $params['use_join_wp_options'] ) ) { | |
| 1102 | + $params['use_compatible_subquery'] = 1; | |
| 1103 | + } | |
| 1104 | + | |
| 1105 | + return MainWP_DB::instance()->get_sql_websites_for_current_user_by_params( $params ); | |
| 1106 | + } | |
| 1107 | + | |
| 1108 | + | |
| 1009 | 1109 | /** |
| 1010 | 1110 | * Method hook_sync_website() |
| 1011 | 1111 | * |
| 1012 | 1112 | * To escape response data. |
| @@ -1316,10 +1416,10 @@ | ||
| 1316 | 1416 | * Hook to upgrade WP. |
| 1317 | 1417 | */ |
| 1318 | 1418 | public function upgrade_wp() { |
| 1319 | 1419 | |
| 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 ) ) ) ); | |
| 1420 | + if ( ! \mainwp_current_user_can( 'dashboard', 'update_wordpress' ) ) { | |
| 1421 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) ); | |
| 1322 | 1422 | } |
| 1323 | 1423 | |
| 1324 | 1424 | try { |
| 1325 | 1425 | $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| @@ -1358,12 +1458,12 @@ | ||
| 1358 | 1458 | $error = ''; |
| 1359 | 1459 | $erCode = ''; |
| 1360 | 1460 | // phpcs:enable |
| 1361 | 1461 | |
| 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 ); | |
| 1462 | + if ( 'plugin' === $type && ! \mainwp_current_user_can( 'dashboard', 'update_plugins' ) ) { | |
| 1463 | + $error = \mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false ); | |
| 1464 | + } elseif ( 'theme' === $type && ! \mainwp_current_user_can( 'dashboard', 'update_themes' ) ) { | |
| 1465 | + $error = \mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false ); | |
| 1366 | 1466 | } |
| 1367 | 1467 | |
| 1368 | 1468 | $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); |
| 1369 | 1469 | |
| @@ -1407,12 +1507,8 @@ | ||
| 1407 | 1507 | * |
| 1408 | 1508 | * @since 4.1 |
| 1409 | 1509 | */ |
| 1410 | 1510 | do_action( 'mainwp_after_plugin_theme_translation_update', $information, $type, implode( ',', $slugs ), $website ); |
| 1411 | - | |
| 1412 | - if ( isset( $information['sync'] ) ) { | |
| 1413 | - unset( $information['sync'] ); | |
| 1414 | - } | |
| 1415 | 1511 | wp_send_json( $information ); |
| 1416 | 1512 | } |
| 1417 | 1513 | } catch ( MainWP_Exception $e ) { |
| 1418 | 1514 | die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) ); |
| @@ -1472,9 +1568,9 @@ | ||
| 1472 | 1568 | * Hook Atarim default column. |
| 1473 | 1569 | */ |
| 1474 | 1570 | public function hook_atarim_default_sitestable_column( $columns ) { |
| 1475 | 1571 | if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) ) { |
| 1476 | - $columns['atarim_tasks'] = esc_html__( 'Atarim', 'mainwp-atarim-extension' ); | |
| 1572 | + $columns['atarim_tasks'] = esc_html__( 'Atarim', 'mainwp' ); | |
| 1477 | 1573 | } |
| 1478 | 1574 | return $columns; |
| 1479 | 1575 | } |
| 1480 | 1576 | |
| @@ -1487,9 +1583,10 @@ | ||
| 1487 | 1583 | */ |
| 1488 | 1584 | public function hook_atarim_manage_sites_default_item( $item ) { |
| 1489 | 1585 | if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) && is_array( $item ) && isset( $item['url'] ) ) { |
| 1490 | 1586 | $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>'; | |
| 1587 | + $icon_link = MAINWP_PLUGIN_URL . 'assets/images/atarim-icon.png'; | |
| 1588 | + $item['atarim_tasks'] = '<a href="' . $collaborate_link . '" target="_balnk" class="ui mini grey basic button" data-tooltip="Collaborate on this website." data-inverted="" data-position="left center"><img src="' . $icon_link . '" style="width:12px"> ' . __( 'Collaborate', 'mainwp' ) . '</a>'; | |
| 1492 | 1589 | } |
| 1493 | 1590 | return $item; |
| 1494 | 1591 | } |
| 1495 | 1592 | |
| @@ -1672,8 +1769,35 @@ | ||
| 1672 | 1769 | return MainWP_DB_Client::instance()->get_wp_client_by( $by, $value, $obj, $params ); |
| 1673 | 1770 | } |
| 1674 | 1771 | |
| 1675 | 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 | + /** | |
| 1676 | 1800 | * Method hook_get_activation_info() |
| 1677 | 1801 | * |
| 1678 | 1802 | * Get extension activation info. |
| 1679 | 1803 | * |
| @@ -1878,8 +2002,21 @@ | ||
| 1878 | 2002 | return MainWP_Keys_Manager::instance()->delete_key_file( $key_file ); |
| 1879 | 2003 | } |
| 1880 | 2004 | |
| 1881 | 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 | + /** | |
| 1882 | 2019 | * Method hook_get_lookup_items(). |
| 1883 | 2020 | * |
| 1884 | 2021 | * @param bool $false_val false value. |
| 1885 | 2022 | * @param string $item_name item name. |
| @@ -1935,6 +2072,60 @@ | ||
| 1935 | 2072 | */ |
| 1936 | 2073 | public function hook_get_indicator( $def_value, $indi_type = 'field', $wrapper_cls = '', $visible = true ) { |
| 1937 | 2074 | unset( $def_value ); |
| 1938 | 2075 | return MainWP_Settings_Indicator::get_indicator( $indi_type, $wrapper_cls, $visible ); |
| 2076 | + } | |
| 2077 | + | |
| 2078 | + /** | |
| 2079 | + * Method hook_get_time_elapsed_string(). | |
| 2080 | + * | |
| 2081 | + * Returns date in time ago format | |
| 2082 | + * | |
| 2083 | + * @param mixed $ptime Date stamp. | |
| 2084 | + * @return string $string Time elapsed string. | |
| 2085 | + */ | |
| 2086 | + public function hook_get_time_elapsed_string( $ptime = 0 ) { | |
| 2087 | + return MainWP_Utility::time_elapsed_string( $ptime ); | |
| 2088 | + } | |
| 2089 | + | |
| 2090 | + /** | |
| 2091 | + * Method hook_get_regular_process_by(). | |
| 2092 | + * | |
| 2093 | + * @param mixed $input_value Input value. | |
| 2094 | + * @param int $item_id Item id. | |
| 2095 | + * @param int $pro_type Process type. | |
| 2096 | + * @param int $pro_slug Process slug. | |
| 2097 | + * | |
| 2098 | + * @return mixed | |
| 2099 | + */ | |
| 2100 | + public function hook_get_regular_process_by( $input_value, $item_id, $pro_type, $pro_slug ) { | |
| 2101 | + unset( $input_value ); | |
| 2102 | + return MainWP_DB::instance()->get_regular_process_by_item_id_type_slug( $item_id, $pro_type, $pro_slug ); | |
| 2103 | + } | |
| 2104 | + | |
| 2105 | + /** | |
| 2106 | + * Method hook_get_primary_backup_method. | |
| 2107 | + * | |
| 2108 | + * @param mixed $inpval Hook input value. | |
| 2109 | + * @param int|false $siteid Optional Site ID; false for global method. | |
| 2110 | + * | |
| 2111 | + * @since 6.0.10. | |
| 2112 | + * | |
| 2113 | + * @return string Global or site primary backup method. | |
| 2114 | + */ | |
| 2115 | + public function hook_get_primary_backup_method( $inpval, $siteid = false ) { | |
| 2116 | + unset( $inpval ); | |
| 2117 | + $primaryBackup = get_option( 'mainwp_primaryBackup' ); | |
| 2118 | + if ( false !== $siteid ) { | |
| 2119 | + $website = MainWP_DB::instance()->get_website_by_id( $siteid ); | |
| 2120 | + if ( is_object( $website ) && property_exists( $website, 'primary_backup_method' ) ) { | |
| 2121 | + if ( '' === $website->primary_backup_method || 'global' === $website->primary_backup_method ) { | |
| 2122 | + $backup_method = $primaryBackup; | |
| 2123 | + } else { | |
| 2124 | + $backup_method = $website->primary_backup_method; | |
| 2125 | + } | |
| 2126 | + return $backup_method; | |
| 2127 | + } | |
| 2128 | + } | |
| 2129 | + return $primaryBackup; | |
| 1939 | 2130 | } |
| 1940 | 2131 | } |