PluginProbe
ActivityPub / 9.0.0
ActivityPub v9.0.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / integration / class-multisite-language-switcher.php

class-multisite-language-switcher.php in ActivityPub 9.0.0, at integration/class-multisite-language-switcher.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
50