Analysis of WordPress plugin implementation process

Source: Internet
Author: User
Tags php code

1, first of all, I now write a pugins folder under the plugin

Copy PHP content to clipboard

PHP Code:

<?php 
/*
Plugin Name: test
Plugin URI: [url=http://wordpress.org/]http://wordpress.org/[/url]#
Description: 我测试用的
Author: lw(fantasy)
Version: 0.1
Author URI: [url=http://www.xxx.com/]http://www.xxx.com/[/url] 
*/ 
$test = "<div id='my_test'>这是我的第一个插件!</div>";
function output(){ 
  global $test;
  echo $test;
}
add_action('wp_footer','output');
?>

And then enable it in the background.

2, WP implementation is loaded in the "wp-settings.php", and in this file, you can find the following plug-in-related code snippets:

Copy PHP content to clipboard

PHP Code:

if ( get_option('active_plugins') ) {
$current_plugins = get_option('active_plugins');
dump($current_plugins);
if ( is_array($current_plugins) ) {
 foreach ($current_plugins as $plugin) {
  if ( '' != $plugin && 0 == validate_file($plugin) && file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
  include_once(WP_PLUGIN_DIR . '/' . $plugin);
 }
}}

I dump a bit of $current_plugins and get

Array
(
  [0] => Fanfou-Daily/Fanfou-Daily.php
  [1] => mulberrykit.php
  [2] => test.php
)

I can see that the test.php plugin I wrote has been included.

3, in the theme template in the footer.php inside will perform a function

<?php Wp_footer ();?>

And this wp_footer inside and out.

Do_action (' Wp_footer ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.