diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php
index 181749c5..112fa94d 100644
--- a/includes/admin/core/class-admin-settings.php
+++ b/includes/admin/core/class-admin-settings.php
@@ -977,6 +977,12 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
'textarea_rows' => 6
)
),
+ array(
+ 'id' => 'menu_item_workaround',
+ 'type' => 'checkbox',
+ 'label' => __( 'WP Menu Item Custom Fields Workaround','ultimate-member' ),
+ 'tooltip' => __( 'Turn on this option if you don\'t see WP Menu Item Restriction options','ultimate-member' ),
+ ),
array(
'id' => 'um_allow_tracking',
'type' => 'checkbox',
diff --git a/includes/class-config.php b/includes/class-config.php
index ea7779ce..20b2d49c 100644
--- a/includes/class-config.php
+++ b/includes/class-config.php
@@ -367,6 +367,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'cover_min_width' => 1000,
'profile_photo_max_size' => 999999999,
'cover_photo_max_size' => 999999999,
+ 'menu_item_workaround' => 0,
);
$tabs = UM()->profile()->tabs_primary();
diff --git a/includes/class-init.php b/includes/class-init.php
index 9f499487..a4034c7a 100644
--- a/includes/class-init.php
+++ b/includes/class-init.php
@@ -1037,7 +1037,9 @@ if ( ! class_exists( 'UM' ) ) {
ob_start();
- require_once 'core/um-navmenu.php';
+ if ( $this->options()->get( 'disable_menu' ) == 0 ) {
+ require_once 'core/um-navmenu.php';
+ }
require_once 'core/um-actions-form.php';
require_once 'core/um-actions-access.php';
diff --git a/includes/core/um-navmenu-walker-edit.php b/includes/core/um-navmenu-walker-edit.php
index 7f9d21f2..c48c9010 100644
--- a/includes/core/um-navmenu-walker-edit.php
+++ b/includes/core/um-navmenu-walker-edit.php
@@ -1,4 +1,7 @@
+
+
@@ -149,4 +154,7 @@ class UM_Menu_Item_Custom_Fields_Editor {
return $columns;
}
}
+
+endif;
+
UM_Menu_Item_Custom_Fields_Editor::init();
\ No newline at end of file
diff --git a/includes/core/um-navmenu-walker-template.php b/includes/core/um-navmenu-walker-template.php
new file mode 100644
index 00000000..27649ccd
--- /dev/null
+++ b/includes/core/um-navmenu-walker-template.php
@@ -0,0 +1,37 @@
+get_fields( $item, $depth, $args, $id ) ){
+ //$item_output = preg_replace('/(?=]+class="[^"]*submitbox)/', $new_fields, $item_output);
+ $item_output = preg_replace('/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/', $new_fields, $item_output);
+ }
+
+ $output .= $item_output;
+
+ }
+
+ protected function get_fields( $item, $depth, $args = array(), $id = 0 ) {
+ ob_start();
+
+ if( isset( $item->ID ) ){
+ $id = esc_attr( $item->ID );
+ }
+
+ do_action( 'wp_nav_menu_item_custom_fields', $id, $item, $depth, $args );
+
+ return ob_get_clean();
+ }
+}
+
+endif;
\ No newline at end of file
diff --git a/includes/core/um-navmenu-walker.php b/includes/core/um-navmenu-walker.php
index a487a15e..5cfe6af1 100644
--- a/includes/core/um-navmenu-walker.php
+++ b/includes/core/um-navmenu-walker.php
@@ -1,11 +1,14 @@
get_fields( $item, $depth, $args, $id ) ){
//$item_output = preg_replace('/(?=
]+class="[^"]*submitbox)/', $new_fields, $item_output);
$item_output = preg_replace('/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/', $new_fields, $item_output);
@@ -26,4 +29,6 @@ class UM_Menu_Item_Custom_Fields_Walker extends Walker_Nav_Menu_Edit {
return ob_get_clean();
}
-}
\ No newline at end of file
+}
+
+endif;
\ No newline at end of file
diff --git a/includes/core/um-navmenu.php b/includes/core/um-navmenu.php
index 5d73c266..e474e9bc 100644
--- a/includes/core/um-navmenu.php
+++ b/includes/core/um-navmenu.php
@@ -1,25 +1,58 @@
options()->get( 'disable_menu' ) == 0 ) {
- add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 99 );
- }
- }
-
- public static function _filter_walker( $walker ) {
- $walker = 'UM_Menu_Item_Custom_Fields_Walker';
- if ( ! class_exists( $walker ) ) {
- require_once dirname( __FILE__ ) . '/um-navmenu-walker.php';
- }
-
- return $walker;
- }
+class UM_Menu_Item_Custom_Fields {
+ /**
+ *
+ */
+ public static function load() {
+ add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 999 );
}
- add_action( 'wp_loaded', array( 'UM_Menu_Item_Custom_Fields', 'load' ), 9 );
+
+
+ /**
+ * @param $walker
+ * @return string
+ */
+ public static function _filter_walker( $walker ) {
+ $um_walker = 'UM_Menu_Item_Custom_Fields_Walker';
+
+ if ( UM()->options()->get( 'menu_item_workaround' ) ) {
+ //hard rewrite workaround with conflicted themes/plugins
+ $walker = 'Walker_Nav_Menu_Edit';
+ }
+
+ $walker_filename = dirname( __FILE__ ) . '/um-navmenu-walker.php';
+ $walker_template = file_get_contents( dirname( __FILE__ ) . '/um-navmenu-walker-template.php' );
+
+ $current_walker_content = file_get_contents( $walker_filename );
+ if ( strpos( $current_walker_content, $um_walker ) === false ||
+ strpos( $current_walker_content, $walker ) === false ) {
+
+ $walker_template = str_replace(
+ array(
+ '{{{%um_navmenu_walker%}}}',
+ '{{{%parent_walker%}}}'
+ ),
+ array(
+ $um_walker,
+ $walker
+ ),
+ $walker_template
+ );
+
+ $fp = fopen( $walker_filename, 'w+' );
+ fwrite( $fp, $walker_template );
+ fclose( $fp );
+ }
+ require_once $walker_filename;
+ return $um_walker;
+ }
+}
+add_action( 'wp_loaded', array( 'UM_Menu_Item_Custom_Fields', 'load' ), 9 );
+
endif;
require_once dirname( __FILE__ ) . '/um-navmenu-walker-edit.php';
\ No newline at end of file