2014-07-20 2 views
-1

나는 짧은 코드로 매우 간단한 플러그인을 만들고자하는데이 단축 코드의 ID를 얻고 싶습니다.짧은 코드 wp 플러그인의 ID를 얻으십시오

내 간단한 코드는 다음과 같습니다

<?php 
/* 
Plugin Name: DEMO 
Plugin URI: http://www.mydemo.com 
Description: DEMO 
Version: 0.1 BETA 
Author: Paul McKnight 
Author URI: http://www.mydemo.com 
*/ 

function demol_handler() { 
    $demolph_output = demoplug_function(); 
    return $demolph_output; 
} 

function demoplug_function() { 
    $demolp_output = "Hello Your Shortcode id is:"; Here i want to display my shortcodes Id 
    return $demolp_output; 
} 

add_shortcode("my_plugin", "demo_handler"); 

?> 

이 간단한 플러그인의 단축 코드는 [my_plugin][/my_plugin] 그래서 나는 당신이 당신의 단축 코드 처리기에서 ID를 전달하는거야 [my_plugin id=9876][/my_plugin]

답변

3

이 ID를 얻으려면입니다 함수.

function demo_handler($atts) { 
    extract(shortcode_atts(array(
     'id' => '', 
    ), $atts, 'my_plugin')); 

    $demolph_output = demoplug_function($id); 
    return $demolph_output; 
} 
add_shortcode("my_plugin", "demo_handler"); 

function demoplug_function($id) { 
    $demolp_output = "Hello Your Shortcode id is: " . $id; 
    return $demolp_output; 
} 

사용법 :

[my_plugin id="1"]