To cite an example of how to use the built-in thickbox wordpress when you write a plug-in.

First step: Create a folder “wp_plugin” in the folder “plugins”

Second step: Create a file with the following code ajax.php

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
     define("VP","wp_plugin");
     define("ABSPATH", str_replace("wp-content/plugins/".VP, "", dirname(__FILE__)));

        //The inclusion of these files allows full use of all functions of wordpress
     require_once(ABSPATH.'wp-load.php');
     require_once(ABSPATH.'wp-admin/includes/admin.php');

    if($_GET['options'])
    {
        echo $_GET['options'];
    }
?>

Go next step

Third step: Create a file with the following code plugin_example.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
Plugin Name: WP plugin example
Plugin URI: http://www.developers-life.com
Description: Example using thickbox
Author: www.developers-life.com
Version: 0.1
Author URI: Vladimir Boichentsov
*/


define("VP","wp_plugin");
define("VP_URL", get_option('home')."/wp-content/plugins/".VP );

include_js();
add_action('admin_menu', 'wp_add_page');

//Add page to menu
function wp_add_page() {
    add_options_page('Admin  Menu', 'Plugin', 'manage_options', VP, 'wp_vp_adminmenu_options_page_includes');
}

//Include javascript
function include_js()
{
     if($_GET["page"] == VP)
     {
          wp_enqueue_script( 'thickbox', get_option('home').'/wp-includes/js/thickbox/thickbox.js', array ('thickbox'), '3.1-20080430' );
          add_action( 'admin_head', 'helperCSS');
     }
     
}
// CSS style for thickbox
function helperCSS()
{
     echo "<link rel='stylesheet' href='".get_option('home')."/wp-includes/js/thickbox/thickbox.css?ver=20080613' type='text/css' media='all' />\n";
     
}

//Main function
function wp_vp_adminmenu_options_page_includes()
{
     echo "<a href=\"".VP_URL."/ajax.php?options=ok&amp;type=image&amp;TB_iframe=true\" class=\"thickbox\"    title='Example'>Example</a>";
}
?>

It’s easy:)

P.S.: Пишу статью на английском т.к. сам не ищу помощи на русских сайтах, а если нахожу, то в основном все на английском :) Заранее извиняюсь за свой english.