mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed menu items compatibility and integration;
This commit is contained in:
@@ -977,6 +977,12 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
|||||||
'textarea_rows' => 6
|
'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(
|
array(
|
||||||
'id' => 'um_allow_tracking',
|
'id' => 'um_allow_tracking',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ if ( ! class_exists( 'um\Config' ) ) {
|
|||||||
'cover_min_width' => 1000,
|
'cover_min_width' => 1000,
|
||||||
'profile_photo_max_size' => 999999999,
|
'profile_photo_max_size' => 999999999,
|
||||||
'cover_photo_max_size' => 999999999,
|
'cover_photo_max_size' => 999999999,
|
||||||
|
'menu_item_workaround' => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
$tabs = UM()->profile()->tabs_primary();
|
$tabs = UM()->profile()->tabs_primary();
|
||||||
|
|||||||
@@ -1037,7 +1037,9 @@ if ( ! class_exists( 'UM' ) ) {
|
|||||||
|
|
||||||
ob_start();
|
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-form.php';
|
||||||
require_once 'core/um-actions-access.php';
|
require_once 'core/um-actions-access.php';
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) :
|
||||||
|
|
||||||
class UM_Menu_Item_Custom_Fields_Editor {
|
class UM_Menu_Item_Custom_Fields_Editor {
|
||||||
|
|
||||||
@@ -137,6 +140,8 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
|||||||
</p>
|
</p>
|
||||||
<?php }
|
<?php }
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
|
<div class="clear"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -149,4 +154,7 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
|||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
UM_Menu_Item_Custom_Fields_Editor::init();
|
UM_Menu_Item_Custom_Fields_Editor::init();
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This is template for NavMenu Walker Class which extends from latest parents
|
||||||
|
*/
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( '{{{%um_navmenu_walker%}}}' ) ) :
|
||||||
|
|
||||||
|
class {{{%um_navmenu_walker%}}} extends {{{%parent_walker%}}} {
|
||||||
|
|
||||||
|
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||||
|
$item_output = '';
|
||||||
|
parent::start_el( $item_output, $item, $depth, $args, $id );
|
||||||
|
|
||||||
|
if( $new_fields = $this->get_fields( $item, $depth, $args, $id ) ){
|
||||||
|
//$item_output = preg_replace('/(?=<div[^>]+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;
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Walker' ) ) :
|
||||||
|
|
||||||
class UM_Menu_Item_Custom_Fields_Walker extends Walker_Nav_Menu_Edit {
|
class UM_Menu_Item_Custom_Fields_Walker extends Walker_Nav_Menu_Edit {
|
||||||
|
|
||||||
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||||
$item_output = '';
|
$item_output = '';
|
||||||
parent::start_el( $item_output, $item, $depth, $args, $id );
|
parent::start_el( $item_output, $item, $depth, $args, $id );
|
||||||
|
|
||||||
if( $new_fields = $this->get_fields( $item, $depth, $args, $id ) ){
|
if( $new_fields = $this->get_fields( $item, $depth, $args, $id ) ){
|
||||||
//$item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $new_fields, $item_output);
|
//$item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $new_fields, $item_output);
|
||||||
$item_output = preg_replace('/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/', $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();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
@@ -1,25 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields' ) ) :
|
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields' ) ) :
|
||||||
|
|
||||||
class UM_Menu_Item_Custom_Fields {
|
class UM_Menu_Item_Custom_Fields {
|
||||||
|
/**
|
||||||
public static function load() {
|
*
|
||||||
if ( UM()->options()->get( 'disable_menu' ) == 0 ) {
|
*/
|
||||||
add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 99 );
|
public static function load() {
|
||||||
}
|
add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 999 );
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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;
|
endif;
|
||||||
|
|
||||||
require_once dirname( __FILE__ ) . '/um-navmenu-walker-edit.php';
|
require_once dirname( __FILE__ ) . '/um-navmenu-walker-edit.php';
|
||||||
Reference in New Issue
Block a user