Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit ed37d78

Browse files
committed
Add CSS and change default on get linkbacks functions to not default to all instead defaulting to current post
1 parent 03aeeb6 commit ed37d78

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

css/semantic-linkbacks.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.mention-list ul {
2+
border-style: solid;
3+
}
4+
5+
.mention-list li {
6+
display: inline-block;
7+
list-style: none;
8+
vertical-align: top;
9+
text-align: center;
10+
}
11+
12+
.mention-list li img {
13+
text-align: left;
14+
border-radius: 20px;
15+
display: block;
16+
}

includes/functions.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
*
99
* @return the number of matching linkbacks
1010
*/
11-
function get_linkbacks_number( $type = null, $post_id = 0 ) {
11+
function get_linkbacks_number( $type = null, $post_id = null ) {
12+
if ( null === $post_id ) {
13+
$post_id = get_the_ID();
14+
}
1215
$args = array(
1316
'post_id' => $post_id,
1417
'count' => true,
@@ -50,15 +53,30 @@ function get_linkbacks_number( $type = null, $post_id = 0 ) {
5053
*
5154
* @return the matching linkback "comments"
5255
*/
53-
function get_linkbacks( $type = null, $post_id = 0, $order = 'DESC' ) {
56+
function get_linkbacks( $type = null, $post_id = null, $order = 'DESC' ) {
57+
if ( null === $post_id ) {
58+
$post_id = get_the_ID();
59+
}
5460
$args = array(
5561
'post_id' => $post_id,
5662
'status' => 'approve',
5763
'order' => $order,
5864
);
5965

6066
if ( $type ) { // use type if set
61-
$args['meta_query'] = array( array( 'key' => 'semantic_linkbacks_type', 'value' => $type ) );
67+
if ( 'mention' == $type ) {
68+
$args['type__not_in'] = 'comment';
69+
$args['meta_query'] = array(
70+
'relation' => 'OR',
71+
array( 'key' => 'semantic_linkbacks_type', 'value' => '' ),
72+
array( 'key' => 'semantic_linkbacks_type', 'compare' => 'NOT EXISTS' ),
73+
array( 'key' => 'semantic_linkbacks_type', 'value' => 'mention' ),
74+
);
75+
} elseif ( 'rsvp' == $type ) {
76+
$args['meta_query'] = array( array( 'key' => 'semantic_linkbacks_type', 'value' => 'rsvp', 'compare' => 'LIKE' ) );
77+
} else {
78+
$args['meta_query'] = array( array( 'key' => 'semantic_linkbacks_type', 'value' => $type ) );
79+
}
6280
} else { // check only if type exists
6381
$args['meta_query'] = array( array( 'key' => 'semantic_linkbacks_type', 'compare' => 'EXISTS' ) );
6482
}
@@ -67,9 +85,10 @@ function get_linkbacks( $type = null, $post_id = 0, $order = 'DESC' ) {
6785
}
6886

6987

70-
function has_linkbacks( $type = null, $post_ID = 0 ) {
88+
function has_linkbacks( $type = null, $post_ID = null ) {
7189
if ( get_linkbacks( $type, $post_ID ) ) {
7290
return true;
7391
}
7492
return false;
7593
}
94+

semantic-linkbacks.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function semantic_linkbacks_activation() {
3030
* @author Matthias Pfefferle
3131
*/
3232
class Semantic_Linkbacks_Plugin {
33+
public static $version = '3.4.1';
3334
/**
3435
* Initialize the plugin, registering WordPress hooks.
3536
*/
@@ -49,6 +50,8 @@ public static function init() {
4950
require_once( dirname( __FILE__ ) . '/includes/compatibility.php' );
5051
}
5152

53+
add_action( 'wp_enqueue_scripts', array( 'Semantic_Linkbacks_Plugin', 'style_load' ) );
54+
5255
remove_filter( 'webmention_comment_data', array( 'Webmention_Receiver', 'default_title_filter' ), 21 );
5356
remove_filter( 'webmention_comment_data', array( 'Webmention_Receiver', 'default_content_filter' ), 22 );
5457

@@ -62,4 +65,8 @@ public static function plugin_textdomain() {
6265
// Note to self, the third argument must not be hardcoded, to account for relocated folders.
6366
load_plugin_textdomain( 'semantic-linkbacks', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
6467
}
68+
69+
public static function style_load() {
70+
wp_enqueue_style( 'semantic-linkbacks-css', plugin_dir_url( __FILE__ ) . 'css/semantic-linkbacks.css', array(), self::$version );
71+
}
6572
}

templates/linkbacks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="likes">
33
<h3>Likes</li>
44

5-
<ul>
5+
<ul class="mention-list">
66
<?php foreach ( get_linkbacks( 'like' ) as $like ) : ?>
77
<li><?php echo get_avatar( $like, 50 ); ?></li>
88
<?php endforeach; ?>

0 commit comments

Comments
 (0)