Skip to content

Commit 4bfe548

Browse files
authored
Add files via upload
1 parent 44effbf commit 4bfe548

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tuts.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,40 @@
22
/*
33
Plugin Name: Shy's Tutorials & Handbooks
44
Description: Create, manage, and restrict access to tutorials and handbooks, with features for manual user assignment and private content sharing.
5-
Version: 1.4
5+
Version: 1.5
66
License: GPLv2
77
Author: HackTheDev
88
*/
99

1010
require 'PayPalLibrary.php';
1111

12+
// Function to output meta description based on tutorial's short description
13+
function thp_add_meta_description() {
14+
if (is_singular('tutorial_handbook')) {
15+
global $post;
16+
17+
// Retrieve the custom short description
18+
$description = get_post_meta($post->ID, '_thp_description', true);
19+
20+
// Use the post excerpt if no short description is set
21+
if (empty($description)) {
22+
$description = get_the_excerpt($post);
23+
}
24+
25+
// Fallback to a generic description if all else fails
26+
if (empty($description)) {
27+
$description = 'Read this tutorial to learn more.';
28+
}
29+
30+
// Output the meta description tag
31+
echo '<meta name="description" content="' . esc_attr($description) . '">' . "\n";
32+
}
33+
}
34+
add_action('wp_head', 'thp_add_meta_description');
35+
36+
37+
38+
1239

1340
// Add a meta box for marking a tutorial as paid/locked
1441
function thp_add_paid_meta_box() {

0 commit comments

Comments
 (0)