*/ class DSAMM_Admin_Interface { private static $depth_count_var = ''; /** * This function runs when plugin activates. (use period) * * This function executes when plugin activates and object initialised. * * @since 1.0.0 */ /** * wordpress hook called in twise that whay we have made custom logic * */ private $past_revision = true; /** * This function runs when menu deleted from the admin page. (use period) * * This function executes when menu deleted from the admin page. * * @since 1.0.0 * @author theDotstore */ public static function dsamm_action_ajax_for_delete_menu() { // Security check check_ajax_referer( 'dsamm_ajax_value_nonce', 'security' ); $delete_menu_id = filter_input( INPUT_POST, "delete_menu_id", FILTER_VALIDATE_INT ); $delete_menu_id = ( !empty( $delete_menu_id ) ? intval( $delete_menu_id ) : 0 ); if ( $delete_menu_id > 0 ) { $delete_menu_obj = wp_delete_nav_menu( $delete_menu_id ); if ( $delete_menu_obj ) { $nav_menus = wp_get_nav_menus(); if ( isset( $nav_menus[0]->term_id ) ) { update_user_meta( get_current_user_id(), 'nav_menu_recently_edited', $nav_menus[0]->term_id ); } wp_die( true ); } } wp_die(); // this is required to terminate immediately and return a proper response } /** * dsamm_save_existing_menu function * * This function is used to save existing menu items. * * @version 1.0.0 * @author Multidots * */ function dsamm_save_existing_menu( $menu_items ) { // Check if the current user has permission to edit theme options if ( !current_user_can( 'edit_theme_options' ) ) { return '

' . __( 'You do not have permission to edit menus.', 'advance-menu-manager' ) . '

'; } check_admin_referer( 'amm_pro_menu_action', 'amm_pro_menu_nonce_field' ); // menu name and setting update $menu_name = filter_input( INPUT_POST, "menu-name", FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( empty( $menu_name ) ) { return $messages = '

' . __( 'Please enter menu name.', 'advance-menu-manager' ) . '

'; } /** * get location, menu id, current menu location for save location on menu */ global $wpdb; $current_edit_menu_id = filter_input( INPUT_POST, "current_edit_menu_id", FILTER_VALIDATE_INT ); if ( empty( $current_edit_menu_id ) || $current_edit_menu_id <= 0 ) { return $messages = '

' . __( 'Menu ID not found. Please try again.', 'advance-menu-manager' ) . '

'; } DSAMM_Classic_Menu_Navigation_Sync::defer(); $locations = get_registered_nav_menus(); $menu_locations = get_nav_menu_locations(); $messages = ''; // Remove menu locations that have been unchecked. foreach ( $locations as $location => $description ) { if ( (empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][$location] )) && isset( $menu_locations[$location] ) && $menu_locations[$location] === $current_edit_menu_id ) { unset($menu_locations[$location]); } } // Merge new and existing menu locations if any new ones are set. if ( isset( $_POST['menu-locations'] ) ) { $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); } // Set menu locations. set_theme_mod( 'nav_menu_locations', $menu_locations ); //menu title and menu related other option will update $_menu_object = wp_get_nav_menu_object( $current_edit_menu_id ); $menu_title = trim( esc_html( $menu_name ) ); if ( !$menu_title ) { $messages = '

' . __( 'Please enter a valid menu name.', 'advance-menu-manager' ) . '

'; $menu_title = $_menu_object->name; } if ( !is_wp_error( $_menu_object ) ) { $old_menu_name = filter_input( INPUT_POST, 'old-menu-name', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( $old_menu_name !== $menu_title ) { $menu_exists = wp_get_nav_menu_object( $menu_title ); if ( empty( $menu_exists ) ) { $current_edit_menu_id = wp_update_nav_menu_object( $current_edit_menu_id, array( 'menu-name' => $menu_title, ) ); if ( is_wp_error( $current_edit_menu_id ) ) { $_menu_object = $current_edit_menu_id; $messages = '

' . __( 'Please try again later.', 'advance-menu-manager' ) . '

'; } else { $nav_menu_selected_title = $_menu_object->name; } } else { DSAMM_Classic_Menu_Navigation_Sync::resume(); return $messages = '

' . $menu_title . ' ' . __( 'is already registered.', 'advance-menu-manager' ) . '

'; } } else { $nav_menu_selected_title = $_menu_object->name; } } // Update menu items. if ( !is_wp_error( $_menu_object ) && !empty( $nav_menu_selected_title ) ) { $messages_wp = array(); $messages_wp = array_merge( $messages_wp, wp_nav_menu_update_menu_items( $current_edit_menu_id, $nav_menu_selected_title ) ); if ( !empty( $messages_wp ) ) { foreach ( $messages_wp as $mesg ) { $messages .= $mesg; } } } if ( !is_wp_error( $current_edit_menu_id ) ) { update_user_meta( get_current_user_id(), 'nav_menu_recently_edited', $current_edit_menu_id ); } // End menu name and setting update code $elements = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type' ); $menu_items_obj = explode( ',', $menu_items ); array_pop( $menu_items_obj ); $menu_item_db_id = ( isset( $_POST['menu-item-db-id'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['menu-item-db-id'] ) ) : array() ); $menu_item_db_id_count = ( is_array( $menu_item_db_id ) ? count( $menu_item_db_id ) : "0" ); $end = 1 + $menu_item_db_id_count - 1; $keys = range( 1, $end ); $deleted_nodes = ( isset( $_POST['delete_menu_items'] ) ? sanitize_text_field( wp_unslash( $_POST['delete_menu_items'] ) ) : '' ); $deleted_nodes = explode( ',', $deleted_nodes ); if ( !empty( $menu_item_db_id ) ) { $menu_item_db_id = array_combine( $keys, $menu_item_db_id ); } $defaults = array( 'menu-item-db-id' => 0, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 0, 'menu-item-type' => 'custom', 'menu-item-title' => '', 'menu-item-url' => '', 'menu-item-description' => '', 'menu-item-attr-title' => '', 'menu-item-target' => '', 'menu-item-classes' => '', 'menu-item-xfn' => '', 'menu-item-status' => '', ); $args = wp_parse_args( $_REQUEST, $defaults ); $menu_order_node = 1; $loop_count = 0; if ( !empty( $args['menu-item-object-id'] ) ) { foreach ( $args['menu-item-object-id'] as $key => $value ) { $current_post_id = $menu_item_db_id[$menu_order_node]; if ( in_array( $current_post_id, $deleted_nodes, true ) ) { wp_delete_post( $current_post_id ); delete_post_meta( $current_post_id, '_menu_item_type', sanitize_key( $args['menu-item-type'][$key] ) ); delete_post_meta( $current_post_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'][$key] ) ); delete_post_meta( $current_post_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'][$key] ) ); delete_post_meta( $current_post_id, '_menu_item_object', sanitize_key( $args['menu-item-object'][$key] ) ); } else { if ( isset( $args['menu-item-attr-title'][$loop_count] ) ) { $update_my_nav_post = array( 'ID' => $current_post_id, 'menu_order' => sanitize_key( $menu_order_node ), 'post_excerpt' => sanitize_key( $args['menu-item-attr-title'][$loop_count] ), ); } else { $update_my_nav_post = array( 'ID' => $current_post_id, 'menu_order' => sanitize_key( $menu_order_node ), ); } wp_update_post( $update_my_nav_post ); update_post_meta( $current_post_id, '_menu_item_type', sanitize_key( $args['menu-item-type'][$key] ) ); update_post_meta( $current_post_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'][$key] ) ); update_post_meta( $current_post_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'][$key] ) ); update_post_meta( $current_post_id, '_menu_item_object', sanitize_key( $args['menu-item-object'][$key] ) ); if ( !empty( $args['menu-item-target'][$key] ) ) { update_post_meta( $current_post_id, '_menu_item_target', $args['menu-item-target'][$key] ); } DSAMM_Menu_Item_Visibility::save_from_request( $current_post_id ); } $menu_order_node++; $loop_count++; } // Foreach close } unset($deleted_nodes); $sync_aliases = array(); $old_menu_name_for_sync = filter_input( INPUT_POST, 'old-menu-name', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( !empty( $old_menu_name_for_sync ) && !empty( $menu_title ) && $old_menu_name_for_sync !== $menu_title ) { $sync_aliases[(int) $current_edit_menu_id] = array($old_menu_name_for_sync); } if ( !is_wp_error( $current_edit_menu_id ) && !empty( $current_edit_menu_id ) ) { DSAMM_Classic_Menu_Navigation_Sync::resume( array((int) $current_edit_menu_id), $sync_aliases ); } else { DSAMM_Classic_Menu_Navigation_Sync::resume(); } return $messages; } /** * dsamm_menu_container_print function * * This function is used to print the menu container in the plugin page. * * @version 1.0.0 * @author Multidots * */ function dsamm_menu_container_print() { global $gloable_all_author_array; global $gloable_all_template_array; global $gloable_all_category_array; global $gloable_all_current_menu_id; $messages = array(); //set all author globaly $allUsers = get_users( 'orderby=ID&order=ASC' ); foreach ( $allUsers as $currentUser ) { if ( !in_array( 'subscriber', $currentUser->roles, true ) ) { $gloable_all_author_array[] = $currentUser; } } // set all template globaly $get_templates_all = get_page_templates(); foreach ( $get_templates_all as $template_name => $template_filename ) { $gloable_all_template_array[$template_name] = $template_filename; } // set all category by globaly $all_category = get_categories( 'orderby=name&hide_empty=0' ); foreach ( $all_category as $cat_data ) { $gloable_all_category_array[$cat_data->cat_ID] = $cat_data->cat_name; } $total_menu_items = filter_input( INPUT_POST, "total_menu_items", FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $form_submited_messages = ( isset( $_POST['save_menu'] ) ? DSAMM_Admin_Interface::dsamm_save_existing_menu( $total_menu_items ) : false ); wp_nav_menu_post_type_meta_boxes(); wp_nav_menu_taxonomy_meta_boxes(); wp_enqueue_script( 'nav-menu' ); if ( wp_is_mobile() ) { //phpcs:ignore wp_enqueue_script( 'jquery-touch-punch' ); } $nav_menu_selected_id = ( isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0 ); // Get recently edited nav menu. $recently_edited = absint( get_user_option( 'nav_menu_recently_edited', get_current_user_id() ) ); if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) { $recently_edited = $nav_menu_selected_id; } // Use $recently_edited if none are selected. if ( empty( $nav_menu_selected_id ) && !isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) { $nav_menu_selected_id = $recently_edited; } $add_new_screen = $add_new_screen ?? false; $nav_menus = $nav_menus ?? []; if ( empty( $nav_menu_selected_id ) && !empty( $nav_menus ) && !$add_new_screen ) { // phpcs:ignore // if we have no selection yet, and we have menus, set to the first one in the list. $nav_menu_selected_id = $nav_menus[0]->term_id; // phpcs:ignore } // Update the user's setting. if ( $nav_menu_selected_id !== $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { update_user_meta( get_current_user_id(), 'nav_menu_recently_edited', $nav_menu_selected_id ); } //if menu hase change on dropdwon and save menu than recently menu option will update if ( !empty( $_POST['page_on_front'] ) ) { $nav_menu_selected_id = (int) $_POST['page_on_front']; $user_id = get_current_user_id(); update_user_meta( $user_id, 'nav_menu_recently_edited', $nav_menu_selected_id ); } $locations = get_registered_nav_menus(); $menu_locations = get_nav_menu_locations(); $num_locations = count( array_keys( $locations ) ); //submit themes location form if ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] && isset( $_POST['menu-locations'] ) ) { if ( isset( $_POST['menu-locations'] ) ) { check_admin_referer( 'save-menu-locations' ); $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); // Set menu locations set_theme_mod( 'nav_menu_locations', $menu_locations ); $messages[] = '

