|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
Plugin Name: Multisite Language Switcher |
|
5
|
|
|
Plugin URI: http://msls.co/ |
|
6
|
|
|
Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation. |
|
7
|
|
|
Version: 1.2 |
|
8
|
|
|
Author: Dennis Ploetner |
|
9
|
|
|
Author URI: http://lloc.de/ |
|
10
|
|
|
Text Domain: multisite-language-switcher |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/* |
|
14
|
|
|
Copyright 2013 Dennis Ploetner (email : [email protected]) |
|
15
|
|
|
|
|
16
|
|
|
This program is free software; you can redistribute it and/or modify |
|
17
|
|
|
it under the terms of the GNU General Public License, version 2, as |
|
18
|
|
|
published by the Free Software Foundation. |
|
19
|
|
|
|
|
20
|
|
|
This program is distributed in the hope that it will be useful, |
|
21
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
GNU General Public License for more details. |
|
24
|
|
|
|
|
25
|
|
|
You should have received a copy of the GNU General Public License |
|
26
|
|
|
along with this program; if not, write to the Free Software |
|
27
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
31
|
|
|
require __DIR__ . '/vendor/autoload.php'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* MultisiteLanguageSwitcher |
|
36
|
|
|
* |
|
37
|
|
|
* @author Dennis Ploetner <[email protected]> |
|
38
|
|
|
*/ |
|
39
|
|
|
if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) { |
|
40
|
|
|
define( 'MSLS_PLUGIN_VERSION', '1.2' ); |
|
41
|
|
|
|
|
42
|
|
|
if ( ! defined( 'MSLS_PLUGIN_PATH' ) ) { |
|
43
|
|
|
define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) ); |
|
44
|
|
|
} |
|
45
|
|
|
if ( ! defined( 'MSLS_PLUGIN__FILE__' ) ) { |
|
46
|
|
|
define( 'MSLS_PLUGIN__FILE__', __FILE__ ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
lloc\Msls\MslsPlugin::init(); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get the output for using the links to the translations in your code |
|
53
|
|
|
* |
|
54
|
|
|
* @package Msls |
|
55
|
|
|
* |
|
56
|
|
|
* @param array $arr |
|
57
|
|
|
* |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
function get_the_msls( array $arr = [] ) { |
|
61
|
|
|
$obj = apply_filters( 'msls_get_output', null ); |
|
62
|
|
|
|
|
63
|
|
|
return ! is_null( $obj ) ? strval( $obj->set_tags( $arr ) ) : ''; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
add_shortcode( 'sc_msls', 'get_the_msls' ); |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Output the links to the translations in your template |
|
70
|
|
|
* |
|
71
|
|
|
* You can call this function directly like that |
|
72
|
|
|
* |
|
73
|
|
|
* if ( function_exists ( 'the_msls' ) ) |
|
74
|
|
|
* the_msls(); |
|
75
|
|
|
* |
|
76
|
|
|
* or just use it as shortcode [sc_msls] |
|
77
|
|
|
* |
|
78
|
|
|
* @package Msls |
|
79
|
|
|
* @uses get_the_msls |
|
80
|
|
|
* |
|
81
|
|
|
* @param array $arr |
|
82
|
|
|
*/ |
|
83
|
|
|
function the_msls( array $arr = [] ) { |
|
84
|
|
|
echo get_the_msls( $arr ); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|