-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
54 lines (38 loc) · 1.3 KB
/
functions.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
function removeAttr($html, $sel) { // remove all attributes from Quip html documents in directory
foreach($html->find($sel) as $s):
if($s):
foreach($s->getAllAttributes() as $attr => $val):
$s->removeAttribute($attr);
endforeach;
endif;
endforeach;
}
/*************************************************************
* Push documents from array to Wordpress Install
************************************************************/
function post_to_wordpress($title, $body, $rpcurl, $username, $password, $category='Uncategorized', $keywords='', $encoding='UTF-8') {
$title = htmlentities($title, ENT_NOQUOTES, $encoding);
$keywords = htmlentities($keywords, ENT_NOQUOTES, $encoding);
$content = array(
'title'=>$title,
'description'=>$body,
'mt_allow_comments'=>0,
'mt_allow_pings'=>0,
'post_type'=>'page',
'post_parent'=>10,
'mt_keywords'=>$keywords,
'categories'=>array($category)
);
$params = array(0, $username, $password, $content, true);
$request = xmlrpc_encode_request('metaWeblog.newPost', $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
?>