[PHP] create plugin and short code in WordPress

<?php

/**
 * Plugin Name: Wonder Fan
 * Plugin URI: http://blog.csdn.net/wonderfan
 * Description: This plugin is created by WF
 * Version: 1.0.0
 * Author: [email protected]
 */

if(!class_exists('WP_WF')){
    class WP_WF {
        
        public function __construct() {
            
        }
        
    }
}

//usage : [sc firstname="good" lastname="china"]

function my_shortcode($attr){
    $attr = shortcode_atts(array('firstname'=>'','lastname'=>''), $attr);
    return 'this is my shortcode and the name is '.$attr['firstname'];
}

add_shortcode('sc', 'my_shortcode');

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章