premium upgrade, without a fatal error from * duplicate constants, functions or classes. */ $amber_mega_menu_is_premium = file_exists( plugin_dir_path( __FILE__ ) . 'premium/class-smm-pro.php' ); if ( function_exists( 'amber_mega_menu_fs' ) ) { amber_mega_menu_fs()->set_basename( $amber_mega_menu_is_premium, __FILE__ ); } else { /** * Freemius handles licensing, payments, activation limits and premium updates * for both the free and the premium build of this single codebase. * * Plans, prices and activation limits are configured in the Freemius dashboard, * never in this code. */ if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/freemius/start.php' ) ) { function amber_mega_menu_fs() { global $amber_mega_menu_fs; if ( ! isset( $amber_mega_menu_fs ) ) { require_once plugin_dir_path( __FILE__ ) . 'vendor/freemius/start.php'; $amber_mega_menu_fs = fs_dynamic_init( array( 'id' => '39701', 'slug' => 'amber-mega-menu', 'type' => 'plugin', 'public_key' => 'pk_e61675066c6c08c30f8e87a35d0a7', 'is_premium' => file_exists( plugin_dir_path( __FILE__ ) . 'premium/class-smm-pro.php' ), 'premium_suffix' => 'Pro', 'has_premium_version' => true, 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'menu' => array( 'slug' => 'amber-mega-menu', 'support' => false, 'contact' => false, 'account' => true, 'pricing' => true, ), ) ); } return $amber_mega_menu_fs; } amber_mega_menu_fs(); do_action( 'amber_mega_menu_fs_loaded' ); } define( 'AMBER_MEGA_MENU_VERSION', '2.1.2' ); define( 'AMBER_MEGA_MENU_FILE', __FILE__ ); define( 'AMBER_MEGA_MENU_DIR', plugin_dir_path( __FILE__ ) ); define( 'AMBER_MEGA_MENU_URL', plugin_dir_url( __FILE__ ) ); define( 'AMBER_MEGA_MENU_CPT', 'smm_menu' ); require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-features.php'; require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-source.php'; require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-admin.php'; require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-settings.php'; require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-license.php'; require_once AMBER_MEGA_MENU_DIR . 'includes/class-smm-render.php'; # --- Premium build only. Freemius strips this block from the free ZIP. # The file_exists() check keeps the free build safe even if it is not stripped. --- #!if!premium_only if ( file_exists( AMBER_MEGA_MENU_DIR . 'premium/class-smm-pro.php' ) && ( ! function_exists( 'amber_mega_menu_fs' ) || amber_mega_menu_fs()->can_use_premium_code() ) ) { define( 'AMBER_MEGA_MENU_PRO', true ); require_once AMBER_MEGA_MENU_DIR . 'premium/class-smm-pro.php'; add_action( 'plugins_loaded', array( 'Amber_Mega_Menu_Pro', 'init' ), 5 ); } #endif add_action( 'init', 'amber_mega_menu_register_cpt' ); function amber_mega_menu_register_cpt() { register_post_type( AMBER_MEGA_MENU_CPT, array( 'labels' => array( 'name' => __( 'Mega Menus', 'amber-mega-menu' ), 'singular_name' => __( 'Mega Menu', 'amber-mega-menu' ), 'add_new_item' => __( 'Add Mega Menu', 'amber-mega-menu' ), 'edit_item' => __( 'Edit Mega Menu', 'amber-mega-menu' ), 'menu_name' => __( 'Mega Menus', 'amber-mega-menu' ), ), 'public' => false, // Editing happens on the plugin's own settings screens, not the post editor. 'show_ui' => false, 'show_in_menu' => false, 'supports' => array( 'title' ), 'capability_type' => 'post', 'map_meta_cap' => true, ) ); } /** * Anyone landing on the classic post editor for a mega menu (old bookmarks, * links saved before the dedicated settings screens existed) is sent to the * plugin screen instead of hitting a permission error. */ add_action( 'load-post.php', 'amber_mega_menu_redirect_legacy_editor' ); add_action( 'load-post-new.php', 'amber_mega_menu_redirect_legacy_editor' ); function amber_mega_menu_redirect_legacy_editor() { // Read-only routing parameters; the redirect only navigates to an admin page. $type = isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $id = isset( $_GET['post'] ) ? (int) $_GET['post'] : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( $id ) { $type = get_post_type( $id ); } if ( AMBER_MEGA_MENU_CPT !== $type ) { return; } $args = array( 'page' => Amber_Mega_Menu_Settings::PAGE ); if ( $id ) { $args['action'] = 'edit'; $args['menu'] = $id; } wp_safe_redirect( add_query_arg( $args, admin_url( 'admin.php' ) ) ); exit; } Amber_Mega_Menu_Admin::init(); Amber_Mega_Menu_Settings::init(); Amber_Mega_Menu_License::init(); Amber_Mega_Menu_Render::init(); }