' . __( 'Menu locations updated.', 'advance-menu-manager' ) . '

'; } } $menu_revision_tab = ''; if ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) { $menu_location_flag = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); } else { $menu_location_flag = ''; } $locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ? true : false ); // Get all nav menus. $nav_menus = wp_get_nav_menus(); $menu_count = count( $nav_menus ); wp_nav_menu_setup(); wp_initial_nav_menu_meta_boxes(); // On deletion of menu, if another menu exists, show it. if ( empty( $nav_menu_selected_id ) && !empty( $nav_menus[0]->term_id ) ) { $nav_menu_selected_id = $nav_menus[0]->term_id; } //menu lock functionality $amm_current_menu_locked = ''; $amm_current_menu_locked = DSAMM_Admin_Interface::dsamm_is_current_menu_locked( $nav_menu_selected_id ); ?>
' . esc_html__( 'Your theme supports one menu. Select which menu you would like to use.', 'advance-menu-manager' ) . '

'; } else { echo '

' . esc_html( sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations, 'advance-menu-manager' ), number_format_i18n( $num_locations ) ) ) . '

'; } ?>
>
>
$item ) { $item_depth[$item->ID] = 0; if ( (int) $item->menu_item_parent !== 0 ) { while ( !empty( $stack ) && (int) $item->menu_item_parent !== $stack[count( $stack ) - 1]->ID ) { array_pop( $stack ); } if ( !empty( $stack ) ) { $parent = $stack[count( $stack ) - 1]; $item_depth[$item->ID] = $item_depth[$parent->ID] + 1; } } $stack[] = $item; } return $item_depth; } /** * dsamm_action_ajax_for_create_menu function * * This function will add your newly entered menu name in textbox. * * @version 1.0.0 * @author theDotstore */ public static function dsamm_action_ajax_for_create_menu() { // Security check check_ajax_referer( 'dsamm_ajax_value_nonce', 'security' ); // Check if the menu exists $menu_name = filter_input( INPUT_POST, 'new_menu_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $menu_exists = wp_get_nav_menu_object( $menu_name ); // If it doesn't exist, let's create it. if ( !$menu_exists ) { $menu_id = wp_create_nav_menu( $menu_name ); $user_details = wp_get_current_user(); update_user_meta( $user_details->ID, 'nav_menu_recently_edited', $menu_id ); echo 1; } else { /* New menu allreday there */ echo 2; } exit; } /** * dsamm_amm_duplicate_menu function * * This function will duplicate the selected menu. * * @version 1.0.0 * @author Multidots */ public static function dsamm_amm_duplicate_menu() { // Security check check_ajax_referer( 'dsamm_ajax_value_nonce', 'security' ); $menuid = filter_input( INPUT_POST, 'menuid', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $menuname = filter_input( INPUT_POST, 'menuname', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $ncm = ''; if ( !empty( $menuid ) && !empty( $menuname ) ) { $menu_exists = wp_get_nav_menu_object( $menuname . ' (copy)' ); if ( !$menu_exists ) { $menu_items = wp_get_nav_menu_items( $menuid ); $menu_id = wp_create_nav_menu( $menuname . ' (copy)' ); $ncm_arry = array(); foreach ( $menu_items as $item ) { if ( !empty( $item->menu_item_parent ) && '0' !== $item->menu_item_parent ) { if ( array_key_exists( $item->menu_item_parent, $ncm_arry ) ) { $ncm_arryval = $ncm_arry[$item->menu_item_parent]; } else { $ncm_arryval = ''; } $childid = $ncm_arryval; } else { $childid = '0'; } $pid = get_post_meta( $item->ID, '_menu_item_object_id', true ); $ppod = get_permalink( $pid ); if ( 'post_type' === $item->type ) { $type_label = ( $item->type_label === 'page' || $item->type_label === 'post' ? $item->type_label : 'page' ); $ncm = wp_update_nav_menu_item( $menu_id, 0, array( 'menu-item-db-id' => $item->db_id, 'menu-item-target' => $item->target, 'menu-item-attr-title' => $item->post_excerpt, 'menu-item-xfn' => $item->xfn, 'menu-item-parent-id' => $childid, 'menu-item-title' => $item->title, 'menu-item-object' => $type_label, 'menu-item-object-id' => $pid, 'menu-item-type' => $item->type, 'menu-item-classes' => esc_attr( implode( ' ', $item->classes ) ), 'menu-item-status' => 'publish', 'menu-item-description' => $item->description, ) ); } else { $ncm = wp_update_nav_menu_item( $menu_id, 0, array( 'menu-item-db-id' => $item->db_id, 'menu-item-parent-id' => $childid, 'menu-item-target' => $item->target, 'menu-item-attr-title' => $item->post_excerpt, 'menu-item-xfn' => $item->xfn, 'menu-item-title' => $item->title, 'menu-item-object' => $item->type_label, 'menu-item-type' => 'custom', 'menu-item-classes' => esc_attr( implode( ' ', $item->classes ) ), 'menu-item-status' => 'publish', 'menu-item-url' => $item->url, 'menu-item-description' => $item->description, ) ); } $ncm_arry[$item->ID] = $ncm; if ( !empty( $ncm ) && !is_wp_error( $ncm ) ) { DSAMM_Menu_Item_Visibility::copy_visibility( $item->ID, $ncm ); } } if ( !empty( $menu_id ) && !is_wp_error( $menu_id ) ) { DSAMM_Classic_Menu_Navigation_Sync::sync_classic_menu( (int) $menu_id ); } } else { echo 0; } } exit; } /** * * AMM lock menu feature * * @version 1.0.0 * @author theDotstore */ function dsamm_is_current_menu_locked( $menu_id = NULL ) { if ( empty( $menu_id ) ) { return false; } else { $user_details = wp_get_current_user(); if ( empty( $user_details->ID ) ) { return false; } $menu_lock_status = get_option( 'menu_lock_status_' . $menu_id ); if ( 'Enabled' === $menu_lock_status ) { $amm_whitelisted_user_for_menu = get_option( 'amm_user_' . $menu_id ); if ( empty( $amm_whitelisted_user_for_menu ) ) { return true; } $user_list = maybe_unserialize( $amm_whitelisted_user_for_menu ); if ( in_array( $user_details->ID, $user_list, true ) ) { return false; } else { return true; } } else { return false; } } } /** * * Allow HTML tags * * @version 1.0.0 * @author theDotstore */ function dsamm_allowed_html_tags( $tags = array() ) { $allowed_tags = array( 'a' => array( 'href' => array(), 'title' => array(), 'data-id' => array(), 'class' => array(), ), 'p' => array( 'href' => array(), 'title' => array(), 'class' => array(), ), 'span' => array( 'href' => array(), 'title' => array(), 'class' => array(), ), 'ul' => array( 'class' => array(), ), 'img' => array( 'href' => array(), 'title' => array(), 'class' => array(), 'src' => array(), ), 'li' => array( 'class' => array(), ), 'h1' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'h2' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'h3' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'h4' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'div' => array( 'class' => array(), 'id' => array(), "data-max" => array(), "data-min" => array(), "stlye" => array(), "data-name" => array(), "data-type" => array(), "data-key" => array(), ), 'select' => array( 'id' => array(), 'name' => array(), 'class' => array(), 'multiple' => array(), 'style' => array(), ), 'input' => array( 'id' => array(), 'value' => array(), 'name' => array(), 'class' => array(), 'type' => array(), ), 'textarea' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'td' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'tr' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'tbody' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'table' => array( 'id' => array(), 'name' => array(), 'class' => array(), ), 'option' => array( 'id' => array(), 'selected' => array(), 'name' => array(), 'value' => array(), ), 'br' => array(), 'em' => array(), 'strong' => array(), 'label' => array( 'for' => array(), ), ); if ( !empty( $tags ) ) { foreach ( $tags as $key => $value ) { $allowed_tags[$key] = $value; } } return $allowed_tags; } /** * Get and save plugin setup wizard data * * @since 3.1.0 * */ public static function dsamm_plugin_setup_wizard_submit() { check_ajax_referer( 'wizard_ajax_nonce', 'nonce' ); $survey_list = filter_input( INPUT_GET, 'survey_list', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( !empty( $survey_list ) && 'Select One' !== $survey_list ) { update_option( 'dsamm_where_hear_about_us', $survey_list ); } wp_die(); } /** * Send setup wizard data to sendinblue * * @since 3.1.0 * */ public static function dsamm_send_wizard_data_after_plugin_activation() { $send_wizard_data = filter_input( INPUT_GET, 'send-wizard-data', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( isset( $send_wizard_data ) && !empty( $send_wizard_data ) ) { if ( !get_option( 'dsamm_data_submited_in_sendiblue' ) ) { $dsamm_where_hear = get_option( 'dsamm_where_hear_about_us' ); $get_user = ammp_fs()->get_user(); $data_insert_array = array(); if ( isset( $get_user ) && !empty( $get_user ) ) { $data_insert_array = array( 'user_email' => $get_user->email, 'ACQUISITION_SURVEY_LIST' => $dsamm_where_hear, ); } $feedback_api_url = DSAMM_STORE_URL . 'wp-json/dotstore-sendinblue-data/v2/dotstore-sendinblue-data?' . wp_rand(); $query_url = $feedback_api_url . '&' . http_build_query( $data_insert_array ); if ( function_exists( 'vip_safe_wp_remote_get' ) ) { $response = vip_safe_wp_remote_get( $query_url, 3, 1, 20 ); } else { $response = wp_remote_get( $query_url ); // phpcs:ignore } if ( !is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) { update_option( 'dsamm_data_submited_in_sendiblue', '1' ); delete_option( 'dsamm_where_hear_about_us' ); } } } } /** * Get dynamic promotional bar of plugin * * @param String $plugin_slug slug of the plugin added in the site option * @since 3.1.0 * * @return null */ public function dsamm_get_promotional_bar( $plugin_slug = '' ) { $promotional_bar_upi_url = DSAMM_STORE_URL . 'wp-json/dpb-promotional-banner/v2/dpb-promotional-banner?' . wp_rand(); $promotional_banner_request = wp_remote_get( $promotional_bar_upi_url ); //phpcs:ignore if ( empty( $promotional_banner_request->errors ) ) { $promotional_banner_request_body = $promotional_banner_request['body']; $promotional_banner_request_body = json_decode( $promotional_banner_request_body, true ); echo '
'; if ( !empty( $promotional_banner_request_body ) && is_array( $promotional_banner_request_body ) ) { foreach ( $promotional_banner_request_body as $promotional_banner_request_body_data ) { $promotional_banner_id = $promotional_banner_request_body_data['promotional_banner_id']; $promotional_banner_cookie = $promotional_banner_request_body_data['promotional_banner_cookie']; $promotional_banner_image = $promotional_banner_request_body_data['promotional_banner_image']; $promotional_banner_description = $promotional_banner_request_body_data['promotional_banner_description']; $promotional_banner_button_group = $promotional_banner_request_body_data['promotional_banner_button_group']; $dpb_schedule_campaign_type = $promotional_banner_request_body_data['dpb_schedule_campaign_type']; $promotional_banner_target_audience = $promotional_banner_request_body_data['promotional_banner_target_audience']; if ( !empty( $promotional_banner_target_audience ) ) { $plugin_keys = array(); if ( is_array( $promotional_banner_target_audience ) ) { foreach ( $promotional_banner_target_audience as $list ) { $plugin_keys[] = $list['value']; } } else { $plugin_keys[] = $promotional_banner_target_audience['value']; } $display_banner_flag = false; if ( in_array( 'all_customers', $plugin_keys, true ) || in_array( $plugin_slug, $plugin_keys, true ) ) { $display_banner_flag = true; } } if ( true === $display_banner_flag ) { if ( 'default' === $dpb_schedule_campaign_type ) { $banner_cookie_show = filter_input( INPUT_COOKIE, 'banner_show_' . $promotional_banner_cookie, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $banner_cookie_visible_once = filter_input( INPUT_COOKIE, 'banner_show_once_' . $promotional_banner_cookie, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $flag = false; if ( empty( $banner_cookie_show ) && empty( $banner_cookie_visible_once ) ) { setcookie( 'banner_show_' . $promotional_banner_cookie, 'yes', time() + 86400 * 7 ); //phpcs:ignore setcookie( 'banner_show_once_' . $promotional_banner_cookie, 'yes' ); //phpcs:ignore $flag = true; } $banner_cookie_show = filter_input( INPUT_COOKIE, 'banner_show_' . $promotional_banner_cookie, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( !empty( $banner_cookie_show ) || true === $flag ) { $banner_cookie = filter_input( INPUT_COOKIE, 'banner_' . $promotional_banner_cookie, FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $banner_cookie = ( isset( $banner_cookie ) ? $banner_cookie : '' ); if ( empty( $banner_cookie ) && 'yes' !== $banner_cookie ) { ?> '; } } /** * Show admin footer review text. * * @since 3.1.0 */ public static function dsamm_admin_footer_review() { $url = ''; $url = esc_url( 'https://wordpress.org/plugins/advance-menu-manager/#reviews' ); $html = sprintf( wp_kses( __( 'We need your support to keep updating and improving the plugin. Please help us by leaving a good review :) Thanks!', 'advance-menu-manager' ), array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => 'blank', ), ) ), esc_url( $url ) ); echo wp_kses_post( $html ); } /** * Set convert_to_pro flag after Freemius purchase. * * @since 3.2.0 */ public static function dsamm_convert_to_pro_purchase() { check_ajax_referer( 'dsamm_convert_to_pro_purchase', 'security' ); if ( !current_user_can( 'manage_options' ) ) { wp_send_json_error(); } update_option( 'dsamm_convert_to_pro', true ); wp_send_json_success(); } /** * Dismiss convert to pro notice. * * @since 3.2.0 */ public static function dsamm_handle_convert_to_pro_dismiss() { $dismiss = filter_input( INPUT_GET, 'dsamm-dismiss-convert-to-pro', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $nonce = filter_input( INPUT_GET, '_dsamm_convert_to_pro_nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( '1' !== sanitize_text_field( $dismiss ) ) { return; } if ( !wp_verify_nonce( sanitize_text_field( $nonce ), 'dsamm_convert_to_pro_dismiss' ) ) { return; } update_option( 'dsamm_convert_to_pro', false ); } }