Task_12281 (#1)

Co-authored-by: User A0264400 <a0264400@jarl.from.sh>
Reviewed-on: #1
Co-authored-by: Anton.AE <ab.an.ev@yandex.ru>
Co-committed-by: Anton.AE <ab.an.ev@yandex.ru>
This commit is contained in:
2026-07-05 16:07:04 +03:00
committed by Антон
parent 50f3a8e626
commit 3e42863ef5
2878 changed files with 59059 additions and 181273 deletions

View File

@@ -0,0 +1,52 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы в multisite режиме.
*
* @version 1.0
*/
class WIO_Multisite {
/**
* Инициализация хуков
*/
public function initHooks() {
add_action( 'wbcr/rio/multisite_current_blog', [ $this, 'setCurrentBlog' ] );
add_action( 'wbcr/rio/multisite_restore_blog', [ $this, 'restoreBlog' ] );
}
/**
* Устанавливает текущий блог в соответствии с выбором пользователя
*/
public function setCurrentBlog() {
$current_blog_id = WRIO_Plugin::app()->getPopulateOption( 'current_blog', 1 );
switch_to_blog( $current_blog_id );
}
/**
* Сбрасывает текущий блог
*/
public function restoreBlog() {
restore_current_blog();
}
/**
* Получает список блогов в зависимости от контекста
*
* @param string $context контекст. Например media-library или nextgen
*
* @return array $blogs
*/
public static function getBlogs( $context = 'media-library' ) {
global $wpdb;
$blogs = $wpdb->get_results( "SELECT blog_id, domain, path FROM {$wpdb->blogs}" );
$blogs = apply_filters( 'wbcr/rio/multisite_blogs', $blogs, $context );
return $blogs;
}
}