Tuesday, November 22, 2022
HomeWordPress Developmentplugins - register_activation_hook not working

plugins – register_activation_hook not working


I’ve a primary file for my plugin that comprises the next:

<?php
/**
Plugin data
 */

outline( 'PLUGIN__DIR', plugin_dir_path( __FILE__ ) );

require_once( PLUGIN__DIR . 'class.properties.php' );

// Init properties
add_action( 'init', array( 'properties', 'init' ) );

Inside the category that’s required I add a register_activation_hook that should create some tables. I observed no tables have been added so I attempted including a die() or wp_die() to see if it even comes there in any respect, however nothing occurs when activating the plugin.

So I’m guessing it by no means will get to the activation hook, however why?

What am I lacking?

My class that comprises the activation hook:

<?php

class Properties
{
    non-public static $initiated = false;

    public static operate init()
    {
        if (!self::$initiated) {
            self::initHooks();
        }
    }

    non-public static operate initHooks()
    {
        self::$initiated = true;
        register_activation_hook(PLUGIN__DIR, 'initTables');
        add_menu_page('Properties', 'Properties', 'manage_options', 'properties/overzicht', array(__CLASS__, 'propertiesIndex'), 'dashicons-admin-multisite', 6);
    }

    public static operate initTables()
    {
        wp_die();

        international $wpdb;
        $charset_collate = $wpdb->get_charset_collate();

        $sql = "
        CREATE TABLE ". $wpdb->prefix ."properties (
        id int(10) UNSIGNED NOT NULL,
        office_id int(10) UNSIGNED NOT NULL,
        system varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        reference varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        tiara_id varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        energetic tinyint(1) NOT NULL DEFAULT '1',
        vertrouwelijk tinyint(1) NOT NULL DEFAULT '0',
        publish tinyint(1) NOT NULL DEFAULT '1',
        featured tinyint(1) NOT NULL DEFAULT '0',
        hidden tinyint(1) NOT NULL DEFAULT '0',
        quiet tinyint(1) NOT NULL DEFAULT '0',
        straat varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
        huisnummer varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huisnummer_toevoeging varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        postcode varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        wijk varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        gemeente varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        plaats varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
        provincie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        land varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        latitude decimal(10,8) DEFAULT NULL,
        longitude decimal(11,8) DEFAULT NULL,
        standing varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        aanmelding varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koop tinyint(1) NOT NULL DEFAULT '0',
        koopprijs_voorvoegsel varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koopprijs int(10) UNSIGNED DEFAULT NULL,
        koopprijs_conditie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koopprijs_specificatie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        vov_datum datetime DEFAULT NULL,
        vov_datum_tot datetime DEFAULT NULL,
        transactie_datum datetime DEFAULT NULL,
        woz_waarde int(10) UNSIGNED DEFAULT NULL,
        woz_peildatum date DEFAULT NULL,
        koopmengvorm varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huur tinyint(1) NOT NULL DEFAULT '0',
        huurprijs_voorvoegsel varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huurprijs int(10) UNSIGNED DEFAULT NULL,
        huurprijs_conditie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huurprijs_specificatie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        prijs_tonen tinyint(1) NOT NULL DEFAULT '1',
        servicekosten int(10) UNSIGNED DEFAULT NULL,
        aanvaarding varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        aanvaarding_datum datetime DEFAULT NULL,
        aanvaarding_toelichting varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        omschrijving longtext COLLATE utf8mb4_unicode_ci,
        omschrijving_engels textual content COLLATE utf8mb4_unicode_ci,
        gekoppelde_makelaar varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        bouwvorm varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        openhuis_van datetime DEFAULT NULL,
        openhuis_tot datetime DEFAULT NULL,
        openhuis_toelichting textual content COLLATE utf8mb4_unicode_ci,
        ingevoerd_op datetime NOT NULL,
        gewijzigd_op datetime DEFAULT NULL,
        veiling_op datetime DEFAULT NULL,
        gewijzigd_status_op datetime DEFAULT NULL,
        gewijzigd_media_op datetime DEFAULT NULL,
        gewijzigd_prijs_op datetime DEFAULT NULL,
        verwijderd_op datetime DEFAULT NULL,
        created_at timestamp NULL DEFAULT NULL,
        updated_at timestamp NULL DEFAULT NULL,
        bouwtype_id int(10) UNSIGNED DEFAULT NULL,
        url_360 varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_tour varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_youtube varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_floorplanner varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        show_maps tinyint(1) NOT NULL DEFAULT '1',
        show_streetview tinyint(1) NOT NULL DEFAULT '1',
        prioriteit int(11) DEFAULT NULL,
        accountmanager varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL
        PRIMARY KEY  (id)
        )". $charset_collate .";";

        require_once(ABSPATH . 'wp-admin/consists of/improve.php');
        dbDelta($sql);
    }

    public static operate propertiesIndex()
    {
        embrace 'views/index.php';
    }

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments