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. <?php
  2.     define("VP","wp_plugin");
  3.     define("ABSPATH", str_replace("wp-content/plugins/".VP, "", dirname(__FILE__)));
  4.  
  5.         //The inclusion of these files allows full use of all functions of wordpress
  6.     require_once(ABSPATH.'wp-load.php');
  7.     require_once(ABSPATH.'wp-admin/includes/admin.php');
  8.  
  9.     if($_GET['options'])
  10.     {
  11.         echo $_GET['options'];
  12.     }
  13. ?>

Go next step

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

  1. <?php
  2. /*
  3. Plugin Name: WP plugin example
  4. Plugin URI: http://www.sakrist.com
  5. Description: Example using thickbox
  6. Author: www.sakrist.com
  7. Version: 0.1
  8. Author URI: Vladimir Boichentsov
  9. */
  10.  
  11. define("VP","wp_plugin");
  12. define("VP_URL", get_option('home')."/wp-content/plugins/".VP );
  13.  
  14. include_js();
  15. add_action('admin_menu', 'wp_add_page');
  16.  
  17. //Add page to menu
  18. function wp_add_page() {
  19.     add_options_page('Admin  Menu', 'Plugin', 'manage_options', VP, 'wp_vp_adminmenu_options_page_includes');
  20. }
  21.  
  22. //Include javascript
  23. function include_js()
  24. {
  25.     if($_GET["page"] == VP)
  26.     {
  27.         wp_enqueue_script( 'thickbox', get_option('home').'/wp-includes/js/thickbox/thickbox.js', array ('thickbox'), '3.1-20080430' );
  28.         add_action( 'admin_head', 'helperCSS');
  29.     }
  30.    
  31. }
  32. // CSS style for thickbox
  33. function helperCSS()
  34. {
  35.     echo "<link rel='stylesheet' href='".get_option('home')."/wp-includes/js/thickbox/thickbox.css?ver=20080613' type='text/css' media='all' />\n";
  36.    
  37. }
  38.  
  39. //Main function
  40. function wp_vp_adminmenu_options_page_includes()
  41. {
  42.     echo "<a href=\"".VP_URL."/ajax.php?options=ok&amp;type=image&amp;TB_iframe=true\" class=\"thickbox\"   title='Example'>Example</a>";
  43. }
  44. ?>

It’s easy:)

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