Wordpress我的第一个插件正在加载每个网站

时间:2016-04-01 14:58:02

标签: wordpress

我是Wordpress的新手并编写了自己的插件。 现在我遇到的问题是我的插件在每个站点上并覆盖其他站点。所以插件正在每个网站上加载内容。

myplugin.php:

<?php
/*
 * Plugin Name: Gw2  Event Timer
 * Plugin URI: http://localhost/wordpress
 * Description: Ein Guild Wars 2 Timer - beinhaltet alle Weltbosse und die neun HoT Gebiete
 * Version: 1.0
 * Author: Niklas Grieger
 * Author URI: http://localhost/wordpress
 * License: No License
 */
function event_timer_head() {

    echo "<link href='../wp-content/plugins/gw2EventTimer/style.css' rel='stylesheet' type='text/css' />
    <script type='text/javascript' src='../wp-content/plugins/gw2EventTimer/js/js.js'></script>
    <script type='text/javascript' src='http://www.moongate.pl/event-timers/moment.min.js'></script>

    ";


}

function event_timer_content($content) {
    $content="<div id='event-wrapper' class='event-wrapper'>
    <div class='event-limit'><span class='event-limit-text'>Nächste</span></div>
    <div class='event-pointer'><span class='event-pointer-time'>00:00 UTC</span></div>
    <div style='height:10px; width:100%;'></div>
    </div>";
    return strtolower($content);
}

function event_timer_title($title) {
    $title = str_replace(' ', ' ', $title);
    return $title;
}
function mh_load_my_script() {
    wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'mh_load_my_script' );
add_action('wp_head', 'event_timer_head');
add_filter('the_content', 'event_timer_content');
add_filter('the_title', 'event_timer_title');
?>

我认为$ content是问题,但我不确定。

1 个答案:

答案 0 :(得分:0)

function event_timer_content($content) {
    $content.="<div id='event-wrapper' class='event-wrapper'>
    <div class='event-limit'><span class='event-limit-text'>Nächste</span></div>
    <div class='event-pointer'><span class='event-pointer-time'>00:00 UTC</span></div>
    <div style='height:10px; width:100%;'></div>
    </div>";
    return strtolower($content);
}

你是覆盖而不是添加内容,如果计时器不应出现在每个页面上,你需要定义它应该运行的时间,即检查postid等等