我有这个代码,我想使用自定义插件添加到 single.php 中。
这是代码:
<?php
echo "Facebook: ". $facebook_like_share_count ("$url"). "<br>";
echo "Pinterest: ". $pinterest_pins ("$url") . "<br>";
echo "Google+: ". $google_plusones ("$url") . "<br>";
?>
安装自定义插件时,我想在 single.php 中打印这些内容。
答案 0 :(得分:2)
有两种选择。
选项1)创建一个简短代码
CREATE PROCEDURE [dbo].[spInsertNumbers]
@StartingNumber nvarchar(25),
@EndingNumber nvarchar(25)
AS
Declare @StartIndex int
Declare @EndIndex int
Declare @Series varchar(5)
Declare @StartNumber int
Declare @EndNumber int
Declare @No nvarchar(25)
Declare @StartCounter int
Declare @EndCounter int
Declare @Number varchar(15)
--Getting the letter
set @Series = substring(@StartingNumber, 1, 1)
--Getting the starting index of the starting and ending Number
set @StartIndex = patindex('%[1-9]%', @StartingNumber)
set @EndIndex = patindex('%[1-9]%', @EndingNumber)
--Getting the starting and ending number
set @StartNumber = substring(@StartingNumber, @StartIndex, 6)
set @EndNumber = substring(@EndingNumber, @EndIndex, 6)
--Converting number string to integer
set @StartCounter = Convert(int, @StartNumber)
set @EndCounter = Convert(int, @EndNumber)
while (@StartCounter <= @EndCounter)
BEGIN
set @Number = CONVERT(varchar, @StartCounter)
if @StartCounter >= 1 and @StartCounter < 10
set @No = @Series + '0000' + @Number
if @StartCounter >= 10 and @StartCounter < 100
set @No= @Series + '000' + @Number
if @StartCounter >= 100 and @StartCounter < 1000
set @No= @Series + '00' + @Number
if @StartCounter >= 1000 and @StartCounter < 10000
set @No= @Series + '0' + @Number
if @StartCounter >= 10000 and @StartCounter < 100000
set @No= @Series + @Number
Insert into TestingNumber(Number)
Values(@No);
set @StartCounter = @StartCounter + 1
END
您的简短代码为[社交]
选项2)对内容应用过滤器
function bartag_func( $atts ) {
echo "Facebook: ". $facebook_like_share_count ("$url"). "<br>";
echo "Pinterest: ". $pinterest_pins ("$url") . "<br>";
echo "Google+: ". $google_plusones ("$url") . "<br>";
}
add_shortcode( 'social', array( &$this, 'bartag_func' ));
注意:由于将变量设置为函数,因此我不确定在此使用函数做什么。据我说,它一定给你错误。
无论如何,根据我的说法,这里有两个可能的选择,而我给了你相同的选择