我正在写我的第一个wordpress插件,我被卡住了.厉害.
我想在插件的管理部分中包含一个css文件.但出于某种原因我不能这样做.我试过的代码(以及它的许多变体):
// Register style sheet.
add_action( 'wp_enqueue_scripts', 'register_plugin_styles' );
/**
* Register style sheet.
*/
function register_plugin_styles() {
wp_register_style( 'statistika', plugins_url( '/statistika/css/style.css' ) );
wp_enqueue_style( 'statistika' );
}
Run Code Online (Sandbox Code Playgroud)
路径很好我很确定,当我在浏览器中手动编写URL时,样式打开就像其他任何一样.我怀疑错误的是我在插件php文件中包含的文件.我在开头只包含了wp-load.php.是否足以使wp_register_style功能起作用?如果不是那么那么问题是什么?请帮忙.
编辑:新问题,如何在wordpress的管理端包含jquery和javascript文件.我试过这个:
wp_enqueue_script('jquery', plugins_url('/js/jquery.js', __file__));
wp_enqueue_script('jquery', plugins_url('/js/functions.js', __file__));
Run Code Online (Sandbox Code Playgroud)
我将此添加到答案中的现有函数中.
编辑2:
知道了,我忘了wordpress不喜欢$作为jquery对象.
我需要创建一条在变量后带有破折号的路线。我想要的很容易用代码解释(这是我尝试过的,但它不起作用)
Route::any('tournament/{sportName}/{regionName}/{tournamentName}-odds', array('as' => 'tournament-page', 'uses' => 'HomeController@tournament'));
Run Code Online (Sandbox Code Playgroud)
问题在于这部分“-赔率”。当我添加时,我收到此内容的 Laravel 错误
$others = $this->checkForAlternateVerbs($request);
if (count($others) > 0)
{
return $this->getOtherMethodsRoute($request, $others);
}
throw new NotFoundHttpException;
Run Code Online (Sandbox Code Playgroud)
我该如何做到这一点(在路线参数后添加破折号)?谢谢
所以我有一个设计糟糕的数据库(我认为),我无法改变.它是一个类似Twitter的应用程序,用户可以互相关注.每个用户在表中都有它的行,并且在该表中有一个名为"following"的列,表示用户正在关注的所有USERID.在该列中,有一个用昏迷分隔的USERID列表.因此,假设ID为1的用户跟随用户2和3,ID为2的用户跟随用户1,表格看起来像这样,用户3不跟随任何人.
USERID | username | following
-------------------------------------------
1 | some user | 2,3
2 | test1 | 1
3 | test2 |
Run Code Online (Sandbox Code Playgroud)
问题是如何显示用户1正在关注的所有用户?
编辑1
从491243无效的代码,在这里张贴,也许我错过了一些PHP的东西
$USERID = $_GET['userid'];//this has a value, so not the problem here
$sql_select = "SELECT B.USERID FROM users A INNER JOIN users B ON FIND_IN_SET(B.USERID, B.following) > 0 WHERE B.USERID = '$USERID'";
$result_select = mysqli_query($link,$sql_select);
while($record = mysqli_fetch_array($result_select))
{
$following = $record['USERID'];
var_dump($following); //result is nothing, not even NULL
}
Run Code Online (Sandbox Code Playgroud)
编辑2只是为了理智检查我这样做:
$sql_select = "SELECT USERID FROM …Run Code Online (Sandbox Code Playgroud)