最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - My Wordpress activation hook isn't working

programmeradmin3浏览0评论

I just can't see why my activation hook isn't working.

/* ****Debug function ****/
function console_log( $data ){

  echo '<script>';
  echo 'console.log('. json_encode( $data ) .')';
  echo '</script>';
}
console_log ("Hello from main");

/* ***Set up activation and deactivation functions**
*** Activate sets up the WP tables "picm"**
*** Deactivate removes the WP tables "picm" */
function picm_activate() {
    global $wpdb;
    console_log ("Hello from activate");
    $wpdb->query("CREATE TABLE ".$wpdb->prefix."picm_menus (
        m_id integer INT, 
        m_type INT, 
        m_stype VARCHAR(50), 
        m_sizeh VARCHAR(20), 
        msizev VARCHAR(20), 
        m_elements INT, 
        m_double TINYINT)"); // to be completed
    $wpdb->query("CREATE TABLE ".$wpdb->prefix."picm_elements (
        m_elid INT, 
        m_id integer INT, 
        m_el_source VARCHAR (500))"); // to be completed
    }
register_activation_hook( __FILE__, 'picm_activate' );

The console output is:

GET.php?action=activate&plugin=picture-menus%2Fpicture-menus.php&plugin_status=all&paged=1&s&_wpnonce=cbb8f69901
[HTTP/2.0 302 Found 236ms]

GET.php?error=true&charsout=98&plugin=picture-menus%2Fpicture-menus.php&plugin_status=all&paged=1&s&_error_nonce=46dd486539
[HTTP/2.0 200 OK 284ms]

Hello from main plugins.php:1:9
GET.php?c=0&dir=ltr&load%5Bchunk_0%5D=dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets&load%5Bchunk_1%5D=,site-icon,l10n,buttons,wp-auth-check&ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.css?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.png
[HTTP/2.0 404 Not Found 250ms]

GET.php?c=0&load%5Bchunk_0%5D=hoverIntent,common,admin-bar,underscore,wp-util&ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=7.4.4
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=2.5.1
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=2.5.1
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=1.11.4
[HTTP/2.0 200 OK 0ms]

GET.js?ver=3.1-20121105
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=2.6.0
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

JQMIGRATE: Migrate is installed, version 1.4.1 load-scripts.php:8:552
GET.min.js?ver=5.3
[HTTP/2.0 200 OK 0ms]

GET;d=mm&r=g
[HTTP/2.0 200 OK 0ms]

GET;d=mm&r=g
[HTTP/2.0 200 OK 0ms]

GET.ico
[HTTP/2.0 200 OK 0ms]

​As you can see, the console output from the main (Hello from main) is present, but the output from within the hooked activation function doesn't show. The tables don't get created either.

发布评论

评论列表(0)

  1. 暂无评论