-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtldrwp.php
More file actions
108 lines (92 loc) · 3.17 KB
/
tldrwp.php
File metadata and controls
108 lines (92 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Plugin Name: TLDRWP
* Plugin URI: https://github.com/mathetos/tldrwp
* Description: Let your readers generate a TL;DR of your content with AI.
* Version: 0.9.0
* Author: Matt Cromwell
* Author URI: https://www.mattcromwell.com
* Requires Plugins: ai
* Requires at least: 6.0
* Requires PHP: 7.4
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: tldrwp
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Define plugin constants
define( 'TLDRWP_VERSION', '0.9.0' );
define( 'TLDRWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'TLDRWP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'TLDRWP_PLUGIN_FILE', __FILE__ );
// Load core components (always needed)
require_once TLDRWP_PLUGIN_PATH . 'includes/settings.php';
require_once TLDRWP_PLUGIN_PATH . 'includes/ai-service.php';
require_once TLDRWP_PLUGIN_PATH . 'includes/social-sharing.php';
// Load admin components conditionally
if ( is_admin() ) {
require_once TLDRWP_PLUGIN_PATH . 'admin/admin.php';
}
// Load public components (needed for frontend and AJAX)
require_once TLDRWP_PLUGIN_PATH . 'public/public.php';
// Load the main plugin class
require_once TLDRWP_PLUGIN_PATH . 'includes/class-tldrwp.php';
/**
* Initialize the plugin
*/
function tldrwp_init() {
// Initialize the main plugin class
TLDRWP::get_instance();
}
add_action( 'plugins_loaded', 'tldrwp_init' );
/**
* Action Hooks for TL;DR Customization
*
* These hooks allow developers to customize the TL;DR output at different points:
*
* @param string $response The AI-generated TL;DR response
* @param int $article_id The current article/post ID
* @param string $article_title The current article title
*/
function tldrwp_action_hooks() {
// Hook: Before the summary heading
do_action( 'tldrwp_before_summary_heading' );
// Hook: After the summary heading
do_action( 'tldrwp_after_summary_heading' );
// Hook: Before the summary content
do_action( 'tldrwp_before_summary_copy' );
// Hook: After the summary content
do_action( 'tldrwp_after_summary_copy' );
// Hook: Summary footer (after social sharing)
do_action( 'tldrwp_summary_footer' );
}
/**
* Filter Hooks for TL;DR Content Customization
*
* These filters allow developers to modify the TL;DR content:
*
* @param string $content The content to be filtered
* @param string $response The AI-generated TL;DR response
* @param int $article_id The current article/post ID
* @param string $article_title The current article title
*/
/**
* Filter the TL;DR response before display
*/
function tldrwp_filter_response( $response, $article_id = null, $article_title = null ) {
return apply_filters( 'tldrwp_response', $response, $article_id, $article_title );
}
/**
* Filter the TL;DR heading text
*/
function tldrwp_filter_heading( $heading = 'Key Insights' ) {
return apply_filters( 'tldrwp_heading', $heading );
}
/**
* Filter the TL;DR summary HTML structure
*/
function tldrwp_filter_summary_html( $html, $response, $social_sharing_html = '' ) {
return apply_filters( 'tldrwp_summary_html', $html, $response, $social_sharing_html );
}