From 104bea16847cad56b3d94695d0b49ccc833ca445 Mon Sep 17 00:00:00 2001 From: Kevin Cristiano <kcristiano@kcristiano.com> Date: Wed, 9 Feb 2022 08:05:03 -0500 Subject: [PATCH] Conditionally set menu position as integer depending on WordPress version - Christian Wach --- includes/civicrm.admin.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/civicrm.admin.php b/includes/civicrm.admin.php index 1e0dd657ff..f35ab87f5a 100644 --- a/includes/civicrm.admin.php +++ b/includes/civicrm.admin.php @@ -587,17 +587,27 @@ class CiviCRM_For_WordPress_Admin { $civilogo = file_get_contents(CIVICRM_PLUGIN_DIR . 'assets/images/civilogo.svg.b64'); + global $wp_version; + if (version_compare($wp_version, '5.9.9999', '>')) { + $menu_position = 3; + } + else { + $menu_position = '3.904981'; + } + /** * Filter the position of the CiviCRM menu item. * - * Currently set to 3.9 + some random digits to reduce risk of conflict. + * As per the code above, the position was previously set to '3.904981' to + * reduce risk of conflicts. The position is now conditionally set depending + * on the version of WordPress. * - * @since 4.4 + * @since 5.47 Conditionally set because WordPress 6.0 enforces integers. Backport to 5.45+ * - * @param str The default menu position expressed as a float. + * @param str|int $menu_position The default menu position. * @return str The modified menu position expressed as a float. */ - $position = apply_filters('civicrm_menu_item_position', '3.904981'); + $position = apply_filters('civicrm_menu_item_position', $menu_position); // Try and initialize CiviCRM. $success = $this->initialize(); -- GitLab