Changeset 3338172
- Timestamp:
- 08/02/2025 09:57:12 AM (8 months ago)
- Location:
- multilang-perelink/trunk
- Files:
-
- 2 added
- 6 edited
-
includes/class-admin-settings.php (modified) (2 diffs)
-
includes/class-languages.php (modified) (3 diffs)
-
includes/class-settings.php (modified) (2 diffs)
-
multilang-perelink.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
templates/admin/settings/partial-blog-page.php (added)
-
templates/admin/settings/partial-home-page.php (added)
-
templates/shortcodes/default.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
multilang-perelink/trunk/includes/class-admin-settings.php
r3327324 r3338172 47 47 register_setting( 48 48 self::GROUP, 49 Settings::FIELD_HOME PAGE,49 Settings::FIELD_HOME_PAGE, 50 50 array( 51 51 'sanitize_callback' => 'sanitize_text_field', … … 53 53 ); 54 54 add_settings_field( 55 Settings::FIELD_HOME PAGE,55 Settings::FIELD_HOME_PAGE, 56 56 __( 'Homepage', 'multilang-perelink' ), 57 57 function() { 58 load_template( PATH . '/templates/admin/settings/partial-homepage.php' ); 58 load_template( PATH . '/templates/admin/settings/partial-home-page.php' ); 59 }, 60 self::SLUG, 61 self::SECTION 62 ); 63 64 register_setting( 65 self::GROUP, 66 Settings::FIELD_BLOG_PAGE, 67 array( 68 'sanitize_callback' => 'sanitize_text_field', 69 ) 70 ); 71 add_settings_field( 72 Settings::FIELD_BLOG_PAGE, 73 __( 'Blog page', 'multilang-perelink' ), 74 function() { 75 load_template( PATH . '/templates/admin/settings/partial-blog-page.php' ); 59 76 }, 60 77 self::SLUG, -
multilang-perelink/trunk/includes/class-languages.php
r3327324 r3338172 38 38 if ( is_front_page() ) { 39 39 40 if ( ! Settings::is_enable_home page() ) {40 if ( ! Settings::is_enable_home_page() ) { 41 41 return; 42 42 } … … 53 53 $this->add_language( $languages[ $site_id ], user_trailingslashit( get_blog_option( $site_id, 'siteurl' ) ) ); 54 54 } 55 } elseif ( is_home() && ! is_front_page() ) { 56 57 if ( ! Settings::is_enable_blog_page() ) { 58 return; 59 } 60 61 $instance = $this; 62 $languages = Helpers::get_languages(); 63 64 $this->add_blog_page_to_language( $languages, get_current_blog_id() ); 65 66 Helpers::walk_sites( 67 function( $site ) use ( $instance, $languages ) { 68 $instance->add_blog_page_to_language( $languages, $site->blog_id ); 69 } 70 ); 71 55 72 } elseif ( is_singular() ) { 56 73 … … 189 206 return $this; 190 207 } 208 209 /** 210 * Add Blog page to language. 211 * 212 * @param array $languages Languages. 213 * @param int $blog_id Blog Id. 214 * @return void 215 */ 216 private function add_blog_page_to_language( $languages, $blog_id ) { 217 // Check lang for site. 218 if ( empty( $languages[ $blog_id ] ) ) { 219 return; 220 } 221 222 $blog_page_id = get_blog_option( $blog_id, 'page_for_posts' ); 223 if ( empty( $blog_page_id ) ) { 224 return; 225 } 226 227 $page = get_post( $blog_page_id ); 228 if ( ! $page instanceof WP_Post ) { 229 return; 230 } 231 232 if ( 'publish' !== $page->post_status ) { 233 return; 234 } 235 236 $url = get_permalink( $page->ID ); 237 if ( empty( $url ) ) { 238 return; 239 } 240 241 $this->add_language( $languages[ $blog_id ], $url ); 242 } 191 243 } -
multilang-perelink/trunk/includes/class-settings.php
r3327324 r3338172 14 14 */ 15 15 final class Settings { 16 const FIELD_HOMEPAGE = '_plance_multilang_perelink__homepage'; 16 const FIELD_BLOG_PAGE = '_plance_multilang_perelink__blogpage'; 17 const FIELD_HOME_PAGE = '_plance_multilang_perelink__homepage'; 17 18 const FIELD_POST_TYPES = '_plance_multilang_perelink__post_types'; 18 19 const FIELD_TAXONOMIES = '_plance_multilang_perelink__taxonomies'; 20 21 const VALUE_YES = 'yes'; 19 22 20 23 /** … … 30 33 31 34 /** 32 * Enable home page for perelink.35 * Enable home page for perelink. 33 36 * 34 37 * @return bool 35 38 */ 36 public static function is_enable_homepage() { 37 return 'yes' === self::get_option( self::FIELD_HOMEPAGE ); 39 public static function is_enable_home_page() { 40 return self::VALUE_YES === self::get_option( self::FIELD_HOME_PAGE ); 41 } 42 43 /** 44 * Enable blog page for perelink. 45 * 46 * @return bool 47 */ 48 public static function is_enable_blog_page() { 49 return self::VALUE_YES === self::get_option( self::FIELD_BLOG_PAGE ); 38 50 } 39 51 -
multilang-perelink/trunk/multilang-perelink.php
r3327324 r3338172 8 8 * Description: Perelinking for a multilingual site 9 9 * Plugin URI: https://plance.top/ 10 * Version: 1.0. 010 * Version: 1.0.1 11 11 * Author: plance 12 12 * License: GPL v2 or later -
multilang-perelink/trunk/readme.txt
r3327324 r3338172 4 4 Requires at least: 6.0 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 06 Stable tag: 1.0.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 54 54 == Changelog == 55 55 56 = 1.0.1 = 57 * Added perelink for blog pages. 58 56 59 = 1.0.0 = 57 60 * Init release. -
multilang-perelink/trunk/templates/shortcodes/default.php
r3327324 r3338172 14 14 wp_enqueue_script( 'multilang-perelink' ); 15 15 ?> 16 <select class="plugin-multilang-perelink-field-select | js-plugin-multilang-perelink-field-select">16 <select id="plugin-multilang-perelink-field-select" class="plugin-multilang-perelink-field-select | js-plugin-multilang-perelink-field-select"> 17 17 <?php foreach ( $args['languages'] as $language ) : ?> 18 18 <option value="<?php echo esc_url( $language['url'] ); ?>"<?php echo selected( $language['locale'], $args['current_locale'] ); ?>><?php echo esc_attr( $language['language'] ); ?></option>
Note: See TracChangeset
for help on using the changeset viewer.