在网站前端或页面中显示插件 [英] showing plugin in frontend of website or in page

查看:32
本文介绍了在网站前端或页面中显示插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站或页面中显示我的插件.我使用 wordpress 2.3.2

I want to show my plugin on my website or in page.. I using wordpress 2.3.2

我也给了文件夹权限.

例如,我编辑并更新了一个著名的插件 Holly dolly,但我不知道如何在前端显示..

Example, there are one famous pluigin Holly dolly i edited that and updated , but i don't know how to show in front end..

我知道我必须打电话

// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'hello_dolly' );

但是怎么做?

我尝试谷歌搜索,但没有找到任何完美的解决方案..

I tried googling but didn't got any perfect solution..

请帮帮我..

推荐答案

这就是我所做的——复制插件文件夹中的 hello.php 文件并将其重命名为 myhello.php.这是在我的系统上运行良好的代码 --

This is what i did-- copied hello.php file in plugin folder and renamed it as myhello.php . Here is the code working fine on my system --

<?php
/**
 * @package myhello
 * @version 1.6
 */
/*
Plugin Name: My Hello
Plugin URI: http://wordpress.org/extend/plugins/myhello/
Description: This is not just a plugin
Author: Swapnesh Sinha
Version: 1.6
Author URI: swapneshsinha.wordpress.com
*/

function myhello_get_lyric() {
    /** These are the lyrics to Hello Dolly */
    $lyrics = "Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
Dolly'll never go away
Dolly'll never go away
Dolly'll never go away again";

    // Here we split it into lines
    $lyrics = explode( "\n", $lyrics );

    // And then randomly choose a line
    return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}

// This just echoes the chosen line, we'll position it later
function myhello() {
    $chosen = myhello_get_lyric();
    echo "<p id='dolly'>$chosen</p>";
}

// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'myhello' );

// We need some CSS to position the paragraph
function dolly_css() {
    // This makes sure that the positioning is also good for right-to-left languages
    $x = is_rtl() ? 'left' : 'right';

    echo "
    <style type='text/css'>
    #dolly {
        float: $x;
        padding-$x: 15px;
        padding-top: 5px;       
        margin: 0;
        font-size: 11px;
    }
    </style>
    ";
}

add_action( 'admin_head', 'dolly_css' );

?>

这篇关于在网站前端或页面中显示插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