PluginProbe
Polylang / 3.3
Polylang v3.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-nav-menu.php +14 -6 2.83.3 View file →
@@ -32,8 +32,10 @@
32 32 * Setups filters and terms
33 33 * adds the language switcher metabox and create new nav menu locations
34 34 *
35 35 * @since 1.1
36 + *
37 + * @return void
36 38 */
37 39 public function admin_init() {
38 40 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
39 41 add_action( 'wp_update_nav_menu_item', array( $this, 'wp_update_nav_menu_item' ), 10, 2 );
@@ -54,8 +56,10 @@
54 56 * The checkbox and all hidden fields are important
55 57 * Thanks to John Morris for his very interesting post http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/
56 58 *
57 59 * @since 1.1
60 + *
61 + * @return void
58 62 */
59 63 public function lang_switch() {
60 64 global $_nav_menu_placeholder, $nav_menu_selected_id;
61 65 $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
@@ -67,9 +71,9 @@
67 71 <label class="menu-item-title">
68 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' ); ?>
69 73 </label>
70 74 <input type="hidden" class="menu-item-type" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-type]" value="custom">
71 - <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' ); ?>">
72 76 <input type="hidden" class="menu-item-url" name="menu-item[<?php echo (int) $_nav_menu_placeholder; ?>][menu-item-url]" value="#pll_switcher">
73 77 </li>
74 78 </ul>
75 79 </div>
@@ -86,17 +90,19 @@
86 90 /**
87 91 * Prepares javascript to modify the language switcher menu item
88 92 *
89 93 * @since 1.1
94 + *
95 + * @return void
90 96 */
91 97 public function admin_enqueue_scripts() {
92 98 $screen = get_current_screen();
93 - if ( 'nav-menus' != $screen->base ) {
99 + if ( empty( $screen ) || 'nav-menus' !== $screen->base ) {
94 100 return;
95 101 }
96 102
97 103 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
98 - wp_enqueue_script( 'pll_nav_menu', plugins_url( '/js/nav-menu' . $suffix . '.js', POLYLANG_FILE ), 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 );
99 105
100 106 $data = array(
101 107 'strings' => PLL_Switcher::get_switcher_options( 'menu', 'string' ), // The strings for the options
102 108 'title' => __( 'Languages', 'polylang' ), // The title
@@ -129,8 +135,9 @@
129 135 * @since 1.1
130 136 *
131 137 * @param int $menu_id not used
132 138 * @param int $menu_item_db_id
139 + * @return void
133 140 */
134 141 public function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0 ) {
135 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
136 143 return;
@@ -178,14 +185,14 @@
178 185 return $locations;
179 186 }
180 187
181 188 /**
182 - * Assign menu languages and translations based on ( temporary ) locations
189 + * Assign menu languages and translations based on ( temporary ) locations.
183 190 *
184 191 * @since 1.1
185 192 *
186 - * @param array $mods theme mods
187 - * @return unmodified $mods
193 + * @param mixed $mods Theme mods.
194 + * @return mixed
188 195 */
189 196 public function pre_update_option_theme_mods( $mods ) {
190 197 if ( current_user_can( 'edit_theme_options' ) && isset( $mods['nav_menu_locations'] ) ) {
191 198
@@ -252,8 +259,9 @@
252 259 *
253 260 * @since 1.7.3
254 261 *
255 262 * @param int $term_id nav menu id
263 + * @return void
256 264 */
257 265 public function delete_nav_menu( $term_id ) {
258 266 if ( isset( $this->options['nav_menus'] ) ) {
259 267 foreach ( $this->options['nav_menus'] as $theme => $locations ) {