Plugin Directory

Changeset 3447876


Ignore:
Timestamp:
01/27/2026 01:06:03 PM (2 months ago)
Author:
samuelsilvapt
Message:

Fullscreen menu 3.0

Location:
animated-fullscreen-menu
Files:
886 added
3 edited

Legend:

Unmodified
Added
Removed
  • animated-fullscreen-menu/trunk/animated-fullscreen-menu.php

    r3412698 r3447876  
    11<?php
    2 
    32/**
    43 * Plugin Name: Fullscreen Menu
     
    65 * Description: Fullscreen Menu for your Website. Create a fullscreen menu with a nice animation effect and a mobile friendly navigation. Customize the menu colors, fonts, background, animations, buttons and more.
    76 * Author: Samuel Silva
    8  * Version: 2.9.0
     7 * Version: 3.0.0
    98 * Author URI: https://wp-fullscreen-menu.com/
    109 * Text Domain: animated-fullscreen-menu
     
    1312 * Tested up to: 6.7
    1413 * Requires PHP: 7.4
    15  **/
     14 *
     15 * @package AnimatedFullscreenMenu
     16 */
    1617
     18// Prevent direct access.
    1719if ( ! defined( 'ABSPATH' ) || ! function_exists( 'add_action' ) ) {
    1820    exit;
    1921}
    2022
    21 // Check PHP version compatibility
    22 if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
    23     add_action( 'admin_notices', 'animatedfsmenu_php_version_notice' );
    24     return;
     23// Define plugin constants.
     24define( 'ANIMATEDFSM_VERSION', '3.0.0' );
     25define( 'ANIMATEDFSM_PLUGIN_FILE', __FILE__ );
     26define( 'ANIMATEDFSM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     27define( 'ANIMATEDFSM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     28
     29/**
     30 * Check PHP version compatibility.
     31 *
     32 * @return bool
     33 */
     34function animatedfsm_check_php_version() {
     35    if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
     36        add_action( 'admin_notices', 'animatedfsm_php_version_notice' );
     37        return false;
     38    }
     39    return true;
    2540}
    2641
    27 function animatedfsmenu_php_version_notice() {
     42/**
     43 * Display PHP version error notice.
     44 *
     45 * @return void
     46 */
     47function animatedfsm_php_version_notice() {
    2848    ?>
    2949    <div class="notice notice-error">
     
    4262}
    4363
    44 function animatedfsmenu_load_textdomain() {
    45     load_plugin_textdomain( 'animated-fullscreen-menu', false, basename( dirname( __FILE__ ) ) . '/languages' );
    46 }
    47 
    48 
    49 function animatedfsmenu_get_plugin_version() {
    50     $plugin_data = get_plugin_data( __FILE__ );
    51     return $plugin_version = $plugin_data['Version'];
     64// Check PHP version before proceeding.
     65if ( ! animatedfsm_check_php_version() ) {
     66    return;
    5267}
    5368
    5469/**
    55  * Handle plugin updates and data migration
     70 * Load Composer autoloader.
     71 *
     72 * @return bool
    5673 */
    57 function animatedfsmenu_check_version_and_migrate() {
    58     $current_version = get_option( 'animatedfsm_version', '0.0.0' );
    59     $new_version = animatedfsmenu_get_plugin_version();
     74function animatedfsm_load_autoloader() {
     75    $autoloader = ANIMATEDFSM_PLUGIN_DIR . 'vendor/autoload.php';
    6076
    61     // Only run migration if version has changed
    62     if ( version_compare( $current_version, $new_version, '<' ) ) {
    63         // Backup current settings before any migration
    64         $current_settings = get_option( 'animatedfsm_settings', array() );
    65         if ( ! empty( $current_settings ) ) {
    66             update_option( 'animatedfsm_settings_backup_' . $current_version, $current_settings );
     77    if ( file_exists( $autoloader ) ) {
     78        require_once $autoloader;
     79        return true;
     80    }
     81
     82    // Fallback: manually require classes if autoloader doesn't exist.
     83    // This ensures the plugin works even without running composer.
     84    animatedfsm_manual_autoload();
     85    return true;
     86}
     87
     88/**
     89 * Manual autoload fallback for when Composer autoload is not available.
     90 *
     91 * @return void
     92 */
     93function animatedfsm_manual_autoload() {
     94    spl_autoload_register(
     95        function ( $class ) {
     96            // Only handle our namespace.
     97            $prefix = 'AnimatedFullscreenMenu\\';
     98            $len    = strlen( $prefix );
     99
     100            if ( strncmp( $prefix, $class, $len ) !== 0 ) {
     101                return;
     102            }
     103
     104            // Get the relative class name.
     105            $relative_class = substr( $class, $len );
     106
     107            // Build the file path.
     108            $file = ANIMATEDFSM_PLUGIN_DIR . 'src/' . str_replace( '\\', '/', $relative_class ) . '.php';
     109
     110            if ( file_exists( $file ) ) {
     111                require_once $file;
     112            }
     113        }
     114    );
     115}
     116
     117/**
     118 * Initialize the plugin.
     119 *
     120 * @return void
     121 */
     122function animatedfsm_init() {
     123    // Load autoloader.
     124    animatedfsm_load_autoloader();
     125
     126    // Initialize the plugin.
     127    \AnimatedFullscreenMenu\Plugin::instance( ANIMATEDFSM_PLUGIN_FILE );
     128}
     129
     130// Initialize on plugins_loaded to ensure all dependencies are available.
     131add_action( 'plugins_loaded', 'animatedfsm_init', 10 );
     132
     133/**
     134 * Plugin activation hook.
     135 *
     136 * @return void
     137 */
     138function animatedfsm_activate() {
     139    // Ensure autoloader is available.
     140    animatedfsm_load_autoloader();
     141
     142    // Set default options if not exists.
     143    if ( false === get_option( 'animatedfsm_settings' ) ) {
     144        update_option( 'animatedfsm_settings', array() );
     145    }
     146
     147    // Store activation time for potential future use.
     148    if ( false === get_option( 'animatedfsm_activation_time' ) ) {
     149        update_option( 'animatedfsm_activation_time', time() );
     150    }
     151
     152    // Flush rewrite rules.
     153    flush_rewrite_rules();
     154}
     155
     156register_activation_hook( __FILE__, 'animatedfsm_activate' );
     157
     158/**
     159 * Plugin deactivation hook.
     160 *
     161 * @return void
     162 */
     163function animatedfsm_deactivate() {
     164    // Flush rewrite rules.
     165    flush_rewrite_rules();
     166}
     167
     168register_deactivation_hook( __FILE__, 'animatedfsm_deactivate' );
     169
     170/**
     171 * Global helper function for Freemius backward compatibility.
     172 *
     173 * This function provides backward compatibility with existing code that uses animatedfsm().
     174 *
     175 * @return \Freemius|null
     176 */
     177if ( ! function_exists( 'animatedfsm' ) ) {
     178    function animatedfsm() {
     179        // Ensure autoloader is loaded.
     180        if ( ! class_exists( '\AnimatedFullscreenMenu\Integrations\Freemius' ) ) {
     181            animatedfsm_load_autoloader();
    67182        }
    68183
    69         // Update version number
    70         update_option( 'animatedfsm_version', $new_version );
    71 
    72         // Hook for future migrations
    73         do_action( 'animatedfsm_after_update', $current_version, $new_version );
     184        return \AnimatedFullscreenMenu\Integrations\Freemius::get_instance();
    74185    }
    75186}
    76187
    77 add_action( 'plugins_loaded', 'animatedfsmenu_load_textdomain' );
    78 add_action( 'plugins_loaded', 'animatedfsmenu_check_version_and_migrate' );
    79 
    80 if ( ! function_exists( 'animatedfsm' ) ) {
    81     // Create a helper function for easy SDK access.
    82     function animatedfsm() {
    83 
    84         global $animatedfsm;
    85         if ( ! isset( $animatedfsm ) ) {
    86             // Include Freemius SDK.
    87             require_once dirname(__FILE__) . '/freemius/start.php';
    88             $pro = false;
    89 
    90             $animatedfsm = fs_dynamic_init( array(
    91                 'id'                  => '3887',
    92                 'slug'                => 'animated-fullscreen-menu',
    93                 'premium_slug'        => 'animated-fullscreen-menu',
    94                 'type'                => 'plugin',
    95                 'public_key'          => 'pk_95d707fced75c19ff9b793853ac8a',
    96                 'is_premium'          => $pro,
    97                 'premium_suffix'      => ( $pro ? 'Pro' : 'Free' ),
    98                 'has_premium_version' => $pro,
    99                 'has_addons'          => false,
    100                 'has_paid_plans'      => true,
    101                 'trial'               => array(
    102                     'days'               => 7,
    103                     'is_require_payment' => true,
    104                 ),
    105                 'menu'                => array(
    106                     'slug'           => 'animatedfsm_settings',
    107                     'first-path'     => 'admin.php?page=animatedfsm_settings',
    108                     'contact'        => ( $pro ? true : false ),
    109                     'support'        => true,
    110                 ),
    111 
    112             ) );
    113         }
    114 
    115         return $animatedfsm;
    116     }
    117 
    118     // Init Freemius.
    119     animatedfsm();
    120     // Signal that SDK was initiated.
    121     do_action( 'animatedfsm_loaded' );
    122 
    123     animatedfsm()->override_i18n(
    124         array(
    125             'start-trial' => __( 'Free 7 Day Pro Trial', 'interactive-geo-maps' ),
    126             'upgrade'     => __( 'Get Pro Features', 'interactive-geo-maps' ),
    127         )
    128     );
    129 
     188/**
     189 * Helper function to get plugin version.
     190 *
     191 * Backward compatibility wrapper.
     192 *
     193 * @return string
     194 */
     195function animatedfsmenu_get_plugin_version() {
     196    return ANIMATEDFSM_VERSION;
    130197}
    131 
    132 
    133 class AnimatedfsMenu {
    134 
    135     //register plugin
    136     function register() {
    137         require_once dirname( __FILE__ ) . '/cmb.php';
    138         //require_once dirname( __FILE__ ) . '/inc/class-analytics.php';
    139         add_action( 'init', array( $this, 'register_menu' ) );
    140         add_action( 'init', array( $this, 'register_block' ) );
    141         add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
    142 
    143     }
    144    
    145     function activate() {
    146 
    147     }
    148 
    149     function register_menu() {
    150         register_nav_menu( 'animated-fullscreen-menu', __( 'Fullscreen Menu', 'animated-fullscreen-menu' ) );
    151     }
    152     function register_block() {
    153         register_block_type( __DIR__ );
    154     }
    155 
    156     // Enqueue the json object from get_option( 'animatedfsm_settings' ) in the backend (Menu Editor, gutenberg only)
    157     function enqueue_block_editor_assets() {
    158    
    159         wp_localize_script(
    160             'animated-fullscreen-menu-hamburger-editor-script',
    161             'animatedfsmenu',
    162             array(
    163                 'animatedfsmenu_settings' => get_option( 'animatedfsm_settings' ),
    164             )
    165         );
    166     }
    167 }
    168 
    169 
    170 if ( class_exists( 'AnimatedfsMenu' ) ) {
    171     $animated_fs_menu = new AnimatedfsMenu();
    172     $animated_fs_menu->register();
    173 }
    174 
    175 
    176 register_activation_hook( __FILE__, array( $animated_fs_menu, 'activate' ) );
    177 
    178 
    179 if ( isset( get_option( 'animatedfsm_settings' )['animatedfsm_on'] ) && 'on' === get_option( 'animatedfsm_settings' )['animatedfsm_on'] ) {
    180     require_once dirname( __FILE__ ) . '/frontend-animatedfsmenu.php';
    181 }
    182 
    183 // Handle preview menu with proper security checks
    184 if ( ! empty( $_GET['afs_preview_menu'] ) ) {
    185     $preview_value = sanitize_text_field( wp_unslash( $_GET['afs_preview_menu'] ) );
    186 
    187     // Verify nonce for preview (admin only)
    188     if ( 'true' === $preview_value && current_user_can( 'manage_options' ) ) {
    189         // Verify nonce if provided
    190         if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'afs_preview_menu' ) ) {
    191             require_once dirname( __FILE__ ) . '/frontend-animatedfsmenu.php';
    192         } elseif ( is_admin() ) {
    193             // In admin context without nonce (backward compatibility for existing preview links)
    194             require_once dirname( __FILE__ ) . '/frontend-animatedfsmenu.php';
    195         }
    196     }
    197 }
  • animated-fullscreen-menu/trunk/cmb.php

    r3044044 r3447876  
    11<?php
    2 
    3 
    4 if ( file_exists( dirname( __FILE__ ) . '/vendor/CMB2/init.php' ) ) {
    5     require_once dirname( __FILE__ ) . '/vendor/CMB2/init.php';
     2/**
     3 * CMB2 Settings Configuration
     4 *
     5 * Note: CMB2 and its extensions are now loaded via src/Admin/Admin.php
     6 * on the admin_init hook (after textdomain is loaded) to fix the
     7 * _load_textdomain_just_in_time warning.
     8 *
     9 * This file only contains the settings configuration, not the library loading.
     10 *
     11 * @package AnimatedFullscreenMenu
     12 */
     13
     14// Prevent direct access.
     15if ( ! defined( 'ABSPATH' ) ) {
     16    exit;
    617}
    718
    8 
    9 if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-field-faiconselect/iconselect.php' ) ) {
    10     require_once dirname( __FILE__ ) . '/vendor/cmb2-field-faiconselect/iconselect.php';
     19// Only load CMB2 here if not already loaded (backward compatibility).
     20// In normal operation, Admin.php loads CMB2 before including this file.
     21if ( ! defined( 'CMB2_LOADED' ) ) {
     22    if ( file_exists( dirname( __FILE__ ) . '/vendor/CMB2/init.php' ) ) {
     23        require_once dirname( __FILE__ ) . '/vendor/CMB2/init.php';
     24    }
     25
     26    if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-field-faiconselect/iconselect.php' ) ) {
     27        require_once dirname( __FILE__ ) . '/vendor/cmb2-field-faiconselect/iconselect.php';
     28    }
     29
     30    if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-tabs/cmb2-tabs.php' ) ) {
     31        require_once dirname( __FILE__ ) . '/vendor/cmb2-tabs/cmb2-tabs.php';
     32    }
     33
     34    if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-conditionals/cmb2-conditionals.php' ) && isset( $_GET['page'] ) && 'animatedfsm_settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     35        require_once dirname( __FILE__ ) . '/vendor/cmb2-conditionals/cmb2-conditionals.php';
     36    }
    1137}
    1238
    13 if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-tabs/cmb2-tabs.php' ) ) {
    14     require_once dirname( __FILE__ ) . '/vendor/cmb2-tabs/cmb2-tabs.php';
    15 }
    16 
    17 function animatedfsmenu_backend_styles() { //phpcs:ignore
    18     wp_enqueue_style( 'styles-fullscreen-menu', plugins_url( 'admin/css/styles.css', __FILE__ ), array(), '1.0' );
    19 }
    20 add_action( 'admin_enqueue_scripts', 'animatedfsmenu_backend_styles' );
    21 
    22 if ( file_exists( dirname( __FILE__ ) . '/vendor/cmb2-conditionals/cmb2-conditionals.php' ) && isset($_GET['page']) && 'animatedfsm_settings' == $_GET['page'] ) {
    23     require_once dirname( __FILE__ ) . '/vendor/cmb2-conditionals/cmb2-conditionals.php';
     39// Enqueue admin styles (only if not already enqueued by Admin class).
     40if ( ! function_exists( 'animatedfsmenu_backend_styles' ) ) {
     41    function animatedfsmenu_backend_styles() { // phpcs:ignore
     42        wp_enqueue_style( 'styles-fullscreen-menu', plugins_url( 'admin/css/styles.css', __FILE__ ), array(), '1.0' );
     43    }
     44    add_action( 'admin_enqueue_scripts', 'animatedfsmenu_backend_styles' );
    2445}
    2546
     
    5677
    5778
    58 add_action( 'cmb2_admin_init', 'animatedfsmenu_register_theme_options_metabox' );
    5979/**
    6080 * Hook in and register a metabox to handle a theme options page and adds a menu item.
     81 *
     82 * Note: This function is called directly when this file is loaded during cmb2_admin_init.
     83 * We don't use add_action('cmb2_admin_init', ...) because the hook is already firing
     84 * when this file is included by Admin.php.
    6185 */
    6286function animatedfsmenu_register_theme_options_metabox() {
     
    6892        array(
    6993            'id'           => 'animatedfsmenu_theme_options_page',
    70             'title'        => esc_html__( 'Fullscreen Menu Options', 'animated-fullscreen-menu' ),
     94            'title'        => esc_html__( 'Fullscreen Menu', 'animated-fullscreen-menu' ),
    7195            'object_types' => array( 'options-page' ),
    7296            'option_key'   => 'animatedfsm_settings',
  • animated-fullscreen-menu/trunk/readme.txt

    r3412698 r3447876  
    55Tested up to: 6.9
    66Requires at least: 5.0
    7 Stable tag: 2.9.0
     7Stable tag: 3.0.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    111111
    112112== Changelog ==
     113= 3.0.0 =
     114* **Major Release:** Complete codebase modernization for better performance and future WordPress Block Editor (Site Editor) compatibility
     115* **Architecture:** Refactored to modern Object-Oriented Programming (OOP) with namespaced classes and PSR-4 autoloading
     116* **New Structure:** Organized code into dedicated classes: Plugin, Admin, Frontend, MenuRenderer, AssetLoader, BlockManager, and integration classes for WooCommerce, Polylang, and Freemius
     117* **Fixed:** Resolved `_load_textdomain_just_in_time` warning by properly deferring CMB2 loading until after textdomain initialization
     118* **Improved:** Centralized options handling with new Options utility class
     119* **Improved:** Better separation of concerns between admin, frontend, and block functionality
     120* **Improved:** Cleaner main plugin file - now serves as bootstrap only
     121* **Developer:** Added Composer support for autoloading
     122* **Compatibility:** Fully backward compatible - all existing settings are preserved and work as before
     123* **Foundation:** This release lays the groundwork for future Site Editor (Full Site Editing) block support
     124
    113125= 2.9.0 =
    114126* **Security:** Enhanced security for preview menu feature with proper input sanitization and nonce verification
Note: See TracChangeset for help on using the changeset viewer.