| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | * Constructor: setups filters and actions |
| 15 | 15 | * |
| 16 | 16 | * @since 1.2 |
| 17 | 17 | * |
| 18 | - * @param object $polylang | |
| 18 | + * @param object $polylang The Polylang object. | |
| 19 | 19 | */ |
| 20 | 20 | public function __construct( &$polylang ) { |
| 21 | 21 | parent::__construct( $polylang ); |
| 22 | 22 | |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | <label class="menu-item-title"> |
| 72 | 72 | <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-object-id]" value="-1"> <?php esc_html_e( 'Languages', 'polylang' ); ?> |
| 73 | 73 | </label> |
| 74 | 74 | <input type="hidden" class="menu-item-type" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-type]" value="custom"> |
| 75 | - <input type="hidden" class="menu-item-title" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-title]" value="<?php esc_html_e( 'Languages', 'polylang' ); ?>"> | |
| 75 | + <input type="hidden" class="menu-item-title" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-title]" value="<?php esc_attr_e( 'Languages', 'polylang' ); ?>"> | |
| 76 | 76 | <input type="hidden" class="menu-item-url" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-url]" value="#pll_switcher"> |
| 77 | 77 | </li> |
| 78 | 78 | </ul> |
| 79 | 79 | </div> |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 104 | - wp_enqueue_script( 'pll_nav_menu', plugins_url( '/js/build/nav-menu' . $suffix . '.js', POLYLANG_BASENAME ), array( 'jquery' ), POLYLANG_VERSION ); | |
| 104 | + wp_enqueue_script( 'pll_nav_menu', plugins_url( '/js/build/nav-menu' . $suffix . '.js', POLYLANG_ROOT_FILE ), array( 'jquery' ), POLYLANG_VERSION ); | |
| 105 | 105 | |
| 106 | 106 | $data = array( |
| 107 | 107 | 'strings' => PLL_Switcher::get_switcher_options( 'menu', 'string' ), // The strings for the options |
| 108 | 108 | 'title' => __( 'Languages', 'polylang' ), // The title |
| @@ -129,14 +129,14 @@ | ||
| 129 | 129 | wp_localize_script( 'pll_nav_menu', 'pll_data', $data ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * Save our menu item options | |
| 133 | + * Save our menu item options. | |
| 134 | 134 | * |
| 135 | 135 | * @since 1.1 |
| 136 | 136 | * |
| 137 | - * @param int $menu_id not used | |
| 138 | - * @param int $menu_item_db_id | |
| 137 | + * @param int $menu_id ID of the updated menu. | |
| 138 | + * @param int $menu_item_db_id ID of the updated menu item. | |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | 141 | public function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0 ) { |
| 142 | 142 | if ( empty( $_POST['menu-item-url'][ $menu_item_db_id ] ) || '#pll_switcher' !== $_POST['menu-item-url'][ $menu_item_db_id ] ) { // phpcs:ignore WordPress.Security.NonceVerification |
| @@ -193,9 +193,9 @@ | ||
| 193 | 193 | * @param mixed $mods Theme mods. |
| 194 | 194 | * @return mixed |
| 195 | 195 | */ |
| 196 | 196 | public function pre_update_option_theme_mods( $mods ) { |
| 197 | - if ( current_user_can( 'edit_theme_options' ) && isset( $mods['nav_menu_locations'] ) ) { | |
| 197 | + if ( current_user_can( 'edit_theme_options' ) && is_array( $mods ) && isset( $mods['nav_menu_locations'] ) ) { | |
| 198 | 198 | |
| 199 | 199 | // Manage Locations tab in Appearance -> Menus |
| 200 | 200 | if ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 201 | 201 | check_admin_referer( 'save-menu-locations' ); |
| @@ -229,10 +229,10 @@ | ||
| 229 | 229 | * Fills temporary menu locations based on menus translations |
| 230 | 230 | * |
| 231 | 231 | * @since 1.2 |
| 232 | 232 | * |
| 233 | - * @param bool|array $menus | |
| 234 | - * @return bool|array modified list of menu locations | |
| 233 | + * @param bool|array $menus Associative array of registered navigation menu IDs keyed by their location name. | |
| 234 | + * @return bool|array | |
| 235 | 235 | */ |
| 236 | 236 | public function theme_mod_nav_menu_locations( $menus ) { |
| 237 | 237 | // Prefill locations with 0 value in case a location does not exist in $menus |
| 238 | 238 | $locations = get_registered_nav_menus(); |