Changeset 3091013 for multisite-language-switcher
- Timestamp:
- 05/22/2024 03:36:52 PM (20 months ago)
- Location:
- multisite-language-switcher
- Files:
-
- 38 edited
- 1 copied
-
tags/2.7.1 (copied) (copied from multisite-language-switcher/trunk)
-
tags/2.7.1/MultisiteLanguageSwitcher.php (modified) (2 diffs)
-
tags/2.7.1/includes/MslsAdmin.php (modified) (28 diffs)
-
tags/2.7.1/includes/MslsAdminIcon.php (modified) (8 diffs)
-
tags/2.7.1/includes/MslsAdminIconTaxonomy.php (modified) (6 diffs)
-
tags/2.7.1/includes/MslsBlog.php (modified) (8 diffs)
-
tags/2.7.1/includes/MslsBlogCollection.php (modified) (24 diffs)
-
tags/2.7.1/includes/MslsOptions.php (modified) (29 diffs)
-
tags/2.7.1/includes/MslsOptionsPost.php (modified) (6 diffs)
-
tags/2.7.1/includes/MslsOptionsQuery.php (modified) (4 diffs)
-
tags/2.7.1/includes/MslsOptionsQueryAuthor.php (modified) (3 diffs)
-
tags/2.7.1/includes/MslsOptionsQueryPostType.php (modified) (3 diffs)
-
tags/2.7.1/includes/MslsOptionsQueryYear.php (modified) (3 diffs)
-
tags/2.7.1/includes/MslsOptionsTax.php (modified) (8 diffs)
-
tags/2.7.1/includes/MslsPlugin.php (modified) (1 diff)
-
tags/2.7.1/includes/MslsPostTag.php (modified) (7 diffs)
-
tags/2.7.1/js/msls-widget-block/block.json (modified) (1 diff)
-
tags/2.7.1/readme.txt (modified) (1 diff)
-
tags/2.7.1/src/msls-widget-block/block.json (modified) (1 diff)
-
tags/2.7.1/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/MultisiteLanguageSwitcher.php (modified) (2 diffs)
-
trunk/includes/MslsAdmin.php (modified) (28 diffs)
-
trunk/includes/MslsAdminIcon.php (modified) (8 diffs)
-
trunk/includes/MslsAdminIconTaxonomy.php (modified) (6 diffs)
-
trunk/includes/MslsBlog.php (modified) (8 diffs)
-
trunk/includes/MslsBlogCollection.php (modified) (24 diffs)
-
trunk/includes/MslsOptions.php (modified) (29 diffs)
-
trunk/includes/MslsOptionsPost.php (modified) (6 diffs)
-
trunk/includes/MslsOptionsQuery.php (modified) (4 diffs)
-
trunk/includes/MslsOptionsQueryAuthor.php (modified) (3 diffs)
-
trunk/includes/MslsOptionsQueryPostType.php (modified) (3 diffs)
-
trunk/includes/MslsOptionsQueryYear.php (modified) (3 diffs)
-
trunk/includes/MslsOptionsTax.php (modified) (8 diffs)
-
trunk/includes/MslsPlugin.php (modified) (1 diff)
-
trunk/includes/MslsPostTag.php (modified) (7 diffs)
-
trunk/js/msls-widget-block/block.json (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/src/msls-widget-block/block.json (modified) (1 diff)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multisite-language-switcher/tags/2.7.1/MultisiteLanguageSwitcher.php
r3088911 r3091013 8 8 * 9 9 * Plugin Name: Multisite Language Switcher 10 * Version: 2.7. 010 * Version: 2.7.1 11 11 * Plugin URI: http://msls.co/ 12 12 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation. … … 41 41 */ 42 42 if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) { 43 define( 'MSLS_PLUGIN_VERSION', '2.7. 0' );43 define( 'MSLS_PLUGIN_VERSION', '2.7.1' ); 44 44 define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) ); 45 45 define( 'MSLS_PLUGIN__FILE__', __FILE__ ); -
multisite-language-switcher/tags/2.7.1/includes/MslsAdmin.php
r3088911 r3091013 50 50 * 51 51 * @since 2.0 52 *53 52 */ 54 53 $caps = apply_filters( 'msls_admin_caps', 'manage_options' ); 55 54 if ( current_user_can( $caps ) ) { 56 55 $title = __( 'Multisite Language Switcher', 'multisite-language-switcher' ); 57 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), [ $obj, 'render' ]);58 59 add_action( 'admin_init', [ $obj, 'register' ]);60 add_action( 'admin_notices', [ $obj, 'has_problems' ]);61 62 add_filter( 'msls_admin_validate', [ $obj, 'set_blog_language' ]);56 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), array( $obj, 'render' ) ); 57 58 add_action( 'admin_init', array( $obj, 'register' ) ); 59 add_action( 'admin_notices', array( $obj, 'has_problems' ) ); 60 61 add_filter( 'msls_admin_validate', array( $obj, 'set_blog_language' ) ); 63 62 } 64 63 } … … 89 88 * 90 89 * @param string $method 91 * @param mixed $args90 * @param mixed $args 92 91 * 93 92 * @return mixed … … 97 96 98 97 if ( is_array( $parts ) && 'rewrite' === $parts[0] ) { 99 return $this->render_rewrite( $parts[1] ); 100 } 101 102 $checkboxes = [ 103 'activate_autocomplete' => __( 'Activate experimental autocomplete inputs', 104 'multisite-language-switcher' ), 105 'activate_content_import' => __( 'Activate the content import functionality', 106 'multisite-language-switcher' ), 98 $this->render_rewrite( $parts[1] ); 99 return; 100 } 101 102 $checkboxes = array( 103 'activate_autocomplete' => __( 104 'Activate experimental autocomplete inputs', 105 'multisite-language-switcher' 106 ), 107 'activate_content_import' => __( 108 'Activate the content import functionality', 109 'multisite-language-switcher' 110 ), 107 111 'sort_by_description' => __( 'Sort languages by description', 'multisite-language-switcher' ), 108 112 'exclude_current_blog' => __( 'Exclude this blog from output', 'multisite-language-switcher' ), … … 110 114 'output_current_blog' => __( 'Display link to the current language', 'multisite-language-switcher' ), 111 115 'content_filter' => __( 'Add hint for available translations', 'multisite-language-switcher' ), 112 ]; 113 114 if ( isset ( $checkboxes[ $method ] ) ) { 115 echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( new Label( $method, 116 $checkboxes[ $method ] ) )->render(); 116 ); 117 118 if ( isset( $checkboxes[ $method ] ) ) { 119 echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( 120 new Label( 121 $method, 122 $checkboxes[ $method ] 123 ) 124 )->render(); 117 125 } else { 118 126 $value = ! empty( $this->options->$method ) ? $this->options->$method : ''; … … 123 131 /** 124 132 * There is something wrong? Here comes the message... 133 * 125 134 * @return bool 126 135 */ 127 public function has_problems() {136 public function has_problems(): bool { 128 137 $message = ''; 129 138 130 139 if ( $this->options->is_empty() ) { 131 140 $message = sprintf( 132 __( 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.', 133 'multisite-language-switcher' ), 141 __( 142 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.', 143 'multisite-language-switcher' 144 ), 134 145 esc_url( admin_url( $this->get_options_page_link() ) ) 135 146 ); 136 147 } elseif ( 1 == count( $this->options->get_available_languages() ) ) { 137 148 $message = sprintf( 138 __( 'There are no language files installed. You can <a href="%s">manually install some language files</a> or you could use a <a href="%s">plugin</a> to download these files automatically.', 139 'multisite-language-switcher' ), 149 __( 150 'There are no language files installed. You can <a href="%1$s">manually install some language files</a> or you could use a <a href="%2$s">plugin</a> to download these files automatically.', 151 'multisite-language-switcher' 152 ), 140 153 esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ), 141 154 esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' ) … … 149 162 * Render the options-page 150 163 */ 151 public function render() {164 public function render(): void { 152 165 printf( 153 166 '<div class="wrap"><div class="icon32" id="icon-options-general"><br/></div><h1>%s</h1>%s<br class="clear"/><form action="options.php" method="post"><p>%s</p>', 154 167 __( 'Multisite Language Switcher Options', 'multisite-language-switcher' ), 155 168 $this->subsubsub(), 156 __( 'To achieve maximum flexibility, you have to configure each blog separately.', 157 'multisite-language-switcher' ) 169 __( 170 'To achieve maximum flexibility, you have to configure each blog separately.', 171 'multisite-language-switcher' 172 ) 158 173 ); 159 174 … … 163 178 printf( 164 179 '<p class="submit"><input name="Submit" type="submit" class="button button-primary" value="%s" /></p></form></div>', 165 ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 'Update', 166 'multisite-language-switcher' ) ) 180 ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 181 'Update', 182 'multisite-language-switcher' 183 ) ) 167 184 ); 168 185 } … … 171 188 /** 172 189 * Create a submenu which contains links to all blogs of the current user 190 * 173 191 * @return string 174 192 */ … … 176 194 $icon_type = $this->options->get_icon_type(); 177 195 178 $arr = [];196 $arr = array(); 179 197 foreach ( $this->collection->get_plugin_active_blogs() as $blog ) { 180 198 $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() ); … … 184 202 } 185 203 186 return empty( $arr ) ? '' : sprintf( '<ul class="subsubsub"><li>%s</li></ul>', 187 implode( ' | </li><li>', $arr ) ); 204 return empty( $arr ) ? '' : sprintf( 205 '<ul class="subsubsub"><li>%s</li></ul>', 206 implode( ' | </li><li>', $arr ) 207 ); 188 208 } 189 209 … … 194 214 */ 195 215 public function register() { 196 register_setting( 'msls', 'msls', [ $this, 'validate' ]);197 198 $sections = [216 register_setting( 'msls', 'msls', array( $this, 'validate' ) ); 217 218 $sections = array( 199 219 'language_section' => __( 'Language Settings', 'multisite-language-switcher' ), 200 220 'main_section' => __( 'Main Settings', 'multisite-language-switcher' ), 201 221 'advanced_section' => __( 'Advanced Settings', 'multisite-language-switcher' ), 202 ];222 ); 203 223 204 224 global $wp_rewrite; … … 208 228 209 229 foreach ( $sections as $id => $title ) { 210 add_settings_section( $id, $title, [ $this, $id ], __CLASS__ );230 add_settings_section( $id, $title, array( $this, $id ), __CLASS__ ); 211 231 } 212 232 … … 217 237 * 218 238 * @since 1.0 219 *220 239 */ 221 240 do_action( 'msls_admin_register', __CLASS__ ); … … 230 249 */ 231 250 public function language_section(): int { 232 $map = [ 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ];251 $map = array( 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ); 233 252 234 253 return $this->add_settings_fields( $map, 'language_section' ); … … 243 262 */ 244 263 public function main_section(): int { 245 $map = [264 $map = array( 246 265 'display' => __( 'Display', 'multisite-language-switcher' ), 247 266 'admin_display' => __( 'Admin Display', 'multisite-language-switcher' ), … … 256 275 'content_filter' => __( 'Available translations hint', 'multisite-language-switcher' ), 257 276 'content_priority' => __( 'Hint priority', 'multisite-language-switcher' ), 258 ];277 ); 259 278 260 279 return $this->add_settings_fields( $map, 'main_section' ); … … 269 288 */ 270 289 public function advanced_section(): int { 271 $map = [290 $map = array( 272 291 'activate_autocomplete' => __( 'Autocomplete', 'multisite-language-switcher' ), 273 292 'image_url' => __( 'Custom URL for flag-images', 'multisite-language-switcher' ), … … 275 294 'exclude_current_blog' => __( 'Exclude blog', 'multisite-language-switcher' ), 276 295 'activate_content_import' => __( 'Content import', 'multisite-language-switcher' ), 277 ];296 ); 278 297 279 298 return $this->add_settings_fields( $map, 'advanced_section' ); … … 288 307 */ 289 308 public function rewrites_section(): int { 290 $map = [];291 foreach ( get_post_types( [ 'public' => true ], 'objects' ) as $key => $object ) {292 $map[ "rewrite_{$key}"] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );309 $map = array(); 310 foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $key => $object ) { 311 $map[ "rewrite_{$key}" ] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label ); 293 312 } 294 313 … … 297 316 298 317 /** 299 * @param array $map318 * @param array $map 300 319 * @param string $section 301 320 * … … 304 323 protected function add_settings_fields( array $map, string $section ): int { 305 324 foreach ( $map as $id => $title ) { 306 add_settings_field( $id, $title, [ $this, $id ], __CLASS__, $section, [ 'label_for' => $id ]);325 add_settings_field( $id, $title, array( $this, $id ), __CLASS__, $section, array( 'label_for' => $id ) ); 307 326 } 308 327 … … 314 333 * 315 334 * @since 2.4.4 316 *317 335 */ 318 336 do_action( "msls_admin_{$section}", __CLASS__, $section ); … … 342 360 */ 343 361 public function admin_display() { 344 echo ( new Select( 'admin_display', 362 echo ( new Select( 363 'admin_display', 345 364 array( 346 365 'flag' => __( 'Flag', 'multisite-language-switcher' ), 347 'label' => __( 'Label', 'multisite-language-switcher' ) 366 'label' => __( 'Label', 'multisite-language-switcher' ), 348 367 ), 349 $this->options->admin_display ) )->render(); 368 $this->options->admin_display 369 ) )->render(); 350 370 } 351 371 … … 354 374 */ 355 375 public function reference_user() { 356 $users = [];357 358 foreach ( ( array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {376 $users = array(); 377 378 foreach ( (array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) { 359 379 $users[ $user->ID ] = $user->user_nicename; 360 380 } … … 364 384 365 385 $message = sprintf( 366 __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!', 367 'multisite-language-switcher' ), 386 __( 387 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!', 388 'multisite-language-switcher' 389 ), 368 390 self::MAX_REFERENCE_USERS 369 391 ); … … 391 413 */ 392 414 public function content_priority() { 393 $temp = array_merge( range( 1, 10 ), [ 20, 50, 100 ]);415 $temp = array_merge( range( 1, 10 ), array( 20, 50, 100 ) ); 394 416 $arr = array_combine( $temp, $temp ); 395 417 $selected = empty( $this->options->content_priority ) ? 10 : $this->options->content_priority; … … 430 452 * 431 453 * @since 1.0 432 *433 454 */ 434 455 $arr = (array) apply_filters( 'msls_admin_validate', $arr ); … … 458 479 return $arr; 459 480 } 460 461 481 } -
multisite-language-switcher/tags/2.7.1/includes/MslsAdminIcon.php
r3079846 r3091013 1 1 <?php 2 /**3 * MslsAdminIcon4 * @author Dennis Ploetner <re@lloc.de>5 * @since 0.9.86 */7 2 8 3 namespace lloc\Msls; … … 13 8 /** 14 9 * Handles the icon links in the backend 10 * 15 11 * @package Msls 16 12 */ … … 122 118 public function set_path(): MslsAdminIcon { 123 119 if ( 'post' != $this->type ) { 124 $query_vars = [ 'post_type' => $this->type ];120 $query_vars = array( 'post_type' => $this->type ); 125 121 $this->path = add_query_arg( $query_vars, $this->path ); 126 122 } … … 210 206 public function get_a(): string { 211 207 if ( empty( $this->href ) ) { 212 $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ), 213 $this->language ); 208 $title = sprintf( 209 __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ), 210 $this->language 211 ); 214 212 $href = $this->get_edit_new(); 215 213 } else { 216 $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ), 217 $this->language ); 214 $title = sprintf( 215 __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ), 216 $this->language 217 ); 218 218 $href = $this->href; 219 219 } … … 233 233 234 234 switch ( $this->icon_type ) { 235 case MslsAdminIcon::TYPE_FLAG: 236 $icon = sprintf( '<span class="flag-icon %s">%s</span>', 235 case self::TYPE_FLAG: 236 $icon = sprintf( 237 '<span class="flag-icon %s">%s</span>', 237 238 ( new IconSvg() )->get( $this->language ), 238 239 $this->language 239 240 ); 240 241 break; 241 case MslsAdminIcon::TYPE_LABEL: 242 $icon = sprintf( '<span class="language-badge %s">%s</span>', 242 case self::TYPE_LABEL: 243 $icon = sprintf( 244 '<span class="language-badge %s">%s</span>', 243 245 $this->language, 244 246 ( new IconLabel() )->get( $this->language ) … … 246 248 break; 247 249 default: 248 $icon = sprintf( '<span class="dashicons %s"></span>', 249 empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' ); 250 $icon = sprintf( 251 '<span class="dashicons %s"></span>', 252 empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' 253 ); 250 254 } 251 255 … … 262 266 263 267 if ( null !== $this->id && null !== $this->origin_language ) { 264 $path = add_query_arg( [ 'msls_id' => $this->id, 'msls_lang' => $this->origin_language ], $this->path ); 268 $path = add_query_arg( 269 array( 270 'msls_id' => $this->id, 271 'msls_lang' => $this->origin_language, 272 ), 273 $this->path 274 ); 265 275 } 266 276 … … 276 286 return get_admin_url( get_current_blog_id(), $path ); 277 287 } 278 279 288 } -
multisite-language-switcher/tags/2.7.1/includes/MslsAdminIconTaxonomy.php
r3088911 r3091013 1 1 <?php 2 /**3 * MslsAdminIconTaxonomy4 * @author Dennis Ploetner <re@lloc.de>5 * @since 0.9.86 */7 2 8 3 namespace lloc\Msls; … … 10 5 /** 11 6 * Handles backend icons for taxonomies 7 * 12 8 * @package Msls 13 9 */ … … 16 12 /** 17 13 * Path 14 * 18 15 * @var string 19 16 */ … … 29 26 */ 30 27 public function set_href( int $id ): MslsAdminIcon { 31 $object_type = MslsTaxonomy::instance()->get_post_type();28 $object_type = MslsTaxonomy::instance()->get_post_type(); 32 29 33 30 $this->href = get_edit_term_link( $id, $this->type, $object_type ); … … 40 37 * 41 38 * @return MslsAdminIconTaxonomy 42 *43 39 */ 44 40 public function set_path(): MslsAdminIcon { 45 $args = [ 'taxonomy' => $this->type ];41 $args = array( 'taxonomy' => $this->type ); 46 42 $post_type = MslsTaxonomy::instance()->get_post_type(); 47 43 48 $post_type !== '' && $args['post_type'] = $post_type;44 $post_type !== '' && $args['post_type'] = $post_type; 49 45 50 46 $this->path = add_query_arg( $args, $this->path ); … … 52 48 return $this; 53 49 } 54 55 50 } -
multisite-language-switcher/tags/2.7.1/includes/MslsBlog.php
r3079846 r3091013 1 <?php 1 <?php declare( strict_types=1 ); 2 2 3 3 namespace lloc\Msls; … … 13 13 /** 14 14 * WordPress generates such an object 15 * 15 16 * @var \StdClass 16 17 */ … … 18 19 19 20 /** 20 * Language-code eg. de_DE 21 * Language-code e.g. "de_DE", or "en_US", or "it_IT" 22 * 21 23 * @var string 22 24 */ 23 private $language; 24 25 /** 26 * Description eg. Deutsch 25 private string $language; 26 27 /** 28 * Description e.g. "Deutsch", or "English", or "Italiano" 29 * 27 30 * @var string 28 31 */ 29 private $description;32 private string $description; 30 33 31 34 /** … … 33 36 * 34 37 * @param ?\StdClass $obj 35 * @param string $description38 * @param string $description 36 39 */ 37 40 public function __construct( $obj, $description ) { … … 61 64 * 62 65 * The method returns the stored language if the description is empty. 66 * 63 67 * @return string 64 68 */ … … 77 81 $icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type ); 78 82 79 return sprintf( '%1$s %2$s', 83 return sprintf( 84 '%1$s %2$s', 80 85 $this->obj->blogname, 81 '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' ); 86 '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' 87 ); 82 88 } 83 89 … … 129 135 switch_to_blog( $this->obj->userblog_id ); 130 136 131 if ( is_object( $options ) && method_exists( $options, 132 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) { 137 if ( is_object( $options ) && method_exists( 138 $options, 139 'has_value' 140 ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) { 133 141 $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this ); 134 142 } … … 201 209 return $blavatar_html; 202 210 } 203 204 211 } -
multisite-language-switcher/tags/2.7.1/includes/MslsBlogCollection.php
r3088911 r3091013 1 <?php 2 /** 3 * MslsBlogCollection 4 * @author Dennis Ploetner <re@lloc.de> 5 * @since 0.9.8 6 */ 1 <?php declare( strict_types=1 ); 7 2 8 3 namespace lloc\Msls; … … 17 12 /** 18 13 * ID of the current blog 14 * 19 15 * @var int 20 16 */ … … 23 19 /** 24 20 * True if the current blog should be in the output 21 * 25 22 * @var bool 26 23 */ … … 29 26 /** 30 27 * Collection of MslsBlog-objects 28 * 31 29 * @var MslsBlog[] 32 30 */ 33 private $objects = [];31 private $objects = array(); 34 32 35 33 /** 36 34 * Order output by language or description 35 * 37 36 * @var string 38 37 */ … … 41 40 /** 42 41 * Active plugins in the whole network 42 * 43 43 * @var array 44 44 */ … … 47 47 /** 48 48 * Container for hreflang-mapping 49 * 49 50 * @var array 50 51 */ 51 private $hreflangmap = [];52 private $hreflangmap = array(); 52 53 53 54 /** … … 56 57 public function __construct() { 57 58 if ( ! has_filter( 'msls_blog_collection_description' ) ) { 58 add_filter( 'msls_blog_collection_description', [ $this, 'get_configured_blog_description' ], 10, 2 );59 add_filter( 'msls_blog_collection_description', array( $this, 'get_configured_blog_description' ), 10, 2 ); 59 60 } 60 61 … … 73 74 * 74 75 * @since 0.9.8 75 *76 76 */ 77 77 $blogs_collection = (array) apply_filters( … … 98 98 } 99 99 } 100 uasort( $this->objects, [ MslsBlog::class, $this->objects_order ]);100 uasort( $this->objects, array( MslsBlog::class, $this->objects_order ) ); 101 101 } 102 102 } … … 105 105 * Returns the description of a configured blog or false if it is not configured 106 106 * 107 * @param int $blog_id107 * @param int $blog_id 108 108 * @param string|bool $description 109 109 * … … 133 133 */ 134 134 public function get_blogs_of_reference_user( MslsOptions $options ) { 135 $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID', 136 1 ) ); 135 $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( 136 $this->get_users( 137 'ID', 138 1 139 ) 140 ); 137 141 $blogs = get_blogs_of_user( $reference_user ); 138 142 … … 185 189 /** 186 190 * Get the id of the current blog 191 * 187 192 * @return int 188 193 */ … … 213 218 /** 214 219 * Gets current blog as object 220 * 215 221 * @return MslsBlog|null 216 222 */ … … 221 227 /** 222 228 * Gets an array with all blog-objects 229 * 223 230 * @return MslsBlog[] 224 231 */ … … 236 243 public function is_plugin_active( $blog_id ) { 237 244 if ( ! is_array( $this->active_plugins ) ) { 238 $this->active_plugins = get_site_option( 'active_sitewide_plugins', []);245 $this->active_plugins = get_site_option( 'active_sitewide_plugins', array() ); 239 246 } 240 247 … … 244 251 } 245 252 246 $plugins = get_blog_option( $blog_id, 'active_plugins', []);253 $plugins = get_blog_option( $blog_id, 'active_plugins', array() ); 247 254 248 255 return in_array( $path, $plugins ); … … 251 258 /** 252 259 * Gets only blogs where the plugin is active 260 * 253 261 * @return array 254 262 */ 255 263 public function get_plugin_active_blogs() { 256 $arr = [];264 $arr = array(); 257 265 258 266 foreach ( $this->get_objects() as $blog ) { … … 267 275 /** 268 276 * Gets an array of all - but not the current - blog-objects 277 * 269 278 * @return MslsBlog[] 270 279 */ … … 286 295 * @return MslsBlog[] 287 296 */ 288 public function get_filtered( $filter = false ) { 289 if ( ! $filter && $this->current_blog_output ) { 290 return $this->get_objects(); 291 } 292 293 return $this->get(); 297 public function get_filtered( bool $filter = false ): array { 298 return ! $filter && $this->current_blog_output ? $this->get_objects() : $this->get(); 294 299 } 295 300 … … 297 302 * Gets the registered users of the current blog 298 303 * 299 * @param string $fields304 * @param string $fields 300 305 * @param int|string $number 301 306 * … … 303 308 */ 304 309 public function get_users( $fields = 'all', $number = '' ) { 305 $args = [310 $args = array( 306 311 'blog_id' => $this->current_blog_id, 307 312 'orderby' => 'registered', … … 309 314 'number' => $number, 310 315 'count_total' => false, 311 ];316 ); 312 317 313 318 $args = (array) apply_filters( 'msls_get_users', $args ); … … 319 324 * Returns a specific blog language. 320 325 * 321 * @param int $blog_id326 * @param int $blog_id 322 327 * @param string $default 323 328 * … … 329 334 } 330 335 331 $language = ( string) get_blog_option( $blog_id, 'WPLANG' );336 $language = (string) get_blog_option( $blog_id, 'WPLANG' ); 332 337 333 338 return '' !== $language ? $language : $default; 334 339 } 335 336 340 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptions.php
r3088911 r3091013 2 2 /** 3 3 * MslsOptions 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 12 13 /** 13 14 * General options class 15 * 14 16 * @package Msls 15 17 * @property bool $activate_autocomplete … … 30 32 /** 31 33 * Args 34 * 32 35 * @var array 33 36 */ … … 36 39 /** 37 40 * Name 41 * 38 42 * @var string 39 43 */ … … 42 46 /** 43 47 * Exists 48 * 44 49 * @var bool 45 50 */ … … 48 53 /** 49 54 * Separator 55 * 50 56 * @var string 51 57 */ … … 54 60 /** 55 61 * Autoload 62 * 56 63 * @var string 57 64 */ … … 60 67 /** 61 68 * Available languages 62 * @var array 63 */ 64 private $available_languages; 69 * 70 * @var array<string, string> 71 */ 72 private array $available_languages; 65 73 66 74 /** 67 75 * Rewrite with front 76 * 68 77 * @var bool 69 78 */ … … 100 109 } 101 110 102 add_filter( ' check_url', [ $options, 'check_for_blog_slug' ], 10, 2 );111 add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 ); 103 112 104 113 return $options; … … 107 116 /** 108 117 * Determines if the current page is the main page (front page, search, 404). 109 *110 * @return boolean118 * 119 * @return boolean 111 120 */ 112 121 public static function is_main_page() { … … 116 125 /** 117 126 * Determines if the current page is a category, tag or taxonomy page. 118 *127 * 119 128 * @return boolean 120 129 */ … … 125 134 /** 126 135 * Determines if the current page is an archive page for a date, author, or any other post type. 127 *136 * 128 137 * @return boolean 129 138 */ … … 143 152 /** 144 153 * Gets an element of arg by index 145 *146 * The returned value will either be cast to the type of `$ retval` or, if nothing is set at this index, it will be the value of `$retval`.147 * 148 * @param int $idx149 * @param mixed $ val154 * 155 * The returned value will either be cast to the type of `$default` or, if nothing is set at this index, it will be the value of `$default`. 156 * 157 * @param int $index 158 * @param mixed $default 150 159 * 151 160 * @return mixed 152 161 */ 153 public function get_arg( $idx, $val = null ) { 154 $arg = isset( $this->args[ $idx ] ) ? $this->args[ $idx ] : $val; 155 settype( $arg, gettype( $val ) ); 162 public function get_arg( int $index, $default = null ) { 163 $arg = $this->args[ $index ] ?? $default; 164 165 settype( $arg, gettype( $default ) ); 156 166 157 167 return $arg; … … 177 187 /** 178 188 * Delete 189 * 179 190 * @codeCoverageIgnore 180 191 */ … … 201 212 * Mapping for us language code 202 213 */ 203 $map = [ 'us' => 'en_US', 'en' => 'en_US' ]; 214 $map = array( 215 'us' => 'en_US', 216 'en' => 'en_US', 217 ); 204 218 foreach ( $map as $old => $new ) { 205 219 if ( isset( $arr[ $old ] ) ) { … … 230 244 * 231 245 * @since 0.9.8 232 *233 246 */ 234 247 $postlink = (string) apply_filters( … … 254 267 /** 255 268 * Get the queried taxonomy 269 * 256 270 * @return string 257 271 */ … … 262 276 /** 263 277 * Get current link 278 * 264 279 * @return string 265 280 */ … … 270 285 /** 271 286 * Is excluded 287 * 272 288 * @return bool 273 289 */ … … 278 294 /** 279 295 * Is content 296 * 280 297 * @return bool 281 298 */ … … 286 303 /** 287 304 * Get order 305 * 288 306 * @return string 289 307 */ … … 306 324 * Returns slug for a post type 307 325 * 326 * @todo This method is not used anywhere in the codebase. Should it be removed? 327 * 308 328 * @param string $post_type 309 329 * 310 330 * @return string 311 331 */ 312 public function get_slug( $post_type ){332 public function get_slug( string $post_type ): string { 313 333 $key = "rewrite_{$post_type}"; 314 334 315 error_log( $key ); 316 317 return isset( $this->$key ) ? $this->$key : ''; 335 return $this->$key ?? ''; 318 336 } 319 337 … … 335 353 */ 336 354 public function get_flag_url( $language ) { 337 if ( ! is_admin() && isset( $this->image_url ) ) { 338 $url = $this->__get( 'image_url' ); 339 } else { 340 $url = $this->get_url( 'flags' ); 341 } 355 $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' ); 342 356 343 357 /** … … 347 361 * 348 362 * @since 0.9.9 349 *350 363 */ 351 364 $url = (string) apply_filters( 'msls_options_get_flag_url', $url ); … … 360 373 * 361 374 * @since 1.0.3 362 *363 375 */ 364 376 $icon = (string) apply_filters( 'msls_options_get_flag_icon', $icon, $language ); … … 376 388 public function get_available_languages() { 377 389 if ( empty( $this->available_languages ) ) { 378 $this->available_languages = [390 $this->available_languages = array( 379 391 'en_US' => __( 'American English', 'multisite-language-switcher' ), 380 ];392 ); 381 393 382 394 foreach ( get_available_languages() as $code ) { … … 390 402 * 391 403 * @since 1.0 392 *393 404 */ 394 405 $this->available_languages = (array) apply_filters( … … 404 415 * The 'blog'-slug-problem :/ 405 416 * 406 * @param string $url417 * @param string $url 407 418 * @param MslsOptions $options 408 419 * … … 444 455 return MslsAdminIcon::TYPE_LABEL === $this->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG; 445 456 } 446 447 457 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsPost.php
r3079846 r3091013 1 <?php 2 /** 3 * MslsOptionsPost 4 * @author Dennis Ploetner <re@lloc.de> 5 * @since 0.9.8 6 */ 1 <?php declare( strict_types=1 ); 7 2 8 3 namespace lloc\Msls; … … 10 5 /** 11 6 * Post options 7 * 12 8 * @package Msls 13 9 */ … … 16 12 /** 17 13 * Separator 14 * 18 15 * @var string 19 16 */ … … 22 19 /** 23 20 * Autoload 21 * 24 22 * @var string 25 23 */ … … 48 46 } 49 47 50 global $current_site; 51 $blog_id = msls_blog_collection()->get_blog_id( $language ); 52 if ( $current_site->blog_id != $blog_id ) { 53 $option = get_blog_option( $blog_id, 'msls' ); 54 //error_log( print_r( $option, true ) ); 55 } 48 $post_link = get_permalink( $post ); 56 49 57 return apply_filters( 'check_url', get_permalink( $post ), $this ); 50 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 51 52 return apply_filters( 'msls_get_postlink', $post_link, $this ); 58 53 } 59 54 … … 66 61 return (string) get_permalink( $this->get_arg( 0, 0 ) ); 67 62 } 68 69 63 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQuery.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQuery 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 17 18 /** 18 19 * Rewrite with front 20 * 19 21 * @var bool 20 22 */ … … 62 64 public function get_postlink( $language ) { 63 65 if ( $this->has_value( $language ) ) { 64 $link = $this->get_current_link(); 65 if ( ! empty( $link ) ) { 66 return apply_filters( 'check_url', $link, $this ); 66 $post_link = $this->get_current_link(); 67 if ( ! empty( $post_link ) ) { 68 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 69 70 return apply_filters( 'msls_get_postlink', $post_link, $this ); 67 71 } 68 72 } … … 70 74 return ''; 71 75 } 72 73 76 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryAuthor.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQueryAuthor 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 45 46 return get_author_posts_url( $this->get_arg( 0, 0 ) ); 46 47 } 47 48 48 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryPostType.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQueryPostType 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 38 39 return (string) get_post_type_archive_link( $this->get_arg( 0, '' ) ); 39 40 } 40 41 41 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryYear.php
r1990702 r3091013 2 2 /** 3 3 * MslsOptionsQueryYear 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 45 46 return get_year_link( $this->get_arg( 0, 0 ) ); 46 47 } 47 48 48 } -
multisite-language-switcher/tags/2.7.1/includes/MslsOptionsTax.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsTax 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 10 11 /** 11 12 * Taxonomy options 13 * 12 14 * @package Msls 13 15 */ … … 16 18 /** 17 19 * Separator 20 * 18 21 * @var string 19 22 */ … … 22 25 /** 23 26 * Autoload 27 * 24 28 * @var string 25 29 */ … … 59 63 60 64 if ( $req ) { 61 add_filter( ' check_url', [ $options, 'check_base' ], 9, 2 );65 add_filter( 'msls_get_postlink', array( $options, 'check_base' ), 9, 2 ); 62 66 } else { 63 67 global $wp_rewrite; … … 71 75 /** 72 76 * Get the queried taxonomy 77 * 73 78 * @return string 74 79 */ … … 93 98 */ 94 99 public function get_postlink( $language ) { 95 $ url= '';100 $post_link = ''; 96 101 97 102 if ( $this->has_value( $language ) ) { 98 $ url= $this->get_term_link( (int) $this->__get( $language ) );103 $post_link = $this->get_term_link( (int) $this->__get( $language ) ); 99 104 } 100 105 101 return apply_filters( 'check_url', $url, $this ); 106 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 107 108 return apply_filters( 'msls_get_postlink', $post_link, $this ); 102 109 } 103 110 104 111 /** 105 112 * Get current link 113 * 106 114 * @return string 107 115 */ … … 130 138 return ''; 131 139 } 132 133 140 } -
multisite-language-switcher/tags/2.7.1/includes/MslsPlugin.php
r3088911 r3091013 250 250 */ 251 251 public function admin_bar_init() { 252 if ( is_admin_bar_showing() && is_super_admin()) {252 if ( is_admin_bar_showing() ) { 253 253 add_action( 'admin_bar_menu', array( __CLASS__, 'update_adminbar' ), 999 ); 254 254 -
multisite-language-switcher/tags/2.7.1/includes/MslsPostTag.php
r3088911 r3091013 1 <?php 1 <?php declare( strict_types=1 ); 2 2 3 /** 3 4 * MslsPostTag 4 5 * 5 6 * @author Dennis Ploetner <re@lloc.de> 6 * @since 0.9.87 7 */ 8 8 … … 30 30 ); 31 31 32 $args = [32 $args = array( 33 33 'orderby' => 'name', 34 34 'order' => 'ASC', 35 35 'number' => 10, 36 36 'hide_empty' => 0, 37 ];37 ); 38 38 39 39 if ( filter_has_var( INPUT_POST, 's' ) ) { … … 82 82 $options = msls_options(); 83 83 $collection = msls_blog_collection(); 84 $class = $options->activate_autocomplete ? MslsPostTag::class : MslsPostTagClassic::class;84 $class = $options->activate_autocomplete ? self::class : MslsPostTagClassic::class; 85 85 $obj = new $class( $options, $collection ); 86 86 87 87 $taxonomy = MslsContentTypes::create()->acl_request(); 88 88 if ( '' != $taxonomy ) { 89 add_action( "{$taxonomy}_add_form_fields", [ $obj, 'add_input' ]);90 add_action( "{$taxonomy}_edit_form_fields", [ $obj, 'edit_input' ], 10, 2 );91 add_action( "edited_{$taxonomy}", [ $obj, 'set' ]);92 add_action( "create_{$taxonomy}", [ $obj, 'set' ]);89 add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) ); 90 add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 ); 91 add_action( "edited_{$taxonomy}", array( $obj, 'set' ) ); 92 add_action( "create_{$taxonomy}", array( $obj, 'set' ) ); 93 93 } 94 94 … … 119 119 * 120 120 * @param \WP_Term $tag 121 * @param string $taxonomy121 * @param string $taxonomy 122 122 */ 123 123 public function edit_input( \WP_Term $tag, string $taxonomy ): void { … … 149 149 * 150 150 * @param ?\WP_Term $tag 151 * @param string $title_format152 * @param string $item_format151 * @param string $title_format 152 * @param string $item_format 153 153 * 154 154 * @return boolean … … 161 161 } 162 162 163 $count ++;163 ++$count; 164 164 165 165 $blogs = $this->collection->get(); … … 259 259 */ 260 260 protected function get_select_title(): string { 261 return apply_filters( 'msls_term_select_title', 262 __( 'Multisite Language Switcher', 'multisite-language-switcher' ) ); 263 } 264 261 return apply_filters( 262 'msls_term_select_title', 263 __( 'Multisite Language Switcher', 'multisite-language-switcher' ) 264 ); 265 } 265 266 } -
multisite-language-switcher/tags/2.7.1/js/msls-widget-block/block.json
r3088911 r3091013 6 6 "category": "widgets", 7 7 "name": "lloc/msls-widget-block", 8 "version": "2.7. 0",8 "version": "2.7.1", 9 9 "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.", 10 10 "example": {}, -
multisite-language-switcher/tags/2.7.1/readme.txt
r3088911 r3091013 7 7 Tested up to: 6.5 8 8 Requires PHP: 7.4 9 Stable tag: 2.7. 09 Stable tag: 2.7.1 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
multisite-language-switcher/tags/2.7.1/src/msls-widget-block/block.json
r3088911 r3091013 6 6 "category": "widgets", 7 7 "name": "lloc/msls-widget-block", 8 "version": "2.7. 0",8 "version": "2.7.1", 9 9 "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.", 10 10 "example": {}, -
multisite-language-switcher/tags/2.7.1/vendor/composer/installed.php
r3088911 r3091013 2 2 'root' => array( 3 3 'name' => 'lloc/multisite-language-switcher', 4 'pretty_version' => '2.7. 0',5 'version' => '2.7. 0.0',6 'reference' => ' 285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',4 'pretty_version' => '2.7.1', 5 'version' => '2.7.1.0', 6 'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'lloc/multisite-language-switcher' => array( 23 'pretty_version' => '2.7. 0',24 'version' => '2.7. 0.0',25 'reference' => ' 285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',23 'pretty_version' => '2.7.1', 24 'version' => '2.7.1.0', 25 'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916', 26 26 'type' => 'wordpress-plugin', 27 27 'install_path' => __DIR__ . '/../../', -
multisite-language-switcher/trunk/MultisiteLanguageSwitcher.php
r3088911 r3091013 8 8 * 9 9 * Plugin Name: Multisite Language Switcher 10 * Version: 2.7. 010 * Version: 2.7.1 11 11 * Plugin URI: http://msls.co/ 12 12 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation. … … 41 41 */ 42 42 if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) { 43 define( 'MSLS_PLUGIN_VERSION', '2.7. 0' );43 define( 'MSLS_PLUGIN_VERSION', '2.7.1' ); 44 44 define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) ); 45 45 define( 'MSLS_PLUGIN__FILE__', __FILE__ ); -
multisite-language-switcher/trunk/includes/MslsAdmin.php
r3088911 r3091013 50 50 * 51 51 * @since 2.0 52 *53 52 */ 54 53 $caps = apply_filters( 'msls_admin_caps', 'manage_options' ); 55 54 if ( current_user_can( $caps ) ) { 56 55 $title = __( 'Multisite Language Switcher', 'multisite-language-switcher' ); 57 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), [ $obj, 'render' ]);58 59 add_action( 'admin_init', [ $obj, 'register' ]);60 add_action( 'admin_notices', [ $obj, 'has_problems' ]);61 62 add_filter( 'msls_admin_validate', [ $obj, 'set_blog_language' ]);56 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), array( $obj, 'render' ) ); 57 58 add_action( 'admin_init', array( $obj, 'register' ) ); 59 add_action( 'admin_notices', array( $obj, 'has_problems' ) ); 60 61 add_filter( 'msls_admin_validate', array( $obj, 'set_blog_language' ) ); 63 62 } 64 63 } … … 89 88 * 90 89 * @param string $method 91 * @param mixed $args90 * @param mixed $args 92 91 * 93 92 * @return mixed … … 97 96 98 97 if ( is_array( $parts ) && 'rewrite' === $parts[0] ) { 99 return $this->render_rewrite( $parts[1] ); 100 } 101 102 $checkboxes = [ 103 'activate_autocomplete' => __( 'Activate experimental autocomplete inputs', 104 'multisite-language-switcher' ), 105 'activate_content_import' => __( 'Activate the content import functionality', 106 'multisite-language-switcher' ), 98 $this->render_rewrite( $parts[1] ); 99 return; 100 } 101 102 $checkboxes = array( 103 'activate_autocomplete' => __( 104 'Activate experimental autocomplete inputs', 105 'multisite-language-switcher' 106 ), 107 'activate_content_import' => __( 108 'Activate the content import functionality', 109 'multisite-language-switcher' 110 ), 107 111 'sort_by_description' => __( 'Sort languages by description', 'multisite-language-switcher' ), 108 112 'exclude_current_blog' => __( 'Exclude this blog from output', 'multisite-language-switcher' ), … … 110 114 'output_current_blog' => __( 'Display link to the current language', 'multisite-language-switcher' ), 111 115 'content_filter' => __( 'Add hint for available translations', 'multisite-language-switcher' ), 112 ]; 113 114 if ( isset ( $checkboxes[ $method ] ) ) { 115 echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( new Label( $method, 116 $checkboxes[ $method ] ) )->render(); 116 ); 117 118 if ( isset( $checkboxes[ $method ] ) ) { 119 echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( 120 new Label( 121 $method, 122 $checkboxes[ $method ] 123 ) 124 )->render(); 117 125 } else { 118 126 $value = ! empty( $this->options->$method ) ? $this->options->$method : ''; … … 123 131 /** 124 132 * There is something wrong? Here comes the message... 133 * 125 134 * @return bool 126 135 */ 127 public function has_problems() {136 public function has_problems(): bool { 128 137 $message = ''; 129 138 130 139 if ( $this->options->is_empty() ) { 131 140 $message = sprintf( 132 __( 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.', 133 'multisite-language-switcher' ), 141 __( 142 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.', 143 'multisite-language-switcher' 144 ), 134 145 esc_url( admin_url( $this->get_options_page_link() ) ) 135 146 ); 136 147 } elseif ( 1 == count( $this->options->get_available_languages() ) ) { 137 148 $message = sprintf( 138 __( 'There are no language files installed. You can <a href="%s">manually install some language files</a> or you could use a <a href="%s">plugin</a> to download these files automatically.', 139 'multisite-language-switcher' ), 149 __( 150 'There are no language files installed. You can <a href="%1$s">manually install some language files</a> or you could use a <a href="%2$s">plugin</a> to download these files automatically.', 151 'multisite-language-switcher' 152 ), 140 153 esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ), 141 154 esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' ) … … 149 162 * Render the options-page 150 163 */ 151 public function render() {164 public function render(): void { 152 165 printf( 153 166 '<div class="wrap"><div class="icon32" id="icon-options-general"><br/></div><h1>%s</h1>%s<br class="clear"/><form action="options.php" method="post"><p>%s</p>', 154 167 __( 'Multisite Language Switcher Options', 'multisite-language-switcher' ), 155 168 $this->subsubsub(), 156 __( 'To achieve maximum flexibility, you have to configure each blog separately.', 157 'multisite-language-switcher' ) 169 __( 170 'To achieve maximum flexibility, you have to configure each blog separately.', 171 'multisite-language-switcher' 172 ) 158 173 ); 159 174 … … 163 178 printf( 164 179 '<p class="submit"><input name="Submit" type="submit" class="button button-primary" value="%s" /></p></form></div>', 165 ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 'Update', 166 'multisite-language-switcher' ) ) 180 ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 181 'Update', 182 'multisite-language-switcher' 183 ) ) 167 184 ); 168 185 } … … 171 188 /** 172 189 * Create a submenu which contains links to all blogs of the current user 190 * 173 191 * @return string 174 192 */ … … 176 194 $icon_type = $this->options->get_icon_type(); 177 195 178 $arr = [];196 $arr = array(); 179 197 foreach ( $this->collection->get_plugin_active_blogs() as $blog ) { 180 198 $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() ); … … 184 202 } 185 203 186 return empty( $arr ) ? '' : sprintf( '<ul class="subsubsub"><li>%s</li></ul>', 187 implode( ' | </li><li>', $arr ) ); 204 return empty( $arr ) ? '' : sprintf( 205 '<ul class="subsubsub"><li>%s</li></ul>', 206 implode( ' | </li><li>', $arr ) 207 ); 188 208 } 189 209 … … 194 214 */ 195 215 public function register() { 196 register_setting( 'msls', 'msls', [ $this, 'validate' ]);197 198 $sections = [216 register_setting( 'msls', 'msls', array( $this, 'validate' ) ); 217 218 $sections = array( 199 219 'language_section' => __( 'Language Settings', 'multisite-language-switcher' ), 200 220 'main_section' => __( 'Main Settings', 'multisite-language-switcher' ), 201 221 'advanced_section' => __( 'Advanced Settings', 'multisite-language-switcher' ), 202 ];222 ); 203 223 204 224 global $wp_rewrite; … … 208 228 209 229 foreach ( $sections as $id => $title ) { 210 add_settings_section( $id, $title, [ $this, $id ], __CLASS__ );230 add_settings_section( $id, $title, array( $this, $id ), __CLASS__ ); 211 231 } 212 232 … … 217 237 * 218 238 * @since 1.0 219 *220 239 */ 221 240 do_action( 'msls_admin_register', __CLASS__ ); … … 230 249 */ 231 250 public function language_section(): int { 232 $map = [ 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ];251 $map = array( 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ); 233 252 234 253 return $this->add_settings_fields( $map, 'language_section' ); … … 243 262 */ 244 263 public function main_section(): int { 245 $map = [264 $map = array( 246 265 'display' => __( 'Display', 'multisite-language-switcher' ), 247 266 'admin_display' => __( 'Admin Display', 'multisite-language-switcher' ), … … 256 275 'content_filter' => __( 'Available translations hint', 'multisite-language-switcher' ), 257 276 'content_priority' => __( 'Hint priority', 'multisite-language-switcher' ), 258 ];277 ); 259 278 260 279 return $this->add_settings_fields( $map, 'main_section' ); … … 269 288 */ 270 289 public function advanced_section(): int { 271 $map = [290 $map = array( 272 291 'activate_autocomplete' => __( 'Autocomplete', 'multisite-language-switcher' ), 273 292 'image_url' => __( 'Custom URL for flag-images', 'multisite-language-switcher' ), … … 275 294 'exclude_current_blog' => __( 'Exclude blog', 'multisite-language-switcher' ), 276 295 'activate_content_import' => __( 'Content import', 'multisite-language-switcher' ), 277 ];296 ); 278 297 279 298 return $this->add_settings_fields( $map, 'advanced_section' ); … … 288 307 */ 289 308 public function rewrites_section(): int { 290 $map = [];291 foreach ( get_post_types( [ 'public' => true ], 'objects' ) as $key => $object ) {292 $map[ "rewrite_{$key}"] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );309 $map = array(); 310 foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $key => $object ) { 311 $map[ "rewrite_{$key}" ] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label ); 293 312 } 294 313 … … 297 316 298 317 /** 299 * @param array $map318 * @param array $map 300 319 * @param string $section 301 320 * … … 304 323 protected function add_settings_fields( array $map, string $section ): int { 305 324 foreach ( $map as $id => $title ) { 306 add_settings_field( $id, $title, [ $this, $id ], __CLASS__, $section, [ 'label_for' => $id ]);325 add_settings_field( $id, $title, array( $this, $id ), __CLASS__, $section, array( 'label_for' => $id ) ); 307 326 } 308 327 … … 314 333 * 315 334 * @since 2.4.4 316 *317 335 */ 318 336 do_action( "msls_admin_{$section}", __CLASS__, $section ); … … 342 360 */ 343 361 public function admin_display() { 344 echo ( new Select( 'admin_display', 362 echo ( new Select( 363 'admin_display', 345 364 array( 346 365 'flag' => __( 'Flag', 'multisite-language-switcher' ), 347 'label' => __( 'Label', 'multisite-language-switcher' ) 366 'label' => __( 'Label', 'multisite-language-switcher' ), 348 367 ), 349 $this->options->admin_display ) )->render(); 368 $this->options->admin_display 369 ) )->render(); 350 370 } 351 371 … … 354 374 */ 355 375 public function reference_user() { 356 $users = [];357 358 foreach ( ( array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {376 $users = array(); 377 378 foreach ( (array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) { 359 379 $users[ $user->ID ] = $user->user_nicename; 360 380 } … … 364 384 365 385 $message = sprintf( 366 __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!', 367 'multisite-language-switcher' ), 386 __( 387 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!', 388 'multisite-language-switcher' 389 ), 368 390 self::MAX_REFERENCE_USERS 369 391 ); … … 391 413 */ 392 414 public function content_priority() { 393 $temp = array_merge( range( 1, 10 ), [ 20, 50, 100 ]);415 $temp = array_merge( range( 1, 10 ), array( 20, 50, 100 ) ); 394 416 $arr = array_combine( $temp, $temp ); 395 417 $selected = empty( $this->options->content_priority ) ? 10 : $this->options->content_priority; … … 430 452 * 431 453 * @since 1.0 432 *433 454 */ 434 455 $arr = (array) apply_filters( 'msls_admin_validate', $arr ); … … 458 479 return $arr; 459 480 } 460 461 481 } -
multisite-language-switcher/trunk/includes/MslsAdminIcon.php
r3079846 r3091013 1 1 <?php 2 /**3 * MslsAdminIcon4 * @author Dennis Ploetner <re@lloc.de>5 * @since 0.9.86 */7 2 8 3 namespace lloc\Msls; … … 13 8 /** 14 9 * Handles the icon links in the backend 10 * 15 11 * @package Msls 16 12 */ … … 122 118 public function set_path(): MslsAdminIcon { 123 119 if ( 'post' != $this->type ) { 124 $query_vars = [ 'post_type' => $this->type ];120 $query_vars = array( 'post_type' => $this->type ); 125 121 $this->path = add_query_arg( $query_vars, $this->path ); 126 122 } … … 210 206 public function get_a(): string { 211 207 if ( empty( $this->href ) ) { 212 $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ), 213 $this->language ); 208 $title = sprintf( 209 __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ), 210 $this->language 211 ); 214 212 $href = $this->get_edit_new(); 215 213 } else { 216 $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ), 217 $this->language ); 214 $title = sprintf( 215 __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ), 216 $this->language 217 ); 218 218 $href = $this->href; 219 219 } … … 233 233 234 234 switch ( $this->icon_type ) { 235 case MslsAdminIcon::TYPE_FLAG: 236 $icon = sprintf( '<span class="flag-icon %s">%s</span>', 235 case self::TYPE_FLAG: 236 $icon = sprintf( 237 '<span class="flag-icon %s">%s</span>', 237 238 ( new IconSvg() )->get( $this->language ), 238 239 $this->language 239 240 ); 240 241 break; 241 case MslsAdminIcon::TYPE_LABEL: 242 $icon = sprintf( '<span class="language-badge %s">%s</span>', 242 case self::TYPE_LABEL: 243 $icon = sprintf( 244 '<span class="language-badge %s">%s</span>', 243 245 $this->language, 244 246 ( new IconLabel() )->get( $this->language ) … … 246 248 break; 247 249 default: 248 $icon = sprintf( '<span class="dashicons %s"></span>', 249 empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' ); 250 $icon = sprintf( 251 '<span class="dashicons %s"></span>', 252 empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' 253 ); 250 254 } 251 255 … … 262 266 263 267 if ( null !== $this->id && null !== $this->origin_language ) { 264 $path = add_query_arg( [ 'msls_id' => $this->id, 'msls_lang' => $this->origin_language ], $this->path ); 268 $path = add_query_arg( 269 array( 270 'msls_id' => $this->id, 271 'msls_lang' => $this->origin_language, 272 ), 273 $this->path 274 ); 265 275 } 266 276 … … 276 286 return get_admin_url( get_current_blog_id(), $path ); 277 287 } 278 279 288 } -
multisite-language-switcher/trunk/includes/MslsAdminIconTaxonomy.php
r3088911 r3091013 1 1 <?php 2 /**3 * MslsAdminIconTaxonomy4 * @author Dennis Ploetner <re@lloc.de>5 * @since 0.9.86 */7 2 8 3 namespace lloc\Msls; … … 10 5 /** 11 6 * Handles backend icons for taxonomies 7 * 12 8 * @package Msls 13 9 */ … … 16 12 /** 17 13 * Path 14 * 18 15 * @var string 19 16 */ … … 29 26 */ 30 27 public function set_href( int $id ): MslsAdminIcon { 31 $object_type = MslsTaxonomy::instance()->get_post_type();28 $object_type = MslsTaxonomy::instance()->get_post_type(); 32 29 33 30 $this->href = get_edit_term_link( $id, $this->type, $object_type ); … … 40 37 * 41 38 * @return MslsAdminIconTaxonomy 42 *43 39 */ 44 40 public function set_path(): MslsAdminIcon { 45 $args = [ 'taxonomy' => $this->type ];41 $args = array( 'taxonomy' => $this->type ); 46 42 $post_type = MslsTaxonomy::instance()->get_post_type(); 47 43 48 $post_type !== '' && $args['post_type'] = $post_type;44 $post_type !== '' && $args['post_type'] = $post_type; 49 45 50 46 $this->path = add_query_arg( $args, $this->path ); … … 52 48 return $this; 53 49 } 54 55 50 } -
multisite-language-switcher/trunk/includes/MslsBlog.php
r3079846 r3091013 1 <?php 1 <?php declare( strict_types=1 ); 2 2 3 3 namespace lloc\Msls; … … 13 13 /** 14 14 * WordPress generates such an object 15 * 15 16 * @var \StdClass 16 17 */ … … 18 19 19 20 /** 20 * Language-code eg. de_DE 21 * Language-code e.g. "de_DE", or "en_US", or "it_IT" 22 * 21 23 * @var string 22 24 */ 23 private $language; 24 25 /** 26 * Description eg. Deutsch 25 private string $language; 26 27 /** 28 * Description e.g. "Deutsch", or "English", or "Italiano" 29 * 27 30 * @var string 28 31 */ 29 private $description;32 private string $description; 30 33 31 34 /** … … 33 36 * 34 37 * @param ?\StdClass $obj 35 * @param string $description38 * @param string $description 36 39 */ 37 40 public function __construct( $obj, $description ) { … … 61 64 * 62 65 * The method returns the stored language if the description is empty. 66 * 63 67 * @return string 64 68 */ … … 77 81 $icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type ); 78 82 79 return sprintf( '%1$s %2$s', 83 return sprintf( 84 '%1$s %2$s', 80 85 $this->obj->blogname, 81 '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' ); 86 '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' 87 ); 82 88 } 83 89 … … 129 135 switch_to_blog( $this->obj->userblog_id ); 130 136 131 if ( is_object( $options ) && method_exists( $options, 132 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) { 137 if ( is_object( $options ) && method_exists( 138 $options, 139 'has_value' 140 ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) { 133 141 $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this ); 134 142 } … … 201 209 return $blavatar_html; 202 210 } 203 204 211 } -
multisite-language-switcher/trunk/includes/MslsBlogCollection.php
r3088911 r3091013 1 <?php 2 /** 3 * MslsBlogCollection 4 * @author Dennis Ploetner <re@lloc.de> 5 * @since 0.9.8 6 */ 1 <?php declare( strict_types=1 ); 7 2 8 3 namespace lloc\Msls; … … 17 12 /** 18 13 * ID of the current blog 14 * 19 15 * @var int 20 16 */ … … 23 19 /** 24 20 * True if the current blog should be in the output 21 * 25 22 * @var bool 26 23 */ … … 29 26 /** 30 27 * Collection of MslsBlog-objects 28 * 31 29 * @var MslsBlog[] 32 30 */ 33 private $objects = [];31 private $objects = array(); 34 32 35 33 /** 36 34 * Order output by language or description 35 * 37 36 * @var string 38 37 */ … … 41 40 /** 42 41 * Active plugins in the whole network 42 * 43 43 * @var array 44 44 */ … … 47 47 /** 48 48 * Container for hreflang-mapping 49 * 49 50 * @var array 50 51 */ 51 private $hreflangmap = [];52 private $hreflangmap = array(); 52 53 53 54 /** … … 56 57 public function __construct() { 57 58 if ( ! has_filter( 'msls_blog_collection_description' ) ) { 58 add_filter( 'msls_blog_collection_description', [ $this, 'get_configured_blog_description' ], 10, 2 );59 add_filter( 'msls_blog_collection_description', array( $this, 'get_configured_blog_description' ), 10, 2 ); 59 60 } 60 61 … … 73 74 * 74 75 * @since 0.9.8 75 *76 76 */ 77 77 $blogs_collection = (array) apply_filters( … … 98 98 } 99 99 } 100 uasort( $this->objects, [ MslsBlog::class, $this->objects_order ]);100 uasort( $this->objects, array( MslsBlog::class, $this->objects_order ) ); 101 101 } 102 102 } … … 105 105 * Returns the description of a configured blog or false if it is not configured 106 106 * 107 * @param int $blog_id107 * @param int $blog_id 108 108 * @param string|bool $description 109 109 * … … 133 133 */ 134 134 public function get_blogs_of_reference_user( MslsOptions $options ) { 135 $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID', 136 1 ) ); 135 $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( 136 $this->get_users( 137 'ID', 138 1 139 ) 140 ); 137 141 $blogs = get_blogs_of_user( $reference_user ); 138 142 … … 185 189 /** 186 190 * Get the id of the current blog 191 * 187 192 * @return int 188 193 */ … … 213 218 /** 214 219 * Gets current blog as object 220 * 215 221 * @return MslsBlog|null 216 222 */ … … 221 227 /** 222 228 * Gets an array with all blog-objects 229 * 223 230 * @return MslsBlog[] 224 231 */ … … 236 243 public function is_plugin_active( $blog_id ) { 237 244 if ( ! is_array( $this->active_plugins ) ) { 238 $this->active_plugins = get_site_option( 'active_sitewide_plugins', []);245 $this->active_plugins = get_site_option( 'active_sitewide_plugins', array() ); 239 246 } 240 247 … … 244 251 } 245 252 246 $plugins = get_blog_option( $blog_id, 'active_plugins', []);253 $plugins = get_blog_option( $blog_id, 'active_plugins', array() ); 247 254 248 255 return in_array( $path, $plugins ); … … 251 258 /** 252 259 * Gets only blogs where the plugin is active 260 * 253 261 * @return array 254 262 */ 255 263 public function get_plugin_active_blogs() { 256 $arr = [];264 $arr = array(); 257 265 258 266 foreach ( $this->get_objects() as $blog ) { … … 267 275 /** 268 276 * Gets an array of all - but not the current - blog-objects 277 * 269 278 * @return MslsBlog[] 270 279 */ … … 286 295 * @return MslsBlog[] 287 296 */ 288 public function get_filtered( $filter = false ) { 289 if ( ! $filter && $this->current_blog_output ) { 290 return $this->get_objects(); 291 } 292 293 return $this->get(); 297 public function get_filtered( bool $filter = false ): array { 298 return ! $filter && $this->current_blog_output ? $this->get_objects() : $this->get(); 294 299 } 295 300 … … 297 302 * Gets the registered users of the current blog 298 303 * 299 * @param string $fields304 * @param string $fields 300 305 * @param int|string $number 301 306 * … … 303 308 */ 304 309 public function get_users( $fields = 'all', $number = '' ) { 305 $args = [310 $args = array( 306 311 'blog_id' => $this->current_blog_id, 307 312 'orderby' => 'registered', … … 309 314 'number' => $number, 310 315 'count_total' => false, 311 ];316 ); 312 317 313 318 $args = (array) apply_filters( 'msls_get_users', $args ); … … 319 324 * Returns a specific blog language. 320 325 * 321 * @param int $blog_id326 * @param int $blog_id 322 327 * @param string $default 323 328 * … … 329 334 } 330 335 331 $language = ( string) get_blog_option( $blog_id, 'WPLANG' );336 $language = (string) get_blog_option( $blog_id, 'WPLANG' ); 332 337 333 338 return '' !== $language ? $language : $default; 334 339 } 335 336 340 } -
multisite-language-switcher/trunk/includes/MslsOptions.php
r3088911 r3091013 2 2 /** 3 3 * MslsOptions 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 12 13 /** 13 14 * General options class 15 * 14 16 * @package Msls 15 17 * @property bool $activate_autocomplete … … 30 32 /** 31 33 * Args 34 * 32 35 * @var array 33 36 */ … … 36 39 /** 37 40 * Name 41 * 38 42 * @var string 39 43 */ … … 42 46 /** 43 47 * Exists 48 * 44 49 * @var bool 45 50 */ … … 48 53 /** 49 54 * Separator 55 * 50 56 * @var string 51 57 */ … … 54 60 /** 55 61 * Autoload 62 * 56 63 * @var string 57 64 */ … … 60 67 /** 61 68 * Available languages 62 * @var array 63 */ 64 private $available_languages; 69 * 70 * @var array<string, string> 71 */ 72 private array $available_languages; 65 73 66 74 /** 67 75 * Rewrite with front 76 * 68 77 * @var bool 69 78 */ … … 100 109 } 101 110 102 add_filter( ' check_url', [ $options, 'check_for_blog_slug' ], 10, 2 );111 add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 ); 103 112 104 113 return $options; … … 107 116 /** 108 117 * Determines if the current page is the main page (front page, search, 404). 109 *110 * @return boolean118 * 119 * @return boolean 111 120 */ 112 121 public static function is_main_page() { … … 116 125 /** 117 126 * Determines if the current page is a category, tag or taxonomy page. 118 *127 * 119 128 * @return boolean 120 129 */ … … 125 134 /** 126 135 * Determines if the current page is an archive page for a date, author, or any other post type. 127 *136 * 128 137 * @return boolean 129 138 */ … … 143 152 /** 144 153 * Gets an element of arg by index 145 *146 * The returned value will either be cast to the type of `$ retval` or, if nothing is set at this index, it will be the value of `$retval`.147 * 148 * @param int $idx149 * @param mixed $ val154 * 155 * The returned value will either be cast to the type of `$default` or, if nothing is set at this index, it will be the value of `$default`. 156 * 157 * @param int $index 158 * @param mixed $default 150 159 * 151 160 * @return mixed 152 161 */ 153 public function get_arg( $idx, $val = null ) { 154 $arg = isset( $this->args[ $idx ] ) ? $this->args[ $idx ] : $val; 155 settype( $arg, gettype( $val ) ); 162 public function get_arg( int $index, $default = null ) { 163 $arg = $this->args[ $index ] ?? $default; 164 165 settype( $arg, gettype( $default ) ); 156 166 157 167 return $arg; … … 177 187 /** 178 188 * Delete 189 * 179 190 * @codeCoverageIgnore 180 191 */ … … 201 212 * Mapping for us language code 202 213 */ 203 $map = [ 'us' => 'en_US', 'en' => 'en_US' ]; 214 $map = array( 215 'us' => 'en_US', 216 'en' => 'en_US', 217 ); 204 218 foreach ( $map as $old => $new ) { 205 219 if ( isset( $arr[ $old ] ) ) { … … 230 244 * 231 245 * @since 0.9.8 232 *233 246 */ 234 247 $postlink = (string) apply_filters( … … 254 267 /** 255 268 * Get the queried taxonomy 269 * 256 270 * @return string 257 271 */ … … 262 276 /** 263 277 * Get current link 278 * 264 279 * @return string 265 280 */ … … 270 285 /** 271 286 * Is excluded 287 * 272 288 * @return bool 273 289 */ … … 278 294 /** 279 295 * Is content 296 * 280 297 * @return bool 281 298 */ … … 286 303 /** 287 304 * Get order 305 * 288 306 * @return string 289 307 */ … … 306 324 * Returns slug for a post type 307 325 * 326 * @todo This method is not used anywhere in the codebase. Should it be removed? 327 * 308 328 * @param string $post_type 309 329 * 310 330 * @return string 311 331 */ 312 public function get_slug( $post_type ){332 public function get_slug( string $post_type ): string { 313 333 $key = "rewrite_{$post_type}"; 314 334 315 error_log( $key ); 316 317 return isset( $this->$key ) ? $this->$key : ''; 335 return $this->$key ?? ''; 318 336 } 319 337 … … 335 353 */ 336 354 public function get_flag_url( $language ) { 337 if ( ! is_admin() && isset( $this->image_url ) ) { 338 $url = $this->__get( 'image_url' ); 339 } else { 340 $url = $this->get_url( 'flags' ); 341 } 355 $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' ); 342 356 343 357 /** … … 347 361 * 348 362 * @since 0.9.9 349 *350 363 */ 351 364 $url = (string) apply_filters( 'msls_options_get_flag_url', $url ); … … 360 373 * 361 374 * @since 1.0.3 362 *363 375 */ 364 376 $icon = (string) apply_filters( 'msls_options_get_flag_icon', $icon, $language ); … … 376 388 public function get_available_languages() { 377 389 if ( empty( $this->available_languages ) ) { 378 $this->available_languages = [390 $this->available_languages = array( 379 391 'en_US' => __( 'American English', 'multisite-language-switcher' ), 380 ];392 ); 381 393 382 394 foreach ( get_available_languages() as $code ) { … … 390 402 * 391 403 * @since 1.0 392 *393 404 */ 394 405 $this->available_languages = (array) apply_filters( … … 404 415 * The 'blog'-slug-problem :/ 405 416 * 406 * @param string $url417 * @param string $url 407 418 * @param MslsOptions $options 408 419 * … … 444 455 return MslsAdminIcon::TYPE_LABEL === $this->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG; 445 456 } 446 447 457 } -
multisite-language-switcher/trunk/includes/MslsOptionsPost.php
r3079846 r3091013 1 <?php 2 /** 3 * MslsOptionsPost 4 * @author Dennis Ploetner <re@lloc.de> 5 * @since 0.9.8 6 */ 1 <?php declare( strict_types=1 ); 7 2 8 3 namespace lloc\Msls; … … 10 5 /** 11 6 * Post options 7 * 12 8 * @package Msls 13 9 */ … … 16 12 /** 17 13 * Separator 14 * 18 15 * @var string 19 16 */ … … 22 19 /** 23 20 * Autoload 21 * 24 22 * @var string 25 23 */ … … 48 46 } 49 47 50 global $current_site; 51 $blog_id = msls_blog_collection()->get_blog_id( $language ); 52 if ( $current_site->blog_id != $blog_id ) { 53 $option = get_blog_option( $blog_id, 'msls' ); 54 //error_log( print_r( $option, true ) ); 55 } 48 $post_link = get_permalink( $post ); 56 49 57 return apply_filters( 'check_url', get_permalink( $post ), $this ); 50 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 51 52 return apply_filters( 'msls_get_postlink', $post_link, $this ); 58 53 } 59 54 … … 66 61 return (string) get_permalink( $this->get_arg( 0, 0 ) ); 67 62 } 68 69 63 } -
multisite-language-switcher/trunk/includes/MslsOptionsQuery.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQuery 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 17 18 /** 18 19 * Rewrite with front 20 * 19 21 * @var bool 20 22 */ … … 62 64 public function get_postlink( $language ) { 63 65 if ( $this->has_value( $language ) ) { 64 $link = $this->get_current_link(); 65 if ( ! empty( $link ) ) { 66 return apply_filters( 'check_url', $link, $this ); 66 $post_link = $this->get_current_link(); 67 if ( ! empty( $post_link ) ) { 68 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 69 70 return apply_filters( 'msls_get_postlink', $post_link, $this ); 67 71 } 68 72 } … … 70 74 return ''; 71 75 } 72 73 76 } -
multisite-language-switcher/trunk/includes/MslsOptionsQueryAuthor.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQueryAuthor 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 45 46 return get_author_posts_url( $this->get_arg( 0, 0 ) ); 46 47 } 47 48 48 } -
multisite-language-switcher/trunk/includes/MslsOptionsQueryPostType.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsQueryPostType 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 38 39 return (string) get_post_type_archive_link( $this->get_arg( 0, '' ) ); 39 40 } 40 41 41 } -
multisite-language-switcher/trunk/includes/MslsOptionsQueryYear.php
r1990702 r3091013 2 2 /** 3 3 * MslsOptionsQueryYear 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 16 17 17 18 /** 18 * Check if the array has a n nonempty item which has $language as a key19 * Check if the array has a non-empty item which has $language as a key 19 20 * 20 21 * @param string $language … … 45 46 return get_year_link( $this->get_arg( 0, 0 ) ); 46 47 } 47 48 48 } -
multisite-language-switcher/trunk/includes/MslsOptionsTax.php
r3079846 r3091013 2 2 /** 3 3 * MslsOptionsTax 4 * 4 5 * @author Dennis Ploetner <re@lloc.de> 5 6 * @since 0.9.8 … … 10 11 /** 11 12 * Taxonomy options 13 * 12 14 * @package Msls 13 15 */ … … 16 18 /** 17 19 * Separator 20 * 18 21 * @var string 19 22 */ … … 22 25 /** 23 26 * Autoload 27 * 24 28 * @var string 25 29 */ … … 59 63 60 64 if ( $req ) { 61 add_filter( ' check_url', [ $options, 'check_base' ], 9, 2 );65 add_filter( 'msls_get_postlink', array( $options, 'check_base' ), 9, 2 ); 62 66 } else { 63 67 global $wp_rewrite; … … 71 75 /** 72 76 * Get the queried taxonomy 77 * 73 78 * @return string 74 79 */ … … 93 98 */ 94 99 public function get_postlink( $language ) { 95 $ url= '';100 $post_link = ''; 96 101 97 102 if ( $this->has_value( $language ) ) { 98 $ url= $this->get_term_link( (int) $this->__get( $language ) );103 $post_link = $this->get_term_link( (int) $this->__get( $language ) ); 99 104 } 100 105 101 return apply_filters( 'check_url', $url, $this ); 106 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' ); 107 108 return apply_filters( 'msls_get_postlink', $post_link, $this ); 102 109 } 103 110 104 111 /** 105 112 * Get current link 113 * 106 114 * @return string 107 115 */ … … 130 138 return ''; 131 139 } 132 133 140 } -
multisite-language-switcher/trunk/includes/MslsPlugin.php
r3088911 r3091013 250 250 */ 251 251 public function admin_bar_init() { 252 if ( is_admin_bar_showing() && is_super_admin()) {252 if ( is_admin_bar_showing() ) { 253 253 add_action( 'admin_bar_menu', array( __CLASS__, 'update_adminbar' ), 999 ); 254 254 -
multisite-language-switcher/trunk/includes/MslsPostTag.php
r3088911 r3091013 1 <?php 1 <?php declare( strict_types=1 ); 2 2 3 /** 3 4 * MslsPostTag 4 5 * 5 6 * @author Dennis Ploetner <re@lloc.de> 6 * @since 0.9.87 7 */ 8 8 … … 30 30 ); 31 31 32 $args = [32 $args = array( 33 33 'orderby' => 'name', 34 34 'order' => 'ASC', 35 35 'number' => 10, 36 36 'hide_empty' => 0, 37 ];37 ); 38 38 39 39 if ( filter_has_var( INPUT_POST, 's' ) ) { … … 82 82 $options = msls_options(); 83 83 $collection = msls_blog_collection(); 84 $class = $options->activate_autocomplete ? MslsPostTag::class : MslsPostTagClassic::class;84 $class = $options->activate_autocomplete ? self::class : MslsPostTagClassic::class; 85 85 $obj = new $class( $options, $collection ); 86 86 87 87 $taxonomy = MslsContentTypes::create()->acl_request(); 88 88 if ( '' != $taxonomy ) { 89 add_action( "{$taxonomy}_add_form_fields", [ $obj, 'add_input' ]);90 add_action( "{$taxonomy}_edit_form_fields", [ $obj, 'edit_input' ], 10, 2 );91 add_action( "edited_{$taxonomy}", [ $obj, 'set' ]);92 add_action( "create_{$taxonomy}", [ $obj, 'set' ]);89 add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) ); 90 add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 ); 91 add_action( "edited_{$taxonomy}", array( $obj, 'set' ) ); 92 add_action( "create_{$taxonomy}", array( $obj, 'set' ) ); 93 93 } 94 94 … … 119 119 * 120 120 * @param \WP_Term $tag 121 * @param string $taxonomy121 * @param string $taxonomy 122 122 */ 123 123 public function edit_input( \WP_Term $tag, string $taxonomy ): void { … … 149 149 * 150 150 * @param ?\WP_Term $tag 151 * @param string $title_format152 * @param string $item_format151 * @param string $title_format 152 * @param string $item_format 153 153 * 154 154 * @return boolean … … 161 161 } 162 162 163 $count ++;163 ++$count; 164 164 165 165 $blogs = $this->collection->get(); … … 259 259 */ 260 260 protected function get_select_title(): string { 261 return apply_filters( 'msls_term_select_title', 262 __( 'Multisite Language Switcher', 'multisite-language-switcher' ) ); 263 } 264 261 return apply_filters( 262 'msls_term_select_title', 263 __( 'Multisite Language Switcher', 'multisite-language-switcher' ) 264 ); 265 } 265 266 } -
multisite-language-switcher/trunk/js/msls-widget-block/block.json
r3088911 r3091013 6 6 "category": "widgets", 7 7 "name": "lloc/msls-widget-block", 8 "version": "2.7. 0",8 "version": "2.7.1", 9 9 "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.", 10 10 "example": {}, -
multisite-language-switcher/trunk/readme.txt
r3088911 r3091013 7 7 Tested up to: 6.5 8 8 Requires PHP: 7.4 9 Stable tag: 2.7. 09 Stable tag: 2.7.1 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
multisite-language-switcher/trunk/src/msls-widget-block/block.json
r3088911 r3091013 6 6 "category": "widgets", 7 7 "name": "lloc/msls-widget-block", 8 "version": "2.7. 0",8 "version": "2.7.1", 9 9 "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.", 10 10 "example": {}, -
multisite-language-switcher/trunk/vendor/composer/installed.php
r3088911 r3091013 2 2 'root' => array( 3 3 'name' => 'lloc/multisite-language-switcher', 4 'pretty_version' => '2.7. 0',5 'version' => '2.7. 0.0',6 'reference' => ' 285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',4 'pretty_version' => '2.7.1', 5 'version' => '2.7.1.0', 6 'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'lloc/multisite-language-switcher' => array( 23 'pretty_version' => '2.7. 0',24 'version' => '2.7. 0.0',25 'reference' => ' 285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',23 'pretty_version' => '2.7.1', 24 'version' => '2.7.1.0', 25 'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916', 26 26 'type' => 'wordpress-plugin', 27 27 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.