<?php

namespace Convertforce;

use Convertforce\Core\Post;
use Convertforce\Frontend\Frontend;

class Convertforce
{
    public static function init()
    {
        Post::register();
        self::register_blocks();
        Frontend::init();
    }


    public static function admin_init()
    {
        wp_register_style(
            'convertforce-editor-style',
            CONVERTFORCE_URL . '/build/editor-style.css',
            [],
            CONVERTFORCE_VERSION
        );

        self::maybe_activation_redirect();
    }

    /**
     * Redirect to the Features (welcome) page once, right after activation.
     */
    public static function maybe_activation_redirect()
    {
        if (!get_transient('convertforce_activation_redirect')) {
            return;
        }

        delete_transient('convertforce_activation_redirect');

        // Don't redirect on bulk plugin activation or network activation.
        if (isset($_GET['activate-multi']) || is_network_admin()) {
            return;
        }

        wp_safe_redirect(admin_url('admin.php?page=convertforce'));
        exit;
    }

    public static function register_blocks()
    {
        Blocks\Conversion::register();
    }
}