Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有子插件的主插件-WP_Php_Wordpress - Fatal编程技术网

Php 带有子插件的主插件-WP

Php 带有子插件的主插件-WP,php,wordpress,Php,Wordpress,我是WordPress的新手,但我想创建一个插件,列出我正在创建的自定义插件的所有插件设置,所以我不必进入每个插件 在主插件中,我有以下内容: if (!function_exists('get_plugins')) require_once (ABSPATH."wp-admin/includes/plugin.php"); $all_plugins = get_plugins(); foreach($all_plugins as $plugin_key => $p

我是WordPress的新手,但我想创建一个插件,列出我正在创建的自定义插件的所有插件设置,所以我不必进入每个插件

在主插件中,我有以下内容:

if (!function_exists('get_plugins'))
    require_once (ABSPATH."wp-admin/includes/plugin.php");
    $all_plugins = get_plugins();
    foreach($all_plugins as $plugin_key => $plugin_data){   
        if (strpos(strtolower($plugin_data['Name']),'prefix') !== false) { 
            //skip this one as this is the main plugin and we do not need to display any thing
            if (strpos(strtolower($plugin_data['Name']),'plugins') === false) {
                 if (is_plugin_active($plugin_key)) {                       
                     require_once(ABSPATH . 'wp-content/plugins/'.$plugin_key);
                     $plugin_class_name =  preg_replace('/\s+/','', str_replace("'", "", ucwords($plugin_data['Name'])));

                     $class_handler = new $plugin_class_name();  
                     ?>
                     <div id="sec-<?php echo $plugin_key ?>" class="section">
                         <div class="section-header">
                             <h3><?php echo $plugin_data['Name']?></h3>
                         </div>
                         <div class="section-content">
                            <?php $class_handler->show_settings() ?>
                         </div>
                     </div>
                     <?php
                 }
            }
        }
    }
但是颜色选择器没有包含在样式中,因为没有调用函数
add\u be\u script()

任何帮助都将不胜感激。

请将css和js排在前面

要在后台添加css/js文件,请使用:

add_action('admin_head', 'add_be_script');
这将在后台头部调用add_be_script()

编辑,安迪回答,备选方案更好:

add_action('admin_enqueue_scripts', 'add_be_script');

或者有
admin\u enqueue\u脚本
add_action('admin_enqueue_scripts', 'add_be_script');