-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
36 lines (32 loc) · 1.15 KB
/
Plugin.php
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
<?php
include_once 'simplehtmldom/simple_html_dom.php';
/**
* 用于主题的部分修改
*
* @package jthack
* @author 教主
* @version 1.0.0
* @link https://jiaozhu.net
*/
class JPlugin_Plugin implements Typecho_Plugin_Interface {
public static function activate() {
Typecho_Plugin::factory('Widget_Archive')-> singleHandle = array('JPlugin_Plugin', 'hack');
}
public function hack($archive, $select){
$html = str_get_html($archive->content);
foreach($html->find('img') as $element){
$src = $element->src;
$alt = $element->alt;
$element->outertext = '<p class="with-img"><img src='.$src.' alt="'.$alt.'" title="'.$alt.'"/></p>';
//$element->outertext = '<p class="with-img">'.$element->outertext.'</p>'
}
foreach($html->find('a') as $element){
$element->target="_blank";
}
$archive->content = $html;
}
public static function deactivate(){}
public static function config(Typecho_Widget_Helper_Form $form) {}
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
public static function render() {}
}