WordPress.org

Make WordPress Core

Ticket #14024: doing-it-wrong.php

File doing-it-wrong.php, 1.0 KB (added by SergeyBiryukov, 9 years ago)

Sample plugin to test the issue

Line 
1<?php
2/*
3Plugin Name: Doing It Wrong
4Version: 0.1
5Plugin URI: http://core.trac.wordpress.org/ticket/14024
6Description: Sample plugin to test the issues brought up in #14024 and #11526
7Author: Sergey Biryukov
8Author URI: http://profiles.wordpress.org/sergeybiryukov/
9*/
10
11/**
12 * Call wp_get_current_user() too early
13 *
14 * Current user information is only available on init action or later.
15 *
16 * @link http://core.trac.wordpress.org/ticket/14024
17 */
18function diw_get_current_user_too_early() {
19        wp_get_current_user();
20}
21add_action('plugins_loaded', 'diw_get_current_user_too_early');
22
23/**
24 * Call wp_register_script() too early
25 *
26 * Scripts and styles should not be registered or enqueued until
27 * the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
28 *
29 * @link http://core.trac.wordpress.org/ticket/11526
30 */
31function diw_register_script_too_early() {
32        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js' );
33}
34add_action('plugins_loaded', 'diw_register_script_too_early');
35?>