下面将检查post creators角色,并根据该角色设置音频播放器的颜色。
在插件中创建,以便在更新主题时在更新函数文件时停止主题更新。
不知道如何根据嵌入播放器的人的每条评论来执行此操作,因为这需要为每个嵌入的播放器向html中添加标记,为每个标记分配不同的CSS样式。
<?php
/**
* Plugin Name: Change colour of the audio player
* Plugin URI: http://www.web.com
* Description: Adds colour to the audio player
* Version: 1.0
* Author: Name
* Author URI: http://www.web.com
*/
add_action( \'wp\',\'my_special_action\' ); function my_special_action() {
//Check if it is a post to run the code
if (is_single())
{
//Get post ID
$post_idz = get_the_ID();
//Pull all field data of post
$post_fields = get_post($post_idz);
//Get authors ID
$author = $post_fields->post_author;
//Get author roles
$user_meta=get_userdata($author);
$user_roles=$user_meta->roles;
//Check author has role
//Start ADD_ROLE_NAME
if (in_array("ADD_ROLE_NAME", $user_roles))
{
?>
<style>
/* change colours of audio player */
.mejs-controls,
.mejs-mediaelement,
.mejs-container {
background: url(\'\') !important;
background-color: #1f7dcd !important;
}
/* change the color of the current time bar */
.mejs-controls .mejs-time-rail .mejs-time-current {
background: #dece66 !important;
}
</style>
<?php
}
//End ADD_ROLE_NAME
} }