These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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: 2.4.5 |
||
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', '2.4.5' ); |
||
41 | define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) ); |
||
42 | define( 'MSLS_PLUGIN__FILE__', __FILE__ ); |
||
43 | |||
44 | lloc\Msls\MslsPlugin::init(); |
||
45 | |||
46 | /** |
||
47 | * Get the output for using the links to the translations in your code |
||
48 | * |
||
49 | * @package Msls |
||
50 | * |
||
51 | * @param array $attr |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | function get_the_msls( $attr ) { |
||
56 | $arr = is_array( $attr ) ? $attr : []; |
||
57 | $obj = apply_filters( 'msls_get_output', null ); |
||
58 | |||
59 | return ! is_null( $obj ) ? strval( $obj->set_tags( $arr ) ) : ''; |
||
60 | } |
||
61 | |||
62 | add_shortcode( 'sc_msls', 'get_the_msls' ); |
||
63 | |||
64 | /** |
||
65 | * Output the links to the translations in your template |
||
66 | * |
||
67 | * You can call this function directly like that |
||
68 | * |
||
69 | * if ( function_exists ( 'the_msls' ) ) |
||
70 | * the_msls(); |
||
71 | * |
||
72 | * or just use it as shortcode [sc_msls] |
||
73 | * |
||
74 | * @package Msls |
||
75 | * @uses get_the_msls |
||
76 | * |
||
77 | * @param array $arr |
||
78 | */ |
||
79 | function the_msls( array $arr = [] ) { |
||
80 | echo get_the_msls( $arr ); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Gets the URL of the country flag-icon for a specific locale |
||
85 | * |
||
86 | * @param string $locale |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | function get_msls_flag_url( $locale ) { |
||
91 | return ( new \lloc\Msls\MslsOptions )->get_flag_url( $locale ); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Gets the description for a blog for a specific locale |
||
96 | * |
||
97 | * @param string $locale |
||
98 | * |
||
99 | * @return bool|string |
||
100 | */ |
||
101 | function get_msls_blog_description( $locale ) { |
||
102 | $blog = \lloc\Msls\MslsBlogCollection::instance()->get_blog( $locale ); |
||
103 | |||
104 | return $blog->get_description(); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Gets the permalink for a translation of the current post in a given language |
||
109 | * |
||
110 | * @param string $locale |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | function get_msls_permalink( $locale ) { |
||
115 | $options = \lloc\Msls\MslsOptions::create(); |
||
116 | $blog = \lloc\Msls\MslsBlogCollection::instance()->get_blog( $locale ); |
||
117 | |||
118 | return $blog->get_url( $options ); |
||
0 ignored issues
–
show
|
|||
119 | } |
||
120 | |||
121 | } |
||
122 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: