menu_item_parent == $parent_id ) {
$nav_menu_item_list[] = $nav_menu_item;
if ( $depth ) {
if ( $children = $this->get_nav_menu_item_children( $nav_menu_item->ID, $nav_menu_items ) )
$nav_menu_item_list = array_merge( $nav_menu_item_list, $children );
}
}
}
return $nav_menu_item_list;
}
function arm_exclude_menu_items_2( $sorted_menu_objects, $args ) {
global $arm_member_forms,$all_child_array,$all_items_array,$all_parent_array;
$child_parent_array = array_merge( $all_parent_array, array_unique($all_child_array) );
foreach ($sorted_menu_objects as $key => $menu_object) {
$url = $menu_object->url;
$menu_id = $menu_object->ID;
$arm_hide_show_val = get_post_meta($menu_id,'arm_is_hide_show_after_login',true);
if($arm_hide_show_val != ''){
if(in_array($menu_id,$child_parent_array)){
unset($sorted_menu_objects[$key]);
}
}
}
return $sorted_menu_objects;
}
function arm_main_hook_for_exclude($nav_menu,$args)
{
global $all_items_array,$all_child_array;
foreach($all_child_array as $k=>$y)
{
foreach($all_items_array as $all_itme => $val){
if($y == $val){
unset($all_items_array[$all_itme]);
}
}
}
return $nav_menu;
}
function arm_exclude_menu_items( $sorted_menu_objects, $args ) {
global $arm_member_forms,$all_child_array,$all_items_array,$all_parent_array;
$show = '';
$arm_logout_url = wp_login_url().'?action=logout';
foreach ($sorted_menu_objects as $key => $menu_object) {
$url = $menu_object->url;
$menu_id = $menu_object->ID;
$all_items_array[] = $menu_id;
$arm_hide_show = get_post_meta($menu_id,'arm_is_hide_show_after_login',true);
if($arm_hide_show == ''){
$arm_hide_show = 'show_to_all';
}
if($arm_hide_show != 'show_to_all'){
if( !is_user_logged_in() ){
if($arm_hide_show == 'show_before_login'){
$show = 1;
}
else if($arm_hide_show == 'show_after_login'){
$show = 0;
}
}
else{
if($arm_hide_show == 'show_before_login'){
$show = 0;
}
else if($arm_hide_show == 'show_after_login'){
$show = 1;
}
}
}
if(($arm_hide_show != 'show_to_all') && ($show == 0)){
$all_child_array_temp = $this->get_nav_menu_item_children($menu_id, $sorted_menu_objects);
}
if(!empty($all_child_array_temp)){
foreach($all_child_array_temp as $key_child => $child){
$all_child_array[] = $child->ID;
if($child->ID == $menu_id)
{
//unset child from sorted object
//unset($sorted_menu_objects[$key]);
}
}
}
if( !is_admin() ){
switch($arm_hide_show){
}
}
if(is_user_logged_in()){
if($url == $arm_logout_url){
$menu_object->url = wp_logout_url( ARMLITE_HOME_URL );
}
}
}
return $sorted_menu_objects;
}
function arm_add_nav_menu_metabox(){
add_meta_box( 'armlogout', __( 'ARMember Logout','ARMember' ), array(&$this, 'arm_logout_menu_metabox'), 'nav-menus', 'side', 'default' );
?>
1,
'db_id' => 0,
'menu_item_parent' => 0,
'object_id' => $lo_navigation_link,
'post_parent' => 0,
'type' => 'custom',
'object' => 'arm-form-slug',
'type_label' => 'ARMember Plugin',
'title' => $_Lolabel,
'url' => $lo_navigation_link,
'target' => '',
'attr_title' => '',
'description' => '',
'classes' => array(),
'xfn' => '',
);
$db_fields = false;
// If your links will be hieararchical, adjust the $db_fields array bellow
if ( false ) {
$db_fields = array( 'parent' => 'parent', 'id' => 'post_parent' );
}
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
?>
NOTE: This feature will only work with those themes which has support of wordpress' navigation menu core hooks.", 'ARMember');?>
$arm_modal_popup ){
echo do_shortcode( $arm_modal_popup );
}
}
if( is_array($arm_inner_form_modal) && count($arm_inner_form_modal) > 0 ){
foreach($arm_inner_form_modal as $modal_popup){
echo do_shortcode($modal_popup);
}
}
}
}
function arm_wp_loaded_walker_menu($nav_menu,$args){
global $ARMember,$bpopup_loaded,$arm_popup_modal_elements;
preg_match('/armaction=(arm_modal_view_menu|arm_modalmembership_setup)/',$nav_menu,$matches);
if( count( $matches ) > 0 ){
$dom = new DOMDocument;
if (extension_loaded('mbstring')) {
@$dom->loadHTML(mb_convert_encoding($nav_menu, 'HTML-ENTITIES', 'UTF-8'));
} else {
@$dom->loadHTML(htmlspecialchars_decode(utf8_decode(htmlentities($nav_menu, ENT_COMPAT, 'utf-8', false))));
}
$n = new DOMXPath($dom);
$new_menu = '';
$anchor_tag = $dom->getElementsByTagName('a');
foreach( $anchor_tag as $tag ){
$href = $tag->getAttribute('href');
$echo = "";
if( preg_match('/armaction=(arm_modal_view_menu|arm_modalmembership_setup)/',$href) ){
$menu_id = '';
/* changes for notice warning need to confirm */
if(isset($args->menu->term_id)) {
$menu_id = $args->menu->term_id;
}
if (!is_admin()) {
$ARMember->set_front_css(true);
$ARMember->set_front_js(true);
do_action('arm_enqueue_js_css_from_outside');
}
$arm_menu_array = array();
$arm_menu_elems = explode("&", str_replace('&', '&', $href));
if (!empty($arm_menu_elems)) {
foreach ($arm_menu_elems as $arm_menu_elem) {
if (!empty($arm_menu_elem)) {
$arm_link_pera = explode("=", $arm_menu_elem);
$arm_menu_array[$arm_link_pera[0]] = $arm_link_pera[1];
}
}
}
if (!empty($arm_menu_array)) {
if (array_key_exists('id', $arm_menu_array) && !empty($arm_menu_array['id'])) {
$formAttr = " id='".$arm_menu_array['id']."' ";
$formRandomID = $arm_menu_array['id'] . arm_generate_random_code(8);
$formAttr .= " link_class=\"arm_form_link_$formRandomID\"";
$formAttr .= " link_type=\"link\" link_title=\" \" link_css=\"\" link_hover_css=\"\"";
$formAttr .= " popup=\"true\"";
if (isset($arm_menu_array['popup_height']) && !empty($arm_menu_array['popup_height'])) {
$formAttr .= " popup_height=\"".$arm_menu_array['popup_height']."\"";
}
if (isset($arm_menu_array['popup_width']) && !empty($arm_menu_array['popup_width'])) {
$formAttr .= " popup_width=\"".$arm_menu_array['popup_width']."\"";
}
if (isset($arm_menu_array['overlay']) && !empty($arm_menu_array['overlay'])) {
$formAttr .= " overlay=\"".$arm_menu_array['overlay']."\"";
}
if (isset($arm_menu_array['modal_bgcolor']) && !empty($arm_menu_array['modal_bgcolor'])) {
$formAttr .= " modal_bgcolor=\"".$arm_menu_array['modal_bgcolor']."\"";
}
if (isset($arm_menu_array['nav_menu']) && $arm_menu_array['nav_menu'] == 1 ) {
$formAttr .= " nav_menu=\"1\"";
}
$onClick = "arm_open_modal_box_in_nav_menu('$menu_id','arm_form_link_".$formRandomID."');return false;";
$arm_data_id = "arm_form_link_".$formRandomID;
$shortcode = "[arm_form ".$formAttr."]";
if( preg_match('/armaction=arm_modalmembership_setup/',$href)){
$shortcode = "[arm_setup $formAttr]";
}
$echo = "";
$arm_popup_modal_elements[$formRandomID] = $echo;
}
$tag->setAttribute('href','#');
$tag->setAttribute('onClick',$onClick);
$tag->setAttribute('arm-data-id',$arm_data_id);
}
$bpopup_loaded = 1;
}
$new_menu = preg_replace('/^/', '', str_replace( array('', '', '', ''), array('', '', '', ''), $dom->saveHTML()));
}
$nav_menu = $new_menu;
}
return $nav_menu;
}
function arm_add_nav_menu_meta_box($menu_id, $menu_item_db_id, $args) {
global $ARMember;
if (isset($_REQUEST['arm_is_hide_show_after_login'])) {
if (is_array($_REQUEST['arm_is_hide_show_after_login'])) {
$custom_value = isset($_REQUEST['arm_is_hide_show_after_login'][$menu_item_db_id]) ? $_REQUEST['arm_is_hide_show_after_login'][$menu_item_db_id] : 'always_show';
update_post_meta($menu_item_db_id, 'arm_is_hide_show_after_login', $custom_value);
if (!empty($_REQUEST['arm_access_rule_menu']) && $custom_value == 'show_after_login') {
$menu_rules = isset($_REQUEST['arm_access_rule_menu'][$menu_item_db_id]) ? $_REQUEST['arm_access_rule_menu'][$menu_item_db_id] : array();
if (!empty($menu_rules) && count($menu_rules) > 0) {
delete_post_meta($menu_item_db_id, 'arm_protection');
delete_post_meta($menu_item_db_id, 'arm_access_plan');
//add_post_meta($menu_item_db_id, 'arm_access_plan', '0');
$wpdb->query("INSERT INTO ".$wpdb->prefix."postmeta (`post_id`, `meta_key`, `meta_value`) VALUES ($menu_item_db_id, 'arm_access_plan', '0')");
foreach ($menu_rules as $plan_id) {
delete_post_meta($menu_item_db_id, 'arm_access_plan', $plan_id);
//add_post_meta($menu_item_db_id, 'arm_access_plan', $plan_id);
$wpdb->query("INSERT INTO ".$wpdb->prefix."postmeta (`post_id`, `meta_key`, `meta_value`) VALUES ($menu_item_db_id, 'arm_access_plan', $plan_id)");
}
} else {
delete_post_meta($menu_item_db_id, 'arm_protection');
delete_post_meta($menu_item_db_id, 'arm_access_plan');
}
} else {
delete_post_meta($menu_item_db_id, 'arm_protection');
delete_post_meta($menu_item_db_id, 'arm_access_plan');
}
if (!isset($_REQUEST['arm_access_rule_menu'])) {
delete_post_meta($menu_item_db_id, 'arm_protection');
delete_post_meta($menu_item_db_id, 'arm_access_plan');
}
}
}
}
function arm_setup_nav_menu_item($menu_item){
$menu_item->custom = get_post_meta($menu_item->ID,'arm_is_hide_show_after_login',true);
return $menu_item;
}
function arm_get_post_meta_for_menu(){
$response = array();
if( isset($_REQUEST['ids']) && !empty($_REQUEST['ids']) ){
$response['error'] = false;
$response['res'] = array();
$ids = json_decode(stripslashes_deep($_REQUEST['ids']));
foreach ($ids as $key => $menu_id) {
$response['res'][$menu_id] = get_post_meta($menu_id, 'arm_is_hide_show_after_login', true);
$response['access_rule'][$menu_id] = get_post_meta($menu_id, 'arm_access_plan', false);
}
} else {
$response['error'] = true;
}
echo json_encode($response);
die();
}
}
}
global $arm_modal_view_in_menu;
$arm_modal_view_in_menu = new ARM_modal_view_in_menu();