| @@ -8,8 +8,13 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Widget_Themes |
| 14 | 19 | */ |
| 15 | 20 | class MainWP_Widget_Themes { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| @@ -92,161 +97,115 @@ | ||
| 92 | 97 | |
| 93 | 98 | $inactive_themes = MainWP_Utility::get_sub_array_having( $allThemes, 'active', 0 ); |
| 94 | 99 | $inactive_themes = MainWP_Utility::sortmulti( $inactive_themes, 'name', 'asc' ); |
| 95 | 100 | |
| 101 | + $wp_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' ); | |
| 102 | + $wp_info = ! empty( $wp_info ) ? json_decode( $wp_info, true ) : array(); | |
| 103 | + | |
| 104 | + if ( ! is_array( $wp_info ) ) { | |
| 105 | + $wp_info = array(); | |
| 106 | + } | |
| 107 | + | |
| 108 | + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array(); | |
| 109 | + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0; | |
| 110 | + $offs_info = esc_html__( ' - Timezone:', 'mainwp' ) . ' UTC ' . ( $offs >= 0 ? '+' . $offs : $offs ); | |
| 111 | + $site_info = $website->name . ' (' . $website->url . ') ' . ( ! empty( $offs_info ) ? $offs_info : '' ); | |
| 112 | + | |
| 96 | 113 | ?> |
| 97 | - <div class="ui grid mainwp-widget-header"> | |
| 98 | - <div class="twelve wide column"> | |
| 99 | - <h3 class="ui header handle-drag"> | |
| 100 | - <?php | |
| 101 | - /** | |
| 102 | - * Filter: mainwp_themes_widget_title | |
| 103 | - * | |
| 104 | - * Filters the Themes widget title text. | |
| 105 | - * | |
| 106 | - * @since 4.1 | |
| 107 | - */ | |
| 108 | - echo esc_html( apply_filters( 'mainwp_themes_widget_title', esc_html__( 'Themes', 'mainwp' ), $website ) ); | |
| 109 | - ?> | |
| 110 | - <div class="sub header"><?php esc_html_e( 'Installed themes on the child site', 'mainwp' ); ?></div> | |
| 111 | - </h3> | |
| 112 | - </div> | |
| 113 | - <div class="four wide column right aligned"> | |
| 114 | - <div class="ui dropdown right pointing mainwp-dropdown-tab"> | |
| 115 | - <div class="text"><?php esc_html_e( 'Active', 'mainwp' ); ?></div> | |
| 116 | - <i class="dropdown icon"></i> | |
| 117 | - <div class="menu"> | |
| 118 | - <a class="item" data-tab="active_themes" data-value="active_themes" title="<?php esc_attr_e( 'Active', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Active', 'mainwp' ); ?></a> | |
| 119 | - <a class="item" data-tab="inactive_themes" data-value="inactive_themes" title="<?php esc_attr_e( 'Inactive', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Inactive', 'mainwp' ); ?></a> | |
| 120 | - </div> | |
| 121 | - </div> | |
| 122 | - </div> | |
| 114 | + <div class="mainwp-widget-header"> | |
| 115 | + <h2 class="ui header handle-drag"> | |
| 116 | + <?php | |
| 117 | + /** | |
| 118 | + * Filter: mainwp_themes_widget_title | |
| 119 | + * | |
| 120 | + * Filters the Themes widget title text. | |
| 121 | + * | |
| 122 | + * @since 4.1 | |
| 123 | + */ | |
| 124 | + echo esc_html( apply_filters( 'mainwp_themes_widget_title', esc_html__( 'Themes', 'mainwp' ), $website ) ); | |
| 125 | + ?> | |
| 126 | + <div class="sub header"><?php esc_html_e( 'Inactive themes on the child site', 'mainwp' ); ?></div> | |
| 127 | + </h2> | |
| 123 | 128 | </div> |
| 124 | 129 | <div class="mainwp-scrolly-overflow"> |
| 125 | - <?php | |
| 126 | - /** | |
| 127 | - * Action: mainwp_themes_widget_top | |
| 128 | - * | |
| 129 | - * Fires at the top of the Themes widget on the Individual site overview page. | |
| 130 | - * | |
| 131 | - * @param object $website Object containing the child site info. | |
| 132 | - * @param array $allThemes Array containing all detected themes data. | |
| 133 | - * | |
| 134 | - * @since 4.1 | |
| 135 | - */ | |
| 136 | - do_action( 'mainwp_themes_widget_top', $website, $allThemes ); | |
| 137 | - ?> | |
| 138 | - <div id="mainwp-widget-active-themes" class="ui tab active" data-tab="active_themes"> | |
| 139 | 130 | <?php |
| 140 | 131 | /** |
| 141 | - * Action: mainwp_before_active_themes_list | |
| 132 | + * Action: mainwp_themes_widget_top | |
| 142 | 133 | * |
| 143 | - * Fires before the active theme list in the Themes widget on the Individual site overview page. | |
| 134 | + * Fires at the top of the Themes widget on the Individual site overview page. | |
| 144 | 135 | * |
| 145 | - * @param object $website Object containing the child site info. | |
| 146 | - * @param array $actived_themes Array containing all active themes data. | |
| 136 | + * @param object $website Object containing the child site info. | |
| 137 | + * @param array $allThemes Array containing all detected themes data. | |
| 147 | 138 | * |
| 148 | 139 | * @since 4.1 |
| 149 | 140 | */ |
| 150 | - do_action( 'mainwp_before_active_themes_list', $website, $actived_themes ); | |
| 141 | + do_action( 'mainwp_themes_widget_top', $website, $allThemes ); | |
| 151 | 142 | ?> |
| 152 | - <div class="ui divided selection list"> | |
| 143 | + <div id="mainwp-widget-inactive-themes" site-info="<?php echo esc_attr( $site_info ); ?>" site-id="<?php echo intval( $website->id ); ?>"> | |
| 153 | 144 | <?php |
| 154 | - $_count = count( $actived_themes ); | |
| 155 | - for ( $i = 0; $i < $_count; $i++ ) { | |
| 156 | - $slug = $actived_themes[ $i ]['slug']; | |
| 157 | - ?> | |
| 158 | - <div class="item"> | |
| 159 | - <input class="themeSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $actived_themes[ $i ]['slug'] ) ); ?>"/> | |
| 160 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 161 | - <div class="right floated content themesAction"> | |
| 162 | - <span data-position="left center" data-tooltip="<?php esc_attr_e( 'Active theme cannot be deactivated.', 'mainwp' ); ?>" data-inverted=""><a href="javascript:void(0);" disabled class="button ui mini grey basic"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></a></span> | |
| 145 | + /** | |
| 146 | + * Action: mainwp_before_inactive_themes_list | |
| 147 | + * | |
| 148 | + * Fires before the inactive themes list in the Themes widget on the Individual site overview page. | |
| 149 | + * | |
| 150 | + * @param object $website Object containing the child site info. | |
| 151 | + * @param array $inactive_themes Array containing all inactive themes data. | |
| 152 | + * | |
| 153 | + * @since 4.1 | |
| 154 | + */ | |
| 155 | + do_action( 'mainwp_before_inactive_themes_list', $website, $inactive_themes ); | |
| 156 | + ?> | |
| 157 | + <div class="ui divided list"> | |
| 158 | + <?php | |
| 159 | + $_count = count( $inactive_themes ); | |
| 160 | + for ( $i = 0; $i < $_count; $i++ ) { | |
| 161 | + $slug = $inactive_themes[ $i ]['slug']; | |
| 162 | + $is_parent = ( isset( $inactive_themes[ $i ]['parent_active'] ) && 1 === (int) $inactive_themes[ $i ]['parent_active'] ) ? true : false; | |
| 163 | + ?> | |
| 164 | + <div class="item row-manage-item"> | |
| 165 | + <input class="themeName" type="hidden" name="name" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_themes[ $i ]['name'] ) ); ?>"/> | |
| 166 | + <input class="themeSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_themes[ $i ]['slug'] ) ); ?>"/> | |
| 167 | + <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 168 | + <div class="right floated content themesAction"> | |
| 169 | + <div class="ui right pointing dropdown"> | |
| 170 | + <i class="ellipsis vertical icon"></i> | |
| 171 | + <div class="menu"> | |
| 172 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_themes' ) ) : ?> | |
| 173 | + <a href="#" class="mainwp-theme-activate item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Activate', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a> | |
| 174 | + <?php endif; ?> | |
| 175 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'delete_themes' ) ) : ?> | |
| 176 | + <a href="#" class="<?php echo $is_parent ? '' : 'mainwp-theme-delete'; ?> item <?php echo $is_demo ? 'disabled' : ''; ?>" <?php echo $is_parent ? 'disabled onclick="javascript:void(0)"' : ''; ?>><?php esc_html_e( 'Delete', 'mainwp' ); ?></a> | |
| 177 | + <?php endif; ?> | |
| 178 | + <a href="#" history-view="widget-themes" class="mainwp-show-history item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'History', 'mainwp' ); ?></a> | |
| 179 | + </div> | |
| 180 | + </div> | |
| 181 | + </div> | |
| 182 | + <div class="middle aligned content"> | |
| 183 | + <?php echo MainWP_System_Utility::get_theme_icon( $slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 184 | + <?php echo esc_html( $inactive_themes[ $i ]['name'] . ' ' . $inactive_themes[ $i ]['version'] ); ?> | |
| 185 | + </div> | |
| 186 | + <div class="mainwp-row-actions-working"> | |
| 187 | + <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 188 | + </div> | |
| 163 | 189 | </div> |
| 164 | - <div class="middle aligned content"> | |
| 165 | - <?php echo MainWP_System_Utility::get_theme_icon( $slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 166 | - <?php echo esc_html( $actived_themes[ $i ]['name'] . ' ' . $actived_themes[ $i ]['version'] ); ?> | |
| 167 | - </div> | |
| 168 | - <div class="mainwp-row-actions-working"> | |
| 169 | - <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 170 | - </div> | |
| 171 | - </div> | |
| 172 | - <?php } ?> | |
| 173 | - </div> | |
| 174 | - <?php | |
| 175 | - /** | |
| 176 | - * Action: mainwp_after_active_themes_list | |
| 177 | - * | |
| 178 | - * Fires after the active themes list in the Themes widget on the Individual site overview page. | |
| 179 | - * | |
| 180 | - * @param object $website Object containing the child site info. | |
| 181 | - * @param array $actived_themes Array containing all active themes data. | |
| 182 | - * | |
| 183 | - * @since 4.1 | |
| 184 | - */ | |
| 185 | - do_action( 'mainwp_after_active_themes_list', $website, $actived_themes ); | |
| 186 | - ?> | |
| 187 | - </div> | |
| 188 | - <div id="mainwp-widget-inactive-themes" class="ui tab" data-tab="inactive_themes"> | |
| 189 | - <?php | |
| 190 | - /** | |
| 191 | - * Action: mainwp_before_inactive_themes_list | |
| 192 | - * | |
| 193 | - * Fires before the inactive themes list in the Themes widget on the Individual site overview page. | |
| 194 | - * | |
| 195 | - * @param object $website Object containing the child site info. | |
| 196 | - * @param array $inactive_themes Array containing all inactive themes data. | |
| 197 | - * | |
| 198 | - * @since 4.1 | |
| 199 | - */ | |
| 200 | - do_action( 'mainwp_before_inactive_themes_list', $website, $inactive_themes ); | |
| 201 | - ?> | |
| 202 | - <div class="ui divided selection list"> | |
| 190 | + <?php } ?> | |
| 191 | + </div> | |
| 203 | 192 | <?php |
| 204 | - $_count = count( $inactive_themes ); | |
| 205 | - for ( $i = 0; $i < $_count; $i++ ) { | |
| 206 | - $slug = $inactive_themes[ $i ]['slug']; | |
| 207 | - $is_parent = ( isset( $inactive_themes[ $i ]['parent_active'] ) && 1 === (int) $inactive_themes[ $i ]['parent_active'] ) ? true : false; | |
| 208 | - ?> | |
| 209 | - <div class="item row-manage-item"> | |
| 210 | - <input class="themeName" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_themes[ $i ]['name'] ) ); ?>"/> | |
| 211 | - <input class="themeSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_themes[ $i ]['slug'] ) ); ?>"/> | |
| 212 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 213 | - <div class="right floated content themesAction"> | |
| 214 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_themes' ) ) { ?> | |
| 215 | - <span data-position="left center" data-tooltip="<?php echo esc_attr__( 'Activate the ', 'mainwp' ) . wp_strip_all_tags( $inactive_themes[ $i ]['name'] ) . ' ' . esc_attr__( 'theme on the child site.', 'mainwp' ); ?>" data-inverted=""><a href="#" class="mainwp-theme-activate ui mini green button <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Activate', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a></span> | |
| 216 | - <?php } ?> | |
| 217 | - <?php | |
| 218 | - if ( mainwp_current_user_have_right( 'dashboard', 'delete_themes' ) ) { | |
| 219 | - $parent_str = sprintf( esc_html__( 'Parent theme of the active theme (%s) on the site can not be deleted.', 'mainwp' ), isset( $inactive_themes[ $i ]['child_theme'] ) ? $inactive_themes[ $i ]['child_theme'] : '' ); | |
| 220 | - ?> | |
| 221 | - <span data-position="left center" data-tooltip="<?php echo ! $is_parent ? esc_attr__( 'Delete the ', 'mainwp' ) . wp_strip_all_tags( $inactive_themes[ $i ]['name'] ) . ' ' . esc_attr__( 'theme from the child site.', 'mainwp' ) : $parent_str; // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-inverted="" ><a href="#" class="<?php echo $is_parent ? '' : 'mainwp-theme-delete'; ?> ui mini basic button <?php echo $is_demo ? 'disabled' : ''; ?>" <?php echo $is_parent ? 'disabled onclick="javascript:void(0)"' : ''; ?>><?php esc_html_e( 'Delete', 'mainwp' ); ?></a><span> | |
| 222 | - <?php } ?> | |
| 223 | - </div> | |
| 224 | - <div class="middle aligned content"> | |
| 225 | - <?php echo MainWP_System_Utility::get_theme_icon( $slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 226 | - <?php echo esc_html( $inactive_themes[ $i ]['name'] . ' ' . $inactive_themes[ $i ]['version'] ); ?> | |
| 227 | - </div> | |
| 228 | - <div class="mainwp-row-actions-working"> | |
| 229 | - <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?> | |
| 230 | - </div> | |
| 231 | - </div> | |
| 232 | - <?php } ?> | |
| 193 | + /** | |
| 194 | + * Action: mainwp_after_inactive_themes_list | |
| 195 | + * | |
| 196 | + * Fires after the inactive themes list in the Themes widget on the Individual site overview page. | |
| 197 | + * | |
| 198 | + * @param object $website Object containing the child site info. | |
| 199 | + * @param array $inactive_themes Array containing all inactive themes data. | |
| 200 | + * | |
| 201 | + * @since 4.1 | |
| 202 | + */ | |
| 203 | + do_action( 'mainwp_after_inactive_themes_list', $website, $inactive_themes ); | |
| 204 | + ?> | |
| 233 | 205 | </div> |
| 234 | - <?php | |
| 235 | - /** | |
| 236 | - * Action: mainwp_after_inactive_themes_list | |
| 237 | - * | |
| 238 | - * Fires after the inactive themes list in the Themes widget on the Individual site overview page. | |
| 239 | - * | |
| 240 | - * @param object $website Object containing the child site info. | |
| 241 | - * @param array $inactive_themes Array containing all inactive themes data. | |
| 242 | - * | |
| 243 | - * @since 4.1 | |
| 244 | - */ | |
| 245 | - do_action( 'mainwp_after_inactive_themes_list', $website, $inactive_themes ); | |
| 246 | - ?> | |
| 247 | 206 | </div> |
| 248 | - </div> | |
| 207 | + | |
| 249 | 208 | <?php |
| 250 | 209 | /** |
| 251 | 210 | * Action: mainwp_themes_widget_bottom |
| 252 | 211 | * |
| @@ -257,8 +216,16 @@ | ||
| 257 | 216 | * |
| 258 | 217 | * @since 4.1 |
| 259 | 218 | */ |
| 260 | 219 | do_action( 'mainwp_themes_widget_bottom', $website, $allThemes ); |
| 220 | + ?> | |
| 221 | + <div class="ui two column grid mainwp-widget-footer"> | |
| 222 | + <div class="left aligned middle aligned column"></div> | |
| 223 | + <div class="right aligned middle aligned column"> | |
| 224 | + <a href="admin.php?page=ThemesManage" class="ui mini basic button"><?php esc_html_e( 'Manage Themes', 'mainwp' ); ?></a> | |
| 225 | + </div> | |
| 226 | + </div> | |
| 227 | + <?php | |
| 261 | 228 | } |
| 262 | 229 | |
| 263 | 230 | /** |
| 264 | 231 | * Method activate_theme() |