我正在尝试从子集“Gene”中创建datTab中的基因,但是“i”在运行代码时仅包含Gene列表中的'h'。 它只重复显示'h'。我想知道如何使“i”可以包含所有基因列表。
<?php
/*
Plugin Name: General Widget
Plugin URI:
Description:
Author:
Version: 1
Author URI:
*/
// register widget
add_action('widgets_init', create_function('', 'return register_widget("General_Widget");'));
class General_Widget extends WP_Widget {
// constructor
function General_Widget() {
// Give widget name here
parent::WP_Widget(false, $name = __('General Widget', 'wp_widget_plugin'));
// link the style sheet for the widget
add_action( 'wp_enqueue_scripts', array($this,'add_styles'));
// link javascript file
add_action( 'wp_enqueue_scripts', array($this,'add_scripts'));
// register the shortcode
// TODO:
add_shortcode('INSERT SHORTCODE HERE', array($this, 'shortcode'));
}
// function that enqueues the necessary javascript files
function add_scripts() {
// TODO:
// NOTE this is risky, might mess with your theme.
wp_deregister_script( 'jquery' ); // we will use our own versions of jquery
wp_deregister_script( 'jquery-migrate' );
global $post;
// only register and add scripts for this widget if the widget is active or if the post has a shortcode
if(has_shortcode($post->post_content, 'INSERT SHORTCODE HERE') || is_active_widget( false, false, $this->id_base, true )) {
// register the different scripts
wp_register_script('jqueryMin', plugins_url('js/lib/jquery-2.2.4.min.js', __FILE__), array(), false, false); // https://developer.wordpress.org/reference/functions/wp_register_script/
// add them to document
wp_enqueue_script('jqueryMin');
}
}
// enqueues the stylesheet
function add_styles() {
// TODO:
global $post;
if(has_shortcode($post->post_content, 'INSERT SHORTCODE HERE') || is_active_widget( false, false, $this->id_base, true )) {
// register the different style sheets
wp_register_style('bootstrapMinStyle', plugins_url('css/lib/bootstrap.min.css', __FILE__), array(), false, "all"); // https://codex.wordpress.org/Function_Reference/wp_register_style
wp_register_style('commonStyle', plugins_url('css/common.css', __FILE__), array(), false, "all"); // https://codex.wordpress.org/Function_Reference/wp_register_style
$arrCoreStyles = array('bootstrapMinStyle', 'commonStyle');
wp_register_style('quoteStyle', plugins_url('css/quote.css', __FILE__),$arrCoreStyles, false, "all"); // https://codex.wordpress.org/Function_Reference/wp_register_style
// add style sheet and all of its dependencies
wp_enqueue_style('quoteStyle');
}
}
// widget form creation. This handles the form that the wordpress admin sees when they add the widget to a widget area
function form($instance) {
}
// updates the data stored in the widget when wordpress admin adds widget
function update($new_instance, $old_instance) {
}
// gives the widget shortcode functionality
function shortcode($atts) {
$args = shortcode_atts( array(), $atts );
$this->add_to_args($args);
$this->display($args);
}
// displays the widget to the client.
function widget($args, $instance) {
$this->add_to_args($args);
$this->display($args);
}
// use this to add fields to args before we display
private function add_to_args(& $args) {
// TODO:
$args['customWidgetHTML'] = "html/NAME OF HTML TEMPLATE.html";
}
// this is an additional function, not inherited from WP_Widget. It is used for displaying html to
// client. Is called by both widget() and shortcode()
private function display($args) {
extract($args);
// TODO:
wp_enqueue_script('quoteJS'); // we dont want this in the header so we just enqueue it here
echo $before_widget;
include(plugin_dir_path(__FILE__) . $customWidgetHTML);
echo $after_widget;
}
}
?>