public function clear_cache($key) { if (nm_get_setting("objcache")) { wp_cache_delete($key, 'neteasemusic'); } else { delete_transient($key); } }
</tr> <tr valign="top"> <th scope="row"><label for="<?php echo nm_setting_key('objcache'); ?> ">对象缓存</label></th> <td> <label for="<?php echo nm_setting_key('objcache'); ?> "> <input type="checkbox" name="<?php echo nm_setting_key('objcache'); ?> " id="objcache" value="1" <?php if (nm_get_setting("objcache")) { echo 'checked="checked"'; } ?> > </label> <p class="description">需服务器开启memcached或者redis。</p> </td> </tr> </tbody> </table> <div class="nm-submit-form"> <input type="submit" class="button-primary muhermit_submit_form_btn" name="save" value="<?php _e('Save Changes'); ?> "/>
function get_pagelink() { $slug = nm_get_setting('pagename'); if ($slug) { $slug = get_permalink(get_page_by_path($slug)); $slug = rtrim($slug, '/\\'); return $slug; } return false; }
function nm_style() { if (nm_get_setting('max-width') || nm_get_setting('css')) { echo '<style>.nmsingle-container,.nms-list,.nmhotcom{max-width:' . nm_get_setting('max-width') . 'px}' . nm_get_setting('css') . '</style>'; } }
function nm_generate_player($source = null, $type = null, $id = null) { $source = $source ? $source : 'netease'; global $nmjson; global $nminstance; if ($source == 'netease') { switch ($type) { case 'album': $data = $nmjson->netease_album($id); $songs = $data['songs']; $html .= nm_single_playform($data['album_id'], $nminstance, $data['album_cover'], $data['album_title'], $data['album_author'], '', true); $class = nm_get_setting('listopen') ? ' hide' : ''; $html .= '<div class="nms-list' . $class . '" id="nm-list-' . $nminstance . '" data-index="' . $nminstance . '">'; foreach ($songs as $key => $song) { $html .= '<div class="nms-list-item">' . $song['title'] . ' - ' . $song['artist'] . '<span class="song-time">' . nm_format_time($song['duration']) . '</span></div>'; } $html .= '</div>'; $html .= '<script>playlist.push(' . json_encode($songs) . ');</script>'; break; case 'song': $data = nm_get_setting('oversea') ? $nmjson->netease_oversea_song($id) : $nmjson->netease_song($id); $html .= nm_single_playform($data['id'], $nminstance, $data['cover'], $data['title'], $data['artist'], $data['duration']); if (nm_get_setting("comment")) { $comments = $nmjson->comments($id); } if (!empty($comments)) { $html .= '<div class="nmhotcom"><span class="com-close">X</span><div class="nmhc-title">网易热评</div>'; foreach ($comments as $key => $comment) { $html .= '<div class="nmh-item"><span style="background-image:url(' . $comment['user']['avatarUrl'] . '?param=48x48)" class="nmu-avatar"></span><span class="nmu-name">' . $comment['user']['nickname'] . '</span>:' . $comment['content'] . '</div>'; } $html .= '</div>'; } $html .= '<script>playlist.push(' . json_encode(array($data)) . ');</script>'; break; case 'playlist': $data = $nmjson->netease_playlist($id); $songs = $data['songs']; $html .= nm_single_playform($data['collect_id'], $nminstance, $data['collect_cover'], $data['collect_title'], $data['collect_author'], '', true); $class = nm_get_setting('listopen') ? ' hide' : ''; $html .= '<div class="nms-list' . $class . '" id="nm-list-' . $nminstance . '" data-index="' . $nminstance . '">'; foreach ($songs as $key => $song) { $html .= '<div class="nms-list-item"><span class="song-info">' . $song['title'] . ' - ' . $song['artist'] . '</span><span class="song-time">' . nm_format_time($song['duration']) . '</span></div>'; } $html .= '</div>'; $html .= '<script>playlist.push(' . json_encode($songs) . ');</script>'; break; case 'program': $data = $nmjson->netease_radio($id); $html .= nm_single_playform($data['id'], $nminstance, $data['cover'], $data['title'], $data['artist'], $data['duration']); $html .= '<script>playlist.push(' . json_encode(array($data)) . ');</script>'; break; default: return $url; break; } } elseif ($source == 'xiami') { switch ($type) { case 'album': $data = $nmjson->xiami_album($id); $songs = $data['songs']; $html .= nm_single_playform($data['album_id'], $nminstance, $data['album_cover'], $data['album_title'], $data['album_author'], '', true); $class = nm_get_setting('listopen') ? ' hide' : ''; $html .= '<div class="nms-list' . $class . '" id="nm-list-' . $nminstance . '" data-index="' . $nminstance . '">'; foreach ($songs as $key => $song) { $html .= '<div class="nms-list-item">' . $song['title'] . ' - ' . $song['artist'] . '<span class="song-time">' . nm_format_time($song['duration']) . '</span></div>'; } $html .= '</div>'; $html .= '<script>playlist.push(' . json_encode($songs) . ');</script>'; break; case 'song': $data = $nmjson->xiami_song($id); $html .= nm_single_playform($data['id'], $nminstance, $data['cover'], $data['title'], $data['artist'], $data['duration']); $html .= '<script>playlist.push(' . json_encode(array($data)) . ');</script>'; break; case 'collect': $data = $nmjson->xiami_collect($id); $songs = $data['songs']; $html .= nm_single_playform($data['collect_id'], $nminstance, $data['collect_cover'], $data['collect_title'], $data['collect_author'], '', true); $class = nm_get_setting('listopen') ? ' hide' : ''; $html .= '<div class="nms-list' . $class . '" id="nm-list-' . $nminstance . '" data-index="' . $nminstance . '">'; foreach ($songs as $key => $song) { $html .= '<div class="nms-list-item"><span class="song-info">' . $song['title'] . ' - ' . $song['artist'] . '</span></div>'; } $html .= '</div>'; $html .= '<script>playlist.push(' . json_encode($songs) . ');</script>'; break; default: return $url; break; } } return $html; }