<?php

/**
 * Freemius runtime bootstrap for packaged release builds.
 *
 * @package Shrinkwell_Image_Optimizer
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( !function_exists( 'shrinkwell_fs' ) ) {
    function shrinkwell_fs() {
        global $shrinkwell_fs;
        if ( is_object( $shrinkwell_fs ) ) {
            return $shrinkwell_fs;
        }
        $sdk_file = __DIR__ . '/vendor/freemius/start.php';
        if ( !is_readable( $sdk_file ) ) {
            return null;
        }
        if ( !function_exists( 'fs_dynamic_init' ) ) {
            require_once $sdk_file;
        }
        if ( !function_exists( 'fs_dynamic_init' ) ) {
            return null;
        }
        $shrinkwell_fs = fs_dynamic_init( [
            'id'               => 30835,
            'slug'             => 'shrinkwell-image-optimizer',
            'type'             => 'plugin',
            'public_key'       => 'pk_624755e4801c8313279c93227b85f',
            'is_premium'       => false,
            'premium_suffix'   => 'Pro',
            'has_paid_plans'   => true,
            'has_addons'       => false,
            'is_org_compliant' => true,
            'anonymous_mode'   => true,
            'menu'             => [
                'slug'        => 'shrinkwell-image-optimizer',
                'account'     => true,
                'contact'     => false,
                'support'     => false,
                'pricing'     => false,
                'affiliation' => false,
                'addons'      => false,
                'parent'      => [
                    'slug' => 'upload.php',
                ],
            ],
            'is_live'          => true,
        ] );
        if ( is_object( $shrinkwell_fs ) && method_exists( $shrinkwell_fs, 'set_basename' ) ) {
            $shrinkwell_fs->set_basename( false, __DIR__ . '/shrinkwell-image-optimizer.php' );
        }
        return ( is_object( $shrinkwell_fs ) ? $shrinkwell_fs : null );
    }

}
if ( !function_exists( 'shrinkwell_hide_freemius_media_submenus' ) ) {
    function shrinkwell_hide_freemius_media_submenus() : void {
        remove_submenu_page( 'upload.php', 'shrinkwell-image-optimizer-account' );
        remove_submenu_page( 'upload.php', 'shrinkwell-image-optimizer-pricing' );
        remove_submenu_page( 'upload.php', 'shrinkwell-image-optimizer-contact' );
        remove_submenu_page( 'upload.php', 'shrinkwell-image-optimizer-affiliation' );
        remove_submenu_page( 'upload.php', 'shrinkwell-image-optimizer-addons' );
    }

}
shrinkwell_fs();
add_action( 'admin_menu', 'shrinkwell_hide_freemius_media_submenus', 999 );
