Skip to content

Commit a6d6b3c

Browse files
authored
Add support for Multisite Language Switcher (#1604)
1 parent 76fe523 commit a6d6b3c

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: fixed
3+
4+
Add support for Multisite Language Switcher
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Multisite Language Switcher integration class file.
4+
*
5+
* @package Activitypub
6+
*/
7+
8+
namespace Activitypub\Integration;
9+
10+
use Activitypub\Collection\Outbox;
11+
12+
/**
13+
* Compatibility with the Multisite Language Switcher plugin.
14+
*
15+
* @see https://github.com/lloc/Multisite-Language-Switcher/
16+
*/
17+
class Multisite_Language_Switcher {
18+
/**
19+
* Initialize the class, registering WordPress hooks.
20+
*/
21+
public static function init() {
22+
\add_action( 'save_post', array( self::class, 'ignore_outbox_post' ), 9, 2 );
23+
\add_action( 'save_post', array( self::class, 'unignore_outbox_post' ), 11, 2 );
24+
}
25+
26+
/**
27+
* Short-circuit saving Multisite Language Switcher data for the Outbox post type.
28+
*
29+
* @param int $post_id The post id.
30+
* @param WP_Post $post The post object.
31+
*/
32+
public static function ignore_outbox_post( $post_id, $post ) {
33+
if ( Outbox::POST_TYPE === $post->post_type ) {
34+
\add_action( 'msls_main_save', '__return_null' );
35+
}
36+
}
37+
38+
/**
39+
* Remove short-circuit for Multisite Language Switcher data.
40+
*
41+
* @param int $post_id The post id.
42+
* @param WP_Post $post The post object.
43+
*/
44+
public static function unignore_outbox_post( $post_id, $post ) {
45+
if ( Outbox::POST_TYPE === $post->post_type ) {
46+
\remove_action( 'msls_main_save', '__return_null' );
47+
}
48+
}
49+
}

integration/load.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ function plugin_init() {
7777
Akismet::init();
7878
}
7979

80+
/**
81+
* Adds Multisite Language Switcher support.
82+
*
83+
* This class handles the compatibility with the Multisite Language Switcher plugin.
84+
*
85+
* @see https://wordpress.org/plugins/multisite-language-switcher/
86+
*/
87+
if ( \defined( 'MSLS_PLUGIN_VERSION' ) ) {
88+
Multisite_Language_Switcher::init();
89+
}
90+
8091
/**
8192
* Adds Seriously Simple Podcasting support.
8293
*

0 commit comments

Comments
 (0)