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.3.0 |
||
| 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.3.0' ); |
||
| 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 |
||
|
0 ignored issues
–
show
|
|||
| 57 | * |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | function get_the_msls( $attr ) { |
||
| 61 | $arr = is_array( $attr ) ? $attr : []; |
||
| 62 | $obj = apply_filters( 'msls_get_output', null ); |
||
| 63 | |||
| 64 | return ! is_null( $obj ) ? strval( $obj->set_tags( $arr ) ) : ''; |
||
| 65 | } |
||
| 66 | |||
| 67 | add_shortcode( 'sc_msls', 'get_the_msls' ); |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Output the links to the translations in your template |
||
| 71 | * |
||
| 72 | * You can call this function directly like that |
||
| 73 | * |
||
| 74 | * if ( function_exists ( 'the_msls' ) ) |
||
| 75 | * the_msls(); |
||
| 76 | * |
||
| 77 | * or just use it as shortcode [sc_msls] |
||
| 78 | * |
||
| 79 | * @package Msls |
||
| 80 | * @uses get_the_msls |
||
| 81 | * |
||
| 82 | * @param array $arr |
||
| 83 | */ |
||
| 84 | function the_msls( array $arr = [] ) { |
||
| 85 | echo get_the_msls( $arr ); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Gets the URL of the country flag-icon for a specific locale |
||
| 90 | * |
||
| 91 | * @param string $locale |
||
| 92 | * |
||
| 93 | * @return string |
||
| 94 | */ |
||
| 95 | function get_msls_flag_url( $locale ) { |
||
| 96 | return ( new \lloc\Msls\MslsOptions )->get_flag_url( $locale ); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Gets the description for a blog for a specific locale |
||
| 101 | * |
||
| 102 | * @param string $locale |
||
| 103 | * |
||
| 104 | * @return bool|string |
||
| 105 | */ |
||
| 106 | function get_msls_blog_description( $locale ) { |
||
| 107 | $collection = \lloc\Msls\MslsBlogCollection::instance(); |
||
| 108 | $blog_objects = $collection->get_objects(); |
||
| 109 | |||
| 110 | if ( $blog_objects ) { |
||
|
0 ignored issues
–
show
The expression
$blog_objects of type lloc\Msls\MslsBlog[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 111 | foreach ( $blog_objects as $blog ) { |
||
| 112 | if ( $locale === $blog->get_language() ) { |
||
| 113 | return $blog->get_description(); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | return false; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Gets the permalink for a translation of the current post in a given language |
||
| 123 | * |
||
| 124 | * @param string $locale |
||
| 125 | * |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | function get_msls_permalink( $locale ) { |
||
| 129 | return \lloc\Msls\MslsOptions::create()->get_permalink( $locale ); |
||
| 130 | } |
||
| 131 | |||
| 132 | } |
||
| 133 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.