-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtootpress_utilities.php
More file actions
169 lines (134 loc) · 2.7 KB
/
tootpress_utilities.php
File metadata and controls
169 lines (134 loc) · 2.7 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/**
* Utilities
*
* @package TootPress
* @since 0.1
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Do we toot here? ;-)
*
* @since 0.1
*
* @return bool Yes or No
*/
function tootpress_toot_here() {
$toot_page=tootpress_get_toot_page();
$current_page=get_the_ID();
if($toot_page==$current_page) {
return true;
} else {
return false;
}
}
/**
* Are Toots in the Database?
*
* @since 0.1
*
* @return bool
*/
function tootpress_are_toots_in_the_database() {
$amount=tootpress_get_amount_of_toots();
if($amount>0) {
return true;
} else {
return false;
}
}
/**
* Convert the MySQL Date to German Format
*
* @since 0.1
*
* @return string German Date
*/
function tootpress_convert_mysqldate_to_german_format($mysql_date) {
$date_stamp = strtotime($mysql_date);
$german_date = date_i18n( 'j. F Y H:i', $date_stamp );
return $german_date;
}
/**
* Convert the MySQL Date to International English Format
*
* @since 0.1
*
* @return string International Date
*/
function tootpress_convert_mysqldate_to_international_format($mysql_date) {
$date_stamp = strtotime($mysql_date);
$international_date = date_i18n( 'Y/m/d H:i', $date_stamp );
return $international_date;
}
/**
* Removes target=_blank from String
*
* @since 0.1
*/
function tootpress_remove_target_blank($toot_content) {
$output=str_replace('target="_blank" ','',$toot_content);
return $output;
}
/**
* Checks if WordPress runs with german language
*
* @since 0.1
*
* @return bool
*/
function tootpress_is_language_german() {
$this_wp_language=get_locale();
if($this_wp_language=='de_DE') {
return true;
} else {
return false;
}
}
/**
* Checks if Pretty Permalink is enabled
*
* @since 0.1
*
* @return bool
*/
function tootpress_is_pretty_permalink_enabled() {
if (get_option('permalink_structure')) {
return true;
}
else {
return false;
}
}
/**
* Retrieve Mastodon Account
*
* Important: API Call Readyness should be checked before Function Call
*
* @since 0.3
*
* @return null
*/
function tootpress_retrieve_mastodon_account() {
// API Request: Verify Credentials
$verifycrendentials=tootpress_mastodon_apirequest_account_verify_credentials();
$mastodon_account=$verifycrendentials['username'];
// Save Mastodon Account Name
update_option('tootpress_mastodon_account_name',$mastodon_account);
}
/**
* Update Rewrite Rules
*
* @since 0.3
*
* @return null
*/
function tootpress_rewrite_update() {
$update_rewrites=get_option('tootpress_rewrite_update');
if($update_rewrites) {
flush_rewrite_rules();
}
update_option('tootpress_rewrite_update','0');
}
?>