wpmmenu_item_id = absint($_POST['menu_item_id']); $saved_settings = array_filter((array) get_post_meta($this->wpmmenu_item_id, '_wpmegamenu', true)); $this->wpmmenu_item_meta = $saved_settings; } if (isset($_POST['menu_item_depth'])) { $this->wpmmenu_item_depth = absint($_POST['menu_item_depth']); } if (isset($_POST['menu_id'])) { $this->wpmmenu_id = absint($_POST['menu_id']); } } /** * Return the default settings for each menu item */ public static function wpmm_menu_item_defaults() { $defaults = array( 'menu_type' => 'flyout', //flyout or megamenu 'panel_columns' => 6, // total number of columns displayed in the panel 'wpmm_mega_menu_columns' => 1, // for sub menu items, how many columns to span in the panel, 'wp_menu_order' => 0, 'general_settings' => array( 'active_link' => 'true', 'disable_text' => 'false', 'visible_hidden_menu' => 'false', 'hide_arrow' => 'false', 'hide_on_mobile' => 'false', 'hide_on_desktop' => 'false', 'menu_icon' => 'disabled', 'active_single_menu' => 'disabled', //useful for custom single menu links 'menu_align' => 'left', //default as left with left or right menitem useful for custom search bar:Right aligned items will appear in reverse order on the right hand side of the menu bar 'top_menu_label' => '', // Hot! , New! for top menu 'hide_sub_menu_on_mobile' => 'false', 'submenu_align' => 'left' //left or right, // flyout menu ), 'mega_menu_settings' => array( 'horizontal-menu-position' => 'full-width', //full-width, center, left-edge and right-edge 'vertical-menu-position' => 'full-height', //full-height or aligned-to-parent 'show_top_content' => 'true', 'show_bottom_content' => 'true', 'top' => array( 'top_content_type' => 'text_only', 'top_content' => '', 'image_url' => '', 'html_content' => '' ), 'bottom' => array( 'bottom_content_type' => 'text_only', 'bottom_content' => '', 'image_url' => '', 'html_content' => '' ), 'choose_menu_type' => 'default', // for default as sub menu and search form display with custom content for shortcodes. 'custom_content' => '' ), 'flyout_settings' => array( 'flyout-position' => 'right', //left or right 'vertical-position' => 'full-height', // full-hegiht or aligned-to-parent, ), 'icons_settings' => array( 'icon_choose' => '', ), 'upload_image_settings' => array( 'use_custom_settings' => 'false', 'text_position' => 'left', // left image, right image or onlyimage , for pro : above, below and image only. 'display_posts_images' => 'featured-image', //featured-image or custom-image of posts 'default_thumbnail_imageurl' => '', 'show_description' => 'true', 'show_desc_length' => '', 'display_readmore' => 'true', 'readmore_text' => 'Read more >>', 'display_post_date' => 'true', 'display_author_name' => 'true', 'display_cat_name' => 'true', 'image_size' => 'default', 'enable_custom_inherit' => '1', 'custom_width' => '' ), ); $wpmm_default_settings = get_option('wpmm_default_settings'); if (empty($wpmm_default_settings)) { update_option('wpmm_default_settings', $defaults); } return $wpmm_default_settings; } /* * Includes ALl Class Files Here */ function apmm_menu_page() { add_menu_page(__(APMM_TITLE, APMM_TD), __(APMM_TITLE, APMM_TD), 'manage_options', APMM_TD, array($this, 'ap_main_page'), ''); add_submenu_page(APMM_TD, __('General Settings', APMM_TD), __('General Settings', APMM_TD), 'manage_options', APMM_TD, array($this, 'ap_main_page')); add_submenu_page(APMM_TD, __('Theme Settings', APMM_TD), __('Theme Settings', APMM_TD), 'manage_options', 'wpmm-theme-settings', array($this, 'add_theme_settings')); add_submenu_page(APMM_TD, __('How to Use', APMM_TD), __('How to Use', APMM_TD), 'manage_options', 'wpmm-how-to-use', array($this, 'how_to_use_page')); add_submenu_page(APMM_TD, __('More WordPress Stuff', APMM_TD), __('More WordPress Stuff', APMM_TD), 'manage_options', 'wpmm-about-us', array($this, 'about_us_page')); if (isset($_GET['action']) && $_GET['action'] == 'edit_theme') { add_submenu_page('null', __('Edit theme', APMM_TD), __('Edit theme', APMM_TD), 'manage_options', 'wpmm-add-theme', array($this, 'apmm_add_theme')); } else { add_submenu_page('null', __('Create theme', APMM_TD), __('Create theme', APMM_TD), 'manage_options', 'wpmm-add-theme', array($this, 'apmm_add_theme')); } } /* * Main Settings Page */ function ap_main_page() { //theme settings or main page include_once(APMM_PATH . '/inc/backend/main_page.php'); } /* * Theme Lists Page */ function add_theme_settings() { include_once(APMM_PATH . '/inc/backend/view/theme_lists_settings.php'); } /* * How to use Page */ function how_to_use_page() { include_once(APMM_PATH . '/inc/backend/how_to_use.php'); } /* * About Us Page */ function about_us_page() { include_once(APMM_PATH . '/inc/backend/about.php'); } /* * Create New Theme Page */ function apmm_add_theme() { include_once(APMM_PATH . '/inc/backend/view/add_theme_settings.php'); } /* * Saves General Settings to database */ function apmegamenu_save_settings() { if (!empty($_POST) && wp_verify_nonce($_POST['apmegamenu-nonce-setup'], 'apmegamenu-nonce')) { if (isset($_POST['settings_submit'])) { include_once(APMM_PATH . '/inc/backend/save_settings.php'); } else if (isset($_POST['export_submit'])) { $custom_theme_id = sanitize_text_field($_POST['custom_theme_id']); if ($custom_theme_id != '') { $theme_details = AP_Theme_Settings::get_theme_detail($custom_theme_id); $filename = sanitize_title($theme_details['title']); $json = json_encode($theme_details); header('Content-disposition: attachment; filename=' . $filename . '.json'); header('Content-type: application/json'); echo( $json); } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu')); exit; } } else if (isset($_POST['import_submit'])) { if (!empty($_FILES) && $_FILES['import_theme_file']['name'] != '') { $filename = $_FILES['import_theme_file']['name']; $filename_array = explode('.', $filename); $filename_ext = end($filename_array); if ($filename_ext == 'json') { $new_filename = 'import-' . rand(111111, 999999) . '.' . $filename_ext; $upload_path = APMM_PATH . 'temp/' . $new_filename; $source_path = $_FILES['import_theme_file']['tmp_name']; $check = @move_uploaded_file($source_path, $upload_path); if ($check) { $url = APMM_URL . 'temp/' . $new_filename; $params = array( 'sslverify' => false, 'timeout' => 60 ); $connection = wp_remote_get($url, $params); if (!is_wp_error($connection)) { $body = $connection['body']; $theme_row = json_decode($body); unlink($upload_path); $check = AP_Theme_Settings::import_custom_theme($theme_row); if ($check) { wp_redirect(admin_url('admin.php?page=ap-mega-menu&message=3')); exit; } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu&error_message=1')); } } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu&error_message=1')); } } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu&error_message=2')); } } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu&error_message=3')); } } else { wp_redirect(admin_url('admin.php?page=ap-mega-menu&error_message=4')); } } else if (isset($_POST['restore_old_settings'])) { $default_settings = APMM_Class::apmm_default_settings(); update_option('apmega_settings', $default_settings); wp_redirect(admin_url('admin.php?page=ap-mega-menu&message=2'));// } } else { die('No script kiddies please!'); } } /* * Admin Enqueue style and js */ function apmegamenu_admin_scripts($hook) { $plugin_pages = array(APMM_TD, 'wpmm-theme-settings', 'wpmm-how-to-use', 'wpmm-add-theme', 'wpmm-edit-theme', 'wpmm-about-us', 'ap-mega-menu'); if (isset($_GET['page']) && in_array($_GET['page'], $plugin_pages)) { wp_enqueue_style('wp_megamenu-bootstrap-style', APMM_CSS_DIR . '/bootstrap.min.css', false, APMM_TD); wp_enqueue_style('wp_megamenu-verticaltabs-style', APMM_CSS_DIR . '/bootstrap.vertical-tabs.css', false, APMM_TD); wp_enqueue_script('wp_megamenu-bootstrap-scripts', APMM_JS_DIR . '/bootstrap.min.js', array('jquery'), false, APMM_TD); wp_enqueue_style('wp-color-picker'); //for including color picker css wp_enqueue_style('wpmm-custom-select-css', APMM_CSS_DIR . '/jquery.selectbox.css', array(), APMM_TD); wp_enqueue_style('wp_megamenu-admin-style', APMM_CSS_DIR . '/backend.css', false, APMM_TD); wp_enqueue_script('wp_megamenu-color-alpha-scripts', APMM_JS_DIR . '/wp-color-picker-alpha.js', array('wp-color-picker'), false, APMM_TD); wp_enqueue_style('wpmm-icon-picker-font-awesome', APMM_CSS_DIR . '/wpmm-icons/font-awesome/font-awesome.css', false, APMM_TD); wp_enqueue_style('wpmm-codemirror-css', APMM_CSS_DIR . '/syntax/codemirror.css', false, APMM_TD); wp_enqueue_script('wpmm-codemirror-js', APMM_JS_DIR . '/syntax/codemirror.js', array('jquery'), APMM_TD); wp_enqueue_script('wpmm-codemirror-css-js', APMM_JS_DIR . '/syntax/css.js', array('jquery', 'wpmm-codemirror-js'), APMM_TD); } wp_enqueue_script('wp-megamenu-custom-select-js', APMM_JS_DIR . '/jquery.selectbox-0.2.min.js', array('jquery'), APMM_TD); wp_enqueue_script('wp_megamenu-admin-scripts', APMM_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-core', 'wp-color-picker', 'wp-megamenu-custom-select-js'), false, APMM_TD); } /** * Enqueue required CSS and JS for AP Mega Menu */ function enqueue_menu_page_scripts($hook) { // echo "hook".$hook; if ('nav-menus.php' != $hook) return; $apmm_variable = array( 'plugin_javascript_path' => APMM_JS_DIR, 'depth_check_message' => __('Option only available for top level menu.', APMM_TD), 'success_msg' => __('Successfully Saved.', APMM_TD), 'saving_msg' => __('Saving Data.', APMM_TD), 'menu_lightbox' => __("AP Mega Menu", APMM_TD), 'ajax_url' => admin_url() . 'admin-ajax.php', 'checked_disabled_error' => __("Please enable AP Mega Menu using the AP Mega Menu Settings on left section of this page.", APMM_TD), 'ajax_nonce' => wp_create_nonce('apmm-ajax-nonce')); wp_localize_script('wp_megamenu-admin-scripts', 'apmm_variable', $apmm_variable); //localization of php variable in edn-pro-frontend-js wp_enqueue_style('wp_megamenu-admin-style', APMM_CSS_DIR . '/backend.css', false, APMM_TD); wp_enqueue_media(); wp_enqueue_editor(); wp_enqueue_script('accordion'); wp_enqueue_script('wpmm-ckeditor-js', APMM_JS_DIR . '/ckeditor/ckeditor.js', array('jquery'), APMM_TD); wp_enqueue_script('wpmm-ckfinder-js', APMM_JS_DIR . '/ckfinder/ckfinder.js', array('jquery'), APMM_TD); wp_enqueue_script('wp-megamenu-custom-select-js', APMM_JS_DIR . '/jquery.selectbox-0.2.min.js', array('jquery'), APMM_TD); wp_enqueue_script('wpmm-mega-menu', APMM_JS_DIR . '/admin-menu.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-accordion' ), APMM_TD); } function displayArr($array) { echo "
";
print_r($array);
echo "";
}
/*
* AP MEGA MENU METABOX
*/
function addAPMegamenuMetaBox() {
if (wp_get_nav_menus()) {
add_meta_box('nav-menu-theme-apmegamenus', __('Select AP Mega Menu Settings', APMM_TD), array($this, 'createAPMegamenuMetaBox'), 'nav-menus', 'side', 'high');
}
}
/*
* Metabox Location
*/
function createAPMegamenuMetaBox() {
$active = get_option(AP_MEGAMENU_MENU_LOCATION, array());
echo "";
}
/**
* Get the current menu ID.
* Derived From: Max Mega Menu
* https://www.maxmegamenu.com
*/
function apmm_get_selected_menu_id() {
$nav_menus = wp_get_nav_menus(array('orderby' => 'name'));
$menu_count = count($nav_menus);
$wpmegamenuselectedid = isset($_REQUEST['menu']) ? (int) $_REQUEST['menu'] : 0;
$add_new_screen = ( isset($_GET['menu']) && 0 == $_GET['menu'] ) ? true : false;
$page_count = wp_count_posts('page');
$one_theme_location_no_menus = ( 1 == count(get_registered_nav_menus()) && !$add_new_screen && empty($nav_menus) && !empty($page_count->publish) ) ? true : false;
// Get recently edited nav menu
$recently_edited = absint(get_user_option('nav_menu_recently_edited'));
if (empty($recently_edited) && is_nav_menu($wpmegamenuselectedid))
$recently_edited = $wpmegamenuselectedid;
// Use $recently_edited if none are selected
if (empty($wpmegamenuselectedid) && !isset($_GET['menu']) && is_nav_menu($recently_edited))
$wpmegamenuselectedid = $recently_edited;
// On deletion of menu, if another menu exists, show it
if (!$add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' == $_GET['action'])
$wpmegamenuselectedid = $nav_menus[0]->term_id;
// Set $wpmegamenuselectedid to 0 if no menus
if ($one_theme_location_no_menus) {
$wpmegamenuselectedid = 0;
} elseif (empty($wpmegamenuselectedid) && !empty($nav_menus) && !$add_new_screen) {
// if we have no selection yet, and we have menus, set to the first one in the list
$wpmegamenuselectedid = $nav_menus[0]->term_id;
}
return $wpmegamenuselectedid;
}
/* Derived From: Max Mega Menu
* https://www.maxmegamenu.com
*/
function apmm_megamenu_options($menuid) {
$tagged_menu_locations = $this->get_taglocation_menuid($menuid); //get location of specific menu id
$menu_theme_locations = get_registered_nav_menus(); // check if theme menu location are empty or is not empty
$menu_general_settings = get_option('wpmegabox_settings');
// echo "";
// print_r($tagged_menu_locations);
if (!count($menu_theme_locations)) {
echo "" . __("This theme does not register any menu locations.", APMM_TD) . "
";
echo "" . __("You will need to create a new menu location to enable AP Mega Menu.", APMM_TD) . "
";
} else if (!count($tagged_menu_locations)) {
echo "" . __("This Menu is not assigned to any theme location yet.
To Enable AP Mega Menu, First please assign this menu to theme location.", APMM_TD) . "
";
} else {
?>
apmm_settings_table($location, $menu_general_settings);
}
?>
";
// print_r($menu_theme_locations);
?>
$name) {
if (isset($nav_menu_locations[$id]) && $nav_menu_locations[$id] == $menuid)
$menu_locations[$id] = $name;
}
return $menu_locations;
}
function apmm_settings_table($location, $menu_general_settings) {
?>
|
/>
|
|
|
|
|
|
|
|
|
|