PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.4.2
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.4.2
3.53.0 3.52.0 3.51.0 3.50.0 3.45.0 3.38.0 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.40.0 3.40.1 3.41.0 3.42.0 3.43.0 3.44.0 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 All 177 releases
simple-tags / inc / functions.inc.php

functions.inc.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.4.2, at inc/functions.inc.php

274 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * trim and remove empty element
4 *
5 * @param string $element
6 *
7 * @return string
8 */
9 function _delete_empty_element( $element ) {
10 $element = stripslashes( $element );
11 $element = trim( $element );
12 if ( ! empty( $element ) ) {
13 return $element;
14 }
15
16 return false;
17 }
18
19 /**
20 * Test if page have tags or not...
21 *
22 * @return boolean
23 * @author WebFactory Ltd
24 */
25 function is_page_have_tags() {
26 $taxonomies = get_object_taxonomies( 'page' );
27
28 return in_array( 'post_tag', $taxonomies, true );
29 }
30
31 /**
32 * Register widget on WP
33 */
34 function st_register_widget() {
35 register_widget( 'SimpleTags_Widget' );
36 if ( 1 === (int) SimpleTags_Plugin::get_option_value( 'active_terms_display' )){
37 register_widget( 'SimpleTags_Shortcode_Widget' );
38 }
39 if ( 1 === (int) SimpleTags_Plugin::get_option_value( 'active_post_tags' )){
40 register_widget( 'SimpleTags_PostTags_Widget' );
41 }
42 if ( 1 === (int) SimpleTags_Plugin::get_option_value( 'active_related_posts_new' )){
43 register_widget( 'SimpleTags_RelatedPosts_Widget' );
44 }
45 }
46
47 /**
48 * Change menu item order
49 */
50 add_action('custom_menu_order', 'taxopress_re_order_menu');
51 function taxopress_re_order_menu() {
52 global $submenu;
53 $newSubmenu = [];
54
55 //we only want to do this if taxonomy is active
56 $active_taxonomies = isset($_POST['updateoptions']) &&
57 (
58 !isset($_POST['active_taxonomies']) ||
59 (isset($_POST['active_taxonomies']) && (int)$_POST['active_taxonomies'] === 0)
60 ) ? 0 : 1;
61 if ( (1 === (int) SimpleTags_Plugin::get_option_value( 'active_taxonomies' ) || (isset($_POST['active_taxonomies']) && (int)$_POST['active_taxonomies'] === 1)) && $active_taxonomies === 1 ) {
62 foreach ($submenu as $menuName => $menuItems) {
63 if ('st_options' === $menuName) {
64 $taxopress_settings = $taxopress_taxonomies = false;
65
66 $taxopress_submenus = $submenu['st_options'];
67 foreach($taxopress_submenus as $key => $taxopress_submenu){
68 if($taxopress_submenu[2] === 'st_options'){//settings
69 $taxopress_settings = $taxopress_submenu;
70 $taxopress_settings_key= $key;
71 unset($taxopress_submenus[$key]);
72 }
73 if($taxopress_submenu[2] === 'st_taxonomies'){//taxonomies
74 $taxopress_taxonomies = $taxopress_submenu;
75 $taxopress_taxonomies_key= $key;
76 unset($taxopress_submenus[$key]);
77 }
78 }
79 if($taxopress_settings && $taxopress_taxonomies ){
80 //swicth position
81 $taxopress_submenus[$taxopress_settings_key] = $taxopress_taxonomies;
82 $taxopress_submenus[$taxopress_taxonomies_key] = $taxopress_settings;
83 }
84
85 //resort array
86 ksort($taxopress_submenus);
87
88 $submenu['st_options'] = $taxopress_submenus;
89 break;
90 }
91 }
92 }
93 }
94
95 // Init TaxoPress
96 function init_simple_tags()
97 {
98 new SimpleTags_Client();
99 new SimpleTags_Client_TagCloud();
100
101 // Admin and XML-RPC
102 if (is_admin()) {
103 require STAGS_DIR . '/inc/class.admin.php';
104 new SimpleTags_Admin();
105 }
106
107 add_action('widgets_init', 'st_register_widget');
108 }
109
110 function taxopress_admin_pages(){
111
112 $taxopress_pages = [
113 'st_mass_terms',
114 'st_auto',
115 'st_options',
116 'st_manage',
117 'st_taxonomies',
118 'st_terms_display',
119 'st_post_tags',
120 'st_related_posts',
121 'st_autolinks',
122 'st_autoterms',
123 'st_suggestterms'
124 ];
125
126 return apply_filters('taxopress_admin_pages', $taxopress_pages);
127 }
128
129 function is_taxopress_admin_page(){
130
131 $taxopress_pages = taxopress_admin_pages();
132
133 $is_taxopress_page = false;
134 if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $taxopress_pages )) {
135 $is_taxopress_page = true;
136 }
137
138 return apply_filters('is_taxopress_admin_page', $is_taxopress_page);
139 }
140
141 function taxopress_starts_with( $haystack, $needle ) {
142 $length = strlen( $needle );
143 return substr( $haystack, 0, $length ) === $needle;
144 }
145
146 function taxopress_is_html($string)
147 {
148 return preg_match("/<[^<]+>/",$string,$m) != 0;
149 }
150
151
152
153 function taxopress_is_screen_main_page(){
154
155 if(isset($_GET['action']) && $_GET['action'] === 'edit'){
156 return false;
157 }
158
159 if(isset($_GET['add']) && $_GET['add'] === 'new_item'){
160 return false;
161 }
162
163 if(isset($_GET['add']) && $_GET['add'] === 'taxonomy'){
164 return false;
165 }
166
167 return true;
168 }
169
170
171
172 function taxopress_format_class($class)
173 {
174 return esc_attr(ltrim($class, '.'));
175 }
176
177 function taxopress_add_class_to_format($xformat, $class) {
178 $classes = $class;
179 $html = $xformat;
180
181 $patterns = array();
182 $replacements = array();
183
184 // matches where anchor has existing classes contained in single quotes
185 $patterns[0] = '/<a([^>]*)class=\'([^\']*)\'([^>]*)>/';
186 $replacements[0] = '<a\1class="' . $classes . ' \2"\3>';
187
188 // matches where anchor has existing classes contained in double quotes
189 $patterns[1] = '/<a([^>]*)class="([^"]*)"([^>]*)>/';
190 $replacements[1] = '<a\1class="' . $classes . ' \2"\3>';
191
192 // matches where anchor tag has no existing classes
193 $patterns[2] = '/<a(?![^>]*class)([^>]*)>/';
194 $replacements[2] = '<a\1 class="' . $classes . '">';
195
196 $html = preg_replace($patterns, $replacements, $html);
197
198 return $html;
199 }
200
201 function taxopress_change_to_strings($join){
202 if(is_array($join)){
203 $join = join(", ", $join);
204 }
205 return $join;
206 }
207
208 function taxopress_change_to_array($array){
209 if(!is_array($array)){
210 $array = preg_split("/\s*,\s*/",$array);
211 }
212 return $array;
213 }
214
215 function taxopress_html_character_and_entity($enity_code_as_key = false){
216 #Source https://dev.w3.org/html5/html-author/charref
217 $character_set = [
218 //'&amp;' => '&#38;',
219 '&lt;' => '&#60;',
220 '&gt;' => '&#62;',
221 '&nbsp;' => '&#160;',
222 '&excl;' => '&#33;',
223 '&quot;' => '&#34;',
224 '&num;' => '&#35;',
225 '&dollar;'=> '&#36;',
226 '&percnt;' => '&#37;',
227 '&apos;' => '&#39;',
228 '&lpar;' => '&#40;',
229 '&rpar;' => '&#41;',
230 '&ast; ' => '&#42;',
231 '&plus;' => '&#43;',
232 '&comma;' => '&#44;',
233 '&period;' => '&#46;',
234 '&sol;' => '&#47;',
235 '&colon;' => '&#58',
236 '&semi;' => '&#59;',
237 '&equals;' => '&#61;',
238 '&quest;' => '&#63;',
239 '&commat;' => '&#64;',
240 '&lsqb;' => '&#91;',
241 '&bsol;' => '&#92;',
242 '&rsqb;' => '&#93;',
243 '&Hat;' => '&#94;',
244 '&lowbar;' => '&#95;',
245 '&grave;' => '&#96;',
246 '&lcub;' => '&#123;',
247 '&verbar;' => '&#124;',
248 '&rcub;' => '&#125;',
249 '&iexcl;' => '&#161;',
250 '&cent;' => '&#162;',
251 '&pound;' => '&#163;',
252 '&copy;' => '&#169;',
253 '&ordf;' => '&#170;',
254 '&laquo;' => '&#171;',
255 '&reg;' => '&#174;',
256 '&deg;' => '&#176;',
257 '&plusmn;' => '&#177;',
258 '&sup2;' => '&#178;',
259 '&sup3;' => '&#179;',
260 '&acute;' => '&#180;',
261 '&sup1;' => '&#185;',
262 '&ordm;' => '&#186;',
263 '&raquo;' => '&#187;',
264 '&frac14;' => '&#188;',
265 '&frac12;' => '&#189;',
266 '&frac34;' => '&#190;'
267 ];
268
269 if($enity_code_as_key){
270 $character_set = array_flip($character_set);
271 }
272
273 return $character_set;
274 }