| @@ -6,903 +6,1055 @@ | ||
| 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 | /** |
| 11 | 16 | * Class MainWP_Manage_Sites_Update_View |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| 14 | 19 | */ |
| 15 | -class MainWP_Manage_Sites_Update_View { | |
| 20 | +class MainWP_Manage_Sites_Update_View { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 16 | 21 | |
| 17 | - /** | |
| 18 | - * Method render_updates() | |
| 19 | - * | |
| 20 | - * If empty do nothing else grab the Child Sites ID and pass it to | |
| 21 | - * method render_individual_updates(). | |
| 22 | - * | |
| 23 | - * @param mixed $website Child Site Info. | |
| 24 | - * | |
| 25 | - * @return self render_individual_updates() | |
| 26 | - */ | |
| 27 | - public static function render_updates( $website ) { | |
| 28 | - if ( empty( $website ) ) { | |
| 29 | - return; | |
| 30 | - } | |
| 22 | + /** | |
| 23 | + * Method render_updates() | |
| 24 | + * | |
| 25 | + * If empty do nothing else grab the Child Sites ID and pass it to | |
| 26 | + * method render_individual_updates(). | |
| 27 | + * | |
| 28 | + * @param mixed $website Child Site Info. | |
| 29 | + * | |
| 30 | + * @return mixed | |
| 31 | + */ | |
| 32 | + public static function render_updates( $website ) { | |
| 33 | + if ( empty( $website ) ) { | |
| 34 | + return; | |
| 35 | + } | |
| 31 | 36 | |
| 32 | - $website_id = $website->id; | |
| 33 | - self::render_individual_updates( $website_id ); | |
| 34 | - } | |
| 37 | + $website_id = $website->id; | |
| 38 | + static::render_individual_updates( $website_id ); | |
| 39 | + } | |
| 35 | 40 | |
| 36 | - /** | |
| 37 | - * Method render_individual_updates() | |
| 38 | - * | |
| 39 | - * Render Plugin updates Tab. | |
| 40 | - * | |
| 41 | - * @param mixed $id Child Site ID. | |
| 42 | - * | |
| 43 | - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() | |
| 44 | - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id() | |
| 45 | - * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 46 | - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 47 | - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_header_tabs() | |
| 48 | - */ | |
| 49 | - public static function render_individual_updates( $id ) { | |
| 41 | + /** | |
| 42 | + * Method render_individual_updates() | |
| 43 | + * | |
| 44 | + * Render Plugin updates Tab. | |
| 45 | + * | |
| 46 | + * @param mixed $id Child Site ID. | |
| 47 | + * | |
| 48 | + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() | |
| 49 | + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id() | |
| 50 | + * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 51 | + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 52 | + * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_header_tabs() | |
| 53 | + */ | |
| 54 | + public static function render_individual_updates( $id ) { | |
| 50 | 55 | |
| 51 | - /** | |
| 52 | - * Current user global. | |
| 53 | - * | |
| 54 | - * @global string | |
| 55 | - */ | |
| 56 | - global $current_user; | |
| 57 | - $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 58 | - $sql = MainWP_DB::instance()->get_sql_website_by_id( $id, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) ); | |
| 59 | - $websites = MainWP_DB::instance()->query( $sql ); | |
| 56 | + /** | |
| 57 | + * Current user global. | |
| 58 | + * | |
| 59 | + * @global string | |
| 60 | + */ | |
| 61 | + global $current_user; | |
| 62 | + $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 63 | + $sql = MainWP_DB::instance()->get_sql_website_by_id( $id, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_upgrades', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) ); | |
| 64 | + $websites = MainWP_DB::instance()->query( $sql ); | |
| 60 | 65 | |
| 61 | - MainWP_DB::data_seek( $websites, 0 ); | |
| 62 | - if ( $websites ) { | |
| 63 | - $website = MainWP_DB::fetch_object( $websites ); | |
| 64 | - } | |
| 66 | + MainWP_DB::data_seek( $websites, 0 ); | |
| 67 | + if ( $websites ) { | |
| 68 | + $website = MainWP_DB::fetch_object( $websites ); | |
| 69 | + } | |
| 65 | 70 | |
| 66 | - $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 ); | |
| 71 | + $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 ); | |
| 67 | 72 | |
| 68 | - $active_tab = 'plugins'; | |
| 69 | - $active_text = esc_html__( 'Plugins Updates', 'mainwp' ); | |
| 70 | - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 71 | - if ( isset( $_GET['tab'] ) ) { | |
| 72 | - if ( 'wordpress-updates' === $_GET['tab'] ) { | |
| 73 | - $active_tab = 'WordPress'; | |
| 74 | - $active_text = esc_html__( 'WordPress Updates', 'mainwp' ); | |
| 75 | - } elseif ( 'themes-updates' === $_GET['tab'] ) { | |
| 76 | - $active_tab = 'themes'; | |
| 77 | - $active_text = esc_html__( 'Themes Updates', 'mainwp' ); | |
| 78 | - } elseif ( 'translations-updates' === $_GET['tab'] ) { | |
| 79 | - $active_tab = 'trans'; | |
| 80 | - $active_text = esc_html__( 'Translations Updates', 'mainwp' ); | |
| 81 | - } elseif ( 'abandoned-plugins' === $_GET['tab'] ) { | |
| 82 | - $active_tab = 'abandoned-plugins'; | |
| 83 | - $active_text = esc_html__( 'Abandoned Plugins', 'mainwp' ); | |
| 84 | - } elseif ( 'abandoned-themes' === $_GET['tab'] ) { | |
| 85 | - $active_tab = 'abandoned-themes'; | |
| 86 | - $active_text = esc_html__( 'Abandoned Themes', 'mainwp' ); | |
| 87 | - } | |
| 88 | - } | |
| 89 | - // phpcs:enable | |
| 90 | - MainWP_Manage_Sites_View::render_header_tabs( $active_tab, $active_text, $mainwp_show_language_updates ) | |
| 91 | - ?> | |
| 92 | - <div class="ui segment" id="mainwp-manage-<?php echo intval( $id ); ?>-updates"> | |
| 93 | - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-site-message' ) ) : ?> | |
| 94 | - <div class="ui info message"> | |
| 95 | - <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-site-message"></i> | |
| 96 | - <div><?php printf( esc_html__( 'Manage available updates for the child site. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/update-themes/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/update-wordpress-core/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 97 | - <div><?php printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/ignore-wordpress-core-update/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/ignore-theme-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 98 | - </div> | |
| 99 | - <?php endif; ?> | |
| 100 | - <?php | |
| 101 | - self::render_wpcore_updates( $website, $active_tab ); | |
| 102 | - self::render_plugins_updates( $website, $active_tab, $userExtension ); | |
| 103 | - self::render_themes_updates( $website, $active_tab, $userExtension ); | |
| 73 | + $active_tab = 'plugins'; | |
| 74 | + $active_text = esc_html__( 'Plugin Updates', 'mainwp' ); | |
| 75 | + // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 76 | + if ( isset( $_GET['tab'] ) ) { | |
| 77 | + if ( 'wordpress-updates' === $_GET['tab'] ) { | |
| 78 | + $active_tab = 'wordpress'; | |
| 79 | + $active_text = esc_html__( 'WordPress Updates', 'mainwp' ); | |
| 80 | + } elseif ( 'themes-updates' === $_GET['tab'] ) { | |
| 81 | + $active_tab = 'themes'; | |
| 82 | + $active_text = esc_html__( 'Theme Updates', 'mainwp' ); | |
| 83 | + } elseif ( 'translations-updates' === $_GET['tab'] ) { | |
| 84 | + $active_tab = 'trans'; | |
| 85 | + $active_text = esc_html__( 'Translation Updates', 'mainwp' ); | |
| 86 | + } elseif ( 'abandoned-plugins' === $_GET['tab'] ) { | |
| 87 | + $active_tab = 'abandoned-plugins'; | |
| 88 | + $active_text = esc_html__( 'Abandoned Plugins', 'mainwp' ); | |
| 89 | + } elseif ( 'abandoned-themes' === $_GET['tab'] ) { | |
| 90 | + $active_tab = 'abandoned-themes'; | |
| 91 | + $active_text = esc_html__( 'Abandoned Themes', 'mainwp' ); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + // phpcs:enable | |
| 95 | + MainWP_Manage_Sites_View::render_header_tabs( $active_tab, $active_text, $mainwp_show_language_updates ) | |
| 96 | + ?> | |
| 97 | + <div class="ui padded segment" id="mainwp-manage-<?php echo intval( $id ); ?>-updates"> | |
| 98 | + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-site-message' ) ) : ?> | |
| 99 | + <div class="ui info message"> | |
| 100 | + <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-site-message"></i> | |
| 101 | + <div> | |
| 102 | + <?php | |
| 103 | + /* translators: 1: Opening anchor tag for plugins, 2: Closing anchor tag, 3: Opening anchor tag for themes, 4: Closing anchor tag, 5: Opening anchor tag for WordPress core, 6: Closing anchor tag */ | |
| 104 | + printf( esc_html__( 'Manage available updates for the child site. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 105 | + ?> | |
| 106 | + </div> | |
| 107 | + <div> | |
| 108 | + <?php | |
| 109 | + /* translators: 1: Opening anchor tag for WordPress core, 2: Closing anchor tag, 3: Opening anchor tag for plugins, 4: Closing anchor tag, 5: Opening anchor tag for themes, 6: Closing anchor tag */ | |
| 110 | + printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 111 | + ?> | |
| 112 | + </div> | |
| 113 | + </div> | |
| 114 | + <?php endif; ?> | |
| 115 | + <?php | |
| 116 | + static::render_wpcore_updates( $website, $active_tab, $userExtension ); | |
| 117 | + static::render_plugins_updates( $website, $active_tab, $userExtension ); | |
| 118 | + static::render_themes_updates( $website, $active_tab, $userExtension ); | |
| 104 | 119 | |
| 105 | - if ( $mainwp_show_language_updates ) : | |
| 106 | - self::render_language_updates( $website, $active_tab ); | |
| 107 | - endif; | |
| 120 | + if ( $mainwp_show_language_updates ) : | |
| 121 | + static::render_language_updates( $website, $active_tab, $userExtension ); | |
| 122 | + endif; | |
| 108 | 123 | |
| 109 | - self::render_abandoned_plugins( $website, $active_tab, $userExtension ); | |
| 110 | - self::render_abandoned_themes( $website, $active_tab, $userExtension ); | |
| 111 | - ?> | |
| 112 | - </div> | |
| 113 | - <script type="text/javascript"> | |
| 114 | - jQuery( document ).ready( function () { | |
| 115 | - jQuery( '.ui.dropdown .item' ).tab(); | |
| 116 | - jQuery( 'table.ui.table' ).DataTable( { | |
| 117 | - "searching": true, | |
| 118 | - "paging" : false, | |
| 119 | - "info" : true, | |
| 120 | - "columnDefs" : [ { "orderable": false, "targets": "no-sort" } ], | |
| 121 | - "language" : { "emptyTable": "No available updates. Please sync your MainWP Dashboard with Child Sites to see if there are any new updates available." } | |
| 122 | - } ); | |
| 123 | - mainwp_get_icon_start(); | |
| 124 | - } ); | |
| 125 | - </script> | |
| 126 | - <?php | |
| 127 | - MainWP_UI::render_modal_upload_icon(); | |
| 128 | - } | |
| 124 | + static::render_abandoned_plugins( $website, $active_tab, $userExtension ); | |
| 125 | + static::render_abandoned_themes( $website, $active_tab, $userExtension ); | |
| 129 | 126 | |
| 130 | - /** | |
| 131 | - * Method get_total_info() | |
| 132 | - * | |
| 133 | - * Get total Updates information. | |
| 134 | - * | |
| 135 | - * @param mixed $site_id Child Site id. | |
| 136 | - */ | |
| 137 | - public static function get_total_info( $site_id ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 127 | + // @since 5.4.0.7 - custom individual update tabs. | |
| 128 | + do_action( 'mainwp_individual_updates_tabs', $website, $userExtension ); | |
| 129 | + ?> | |
| 130 | + </div> | |
| 131 | + <script type="text/javascript"> | |
| 132 | + jQuery(function ($) { | |
| 133 | + $( '.ui.dropdown.select-individual-updates .item' ).tab({ | |
| 134 | + 'autoTabActivation': false, | |
| 135 | + 'onVisible': function (tab) { | |
| 136 | + $('.select-buttons-individual-updates .button.ui').addClass('hidden'); | |
| 137 | + $('.select-buttons-individual-updates .button.ui.' + tab).removeClass('hidden'); | |
| 138 | + } | |
| 139 | + }); | |
| 140 | + var $activeItem = $('.ui.dropdown.select-individual-updates .item.active'); | |
| 141 | + if ($activeItem.length) { | |
| 142 | + var initialTab = $activeItem.data('tab'); | |
| 143 | + $('.select-buttons-individual-updates .button.ui').addClass('hidden'); | |
| 144 | + $('.select-buttons-individual-updates .button.ui.' + initialTab).removeClass('hidden'); | |
| 145 | + } | |
| 146 | + jQuery( 'table.ui.table:not(.not-default-init)' ).DataTable( { | |
| 147 | + "searching": true, | |
| 148 | + "paging" : false, | |
| 149 | + "info" : true, | |
| 150 | + "columnDefs" : [ { "orderable": false, "targets": "no-sort" } ], | |
| 151 | + "language" : { "emptyTable": "No available updates. Please sync your MainWP Dashboard with Child Sites to see if there are any new updates available." } | |
| 152 | + } ); | |
| 153 | + mainwp_get_icon_start(); | |
| 154 | + }); | |
| 155 | + </script> | |
| 156 | + <?php | |
| 157 | + MainWP_UI::render_modal_upload_icon(); | |
| 158 | + MainWP_Updates::render_changes_history_modal(); | |
| 159 | + } | |
| 138 | 160 | |
| 139 | - $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 140 | - $sql = MainWP_DB::instance()->get_sql_website_by_id( $site_id, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) ); | |
| 141 | - $websites = MainWP_DB::instance()->query( $sql ); | |
| 161 | + /** | |
| 162 | + * Method get_total_info() | |
| 163 | + * | |
| 164 | + * Get total Updates information. | |
| 165 | + * | |
| 166 | + * @param mixed $site_id Child Site id. | |
| 167 | + */ | |
| 168 | + public static function get_total_info( $site_id ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 142 | 169 | |
| 143 | - MainWP_DB::data_seek( $websites, 0 ); | |
| 144 | - if ( $websites ) { | |
| 145 | - $website = MainWP_DB::fetch_object( $websites ); | |
| 146 | - } | |
| 170 | + $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 147 | 171 | |
| 148 | - $return = array( | |
| 149 | - 'total_wp' => 0, | |
| 150 | - 'total_plugins' => 0, | |
| 151 | - 'total_themes' => 0, | |
| 152 | - 'total_trans' => 0, | |
| 153 | - 'total_aband_plugins' => 0, | |
| 154 | - 'total_aband_themes' => 0, | |
| 155 | - 'total_upgrades' => 0, | |
| 156 | - ); | |
| 172 | + $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array(); | |
| 173 | + if ( ! is_array( $decodedIgnoredCores ) ) { | |
| 174 | + $decodedIgnoredCores = array(); | |
| 175 | + } | |
| 157 | 176 | |
| 158 | - if ( empty( $website ) ) { | |
| 159 | - return $return; | |
| 160 | - } | |
| 177 | + $sql = MainWP_DB::instance()->get_sql_website_by_id( $site_id, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) ); | |
| 178 | + $websites = MainWP_DB::instance()->query( $sql ); | |
| 161 | 179 | |
| 162 | - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ); | |
| 163 | - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array(); | |
| 180 | + MainWP_DB::data_seek( $websites, 0 ); | |
| 181 | + if ( $websites ) { | |
| 182 | + $website = MainWP_DB::fetch_object( $websites ); | |
| 183 | + } | |
| 164 | 184 | |
| 165 | - if ( $website->is_ignoreCoreUpdates ) { | |
| 166 | - $wp_upgrades = array(); | |
| 167 | - } | |
| 185 | + $return = array( | |
| 186 | + 'total_wp' => 0, | |
| 187 | + 'total_plugins' => 0, | |
| 188 | + 'total_themes' => 0, | |
| 189 | + 'total_trans' => 0, | |
| 190 | + 'total_aband_plugins' => 0, | |
| 191 | + 'total_aband_themes' => 0, | |
| 192 | + 'total_upgrades' => 0, | |
| 193 | + ); | |
| 168 | 194 | |
| 169 | - $return['total_wp'] = ! empty( $wp_upgrades ) ? 1 : 0; | |
| 195 | + if ( empty( $website ) ) { | |
| 196 | + return $return; | |
| 197 | + } | |
| 170 | 198 | |
| 171 | - $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); | |
| 199 | + $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array(); | |
| 200 | + $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array(); | |
| 172 | 201 | |
| 173 | - if ( $website->is_ignorePluginUpdates ) { | |
| 174 | - $plugin_upgrades = array(); | |
| 175 | - } | |
| 202 | + if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) { | |
| 203 | + $wp_upgrades = array(); | |
| 204 | + } | |
| 176 | 205 | |
| 177 | - if ( ! is_array( $plugin_upgrades ) ) { | |
| 178 | - $plugin_upgrades = array(); | |
| 179 | - } | |
| 206 | + $return['total_wp'] = ! empty( $wp_upgrades ) ? 1 : 0; | |
| 180 | 207 | |
| 181 | - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 182 | - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 208 | + $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); | |
| 183 | 209 | |
| 184 | - if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 185 | - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 186 | - $premiumUpgrade['premium'] = true; | |
| 187 | - if ( 'plugin' === $premiumUpgrade['type'] ) { | |
| 188 | - $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 210 | + if ( $website->is_ignorePluginUpdates ) { | |
| 211 | + $plugin_upgrades = array(); | |
| 212 | + } | |
| 189 | 213 | |
| 190 | - if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { | |
| 191 | - $plugin_upgrades[ $crrSlug ] = array(); | |
| 192 | - } | |
| 193 | - $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 194 | - } | |
| 195 | - } | |
| 196 | - } | |
| 197 | - $ignored_plugins = json_decode( $website->ignored_plugins, true ); | |
| 198 | - if ( is_array( $ignored_plugins ) ) { | |
| 199 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 200 | - } | |
| 214 | + if ( ! is_array( $plugin_upgrades ) ) { | |
| 215 | + $plugin_upgrades = array(); | |
| 216 | + } | |
| 201 | 217 | |
| 202 | - $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); | |
| 203 | - if ( is_array( $ignored_plugins ) ) { | |
| 204 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 205 | - } | |
| 218 | + $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 219 | + $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 206 | 220 | |
| 207 | - $return['total_plugins'] = count( $plugin_upgrades ); | |
| 221 | + if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 222 | + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 223 | + $premiumUpgrade['premium'] = true; | |
| 224 | + if ( 'plugin' === $premiumUpgrade['type'] ) { | |
| 225 | + $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 208 | 226 | |
| 209 | - $theme_upgrades = json_decode( $website->theme_upgrades, true ); | |
| 227 | + if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { | |
| 228 | + continue; | |
| 229 | + } | |
| 230 | + $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + } | |
| 234 | + $ignored_plugins = json_decode( $website->ignored_plugins, true ); | |
| 235 | + if ( is_array( $ignored_plugins ) ) { | |
| 236 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 237 | + } | |
| 210 | 238 | |
| 211 | - if ( $website->is_ignoreThemeUpdates ) { | |
| 212 | - $theme_upgrades = array(); | |
| 213 | - } | |
| 239 | + $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); | |
| 240 | + if ( is_array( $ignored_plugins ) ) { | |
| 241 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 242 | + } | |
| 214 | 243 | |
| 215 | - if ( ! is_array( $theme_upgrades ) ) { | |
| 216 | - $theme_upgrades = array(); | |
| 217 | - } | |
| 218 | - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 219 | - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 244 | + $return['total_plugins'] = count( $plugin_upgrades ); | |
| 220 | 245 | |
| 221 | - if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 222 | - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 223 | - $premiumUpgrade['premium'] = true; | |
| 246 | + $theme_upgrades = json_decode( $website->theme_upgrades, true ); | |
| 224 | 247 | |
| 225 | - if ( 'theme' === $premiumUpgrade['type'] ) { | |
| 226 | - $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 248 | + if ( $website->is_ignoreThemeUpdates ) { | |
| 249 | + $theme_upgrades = array(); | |
| 250 | + } | |
| 227 | 251 | |
| 228 | - if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { | |
| 229 | - $theme_upgrades[ $crrSlug ] = array(); | |
| 230 | - } | |
| 231 | - $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 232 | - } | |
| 233 | - } | |
| 234 | - } | |
| 235 | - $ignored_themes = json_decode( $website->ignored_themes, true ); | |
| 236 | - if ( is_array( $ignored_themes ) ) { | |
| 237 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 238 | - } | |
| 252 | + if ( ! is_array( $theme_upgrades ) ) { | |
| 253 | + $theme_upgrades = array(); | |
| 254 | + } | |
| 255 | + $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 256 | + $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 239 | 257 | |
| 240 | - $ignored_themes = json_decode( $userExtension->ignored_themes, true ); | |
| 241 | - if ( is_array( $ignored_themes ) ) { | |
| 242 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 243 | - } | |
| 258 | + if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 259 | + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 260 | + $premiumUpgrade['premium'] = true; | |
| 244 | 261 | |
| 245 | - $return['total_themes'] = count( $theme_upgrades ); | |
| 262 | + if ( 'theme' === $premiumUpgrade['type'] ) { | |
| 263 | + $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 246 | 264 | |
| 247 | - $translation_upgrades = json_decode( $website->translation_upgrades, true ); | |
| 248 | - if ( ! is_array( $translation_upgrades ) ) { | |
| 249 | - $translation_upgrades = array(); | |
| 250 | - } | |
| 251 | - $return['total_trans'] = count( $translation_upgrades ); | |
| 265 | + if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { | |
| 266 | + $theme_upgrades[ $crrSlug ] = array(); | |
| 267 | + } | |
| 268 | + $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 269 | + } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + $ignored_themes = json_decode( $website->ignored_themes, true ); | |
| 273 | + if ( is_array( $ignored_themes ) ) { | |
| 274 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 275 | + } | |
| 252 | 276 | |
| 253 | - $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ); | |
| 254 | - $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array(); | |
| 277 | + $ignored_themes = json_decode( $userExtension->ignored_themes, true ); | |
| 278 | + if ( is_array( $ignored_themes ) ) { | |
| 279 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 280 | + } | |
| 255 | 281 | |
| 256 | - if ( ! is_array( $plugins_outdate ) ) { | |
| 257 | - $plugins_outdate = array(); | |
| 258 | - } | |
| 259 | - if ( 0 < count( $plugins_outdate ) ) { | |
| 260 | - $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); | |
| 261 | - $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array(); | |
| 282 | + $return['total_themes'] = count( $theme_upgrades ); | |
| 262 | 283 | |
| 263 | - if ( is_array( $pluginsOutdateDismissed ) ) { | |
| 264 | - $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed ); | |
| 265 | - } | |
| 284 | + $translation_upgrades = json_decode( $website->translation_upgrades, true ); | |
| 285 | + if ( ! is_array( $translation_upgrades ) ) { | |
| 286 | + $translation_upgrades = array(); | |
| 287 | + } | |
| 266 | 288 | |
| 267 | - $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); | |
| 268 | - if ( is_array( $decodedDismissedPlugins ) ) { | |
| 269 | - $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); | |
| 270 | - } | |
| 271 | - } | |
| 272 | - $return['total_aband_plugins'] = count( $plugins_outdate ); | |
| 289 | + if ( ! empty( $website->ignored_trans_updates ) ) { | |
| 290 | + $translation_upgrades = array(); | |
| 291 | + } | |
| 273 | 292 | |
| 274 | - $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ); | |
| 275 | - $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array(); | |
| 293 | + $return['total_trans'] = count( $translation_upgrades ); | |
| 276 | 294 | |
| 277 | - if ( ! is_array( $themes_outdate ) ) { | |
| 278 | - $themes_outdate = array(); | |
| 279 | - } | |
| 295 | + $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ); | |
| 296 | + $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array(); | |
| 280 | 297 | |
| 281 | - if ( 0 < count( $themes_outdate ) ) { | |
| 282 | - $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); | |
| 283 | - $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array(); | |
| 298 | + if ( ! is_array( $plugins_outdate ) ) { | |
| 299 | + $plugins_outdate = array(); | |
| 300 | + } | |
| 301 | + if ( ! empty( $plugins_outdate ) ) { | |
| 302 | + $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); | |
| 303 | + $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array(); | |
| 284 | 304 | |
| 285 | - if ( is_array( $themesOutdateDismissed ) ) { | |
| 286 | - $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed ); | |
| 287 | - } | |
| 305 | + if ( is_array( $pluginsOutdateDismissed ) ) { | |
| 306 | + $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed ); | |
| 307 | + } | |
| 288 | 308 | |
| 289 | - $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); | |
| 290 | - if ( is_array( $decodedDismissedThemes ) ) { | |
| 291 | - $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); | |
| 292 | - } | |
| 293 | - } | |
| 309 | + $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); | |
| 310 | + if ( is_array( $decodedDismissedPlugins ) ) { | |
| 311 | + $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); | |
| 312 | + } | |
| 313 | + } | |
| 314 | + $return['total_aband_plugins'] = count( $plugins_outdate ); | |
| 294 | 315 | |
| 295 | - $return['total_aband_themes'] = count( $themes_outdate ); | |
| 316 | + $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ); | |
| 317 | + $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array(); | |
| 296 | 318 | |
| 297 | - $return['total_upgrades'] = $return['total_wp'] + $return['total_plugins'] + $return['total_themes'] + $return['total_trans']; | |
| 319 | + if ( ! is_array( $themes_outdate ) ) { | |
| 320 | + $themes_outdate = array(); | |
| 321 | + } | |
| 298 | 322 | |
| 299 | - return $return; | |
| 300 | - } | |
| 323 | + if ( ! empty( $themes_outdate ) ) { | |
| 324 | + $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); | |
| 325 | + $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array(); | |
| 301 | 326 | |
| 327 | + if ( is_array( $themesOutdateDismissed ) ) { | |
| 328 | + $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed ); | |
| 329 | + } | |
| 302 | 330 | |
| 303 | - /** | |
| 304 | - * Method render_wpcore_updates() | |
| 305 | - * | |
| 306 | - * Render the WordPress Updates Tab. | |
| 307 | - * | |
| 308 | - * @param mixed $website Child Site info. | |
| 309 | - * @param mixed $active_tab Current active tab. | |
| 310 | - * | |
| 311 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 312 | - */ | |
| 313 | - public static function render_wpcore_updates( $website, $active_tab ) { | |
| 314 | - $user_can_update_wp = mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ); | |
| 315 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 316 | - ?> | |
| 317 | - <div class="ui <?php echo 'WordPress' === $active_tab ? 'active' : ''; ?> tab" data-tab="wordpress"> | |
| 318 | - <table class="ui tablet stackable table" id="mainwp-wordpress-updates-table mainwp-manage-updates-table"> | |
| 319 | - <thead> | |
| 320 | - <tr> | |
| 321 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 322 | - <th><?php esc_html_e( 'New Version', 'mainwp' ); ?></th> | |
| 323 | - <th></th> | |
| 324 | - </tr> | |
| 325 | - </thead> | |
| 326 | - <tbody> | |
| 327 | - <?php if ( ! $website->is_ignoreCoreUpdates ) : ?> | |
| 328 | - <?php | |
| 329 | - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ); | |
| 330 | - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array(); | |
| 331 | + $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); | |
| 332 | + if ( is_array( $decodedDismissedThemes ) ) { | |
| 333 | + $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); | |
| 334 | + } | |
| 335 | + } | |
| 331 | 336 | |
| 332 | - $wpcore_update_disabled_by = ''; | |
| 333 | - if ( 0 < count( $wp_upgrades ) ) { | |
| 334 | - $wpcore_update_disabled_by = MainWP_System_Utility::disabled_wpcore_update_by( $website ); | |
| 335 | - } | |
| 336 | - ?> | |
| 337 | - <?php if ( ( 0 !== count( $wp_upgrades ) ) && ! ( '' !== $website->sync_errors ) ) : ?> | |
| 338 | - <tr class="mainwp-wordpress-update" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" updated="<?php echo ( 0 < count( $wp_upgrades ) && empty( $wpcore_update_disabled_by ) ) ? '0' : '1'; ?>"> | |
| 339 | - <td> | |
| 340 | - <?php if ( 0 < count( $wp_upgrades ) ) : ?> | |
| 341 | - <?php echo esc_html( $wp_upgrades['current'] ); ?> | |
| 342 | - <?php endif; ?> | |
| 343 | - </td> | |
| 344 | - <td> | |
| 345 | - <?php if ( 0 < count( $wp_upgrades ) ) : ?> | |
| 346 | - <?php echo esc_html( $wp_upgrades['new'] ); ?> | |
| 347 | - <?php endif; ?> | |
| 348 | - </td> | |
| 349 | - <td> | |
| 350 | - <?php if ( $user_can_update_wp ) : ?> | |
| 351 | - <?php | |
| 352 | - if ( 0 < count( $wp_upgrades ) ) : | |
| 353 | - if ( '' !== $wpcore_update_disabled_by ) { | |
| 354 | - ?> | |
| 355 | - <span data-tooltip="<?php echo esc_html( $wpcore_update_disabled_by ); ?>" data-inverted="" data-position="left center"><a href="javascript:void(0)" class="ui green button mini disabled"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a></span> | |
| 356 | - <?php | |
| 357 | - } else { | |
| 358 | - if ( $is_demo ) { | |
| 359 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green button mini disabled" disabled="disabled">' . esc_html__( 'Update Now', 'mainwp' ) . '</a>' ); | |
| 360 | - } else { | |
| 361 | - ?> | |
| 362 | - <a href="javascript:void(0)" data-tooltip="<?php esc_attr_e( 'Update', 'mainwp' ) . ' ' . esc_attr( $website->name ); ?>" data-inverted="" data-position="left center" class="ui green button mini" onClick="return updatesoverview_upgrade(<?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a> | |
| 363 | - <?php | |
| 364 | - } | |
| 365 | - ?> | |
| 366 | - <input type="hidden" id="wp-updated-<?php echo intval( $website->id ); ?>" value="<?php echo ( 0 < count( $wp_upgrades ) ? '0' : '1' ); ?>" /> | |
| 367 | - <?php | |
| 368 | - } | |
| 369 | - endif; | |
| 370 | - ?> | |
| 371 | - <?php endif; ?> | |
| 372 | - </td> | |
| 373 | - </tr> | |
| 374 | - <?php endif; ?> | |
| 375 | - <?php endif; ?> | |
| 376 | - </tbody> | |
| 377 | - <thead> | |
| 378 | - <tr> | |
| 379 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 380 | - <th><?php esc_html_e( 'New Version', 'mainwp' ); ?></th> | |
| 381 | - <th></th> | |
| 382 | - </tr> | |
| 383 | - </thead> | |
| 384 | - </table> | |
| 385 | - </div> | |
| 386 | - <?php | |
| 387 | - } | |
| 337 | + $return['total_aband_themes'] = count( $themes_outdate ); | |
| 388 | 338 | |
| 389 | - /** | |
| 390 | - * Method render_plugins_updates() | |
| 391 | - * | |
| 392 | - * Render the Plugin Updates Tab. | |
| 393 | - * | |
| 394 | - * @param mixed $website Child Site info. | |
| 395 | - * @param mixed $active_tab Current active tab. | |
| 396 | - * @param mixed $userExtension MainWP trusted plugin data. | |
| 397 | - * | |
| 398 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 399 | - * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper | |
| 400 | - */ | |
| 401 | - public static function render_plugins_updates( $website, $active_tab, $userExtension ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 339 | + $return['total_upgrades'] = $return['total_wp'] + $return['total_plugins'] + $return['total_themes'] + $return['total_trans']; | |
| 402 | 340 | |
| 403 | - $trustedPlugins = json_decode( $userExtension->trusted_plugins, true ); | |
| 404 | - if ( ! is_array( $trustedPlugins ) ) { | |
| 405 | - $trustedPlugins = array(); | |
| 406 | - } | |
| 341 | + return $return; | |
| 342 | + } | |
| 407 | 343 | |
| 408 | - $user_can_update_plugins = mainwp_current_user_have_right( 'dashboard', 'update_plugins' ); | |
| 409 | - $user_can_ignore_unignore = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ); | |
| 410 | - ?> | |
| 411 | - <div id="plugins-updates-global" class="ui <?php echo 'plugins' === $active_tab ? 'active' : ''; ?> tab" data-tab="plugins"> | |
| 412 | - <?php if ( ! $website->is_ignorePluginUpdates ) : ?> | |
| 413 | - <?php | |
| 414 | - $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); | |
| 415 | - if ( ! is_array( $plugin_upgrades ) ) { | |
| 416 | - $plugin_upgrades = array(); | |
| 417 | - } | |
| 418 | - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 419 | - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 420 | - if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 421 | - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 422 | - $premiumUpgrade['premium'] = true; | |
| 423 | - if ( 'plugin' === $premiumUpgrade['type'] ) { | |
| 424 | - $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 425 | - if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { | |
| 426 | - $plugin_upgrades[ $crrSlug ] = array(); | |
| 427 | - } | |
| 428 | - $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 429 | - } | |
| 430 | - } | |
| 431 | - } | |
| 432 | - $ignored_plugins = json_decode( $website->ignored_plugins, true ); | |
| 433 | - if ( is_array( $ignored_plugins ) ) { | |
| 434 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 435 | - } | |
| 436 | 344 | |
| 437 | - $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); | |
| 438 | - if ( is_array( $ignored_plugins ) ) { | |
| 439 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 440 | - } | |
| 345 | + /** | |
| 346 | + * Method render_wpcore_updates() | |
| 347 | + * | |
| 348 | + * Render the WordPress Updates Tab. | |
| 349 | + * | |
| 350 | + * @param mixed $website Child Site info. | |
| 351 | + * @param mixed $active_tab Current active tab. | |
| 352 | + * @param object $userExtension User Extension. | |
| 353 | + * | |
| 354 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 355 | + */ | |
| 356 | + public static function render_wpcore_updates( $website, $active_tab, $userExtension ) { // phpcs:ignore -- NOSONAR - complex. | |
| 357 | + $user_can_update_wp = \mainwp_current_user_can( 'dashboard', 'update_wordpress' ); | |
| 358 | + $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array(); | |
| 359 | + if ( ! is_array( $decodedIgnoredCores ) ) { | |
| 360 | + $decodedIgnoredCores = array(); | |
| 361 | + } | |
| 362 | + $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array(); | |
| 363 | + $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array(); | |
| 364 | + $wpcore_update_disabled_by = ''; | |
| 365 | + $last_version = ''; | |
| 366 | + $show_wp_update = false; | |
| 367 | + if ( ! $website->is_ignoreCoreUpdates && ! MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) && ! MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) { | |
| 368 | + if ( ! empty( $wp_upgrades ) ) { | |
| 369 | + $wpcore_update_disabled_by = MainWP_System_Utility::disabled_wpcore_update_by( $website ); | |
| 370 | + $last_version = $wp_upgrades['new']; | |
| 371 | + } | |
| 372 | + $show_wp_update = ! empty( $wp_upgrades ) && '' === $website->sync_errors; | |
| 373 | + } | |
| 374 | + ?> | |
| 375 | + <div class="ui <?php echo 'wordpress' === $active_tab ? 'active' : ''; ?> tab" data-tab="wordpress"> | |
| 376 | + <?php if ( $show_wp_update ) : ?> | |
| 377 | + <table style="width:100% !important;" class="ui tablet stackable table mainwp-manage-updates-table not-default-init" id="mainwp-wordpress-updates-table"> | |
| 378 | + <thead> | |
| 379 | + <tr> | |
| 380 | + <th scope="col"><?php esc_html_e( 'Detected Version', 'mainwp' ); ?></th> | |
| 381 | + <th scope="col" class="right aligned collapsing"><?php esc_html_e( 'New Version', 'mainwp' ); ?></th> | |
| 382 | + <th scope="col"></th> | |
| 383 | + </tr> | |
| 384 | + </thead> | |
| 385 | + <tbody> | |
| 386 | + <tr class="mainwp-wordpress-update" site_id="<?php echo intval( $website->id ); ?>" last-version="<?php echo esc_attr( rawurlencode( $last_version ) ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" updated="<?php echo ! empty( $wp_upgrades ) && empty( $wpcore_update_disabled_by ) ? '0' : '1'; ?>"> | |
| 387 | + <td> | |
| 388 | + <?php if ( ! empty( $wp_upgrades ) ) : ?> | |
| 389 | + <?php echo esc_html( $wp_upgrades['current'] ); ?> | |
| 390 | + <?php endif; ?> | |
| 391 | + </td> | |
| 392 | + <td> | |
| 393 | + <?php echo esc_html( $last_version ); ?> | |
| 394 | + </td> | |
| 395 | + <td> | |
| 396 | + <?php if ( $user_can_update_wp ) : ?> | |
| 397 | + <?php | |
| 398 | + if ( ! empty( $wp_upgrades ) ) : | |
| 399 | + if ( '' !== $wpcore_update_disabled_by ) { | |
| 400 | + ?> | |
| 401 | + <span data-tooltip="<?php echo esc_html( $wpcore_update_disabled_by ); ?>" data-inverted="" data-position="left center"><a href="javascript:void(0)" class="ui green button mini disabled"><?php esc_html_e( 'Update', 'mainwp' ); ?></a></span> | |
| 402 | + <?php } else { ?> | |
| 441 | 403 | |
| 442 | - $updates_table_helper = new MainWP_Updates_Table_Helper( MAINWP_VIEW_PER_SITE, 'plugin', array( 'show_select' => true ) ); | |
| 404 | + <div class="ui bottom left pointing dropdown mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?> | |
| 405 | + <i class="dropdown icon"></i> | |
| 406 | + <div class="menu"> | |
| 407 | + <a href="javascript:void(0)" onClick="return updatesoverview_upgrade_ignore( <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )" class="item"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a> | |
| 408 | + <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_upgrade_ignore_this_version_globally( '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a> | |
| 409 | + <a href="javascript:void(0)" onClick="return updatesoverview_upgrade_ignore_all_version( <?php echo intval( $website->id ); ?>, this )" class="item"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a> | |
| 410 | + </div> | |
| 411 | + </div> | |
| 412 | + <a href="javascript:void(0)" class="ui green button mini" onClick="return updatesoverview_upgrade(<?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a> | |
| 443 | 413 | |
| 444 | - add_filter( 'mainwp_updates_table_header_content', array( self::class, 'hook_table_update_plugins_header_content' ), 10, 4 ); | |
| 414 | + <input type="hidden" id="wp-updated-<?php echo intval( $website->id ); ?>" value="<?php echo ! empty( $wp_upgrades ) ? '0' : '1'; ?>" /> | |
| 415 | + <?php | |
| 416 | + } | |
| 417 | + endif; | |
| 418 | + ?> | |
| 419 | + <?php endif; ?> | |
| 420 | + </td> | |
| 421 | + </tr> | |
| 422 | + </tbody> | |
| 423 | + </table> | |
| 424 | + <?php else : ?> | |
| 425 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'WordPress is up to date', 'mainwp' ), __( 'No WordPress core update available right now.', 'mainwp' ) ); ?> | |
| 426 | + <?php endif; ?> | |
| 427 | + </div> | |
| 428 | + <?php | |
| 429 | + } | |
| 445 | 430 | |
| 446 | - ?> | |
| 447 | - <table id="mainwp-updates-plugins-table" class="ui tablet stackable table mainwp-updates-list mainwp-manage-updates-table"> | |
| 448 | - <thead class="master-checkbox"> | |
| 449 | - <tr> | |
| 450 | - <?php $updates_table_helper->print_column_headers(); ?> | |
| 451 | - </tr> | |
| 452 | - </thead> | |
| 453 | - <tbody class="plugins-bulk-updates child-checkbox" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 454 | - <?php foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) : ?> | |
| 455 | - <?php $plugin_name = rawurlencode( $slug ); ?> | |
| 456 | - <?php | |
| 457 | - $item_slug = MainWP_Utility::get_dir_slug( rawurldecode( $slug ) ); | |
| 458 | - $indent_hidden = '<input type="hidden" id="wp_upgraded_plugin_' . intval( $website->id ) . '_' . esc_html( $plugin_name ) . '" value="0" />'; | |
| 459 | - $row_columns = array( | |
| 460 | - 'title' => MainWP_System_Utility::get_plugin_icon( $item_slug ) . ' <a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '" target="_blank" class="open-plugin-details-modal">' . esc_html( $plugin_upgrade['Name'] ) . '</a>' . $indent_hidden, | |
| 461 | - 'version' => esc_html( $plugin_upgrade['Version'] ), | |
| 462 | - 'latest' => '<a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '§ion=changelog" target="_blank" class="open-plugin-details-modal">' . esc_html( $plugin_upgrade['update']['new_version'] ) . '</a>', | |
| 463 | - 'trusted' => ( in_array( $slug, $trustedPlugins ) ? true : false ), | |
| 464 | - 'status' => ( isset( $plugin_upgrade['active'] ) && $plugin_upgrade['active'] ) ? true : false, | |
| 465 | - ); | |
| 466 | - ?> | |
| 467 | - <tr plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" premium="<?php echo ( isset( $plugin_upgrade['premium'] ) && ! empty( $plugin_upgrade['premium'] ) ) ? 1 : 0; ?>" updated="0"> | |
| 468 | - <?php | |
| 469 | - $row_columns = $updates_table_helper->render_columns( $row_columns, $website ); | |
| 470 | - $action_rendered = isset( $row_columns['action'] ) ? true : false; | |
| 471 | - if ( ! $action_rendered ) : | |
| 472 | - ?> | |
| 473 | - <td> | |
| 474 | - <?php if ( $user_can_ignore_unignore ) : ?> | |
| 475 | - <a href="javascript:void(0)" onClick="return updatesoverview_plugins_ignore_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )" class="ui mini button"><?php esc_html_e( 'Ignore Update', 'mainwp' ); ?></a> | |
| 476 | - <?php endif; ?> | |
| 477 | - <?php | |
| 478 | - if ( $user_can_update_plugins ) : | |
| 479 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 480 | - if ( $is_demo ) { | |
| 481 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini button" disabled="disabled">' . esc_html__( 'Update Now', 'mainwp' ) . '</a>' ); | |
| 482 | - } else { | |
| 483 | - ?> | |
| 484 | - <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_plugin( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $plugin_name ); ?>' )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a> | |
| 485 | - <?php } ?> | |
| 486 | - <?php endif; ?> | |
| 487 | - </td> | |
| 488 | - <?php endif; ?> | |
| 489 | - </tr> | |
| 490 | - <?php endforeach; ?> | |
| 491 | - </tbody> | |
| 492 | - <tfoot> | |
| 493 | - <tr> | |
| 494 | - <?php $updates_table_helper->print_column_headers( false ); ?> | |
| 495 | - </tr> | |
| 496 | - </tfoot> | |
| 497 | - </table> | |
| 498 | - <?php endif; ?> | |
| 499 | - </div> | |
| 500 | - <?php | |
| 501 | - remove_filter( 'mainwp_updates_table_header_content', array( self::class, 'hook_table_update_plugins_header_content' ), 10, 4 ); | |
| 431 | + /** | |
| 432 | + * Method render_plugins_updates() | |
| 433 | + * | |
| 434 | + * Render the Plugin Updates Tab. | |
| 435 | + * | |
| 436 | + * @param mixed $website Child Site info. | |
| 437 | + * @param mixed $active_tab Current active tab. | |
| 438 | + * @param mixed $userExtension MainWP trusted plugin data. | |
| 439 | + * | |
| 440 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 441 | + * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper | |
| 442 | + */ | |
| 443 | + public static function render_plugins_updates( $website, $active_tab, $userExtension ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 502 | 444 | |
| 503 | - MainWP_Updates::render_updates_modal(); | |
| 504 | - MainWP_Updates::render_plugin_details_modal(); | |
| 505 | - } | |
| 445 | + $trustedPlugins = json_decode( $userExtension->trusted_plugins, true ); | |
| 446 | + if ( ! is_array( $trustedPlugins ) ) { | |
| 447 | + $trustedPlugins = array(); | |
| 448 | + } | |
| 506 | 449 | |
| 507 | - /** | |
| 508 | - * Method hook_table_update_plugins_header_content() | |
| 509 | - * | |
| 510 | - * Hook render the column header updates table. | |
| 511 | - * | |
| 512 | - * @param string $column_display_name column display name. | |
| 513 | - * @param mixed $column_key column key. | |
| 514 | - * @param bool $top Top or bottom header. | |
| 515 | - */ | |
| 516 | - public static function hook_table_update_plugins_header_content( $column_display_name, $column_key, $top ) { | |
| 517 | - if ( $top ) { | |
| 518 | - if ( 'action' === $column_key ) { | |
| 519 | - if ( MainWP_Demo_Handle::is_demo_mode() ) { | |
| 520 | - $demo_tip = MainWP_Demo_Handle::get_instance()->get_demo_tooltip(); | |
| 521 | - $selected_act = '<span data-tooltip="' . esc_html( $demo_tip ) . '" data-inverted="" data-position="top right"><a href="javascript:void(0)" class="ui mini green basic button disabled" >' . esc_html__( 'Update Selected' ) . '</a></span>'; | |
| 522 | - } else { | |
| 523 | - $selected_act = '<a href="javascript:void(0)" data-tooltip="' . esc_html__( 'Update Selected Plugins.', 'mainwp' ) . '" onClick="return updatesoverview_plugins_global_upgrade_all( false, true );" class="ui mini green basic button" data-inverted="" data-position="top right">' . esc_html__( 'Update Selected' ) . '</a>'; | |
| 524 | - } | |
| 525 | - $column_display_name .= $selected_act; | |
| 526 | - } elseif ( 'title' === $column_key ) { | |
| 527 | - $column_display_name = '<div class="ui master checkbox "><input type="checkbox" name=""><label>' . $column_display_name . '</label></div>'; | |
| 528 | - } | |
| 529 | - } | |
| 530 | - return $column_display_name; | |
| 531 | - } | |
| 450 | + $user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' ); | |
| 451 | + $user_can_ignore_unignore = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ); | |
| 452 | + ?> | |
| 453 | + <div id="plugins-updates-global" class="ui <?php echo 'plugins' === $active_tab ? 'active' : ''; ?> tab" data-tab="plugins"> | |
| 454 | + <?php if ( ! $website->is_ignorePluginUpdates ) : ?> | |
| 455 | + <?php | |
| 456 | + $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); | |
| 457 | + if ( ! is_array( $plugin_upgrades ) ) { | |
| 458 | + $plugin_upgrades = array(); | |
| 459 | + } | |
| 532 | 460 | |
| 533 | - /** | |
| 534 | - * Method hook_table_update_themes_header_content() | |
| 535 | - * | |
| 536 | - * Hook render the column header updates table. | |
| 537 | - * | |
| 538 | - * @param string $column_display_name column display name. | |
| 539 | - * @param mixed $column_key column key. | |
| 540 | - * @param bool $top Top or bottom header. | |
| 541 | - */ | |
| 542 | - public static function hook_table_update_themes_header_content( $column_display_name, $column_key, $top ) { | |
| 543 | - if ( $top ) { | |
| 544 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 545 | - if ( 'action' === $column_key ) { | |
| 546 | - if ( $is_demo ) { | |
| 547 | - $selected_act = MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui mini green basic button disabled" disabled="disabled">' . esc_html__( 'Update Selected', 'mainwp' ) . '</a>', false ); | |
| 548 | - } else { | |
| 549 | - $selected_act = '<a href="javascript:void(0)" onClick="return updatesoverview_themes_global_upgrade_all( false, true );" class="ui mini green basic button" data-tooltip="' . esc_html__( 'Update Selected Themes.', 'mainwp' ) . '" data-inverted="" data-position="top right">' . esc_html__( 'Update Selected' ) . '</a>'; | |
| 550 | - } | |
| 551 | - $column_display_name .= $selected_act; | |
| 552 | - } elseif ( 'title' === $column_key ) { | |
| 553 | - $column_display_name = '<div class="ui master checkbox "><input type="checkbox" name=""><label>' . $column_display_name . '</label></div>'; | |
| 554 | - } | |
| 555 | - } | |
| 556 | - return $column_display_name; | |
| 557 | - } | |
| 461 | + $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data', 'site_info' ) ); | |
| 462 | + if ( ! is_array( $site_opts ) ) { | |
| 463 | + $site_opts = array(); | |
| 464 | + } | |
| 465 | + $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array(); | |
| 558 | 466 | |
| 559 | - /** | |
| 560 | - * Method render_themes_updates() | |
| 561 | - * | |
| 562 | - * Render the Themes Updates Tab. | |
| 563 | - * | |
| 564 | - * @param mixed $website Child Site info. | |
| 565 | - * @param mixed $active_tab Current active tab. | |
| 566 | - * @param mixed $userExtension MainWP trusted themes data. | |
| 567 | - * | |
| 568 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 569 | - * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper | |
| 570 | - */ | |
| 571 | - public static function render_themes_updates( $website, $active_tab, $userExtension ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 467 | + $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array(); | |
| 572 | 468 | |
| 573 | - $trustedThemes = json_decode( $userExtension->trusted_themes, true ); | |
| 574 | - if ( ! is_array( $trustedThemes ) ) { | |
| 575 | - $trustedThemes = array(); | |
| 576 | - } | |
| 469 | + $rollPlugins = array(); | |
| 470 | + if ( is_array( $rollItems ) && ! empty( $rollItems['plugin'] ) && is_array( $rollItems['plugin'] ) ) { | |
| 471 | + $rollPlugins = $rollItems['plugin']; | |
| 472 | + } | |
| 577 | 473 | |
| 578 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 474 | + if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 475 | + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 476 | + $premiumUpgrade['premium'] = true; | |
| 477 | + if ( 'plugin' === $premiumUpgrade['type'] ) { | |
| 478 | + $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 479 | + if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { | |
| 480 | + continue; | |
| 481 | + } | |
| 482 | + $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 483 | + } | |
| 484 | + } | |
| 485 | + } | |
| 486 | + $ignored_plugins = json_decode( $website->ignored_plugins, true ); | |
| 487 | + if ( is_array( $ignored_plugins ) ) { | |
| 488 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 489 | + } | |
| 579 | 490 | |
| 580 | - $user_can_update_themes = mainwp_current_user_have_right( 'dashboard', 'update_themes' ); | |
| 581 | - $user_can_ignore_unignore = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ); | |
| 491 | + $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); | |
| 492 | + if ( is_array( $ignored_plugins ) ) { | |
| 493 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 494 | + } | |
| 582 | 495 | |
| 583 | - ?> | |
| 584 | - <div id="themes-updates-global" class="ui <?php echo 'themes' === $active_tab ? 'active' : ''; ?> tab" data-tab="themes"> | |
| 585 | - <?php if ( ! $website->is_ignoreThemeUpdates ) : ?> | |
| 586 | - <?php | |
| 587 | - $theme_upgrades = json_decode( $website->theme_upgrades, true ); | |
| 588 | - if ( ! is_array( $theme_upgrades ) ) { | |
| 589 | - $theme_upgrades = array(); | |
| 590 | - } | |
| 496 | + $updates_table_helper = new MainWP_Updates_Table_Helper( MAINWP_VIEW_PER_SITE, 'plugin', array( 'show_select' => true ) ); | |
| 591 | 497 | |
| 592 | - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); | |
| 593 | - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); | |
| 498 | + add_filter( 'mainwp_updates_table_header_content', array( static::class, 'hook_table_update_plugins_header_content' ), 10, 3 ); | |
| 594 | 499 | |
| 595 | - if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 596 | - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 597 | - $premiumUpgrade['premium'] = true; | |
| 598 | - if ( 'theme' === $premiumUpgrade['type'] ) { | |
| 599 | - $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 600 | - if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { | |
| 601 | - $theme_upgrades[ $crrSlug ] = array(); | |
| 602 | - } | |
| 603 | - $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 604 | - } | |
| 605 | - } | |
| 606 | - } | |
| 607 | - $ignored_themes = json_decode( $website->ignored_themes, true ); | |
| 608 | - if ( is_array( $ignored_themes ) ) { | |
| 609 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 610 | - } | |
| 500 | + $wp_info = ! empty( $site_opts['site_info'] ) ? json_decode( $site_opts['site_info'], true ) : array(); | |
| 501 | + if ( ! is_array( $wp_info ) ) { | |
| 502 | + $wp_info = array(); | |
| 503 | + } | |
| 504 | + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array(); | |
| 505 | + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0; | |
| 506 | + $offs_info = esc_html__( '- Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs ); | |
| 611 | 507 | |
| 612 | - $ignored_themes = json_decode( $userExtension->ignored_themes, true ); | |
| 613 | - if ( is_array( $ignored_themes ) ) { | |
| 614 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 615 | - } | |
| 508 | + ?> | |
| 509 | + <?php if ( ! empty( $plugin_upgrades ) ) : ?> | |
| 510 | + <table id="mainwp-updates-plugins-table" style="width:100% !important;" class="ui tablet stackable table mainwp-updates-list mainwp-manage-updates-table"> | |
| 511 | + <thead class="master-checkbox"> | |
| 512 | + <tr> | |
| 513 | + <?php $updates_table_helper->print_column_headers(); ?> | |
| 514 | + </tr> | |
| 515 | + </thead> | |
| 516 | + <tbody class="plugins-bulk-updates child-checkbox" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" tz-info="<?php echo esc_attr( $offs_info ); ?>"> | |
| 517 | + <?php foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) : ?> | |
| 518 | + <?php $plugin_name = rawurlencode( $slug ); ?> | |
| 519 | + <?php | |
| 520 | + $item_slug = MainWP_Utility::get_dir_slug( rawurldecode( $slug ) ); | |
| 521 | + $indent_hidden = '<input type="hidden" id="wp_upgraded_plugin_' . intval( $website->id ) . '_' . esc_html( $plugin_name ) . '" value="0" />'; | |
| 522 | + $last_version = $plugin_upgrade['update']['new_version']; | |
| 523 | + $row_columns = array( | |
| 524 | + 'title' => MainWP_System_Utility::get_plugin_icon( $item_slug ) . ' <a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '" target="_blank" class="open-plugin-details-modal">' . esc_html( $plugin_upgrade['Name'] ) . '</a>' . $indent_hidden, | |
| 525 | + 'version' => esc_html( $plugin_upgrade['Version'] ), | |
| 526 | + 'latest' => '<a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '§ion=changelog" target="_blank" class="open-plugin-details-modal">' . esc_html( $last_version ) . '</a>', | |
| 527 | + 'trusted' => ( in_array( $slug, $trustedPlugins ) ? true : false ), | |
| 528 | + 'status' => ( isset( $plugin_upgrade['active'] ) && $plugin_upgrade['active'] ) ? true : false, | |
| 529 | + ); | |
| 616 | 530 | |
| 617 | - $updates_table_helper = new MainWP_Updates_Table_Helper( MAINWP_VIEW_PER_SITE, 'theme', array( 'show_select' => true ) ); | |
| 531 | + $others = array(); | |
| 532 | + if ( ! empty( $rollPlugins[ $slug ][ $last_version ] ) ) { | |
| 533 | + $msg = MainWP_Updates_Helper::get_roll_msg( $rollPlugins[ $slug ][ $last_version ], true, 'notice' ); | |
| 534 | + $others['roll_info'] = $msg; | |
| 535 | + } | |
| 618 | 536 | |
| 619 | - add_filter( 'mainwp_updates_table_header_content', array( self::class, 'hook_table_update_themes_header_content' ), 10, 4 ); | |
| 537 | + $compatible_php = isset( $plugin_upgrade['wp_compatible'] ) ? $plugin_upgrade['wp_compatible'] : true; | |
| 538 | + $compatible_wp = isset( $plugin_upgrade['php_compatible'] ) ? $plugin_upgrade['php_compatible'] : true; | |
| 620 | 539 | |
| 621 | - ?> | |
| 622 | - <table id="mainwp-updates-themes-table" class="ui tablet stackable table mainwp-updates-list mainwp-manage-updates-table"> | |
| 623 | - <thead class="master-checkbox" > | |
| 624 | - <tr> | |
| 625 | - <?php $updates_table_helper->print_column_headers(); ?> | |
| 626 | - </tr> | |
| 627 | - </thead> | |
| 628 | - <tbody class="themes-bulk-updates child-checkbox" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 629 | - <?php foreach ( $theme_upgrades as $slug => $theme_upgrade ) : ?> | |
| 630 | - <?php $theme_name = rawurlencode( $slug ); ?> | |
| 631 | - <?php $indent_hidden = '<input type="hidden" id="wp_upgraded_theme_' . intval( $website->id ) . '_' . esc_attr( $theme_name ) . '" value="0" />'; ?> | |
| 632 | - <?php | |
| 633 | - $row_columns = array( | |
| 634 | - 'title' => MainWP_System_Utility::get_theme_icon( $slug ) . ' ' . esc_html( $theme_upgrade['Name'] ) . $indent_hidden, | |
| 635 | - 'version' => esc_html( $theme_upgrade['Version'] ), | |
| 636 | - 'latest' => esc_html( $theme_upgrade['update']['new_version'] ), | |
| 637 | - 'trusted' => ( in_array( $slug, $trustedThemes, true ) ? true : false ), | |
| 638 | - 'status' => ( isset( $theme_upgrade['active'] ) && $theme_upgrade['active'] ) ? true : false, | |
| 639 | - ); | |
| 640 | - ?> | |
| 641 | - <tr theme_slug="<?php echo esc_attr( $theme_name ); ?>" premium="<?php echo ( isset( $theme_upgrade['premium'] ) && ! empty( $theme_upgrade['premium'] ) ? 1 : 0 ); ?>" updated="0"> | |
| 642 | - <?php | |
| 643 | - $row_columns = $updates_table_helper->render_columns( $row_columns, $website ); | |
| 644 | - $action_rendered = isset( $row_columns['action'] ) ? true : false; | |
| 645 | - if ( ! $action_rendered ) : | |
| 646 | - ?> | |
| 647 | - <td> | |
| 648 | - <?php if ( $user_can_ignore_unignore ) : ?> | |
| 649 | - <a href="javascript:void(0)" onClick="return updatesoverview_themes_ignore_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )" class="ui mini button"><?php esc_html_e( 'Ignore Update', 'mainwp' ); ?></a> | |
| 650 | - <?php endif; ?> | |
| 651 | - <?php | |
| 652 | - if ( $user_can_update_themes ) : | |
| 653 | - if ( $is_demo ) { | |
| 654 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini button disabled" disabled="disabled">' . esc_html__( 'Update Now', 'mainwp' ) . '</a>' ); | |
| 655 | - } else { | |
| 656 | - ?> | |
| 657 | - <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_theme( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $theme_name ); ?>' )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a> | |
| 658 | - <?php } ?> | |
| 659 | - <?php endif; ?> | |
| 660 | - </td> | |
| 661 | - <?php endif; ?> | |
| 662 | - </tr> | |
| 663 | - <?php endforeach; ?> | |
| 664 | - </tbody> | |
| 665 | - <tfoot> | |
| 666 | - <tr> | |
| 667 | - <?php $updates_table_helper->print_column_headers( false ); ?> | |
| 668 | - </tr> | |
| 669 | - </tfoot> | |
| 670 | - </table> | |
| 671 | - <?php endif; ?> | |
| 672 | - </div> | |
| 673 | - <?php | |
| 674 | - remove_filter( 'mainwp_updates_table_header_content', array( self::class, 'hook_table_update_themes_header_content' ), 10, 4 ); | |
| 675 | - } | |
| 540 | + ?> | |
| 541 | + <tr plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" plugin_name="<?php echo esc_attr( $plugin_upgrade['Name'] ); ?>" last-version="<?php echo esc_js( rawurlencode( $last_version ) ); ?>" premium="<?php echo isset( $plugin_upgrade['premium'] ) && ! empty( $plugin_upgrade['premium'] ) ? 1 : 0; ?>" updated="0"> | |
| 542 | + <?php | |
| 543 | + $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others ); | |
| 544 | + $action_rendered = isset( $row_columns['action'] ) ? true : false; | |
| 545 | + if ( ! $action_rendered ) : | |
| 546 | + ?> | |
| 547 | + <td> | |
| 548 | + <a href="#" history-view="update-plugins-individual" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a> | |
| 549 | + <?php if ( $user_can_ignore_unignore ) : ?> | |
| 550 | + <div class="ui bottom left pointing dropdown mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?> | |
| 551 | + <i class="dropdown icon"></i> | |
| 552 | + <div class="menu"> | |
| 553 | + <a href="javascript:void(0)" onClick="return updatesoverview_plugins_ignore_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )" class="item"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a> | |
| 554 | + <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_plugins_ignore_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a> | |
| 555 | + <a href="javascript:void(0)" onClick="return updatesoverview_plugins_ignore_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, 'all_versions' )" class="item"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a> | |
| 556 | + </div> | |
| 557 | + </div> | |
| 558 | + <?php endif; ?> | |
| 559 | + <?php | |
| 560 | + if ( $user_can_update_plugins ) : | |
| 561 | + if ( $compatible_php && $compatible_wp ) { | |
| 562 | + ?> | |
| 563 | + <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_plugin( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $plugin_name ); ?>' )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a> | |
| 564 | + <?php | |
| 565 | + } else { | |
| 566 | + MainWP_Updates_Per_Item::render_incompatible_message( $compatible_php, $compatible_wp ); | |
| 567 | + } | |
| 568 | + ?> | |
| 569 | + <?php endif; ?> | |
| 570 | + </td> | |
| 571 | + <?php endif; ?> | |
| 572 | + </tr> | |
| 573 | + <?php endforeach; ?> | |
| 574 | + </tbody> | |
| 575 | + <tfoot> | |
| 576 | + <tr> | |
| 577 | + <?php $updates_table_helper->print_column_headers( false ); ?> | |
| 578 | + </tr> | |
| 579 | + </tfoot> | |
| 580 | + </table> | |
| 581 | + <?php else : ?> | |
| 582 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'Plugins are up to date', 'mainwp' ), __( 'No plugin updates available right now.', 'mainwp' ) ); ?> | |
| 583 | + <?php endif; ?> | |
| 584 | + <?php endif; ?> | |
| 585 | + </div> | |
| 586 | + <?php | |
| 587 | + remove_filter( 'mainwp_updates_table_header_content', array( static::class, 'hook_table_update_plugins_header_content' ), 10, 3 ); | |
| 676 | 588 | |
| 677 | - /** | |
| 678 | - * Method render_language_updates() | |
| 679 | - * | |
| 680 | - * Render the Language Updates Tab. | |
| 681 | - * | |
| 682 | - * @param mixed $website Child Site info. | |
| 683 | - * @param mixed $active_tab Current active tab. | |
| 684 | - */ | |
| 685 | - public static function render_language_updates( $website, $active_tab ) { | |
| 686 | - $user_can_update_translation = mainwp_current_user_have_right( 'dashboard', 'update_translations' ); | |
| 687 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 688 | - ?> | |
| 689 | - <div class="ui <?php echo 'trans' === $active_tab ? 'active' : ''; ?> tab" data-tab="translations"> | |
| 690 | - <table class="ui tablet stackable table mainwp-manage-updates-table" id="mainwp-translations-table"> | |
| 691 | - <thead> | |
| 692 | - <tr> | |
| 693 | - <th><?php esc_html_e( 'Translation', 'mainwp' ); ?></th> | |
| 694 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 695 | - <th class="collapsing no-sort"></th> | |
| 696 | - </tr> | |
| 697 | - </thead> | |
| 698 | - <tbody class="translations-bulk-updates" id="wp_translation_upgrades_<?php echo intval( $website->id ); ?>" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 699 | - <?php $translation_upgrades = json_decode( $website->translation_upgrades, true ); ?> | |
| 700 | - <?php foreach ( $translation_upgrades as $translation_upgrade ) : ?> | |
| 701 | - <?php | |
| 702 | - $translation_name = isset( $translation_upgrade['name'] ) ? $translation_upgrade['name'] : $translation_upgrade['slug']; | |
| 703 | - $translation_slug = esc_attr( $translation_upgrade['slug'] ); | |
| 704 | - ?> | |
| 705 | - <tr translation_slug="<?php echo esc_attr( $translation_slug ); ?>" updated="0"> | |
| 706 | - <td> | |
| 707 | - <?php echo esc_html( $translation_name ); ?> | |
| 708 | - <input type="hidden" id="wp_upgraded_translation_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $translation_slug ); ?>" value="0"/> | |
| 709 | - </td> | |
| 710 | - <td> | |
| 711 | - <?php echo esc_html( $translation_upgrade['version'] ); ?> | |
| 712 | - </td> | |
| 713 | - <td> | |
| 714 | - <?php | |
| 715 | - if ( $user_can_update_translation ) { | |
| 716 | - if ( $is_demo ) { | |
| 717 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini button disabled" disabled="disabled">' . esc_html__( 'Update Now', 'mainwp' ) . '</a>' ); | |
| 718 | - } else { | |
| 719 | - ?> | |
| 720 | - <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_translation( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $translation_slug ); ?>' )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a> | |
| 721 | - <?php } ?> | |
| 722 | - <?php } ?> | |
| 723 | - </td> | |
| 724 | - </tr> | |
| 725 | - <?php endforeach; ?> | |
| 726 | - </tbody> | |
| 727 | - <tfoot> | |
| 728 | - <tr> | |
| 729 | - <th><?php esc_html_e( 'Translation', 'mainwp' ); ?></th> | |
| 730 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 731 | - <th class="collapsing no-sort"></th> | |
| 732 | - </tr> | |
| 733 | - </tfoot> | |
| 734 | - </table> | |
| 735 | - </div> | |
| 736 | - <?php | |
| 737 | - } | |
| 589 | + MainWP_Updates::render_updates_modal(); | |
| 590 | + MainWP_Updates::render_plugin_details_modal(); | |
| 591 | + } | |
| 738 | 592 | |
| 739 | - /** | |
| 740 | - * Method render_abandoned_plugins() | |
| 741 | - * | |
| 742 | - * Render the Abandoned Plugin Tab. | |
| 743 | - * | |
| 744 | - * @param mixed $website Child Site info. | |
| 745 | - * @param mixed $active_tab Current active tab. | |
| 746 | - * @param mixed $userExtension MainWP trusted plugin data. | |
| 747 | - * | |
| 748 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 749 | - */ | |
| 750 | - public static function render_abandoned_plugins( $website, $active_tab, $userExtension ) { | |
| 593 | + /** | |
| 594 | + * Method hook_table_update_plugins_header_content() | |
| 595 | + * | |
| 596 | + * Hook render the column header updates table. | |
| 597 | + * | |
| 598 | + * @param string $column_display_name column display name. | |
| 599 | + * @param mixed $column_key column key. | |
| 600 | + * @param bool $top Top or bottom header. | |
| 601 | + */ | |
| 602 | + public static function hook_table_update_plugins_header_content( $column_display_name, $column_key, $top ) { | |
| 603 | + if ( $top && 'title' === $column_key ) { | |
| 604 | + $column_display_name = '<div class="ui master checkbox plugins-checkbox"><input type="checkbox" name=""><label>' . $column_display_name . '</label></div>'; | |
| 605 | + } | |
| 606 | + return $column_display_name; | |
| 607 | + } | |
| 751 | 608 | |
| 752 | - $user_can_ignore_unignore = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ); | |
| 609 | + /** | |
| 610 | + * Method hook_table_update_themes_header_content() | |
| 611 | + * | |
| 612 | + * Hook render the column header updates table. | |
| 613 | + * | |
| 614 | + * @param string $column_display_name column display name. | |
| 615 | + * @param mixed $column_key column key. | |
| 616 | + * @param bool $top Top or bottom header. | |
| 617 | + */ | |
| 618 | + public static function hook_table_update_themes_header_content( $column_display_name, $column_key, $top ) { | |
| 619 | + if ( $top && 'title' === $column_key ) { | |
| 620 | + $column_display_name = '<div class="ui master checkbox themes-checkbox"><input type="checkbox" name=""><label>' . $column_display_name . '</label></div>'; | |
| 621 | + } | |
| 622 | + return $column_display_name; | |
| 623 | + } | |
| 753 | 624 | |
| 754 | - $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ); | |
| 755 | - $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array(); | |
| 625 | + /** | |
| 626 | + * Method render_themes_updates() | |
| 627 | + * | |
| 628 | + * Render the Themes Update Tab. | |
| 629 | + * | |
| 630 | + * @param mixed $website Child Site info. | |
| 631 | + * @param mixed $active_tab Current active tab. | |
| 632 | + * @param mixed $userExtension MainWP trusted themes data. | |
| 633 | + * | |
| 634 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 635 | + * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper | |
| 636 | + */ | |
| 637 | + public static function render_themes_updates( $website, $active_tab, $userExtension ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 756 | 638 | |
| 757 | - if ( ! is_array( $plugins_outdate ) ) { | |
| 758 | - $plugins_outdate = array(); | |
| 759 | - } | |
| 760 | - $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); | |
| 761 | - $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array(); | |
| 639 | + $trustedThemes = json_decode( $userExtension->trusted_themes, true ); | |
| 640 | + if ( ! is_array( $trustedThemes ) ) { | |
| 641 | + $trustedThemes = array(); | |
| 642 | + } | |
| 762 | 643 | |
| 763 | - if ( is_array( $pluginsOutdateDismissed ) ) { | |
| 764 | - $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed ); | |
| 765 | - } | |
| 644 | + $user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' ); | |
| 645 | + $user_can_ignore_unignore = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ); | |
| 766 | 646 | |
| 767 | - $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); | |
| 768 | - if ( is_array( $decodedDismissedPlugins ) ) { | |
| 769 | - $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); | |
| 770 | - } | |
| 771 | - $str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); | |
| 772 | - ?> | |
| 647 | + ?> | |
| 648 | + <div id="themes-updates-global" class="ui <?php echo 'themes' === $active_tab ? 'active' : ''; ?> tab" data-tab="themes"> | |
| 649 | + <?php if ( ! $website->is_ignoreThemeUpdates ) : ?> | |
| 650 | + <?php | |
| 651 | + $theme_upgrades = json_decode( $website->theme_upgrades, true ); | |
| 652 | + if ( ! is_array( $theme_upgrades ) ) { | |
| 653 | + $theme_upgrades = array(); | |
| 654 | + } | |
| 773 | 655 | |
| 774 | - <div class="ui <?php echo 'abandoned-plugins' === $active_tab ? 'active' : ''; ?> tab" data-tab="abandoned-plugins"> | |
| 775 | - <table class="ui tablet stackable table mainwp-manage-updates-table" id="mainwp-abandoned-plugins-table"> | |
| 776 | - <thead> | |
| 777 | - <tr> | |
| 778 | - <tr> | |
| 779 | - <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th> | |
| 780 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 781 | - <th><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 782 | - <th class="no-sort"></th> | |
| 783 | - </tr> | |
| 784 | - </tr> | |
| 785 | - </thead> | |
| 786 | - <tbody id="wp_plugins_outdate_<?php echo intval( $website->id ); ?>" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 787 | - <?php foreach ( $plugins_outdate as $slug => $plugin_outdate ) : ?> | |
| 788 | - <?php | |
| 789 | - $plugin_name = rawurlencode( $slug ); | |
| 790 | - $item_slug = MainWP_Utility::get_dir_slug( rawurldecode( $slug ) ); | |
| 791 | - $now = new \DateTime(); | |
| 792 | - $last_updated = $plugin_outdate['last_updated']; | |
| 793 | - $plugin_last_updated_date = new \DateTime( '@' . $last_updated ); | |
| 794 | - $diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' ); | |
| 795 | - $outdate_notice = sprintf( $str_format, $diff_in_days ); | |
| 656 | + $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data', 'site_info' ) ); | |
| 657 | + if ( ! is_array( $site_opts ) ) { | |
| 658 | + $site_opts = array(); | |
| 659 | + } | |
| 660 | + $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array(); | |
| 796 | 661 | |
| 797 | - ?> | |
| 798 | - <tr dismissed="0"> | |
| 799 | - <td> <?php echo MainWP_System_Utility::get_plugin_icon( $item_slug ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 800 | - <a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $slug ) ) . '&url=' . ( isset( $plugin_outdate['PluginURI'] ) ? esc_url( rawurlencode( $plugin_outdate['PluginURI'] ) ) : '' ) . '&name=' . esc_url( rawurlencode( $plugin_outdate['Name'] ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $plugin_outdate['Name'] ); ?></a> | |
| 801 | - <input type="hidden" id="wp_dismissed_plugin_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>" value="0"/> | |
| 802 | - </td> | |
| 803 | - <td><?php echo esc_html( $plugin_outdate['Version'] ); ?></td> | |
| 804 | - <td><?php echo esc_html( $outdate_notice ); ?></td> | |
| 805 | - <td id="wp_dismissbuttons_plugin_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>"> | |
| 806 | - <?php if ( $user_can_ignore_unignore ) { ?> | |
| 807 | - <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_plugins_dismiss_outdate_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_outdate['Name'] ) ); ?>', <?php echo esc_js( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a> | |
| 808 | - <?php } ?> | |
| 809 | - </td> | |
| 810 | - </tr> | |
| 811 | - <?php endforeach; ?> | |
| 812 | - </tbody> | |
| 813 | - <tfoot> | |
| 814 | - <tr> | |
| 815 | - <tr> | |
| 816 | - <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th> | |
| 817 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 818 | - <th><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 819 | - <th class="no-sort"></th> | |
| 820 | - </tr> | |
| 821 | - </tr> | |
| 822 | - </tfoot> | |
| 823 | - </table> | |
| 824 | - </div> | |
| 825 | - <?php | |
| 826 | - } | |
| 662 | + $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array(); | |
| 827 | 663 | |
| 828 | - /** | |
| 829 | - * Method render_abandoned_themes() | |
| 830 | - * | |
| 831 | - * Render the Abandoned Themes tab. | |
| 832 | - * | |
| 833 | - * @param mixed $website Child Site info. | |
| 834 | - * @param mixed $active_tab Current active tab. | |
| 835 | - * @param mixed $userExtension MainWP trusted themes data. | |
| 836 | - * | |
| 837 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 838 | - */ | |
| 839 | - public static function render_abandoned_themes( $website, $active_tab, $userExtension ) { | |
| 664 | + $rollThemes = array(); | |
| 665 | + if ( is_array( $rollItems ) && ! empty( $rollItems['theme'] ) && is_array( $rollItems['theme'] ) ) { | |
| 666 | + $rollThemes = $rollItems['theme']; | |
| 667 | + } | |
| 840 | 668 | |
| 841 | - $user_can_ignore_unignore = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ); | |
| 669 | + if ( is_array( $decodedPremiumUpgrades ) ) { | |
| 670 | + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { | |
| 671 | + $premiumUpgrade['premium'] = true; | |
| 672 | + if ( 'theme' === $premiumUpgrade['type'] ) { | |
| 673 | + $premiumUpgrade = array_filter( $premiumUpgrade ); | |
| 674 | + if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { | |
| 675 | + $theme_upgrades[ $crrSlug ] = array(); | |
| 676 | + } | |
| 677 | + $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); | |
| 678 | + } | |
| 679 | + } | |
| 680 | + } | |
| 681 | + $ignored_themes = json_decode( $website->ignored_themes, true ); | |
| 682 | + if ( is_array( $ignored_themes ) ) { | |
| 683 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 684 | + } | |
| 842 | 685 | |
| 843 | - $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ); | |
| 844 | - $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array(); | |
| 686 | + $ignored_themes = json_decode( $userExtension->ignored_themes, true ); | |
| 687 | + if ( is_array( $ignored_themes ) ) { | |
| 688 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 689 | + } | |
| 845 | 690 | |
| 846 | - if ( ! is_array( $themes_outdate ) ) { | |
| 847 | - $themes_outdate = array(); | |
| 848 | - } | |
| 691 | + $updates_table_helper = new MainWP_Updates_Table_Helper( MAINWP_VIEW_PER_SITE, 'theme', array( 'show_select' => true ) ); | |
| 849 | 692 | |
| 850 | - if ( 0 < count( $themes_outdate ) ) { | |
| 851 | - $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); | |
| 852 | - $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array(); | |
| 693 | + add_filter( 'mainwp_updates_table_header_content', array( static::class, 'hook_table_update_themes_header_content' ), 10, 3 ); | |
| 853 | 694 | |
| 854 | - if ( is_array( $themesOutdateDismissed ) ) { | |
| 855 | - $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed ); | |
| 856 | - } | |
| 695 | + $wp_info = ! empty( $site_opts['site_info'] ) ? json_decode( $site_opts['site_info'], true ) : array(); | |
| 696 | + if ( ! is_array( $wp_info ) ) { | |
| 697 | + $wp_info = array(); | |
| 698 | + } | |
| 699 | + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array(); | |
| 700 | + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0; | |
| 701 | + $offs_info = esc_html__( '- Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs ); | |
| 857 | 702 | |
| 858 | - $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); | |
| 859 | - if ( is_array( $decodedDismissedThemes ) ) { | |
| 860 | - $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); | |
| 861 | - } | |
| 862 | - } | |
| 703 | + ?> | |
| 704 | + <?php if ( ! empty( $theme_upgrades ) ) : ?> | |
| 705 | + <table id="mainwp-updates-themes-table" style="width:100% !important;" class="ui tablet stackable table mainwp-updates-list mainwp-manage-updates-table"> | |
| 706 | + <thead class="master-checkbox full-width" > | |
| 707 | + <tr> | |
| 708 | + <?php $updates_table_helper->print_column_headers(); ?> | |
| 709 | + </tr> | |
| 710 | + </thead> | |
| 711 | + <tbody class="themes-bulk-updates child-checkbox" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" tz-info="<?php echo esc_attr( $offs_info ); ?>"> | |
| 712 | + <?php foreach ( $theme_upgrades as $slug => $theme_upgrade ) : ?> | |
| 713 | + <?php $theme_name = rawurlencode( $slug ); ?> | |
| 714 | + <?php $indent_hidden = '<input type="hidden" id="wp_upgraded_theme_' . intval( $website->id ) . '_' . esc_attr( $theme_name ) . '" value="0" />'; ?> | |
| 715 | + <?php | |
| 716 | + $last_version = $theme_upgrade['update']['new_version']; | |
| 717 | + $row_columns = array( | |
| 718 | + 'title' => MainWP_System_Utility::get_theme_icon( $slug ) . ' ' . esc_html( $theme_upgrade['Name'] ) . $indent_hidden, | |
| 719 | + 'version' => esc_html( $theme_upgrade['Version'] ), | |
| 720 | + 'latest' => esc_html( $last_version ), | |
| 721 | + 'trusted' => ( in_array( $slug, $trustedThemes, true ) ? true : false ), | |
| 722 | + 'status' => ( isset( $theme_upgrade['active'] ) && $theme_upgrade['active'] ) ? true : false, | |
| 723 | + ); | |
| 724 | + $others = array(); | |
| 725 | + if ( ! empty( $rollThemes[ $slug ][ $last_version ] ) ) { | |
| 726 | + $msg = MainWP_Updates_Helper::get_roll_msg( $rollThemes[ $slug ][ $last_version ], true, 'notice' ); | |
| 727 | + $others['roll_info'] = $msg; | |
| 728 | + } | |
| 729 | + ?> | |
| 730 | + <tr theme_slug="<?php echo esc_attr( $theme_name ); ?>" theme_name="<?php echo esc_attr( $theme_upgrade['Name'] ); ?>" last-version="<?php echo esc_js( rawurlencode( $last_version ) ); ?>" premium="<?php echo isset( $theme_upgrade['premium'] ) && ! empty( $theme_upgrade['premium'] ) ? 1 : 0; ?>" updated="0"> | |
| 731 | + <?php | |
| 732 | + $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others ); | |
| 733 | + $action_rendered = isset( $row_columns['action'] ) ? true : false; | |
| 734 | + if ( ! $action_rendered ) : | |
| 735 | + ?> | |
| 736 | + <td> | |
| 737 | + <a href="#" history-view="update-themes-individual" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a> | |
| 738 | + <?php if ( $user_can_ignore_unignore ) : ?> | |
| 739 | + <div class="ui bottom left pointing dropdown mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?> | |
| 740 | + <i class="dropdown icon"></i> | |
| 741 | + <div class="menu"> | |
| 742 | + <a href="javascript:void(0)" onClick="return updatesoverview_themes_ignore_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )" class="item"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a> | |
| 743 | + <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_themes_ignore_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a> | |
| 744 | + <a href="javascript:void(0)" onClick="return updatesoverview_themes_ignore_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, 'all_versions' )" class="item"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a> | |
| 745 | + </div> | |
| 746 | + </div> | |
| 747 | + <?php endif; ?> | |
| 748 | + <?php if ( $user_can_update_themes ) : ?> | |
| 749 | + <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_theme( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $theme_name ); ?>' )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a> | |
| 750 | + <?php endif; ?> | |
| 751 | + </td> | |
| 752 | + <?php endif; ?> | |
| 753 | + </tr> | |
| 754 | + <?php endforeach; ?> | |
| 755 | + </tbody> | |
| 756 | + <tfoot class="full-width"> | |
| 757 | + <tr> | |
| 758 | + <?php $updates_table_helper->print_column_headers( false ); ?> | |
| 759 | + </tr> | |
| 760 | + </tfoot> | |
| 761 | + </table> | |
| 762 | + <?php else : ?> | |
| 763 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'Themes are up to date', 'mainwp' ), __( 'No theme updates available right now.', 'mainwp' ) ); ?> | |
| 764 | + <?php endif; ?> | |
| 765 | + <?php endif; ?> | |
| 766 | + </div> | |
| 767 | + <?php | |
| 768 | + remove_filter( 'mainwp_updates_table_header_content', array( static::class, 'hook_table_update_themes_header_content' ), 10, 3 ); | |
| 769 | + } | |
| 863 | 770 | |
| 864 | - $str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); | |
| 771 | + /** | |
| 772 | + * Method render_language_updates() | |
| 773 | + * | |
| 774 | + * Render the Language Updates Tab. | |
| 775 | + * | |
| 776 | + * @param mixed $website Child Site info. | |
| 777 | + * @param mixed $active_tab Current active tab. | |
| 778 | + * @param object $userExtension User extension data. | |
| 779 | + */ | |
| 780 | + public static function render_language_updates( $website, $active_tab, $userExtension ) { | |
| 781 | + $trustedPlugins = MainWP_Utility::get_decoded_array( $userExtension->trusted_plugins ); | |
| 782 | + $trustedThemes = MainWP_Utility::get_decoded_array( $userExtension->trusted_themes ); | |
| 783 | + $user_can_update_translation = \mainwp_current_user_can( 'dashboard', 'update_translations' ); | |
| 784 | + if ( empty( $website->ignored_trans_updates ) ) { | |
| 785 | + $translation_upgrades = json_decode( $website->translation_upgrades, true ); | |
| 786 | + if ( ! is_array( $translation_upgrades ) ) { | |
| 787 | + $translation_upgrades = array(); | |
| 788 | + } | |
| 789 | + } else { | |
| 790 | + $translation_upgrades = array(); | |
| 791 | + } | |
| 792 | + ?> | |
| 793 | + <div class="ui <?php echo 'trans' === $active_tab ? 'active' : ''; ?> tab" data-tab="translations"> | |
| 794 | + <?php if ( ! empty( $translation_upgrades ) ) : ?> | |
| 795 | + <table style="width:100% !important;" class="ui tablet stackable table mainwp-manage-updates-table" id="mainwp-translations-table"> | |
| 796 | + <thead> | |
| 797 | + <tr> | |
| 798 | + <th scope="col" ><?php esc_html_e( 'Translation', 'mainwp' ); ?></th> | |
| 799 | + <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 800 | + <th scope="col" ><?php esc_html_e( 'Trusted', 'mainwp' ); ?></th> | |
| 801 | + <th scope="col" class="collapsing no-sort"></th> | |
| 802 | + </tr> | |
| 803 | + </thead> | |
| 804 | + <tbody class="translations-bulk-updates" id="wp_translation_upgrades_<?php echo intval( $website->id ); ?>" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 805 | + <?php foreach ( $translation_upgrades as $translation_upgrade ) : ?> | |
| 806 | + <?php | |
| 807 | + $translation_name = isset( $translation_upgrade['name'] ) ? $translation_upgrade['name'] : $translation_upgrade['slug']; | |
| 808 | + $translation_slug = esc_attr( $translation_upgrade['slug'] ); | |
| 809 | + ?> | |
| 810 | + <tr translation_slug="<?php echo esc_attr( $translation_slug ); ?>" updated="0"> | |
| 811 | + <td> | |
| 812 | + <?php echo esc_html( $translation_name ); ?> | |
| 813 | + <input type="hidden" id="wp_upgraded_translation_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $translation_slug ); ?>" value="0"/> | |
| 814 | + </td> | |
| 815 | + <td> | |
| 816 | + <?php echo esc_html( $translation_upgrade['version'] ); ?> | |
| 817 | + </td> | |
| 818 | + <?php | |
| 819 | + $is_trust = static::is_trans_trusted_update( $translation_upgrade, $trustedPlugins, $trustedThemes ); | |
| 820 | + echo static::get_column_trusted($is_trust ); //phpcs:ignore -- NOSONAR - escaped. | |
| 821 | + ?> | |
| 822 | + <td> | |
| 823 | + <?php if ( $user_can_update_translation ) : ?> | |
| 824 | + <a href="javascript:void(0)" class="ui green mini button" onClick="return updatesoverview_upgrade_translation( <?php echo intval( $website->id ); ?>, '<?php echo esc_js( $translation_slug ); ?>' )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a> | |
| 825 | + | |
| 826 | + <?php endif; ?> | |
| 827 | + </td> | |
| 828 | + </tr> | |
| 829 | + <?php endforeach; ?> | |
| 830 | + </tbody> | |
| 831 | + <tfoot> | |
| 832 | + <tr> | |
| 833 | + <th scope="col" ><?php esc_html_e( 'Translation', 'mainwp' ); ?></th> | |
| 834 | + <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 835 | + <th scope="col" ><?php esc_html_e( 'Trusted', 'mainwp' ); ?></th> | |
| 836 | + <th scope="col" class="collapsing no-sort"></th> | |
| 837 | + </tr> | |
| 838 | + </tfoot> | |
| 839 | + </table> | |
| 840 | + <?php else : ?> | |
| 841 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'Translations are up to date', 'mainwp' ), __( 'No translation updates available right now.', 'mainwp' ) ); ?> | |
| 842 | + <?php endif; ?> | |
| 843 | + </div> | |
| 844 | + <?php | |
| 845 | + } | |
| 865 | 846 | |
| 866 | - ?> | |
| 867 | - <div class="ui <?php echo 'abandoned-themes' === $active_tab ? 'active' : ''; ?> tab" data-tab="abandoned-themes"> | |
| 868 | - <table class="ui tablet stackable table mainwp-manage-updates-table" id="mainwp-abandoned-themes-table"> | |
| 869 | - <thead> | |
| 870 | - <tr> | |
| 871 | - <tr> | |
| 872 | - <th><?php esc_html_e( 'Theme', 'mainwp' ); ?></th> | |
| 873 | - <th><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 874 | - <th><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 875 | - <th class="no-sort"></th> | |
| 876 | - </tr> | |
| 877 | - </tr> | |
| 878 | - </thead> | |
| 879 | - <tbody site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 880 | - <?php foreach ( $themes_outdate as $slug => $theme_outdate ) : ?> | |
| 881 | - <?php | |
| 882 | - $theme_name = rawurlencode( $slug ); | |
| 883 | - $now = new \DateTime(); | |
| 884 | - $last_updated = $theme_outdate['last_updated']; | |
| 885 | - $theme_last_updated_date = new \DateTime( '@' . $last_updated ); | |
| 886 | - $diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' ); | |
| 887 | - $outdate_notice = sprintf( $str_format, $diff_in_days ); | |
| 888 | - ?> | |
| 889 | - <tr dismissed="0"> | |
| 890 | - <td> | |
| 891 | - <?php echo MainWP_System_Utility::get_theme_icon( $slug ) . ' ' . esc_html( $theme_outdate['Name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 892 | - <input type="hidden" id="wp_dismissed_theme_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>" value="0"/> | |
| 893 | - </td> | |
| 894 | - <td><?php echo esc_html( $theme_outdate['Version'] ); ?></td> | |
| 895 | - <td><?php echo esc_html( $outdate_notice ); ?></td> | |
| 896 | - <td id="wp_dismissbuttons_theme_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>"> | |
| 897 | - <?php if ( $user_can_ignore_unignore ) { ?> | |
| 898 | - <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_themes_dismiss_outdate_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_outdate['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a> | |
| 899 | - <?php } ?> | |
| 900 | - </td> | |
| 901 | - </tr> | |
| 902 | - <?php endforeach; ?> | |
| 903 | - </tbody> | |
| 904 | - </table> | |
| 905 | - </div> | |
| 906 | - <?php | |
| 907 | - } | |
| 847 | + | |
| 848 | + /** | |
| 849 | + * Get trusted column. | |
| 850 | + * | |
| 851 | + * @param mixed $value Value of column. | |
| 852 | + */ | |
| 853 | + public static function get_column_trusted( $value ) { | |
| 854 | + if ( $value ) { | |
| 855 | + $label = '<span class="ui tiny basic green label mainwp-768-fluid">Trusted</span>'; | |
| 856 | + } else { | |
| 857 | + $label = '<span class="ui tiny basic grey label mainwp-768-fluid">Not Trusted</span>'; | |
| 858 | + } | |
| 859 | + return '<td class="mainwp-768-half-width-cell">' . $label . '</td>'; | |
| 860 | + } | |
| 861 | + | |
| 862 | + /** | |
| 863 | + * Check if trans is trusted update. | |
| 864 | + * | |
| 865 | + * @param string $tran_info Translation slug. | |
| 866 | + * @param array $trusted_plugins Trusted update plugins. | |
| 867 | + * @param array $trusted_themes Trusted update themes. | |
| 868 | + */ | |
| 869 | + public static function is_trans_trusted_update( $tran_info, $trusted_plugins, $trusted_themes ) { | |
| 870 | + if ( is_array( $tran_info ) && isset( $tran_info['type'] ) && isset( $tran_info['slug'] ) ) { | |
| 871 | + $tran_slug = $tran_info['slug']; | |
| 872 | + if ( 'plugin' === $tran_info['type'] && is_array( $trusted_plugins ) ) { | |
| 873 | + foreach ( $trusted_plugins as $slug ) { | |
| 874 | + $_slug = explode( '/', $slug )[0]; | |
| 875 | + if ( $tran_slug === $_slug ) { | |
| 876 | + return true; | |
| 877 | + } | |
| 878 | + } | |
| 879 | + } elseif ( 'theme' === $tran_info['type'] && is_array( $trusted_themes ) && in_array( $tran_slug, $trusted_themes ) ) { | |
| 880 | + return true; | |
| 881 | + } | |
| 882 | + } | |
| 883 | + return false; | |
| 884 | + } | |
| 885 | + | |
| 886 | + | |
| 887 | + /** | |
| 888 | + * Method render_abandoned_plugins() | |
| 889 | + * | |
| 890 | + * Render the Abandoned Plugin Tab. | |
| 891 | + * | |
| 892 | + * @param mixed $website Child Site info. | |
| 893 | + * @param mixed $active_tab Current active tab. | |
| 894 | + * @param mixed $userExtension MainWP trusted plugin data. | |
| 895 | + * | |
| 896 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 897 | + */ | |
| 898 | + public static function render_abandoned_plugins( $website, $active_tab, $userExtension ) { | |
| 899 | + | |
| 900 | + $user_can_ignore_unignore = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ); | |
| 901 | + | |
| 902 | + $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ); | |
| 903 | + $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array(); | |
| 904 | + | |
| 905 | + if ( ! is_array( $plugins_outdate ) ) { | |
| 906 | + $plugins_outdate = array(); | |
| 907 | + } | |
| 908 | + $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); | |
| 909 | + $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array(); | |
| 910 | + | |
| 911 | + if ( is_array( $pluginsOutdateDismissed ) ) { | |
| 912 | + $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed ); | |
| 913 | + } | |
| 914 | + | |
| 915 | + $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); | |
| 916 | + if ( is_array( $decodedDismissedPlugins ) ) { | |
| 917 | + $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); | |
| 918 | + } | |
| 919 | + /* translators: %s: Number of days since last update */ | |
| 920 | + $str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); | |
| 921 | + ?> | |
| 922 | + | |
| 923 | + <div class="ui <?php echo 'abandoned-plugins' === $active_tab ? 'active' : ''; ?> tab" data-tab="abandoned-plugins"> | |
| 924 | + <?php if ( ! empty( $plugins_outdate ) ) : ?> | |
| 925 | + <table style="width:100% !important;" class=" ui tablet stackable table mainwp-manage-updates-table" id="mainwp-abandoned-plugins-table"> | |
| 926 | + <thead> | |
| 927 | + <tr> | |
| 928 | + <th scope="col" ><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th> | |
| 929 | + <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 930 | + <th scope="col" ><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 931 | + <th scope="col" class="no-sort"></th> | |
| 932 | + </tr> | |
| 933 | + </thead> | |
| 934 | + <tbody id="wp_plugins_outdate_<?php echo intval( $website->id ); ?>" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 935 | + <?php foreach ( $plugins_outdate as $slug => $plugin_outdate ) : ?> | |
| 936 | + <?php | |
| 937 | + $plugin_name = rawurlencode( $slug ); | |
| 938 | + $item_slug = MainWP_Utility::get_dir_slug( rawurldecode( $slug ) ); | |
| 939 | + $now = new \DateTime(); | |
| 940 | + $last_updated = $plugin_outdate['last_updated']; | |
| 941 | + $plugin_last_updated_date = new \DateTime( '@' . $last_updated ); | |
| 942 | + $diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' ); | |
| 943 | + $outdate_notice = sprintf( $str_format, $diff_in_days ); | |
| 944 | + | |
| 945 | + ?> | |
| 946 | + <tr dismissed="0"> | |
| 947 | + <td> <?php echo MainWP_System_Utility::get_plugin_icon( $item_slug ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 948 | + <a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $slug ) ) . '&url=' . ( isset( $plugin_outdate['PluginURI'] ) ? esc_url( rawurlencode( $plugin_outdate['PluginURI'] ) ) : '' ) . '&name=' . esc_url( rawurlencode( $plugin_outdate['Name'] ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $plugin_outdate['Name'] ); ?></a> | |
| 949 | + <input type="hidden" id="wp_dismissed_plugin_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>" value="0"/> | |
| 950 | + </td> | |
| 951 | + <td><?php echo esc_html( $plugin_outdate['Version'] ); ?></td> | |
| 952 | + <td><?php echo esc_html( $outdate_notice ); ?></td> | |
| 953 | + <td id="wp_dismissbuttons_plugin_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>"> | |
| 954 | + <?php if ( $user_can_ignore_unignore ) { ?> | |
| 955 | + <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_plugins_dismiss_outdate_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_outdate['Name'] ) ); ?>', <?php echo esc_js( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a> | |
| 956 | + <?php } ?> | |
| 957 | + </td> | |
| 958 | + </tr> | |
| 959 | + <?php endforeach; ?> | |
| 960 | + </tbody> | |
| 961 | + <tfoot> | |
| 962 | + <tr> | |
| 963 | + <th scope="col" ><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th> | |
| 964 | + <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 965 | + <th scope="col" ><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 966 | + <th scope="col" class="no-sort"></th> | |
| 967 | + </tr> | |
| 968 | + </tfoot> | |
| 969 | + </table> | |
| 970 | + <?php else : ?> | |
| 971 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned plugins found', 'mainwp' ), __( 'No abandoned plugins detected on this site.', 'mainwp' ) ); ?> | |
| 972 | + <?php endif; ?> | |
| 973 | + </div> | |
| 974 | + <?php | |
| 975 | + } | |
| 976 | + | |
| 977 | + /** | |
| 978 | + * Method render_abandoned_themes() | |
| 979 | + * | |
| 980 | + * Render the Abandoned Themes tab. | |
| 981 | + * | |
| 982 | + * @param mixed $website Child Site info. | |
| 983 | + * @param mixed $active_tab Current active tab. | |
| 984 | + * @param mixed $userExtension MainWP trusted themes data. | |
| 985 | + * | |
| 986 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() | |
| 987 | + */ | |
| 988 | + public static function render_abandoned_themes( $website, $active_tab, $userExtension ) { | |
| 989 | + | |
| 990 | + $user_can_ignore_unignore = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ); | |
| 991 | + | |
| 992 | + $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ); | |
| 993 | + $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array(); | |
| 994 | + | |
| 995 | + if ( ! is_array( $themes_outdate ) ) { | |
| 996 | + $themes_outdate = array(); | |
| 997 | + } | |
| 998 | + | |
| 999 | + if ( ! empty( $themes_outdate ) ) { | |
| 1000 | + $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); | |
| 1001 | + $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array(); | |
| 1002 | + | |
| 1003 | + if ( is_array( $themesOutdateDismissed ) ) { | |
| 1004 | + $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed ); | |
| 1005 | + } | |
| 1006 | + | |
| 1007 | + $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); | |
| 1008 | + if ( is_array( $decodedDismissedThemes ) ) { | |
| 1009 | + $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); | |
| 1010 | + } | |
| 1011 | + } | |
| 1012 | + | |
| 1013 | + /* translators: %s: Number of days since last update */ | |
| 1014 | + $str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); | |
| 1015 | + | |
| 1016 | + ?> | |
| 1017 | + <div class="ui <?php echo 'abandoned-themes' === $active_tab ? 'active' : ''; ?> tab" data-tab="abandoned-themes"> | |
| 1018 | + <?php if ( ! empty( $themes_outdate ) ) : ?> | |
| 1019 | + <table style="width:100% !important;" class="ui tablet stackable table mainwp-manage-updates-table" id="mainwp-abandoned-themes-table"> | |
| 1020 | + <thead> | |
| 1021 | + <tr> | |
| 1022 | + <th scope="col"><?php esc_html_e( 'Theme', 'mainwp' ); ?></th> | |
| 1023 | + <th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th> | |
| 1024 | + <th scope="col"><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> | |
| 1025 | + <th scope="col" class="no-sort"></th> | |
| 1026 | + </tr> | |
| 1027 | + </thead> | |
| 1028 | + <tbody site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>"> | |
| 1029 | + <?php foreach ( $themes_outdate as $slug => $theme_outdate ) : ?> | |
| 1030 | + <?php | |
| 1031 | + $theme_name = rawurlencode( $slug ); | |
| 1032 | + $now = new \DateTime(); | |
| 1033 | + $last_updated = $theme_outdate['last_updated']; | |
| 1034 | + $theme_last_updated_date = new \DateTime( '@' . $last_updated ); | |
| 1035 | + $diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' ); | |
| 1036 | + $outdate_notice = sprintf( $str_format, $diff_in_days ); | |
| 1037 | + ?> | |
| 1038 | + <tr dismissed="0"> | |
| 1039 | + <td> | |
| 1040 | + <?php echo MainWP_System_Utility::get_theme_icon( $slug ) . ' ' . esc_html( $theme_outdate['Name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 1041 | + <input type="hidden" id="wp_dismissed_theme_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>" value="0"/> | |
| 1042 | + </td> | |
| 1043 | + <td><?php echo esc_html( $theme_outdate['Version'] ); ?></td> | |
| 1044 | + <td><?php echo esc_html( $outdate_notice ); ?></td> | |
| 1045 | + <td id="wp_dismissbuttons_theme_<?php echo intval( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>"> | |
| 1046 | + <?php if ( $user_can_ignore_unignore ) { ?> | |
| 1047 | + <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_themes_dismiss_outdate_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_outdate['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a> | |
| 1048 | + <?php } ?> | |
| 1049 | + </td> | |
| 1050 | + </tr> | |
| 1051 | + <?php endforeach; ?> | |
| 1052 | + </tbody> | |
| 1053 | + </table> | |
| 1054 | + <?php else : ?> | |
| 1055 | + <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned themes found', 'mainwp' ), __( 'No abandoned themes detected on this site.', 'mainwp' ) ); ?> | |
| 1056 | + <?php endif; ?> | |
| 1057 | + </div> | |
| 1058 | + <?php | |
| 1059 | + } | |
| 908 | 1060 | } |