更新到1.2.2版本
This commit is contained in:
@@ -5,11 +5,12 @@ function flm_display_friend_links($atts) {
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix . 'friend_links';
|
||||
|
||||
$atts = shortcode_atts(array(
|
||||
'random' => 'true'
|
||||
), $atts);
|
||||
// 完全使用后台设置,忽略用户传递的参数
|
||||
$random_display = get_option('flm_random_display', 1);
|
||||
$desktop_columns = get_option('flm_desktop_columns', 3);
|
||||
$show_descriptions = get_option('flm_show_descriptions', 1);
|
||||
|
||||
$order_by = ($atts['random'] === 'true') ? 'RAND()' : 'sort_order ASC';
|
||||
$order_by = $random_display ? 'RAND()' : 'sort_order ASC';
|
||||
$links = $wpdb->get_results("SELECT * FROM $table_name ORDER BY $order_by");
|
||||
|
||||
if (empty($links)) {
|
||||
@@ -18,7 +19,7 @@ function flm_display_friend_links($atts) {
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="flm-links-container">
|
||||
<div class="flm-links-container" data-columns="<?php echo $desktop_columns; ?>">
|
||||
<?php foreach ($links as $link): ?>
|
||||
<div class="flm-link-card">
|
||||
<a href="<?php echo esc_url($link->url); ?>" target="_blank" rel="noopener noreferrer">
|
||||
@@ -28,10 +29,18 @@ function flm_display_friend_links($atts) {
|
||||
class="flm-link-icon">
|
||||
</div>
|
||||
<div class="flm-link-name"><?php echo esc_html($link->name); ?></div>
|
||||
<?php if ($show_descriptions && !empty($link->description)): ?>
|
||||
<div class="flm-link-description"><?php echo esc_html($link->description); ?></div>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<style>
|
||||
.flm-links-container {
|
||||
grid-template-columns: repeat(<?php echo $desktop_columns; ?>, 1fr) !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
Reference in New Issue
Block a user