woocommerce-multilingual
/
addons
/
wpml-dependencies
/
lib
/
classes
/
wpml-wp
/
class-wpml-wp-api.php
class-wpml-wp-api.php
4 weeks ago
class-wpml-wp-roles.php
4 weeks ago
class-wpml-wp-taxonomy.php
4 weeks ago
iwpml-wp-element-type.php
4 weeks ago
wpml-php-functions.php
4 weeks ago
wpml-wp-post-type.php
4 weeks ago
class-wpml-wp-api.php
713 lines
| 1 | <?php |
| 2 | |
| 3 | use WPML\API\Sanitize; |
| 4 | use WPML\Core\Twig_Environment; |
| 5 | use WPML\Core\Twig_Loader_Filesystem; |
| 6 | use WPML\Core\Twig_Loader_String; |
| 7 | use WPML\Core\Twig_LoaderInterface; |
| 8 | use function WPML\Container\make; |
| 9 | |
| 10 | class WPML_WP_API extends WPML_PHP_Functions { |
| 11 | public function get_file_mime_type( $file, $filename ) { |
| 12 | |
| 13 | $mime_type = false; |
| 14 | if ( file_exists( $file ) ) { |
| 15 | $file_info = wp_check_filetype_and_ext( $file, $filename ); |
| 16 | $mime_type = $file_info['type']; |
| 17 | } |
| 18 | |
| 19 | return $mime_type; |
| 20 | } |
| 21 | |
| 22 | public function get_option( $option, $default = false ) { |
| 23 | |
| 24 | return get_option( $option, $default ); |
| 25 | } |
| 26 | |
| 27 | public function is_url( $value ) { |
| 28 | $regex = '((https?|ftp)\:\/\/)?'; |
| 29 | $regex .= '([a-z0-9+!*(),;?&=$_.-]+(\:[a-z0-9+!*(),;?&=$_.-]+)?@)?'; |
| 30 | $regex .= '([a-z0-9-.]*)\.([a-z]{2,3})'; |
| 31 | $regex .= '(\:[0-9]{2,5})?'; |
| 32 | $regex .= '(\/([a-z0-9+$_-]\.?)+)*\/?'; |
| 33 | $regex .= '(\?[a-z+&$_.-][a-z0-9;:@&%=+\/$_.-]*)?'; |
| 34 | $regex .= '(#[a-z_.-][a-z0-9+$_.-]*)?'; |
| 35 | |
| 36 | return preg_match( "/^$regex$/", $value ); |
| 37 | } |
| 38 | |
| 39 | public function get_transient( $transient ) { |
| 40 | return get_transient( $transient ); |
| 41 | } |
| 42 | |
| 43 | public function set_transient( $transient, $value, $expiration = 0 ) { |
| 44 | set_transient( $transient, $value, $expiration ); |
| 45 | } |
| 46 | |
| 47 | public function update_option( $option, $value, $autoload = null ) { |
| 48 | return update_option( $option, $value, $autoload ); |
| 49 | } |
| 50 | |
| 51 | public function get_post_status( $ID = '' ) { |
| 52 | return get_post_status( $ID ); |
| 53 | } |
| 54 | |
| 55 | public function get_term_link( $term, $taxonomy = '' ) { |
| 56 | |
| 57 | return get_term_link( $term, $taxonomy ); |
| 58 | } |
| 59 | |
| 60 | public function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) { |
| 61 | return get_term_by( $field, $value, $taxonomy, $output, $filter ); |
| 62 | } |
| 63 | |
| 64 | public function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 65 | |
| 66 | return add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 67 | } |
| 68 | |
| 69 | public function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { |
| 70 | |
| 71 | return add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); |
| 72 | } |
| 73 | |
| 74 | public function get_post_type_archive_link( $post_type ) { |
| 75 | |
| 76 | return get_post_type_archive_link( $post_type ); |
| 77 | } |
| 78 | |
| 79 | public function get_edit_post_link( $id = 0, $context = 'display' ) { |
| 80 | |
| 81 | return get_edit_post_link( $id, $context ); |
| 82 | } |
| 83 | |
| 84 | public function get_the_title( $post ) { |
| 85 | |
| 86 | return get_the_title( $post ); |
| 87 | } |
| 88 | |
| 89 | public function get_day_link( $year, $month, $day ) { |
| 90 | |
| 91 | return get_day_link( $year, $month, $day ); |
| 92 | } |
| 93 | |
| 94 | public function get_month_link( $year, $month ) { |
| 95 | |
| 96 | return get_month_link( $year, $month ); |
| 97 | } |
| 98 | |
| 99 | public function get_year_link( $year ) { |
| 100 | |
| 101 | return get_year_link( $year ); |
| 102 | } |
| 103 | |
| 104 | public function get_author_posts_url( $author_id, $author_nicename = '' ) { |
| 105 | |
| 106 | return get_author_posts_url( $author_id, $author_nicename ); |
| 107 | } |
| 108 | |
| 109 | public function current_user_can( $capability ) { |
| 110 | |
| 111 | return current_user_can( $capability ); |
| 112 | } |
| 113 | |
| 114 | public function get_user_meta( $user_id, $key = '', $single = false ) { |
| 115 | |
| 116 | return get_user_meta( $user_id, $key, $single ); |
| 117 | } |
| 118 | |
| 119 | public function get_post_type( $post = null ) { |
| 120 | |
| 121 | return get_post_type( $post ); |
| 122 | } |
| 123 | |
| 124 | public function is_archive() { |
| 125 | return is_archive(); |
| 126 | } |
| 127 | |
| 128 | public function is_front_page() { |
| 129 | return is_front_page(); |
| 130 | } |
| 131 | |
| 132 | public function is_home() { |
| 133 | return is_home(); |
| 134 | } |
| 135 | |
| 136 | public function is_page( $page = '' ) { |
| 137 | return is_page( $page ); |
| 138 | } |
| 139 | |
| 140 | public function is_paged() { |
| 141 | return is_paged(); |
| 142 | } |
| 143 | |
| 144 | public function is_single( $post = '' ) { |
| 145 | return is_single( $post ); |
| 146 | } |
| 147 | |
| 148 | public function is_singular( $post_types = '' ) { |
| 149 | return is_singular( $post_types ); |
| 150 | } |
| 151 | |
| 152 | public function user_can( $user, $capability ) { |
| 153 | |
| 154 | return user_can( $user, $capability ); |
| 155 | } |
| 156 | |
| 157 | public function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { |
| 158 | |
| 159 | return add_filter( $tag, $function_to_add, $priority, $accepted_args ); |
| 160 | } |
| 161 | |
| 162 | public function remove_filter( $tag, $function_to_remove, $priority = 10 ) { |
| 163 | |
| 164 | return remove_filter( $tag, $function_to_remove, $priority ); |
| 165 | } |
| 166 | |
| 167 | public function current_filter() { |
| 168 | return current_filter(); |
| 169 | } |
| 170 | |
| 171 | public function get_tm_url( $tab = null, $hash = null ) { |
| 172 | $tm_url = menu_page_url( $this->constant( 'WPML_TM_FOLDER' ) . '/menu/main.php', false ); |
| 173 | |
| 174 | $query_vars = array(); |
| 175 | if ( $tab ) { |
| 176 | $query_vars['sm'] = $tab; |
| 177 | } |
| 178 | |
| 179 | $tm_url = add_query_arg( $query_vars, $tm_url ); |
| 180 | |
| 181 | if ( $hash ) { |
| 182 | if ( strpos( $hash, '#' ) !== 0 ) { |
| 183 | $hash = '#' . $hash; |
| 184 | } |
| 185 | $tm_url .= $hash; |
| 186 | } |
| 187 | |
| 188 | return $tm_url; |
| 189 | } |
| 190 | |
| 191 | public function is_admin() { |
| 192 | |
| 193 | return is_admin(); |
| 194 | } |
| 195 | |
| 196 | public function is_jobs_tab() { |
| 197 | return $this->is_tm_page( 'jobs' ); |
| 198 | } |
| 199 | |
| 200 | public function is_tm_page( $tab = null, $page_type = 'management' ) { |
| 201 | if ( 'settings' === $page_type ) { |
| 202 | $page_suffix = '/menu/settings'; |
| 203 | $default_tab = 'mcsetup'; |
| 204 | } else { |
| 205 | $page_suffix = '/menu/main.php'; |
| 206 | $default_tab = 'dashboard'; |
| 207 | } |
| 208 | |
| 209 | $result = is_admin() |
| 210 | && isset( $_GET['page'] ) |
| 211 | && $_GET['page'] == $this->constant( 'WPML_TM_FOLDER' ) . $page_suffix; |
| 212 | |
| 213 | if ( $tab ) { |
| 214 | if ( $tab == $default_tab && ! isset( $_GET['sm'] ) ) { |
| 215 | $result = $result && true; |
| 216 | } else { |
| 217 | $result = $result && isset( $_GET['sm'] ) && $_GET['sm'] == $tab; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | return $result; |
| 222 | } |
| 223 | |
| 224 | public function is_translation_queue_page() { |
| 225 | return is_admin() && isset( $_GET['page'] ) && $this->constant( 'WPML_TM_FOLDER' ) . '/menu/translations-queue.php' == $_GET['page']; |
| 226 | } |
| 227 | |
| 228 | public function is_string_translation_page() { |
| 229 | return is_admin() && isset( $_GET['page'] ) && $this->constant( 'WPML_ST_FOLDER' ) . '/menu/string-translation.php' == $_GET['page']; |
| 230 | } |
| 231 | |
| 232 | public function is_support_page() { |
| 233 | return $this->is_core_page( 'support.php' ); |
| 234 | } |
| 235 | |
| 236 | public function is_troubleshooting_page() { |
| 237 | return $this->is_core_page( 'troubleshooting.php' ); |
| 238 | } |
| 239 | |
| 240 | public function is_core_page( $page = '' ) { |
| 241 | $result = is_admin() |
| 242 | && isset( $_GET['page'] ) |
| 243 | && stripos( $_GET['page'], 'sitepress-multilingual-cms/menu/' . $page ) !== false; |
| 244 | return $result; |
| 245 | } |
| 246 | |
| 247 | public function is_back_end() { |
| 248 | return is_admin() && ! $this->is_ajax() && ! $this->is_cron_job(); |
| 249 | } |
| 250 | |
| 251 | public function is_front_end() { |
| 252 | return ! is_admin() && |
| 253 | ! $this->is_ajax() && |
| 254 | ! $this->is_cron_job() && |
| 255 | ! wpml_is_rest_request(); |
| 256 | } |
| 257 | |
| 258 | public function is_ajax() { |
| 259 | |
| 260 | $result = defined( 'DOING_AJAX' ) && DOING_AJAX; |
| 261 | |
| 262 | if ( $this->function_exists( 'wpml_is_ajax' ) ) { |
| 263 | $result = $result || wpml_is_ajax(); |
| 264 | } |
| 265 | |
| 266 | return $result; |
| 267 | } |
| 268 | |
| 269 | public function is_cron_job() { |
| 270 | return defined( 'DOING_CRON' ) && DOING_CRON; |
| 271 | } |
| 272 | |
| 273 | public function is_heartbeat() { |
| 274 | $action = Sanitize::stringProp( 'action', $_POST ); |
| 275 | |
| 276 | return 'heartbeat' === $action; |
| 277 | } |
| 278 | |
| 279 | public function is_post_edit_page() { |
| 280 | global $pagenow; |
| 281 | |
| 282 | return 'post.php' === $pagenow && isset( $_GET['action'], $_GET['post'] ) |
| 283 | && 'edit' === Sanitize::stringProp( 'action', $_GET ); |
| 284 | } |
| 285 | |
| 286 | public function is_new_post_page() { |
| 287 | global $pagenow; |
| 288 | |
| 289 | return 'post-new.php' === $pagenow; |
| 290 | } |
| 291 | |
| 292 | public function is_term_edit_page() { |
| 293 | global $pagenow; |
| 294 | |
| 295 | return 'term.php' === $pagenow || ( 'edit-tags.php' === $pagenow && isset( $_GET['action'] ) && 'edit' === filter_var( $_GET['action'] ) ); |
| 296 | } |
| 297 | |
| 298 | public function is_customize_page() { |
| 299 | global $pagenow; |
| 300 | |
| 301 | return 'customize.php' === $pagenow; |
| 302 | } |
| 303 | |
| 304 | public function is_comments_post_page() { |
| 305 | global $pagenow; |
| 306 | |
| 307 | return 'wp-comments-post.php' === $pagenow; |
| 308 | } |
| 309 | |
| 310 | public function is_plugins_page() { |
| 311 | global $pagenow; |
| 312 | |
| 313 | return 'plugins.php' === $pagenow; |
| 314 | } |
| 315 | |
| 316 | public function is_themes_page() { |
| 317 | global $pagenow; |
| 318 | |
| 319 | return 'themes.php' === $pagenow; |
| 320 | } |
| 321 | |
| 322 | public function is_feed( $feeds = '' ) { |
| 323 | global $wp_query; |
| 324 | |
| 325 | return isset( $wp_query ) && is_feed( $feeds ); |
| 326 | } |
| 327 | |
| 328 | public function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) { |
| 329 | |
| 330 | return wp_update_term_count( $terms, $taxonomy, $do_deferred ); |
| 331 | } |
| 332 | |
| 333 | public function get_taxonomy( $taxonomy ) { |
| 334 | |
| 335 | return get_taxonomy( $taxonomy ); |
| 336 | } |
| 337 | |
| 338 | public function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { |
| 339 | |
| 340 | return wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); |
| 341 | } |
| 342 | |
| 343 | public function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) { |
| 344 | |
| 345 | return get_post_types( $args, $output, $operator ); |
| 346 | } |
| 347 | |
| 348 | public function wp_send_json( $response ) { |
| 349 | wp_send_json( $response ); |
| 350 | |
| 351 | return $response; |
| 352 | } |
| 353 | |
| 354 | public function wp_send_json_success( $data = null ) { |
| 355 | wp_send_json_success( $data ); |
| 356 | |
| 357 | return $data; |
| 358 | } |
| 359 | |
| 360 | public function wp_send_json_error( $data = null ) { |
| 361 | wp_send_json_error( $data ); |
| 362 | |
| 363 | return $data; |
| 364 | } |
| 365 | |
| 366 | public function get_current_user_id() { |
| 367 | |
| 368 | return get_current_user_id(); |
| 369 | } |
| 370 | |
| 371 | public function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { |
| 372 | |
| 373 | return get_post( $post, $output, $filter ); |
| 374 | } |
| 375 | |
| 376 | public function get_post_meta( $post_id, $key = '', $single = false ) { |
| 377 | |
| 378 | return get_post_meta( $post_id, $key, $single ); |
| 379 | } |
| 380 | |
| 381 | public function update_post_meta( |
| 382 | $post_id, |
| 383 | $key, |
| 384 | $value, |
| 385 | $prev_value = '' |
| 386 | ) { |
| 387 | |
| 388 | return update_post_meta( $post_id, $key, $value, $prev_value ); |
| 389 | } |
| 390 | |
| 391 | public function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { |
| 392 | return add_post_meta( $post_id, $meta_key, $meta_value, $unique ); |
| 393 | } |
| 394 | |
| 395 | public function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) { |
| 396 | return delete_post_meta( $post_id, $meta_key, $meta_value ); |
| 397 | } |
| 398 | |
| 399 | public function get_term_meta( $term_id, $key = '', $single = false ) { |
| 400 | |
| 401 | return get_term_meta( $term_id, $key, $single ); |
| 402 | } |
| 403 | |
| 404 | public function get_permalink( $id = 0, $leavename = false ) { |
| 405 | |
| 406 | return get_permalink( $id, $leavename ); |
| 407 | } |
| 408 | |
| 409 | public function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { |
| 410 | |
| 411 | return wp_mail( $to, $subject, $message, $headers, $attachments ); |
| 412 | } |
| 413 | |
| 414 | public function get_post_custom( $post_id = 0 ) { |
| 415 | |
| 416 | return get_post_custom( $post_id ); |
| 417 | } |
| 418 | |
| 419 | public function is_dashboard_tab() { |
| 420 | return $this->is_tm_page( 'dashboard' ); |
| 421 | } |
| 422 | |
| 423 | public function wp_safe_redirect( $redir_target, $status = 302 ) { |
| 424 | if ( wp_safe_redirect( $redir_target, $status, 'WPML' ) ) { |
| 425 | exit; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | public function load_textdomain( $domain, $mofile ) { |
| 430 | |
| 431 | return load_textdomain( $domain, $mofile ); |
| 432 | } |
| 433 | |
| 434 | public function get_home_url( |
| 435 | $blog_id = null, |
| 436 | $path = '', |
| 437 | $scheme = null |
| 438 | ) { |
| 439 | |
| 440 | return get_home_url( $blog_id, $path, $scheme ); |
| 441 | } |
| 442 | |
| 443 | public function get_site_url( |
| 444 | $blog_id = null, |
| 445 | $path = '', |
| 446 | $scheme = null |
| 447 | ) { |
| 448 | |
| 449 | return get_site_url( $blog_id, $path, $scheme ); |
| 450 | } |
| 451 | |
| 452 | public function is_multisite() { |
| 453 | |
| 454 | return is_multisite(); |
| 455 | } |
| 456 | |
| 457 | public function is_main_site( $site_id = null ) { |
| 458 | return is_main_site( $site_id ); |
| 459 | } |
| 460 | |
| 461 | public function ms_is_switched() { |
| 462 | |
| 463 | return ms_is_switched(); |
| 464 | } |
| 465 | |
| 466 | public function get_current_blog_id() { |
| 467 | |
| 468 | return get_current_blog_id(); |
| 469 | } |
| 470 | |
| 471 | public function wp_get_post_terms( |
| 472 | $post_id = 0, |
| 473 | $taxonomy = 'post_tag', |
| 474 | $args = array() |
| 475 | ) { |
| 476 | |
| 477 | return wp_get_post_terms( $post_id, $taxonomy, $args ); |
| 478 | } |
| 479 | |
| 480 | public function get_taxonomies( |
| 481 | $args = array(), |
| 482 | $output = 'names', |
| 483 | $operator = 'and' |
| 484 | ) { |
| 485 | |
| 486 | return get_taxonomies( $args, $output, $operator ); |
| 487 | } |
| 488 | |
| 489 | public function wp_get_theme( $stylesheet = null, $theme_root = null ) { |
| 490 | |
| 491 | return wp_get_theme( $stylesheet, $theme_root ); |
| 492 | } |
| 493 | |
| 494 | public function get_theme_name() { |
| 495 | |
| 496 | return wp_get_theme()->get( 'Name' ); |
| 497 | } |
| 498 | |
| 499 | public function get_theme_parent_name() { |
| 500 | |
| 501 | return wp_get_theme()->parent_theme; |
| 502 | } |
| 503 | |
| 504 | public function get_theme_URI() { |
| 505 | |
| 506 | return wp_get_theme()->get( 'URI' ); |
| 507 | } |
| 508 | |
| 509 | public function get_theme_author() { |
| 510 | |
| 511 | return wp_get_theme()->get( 'Author' ); |
| 512 | } |
| 513 | |
| 514 | public function get_theme_authorURI() { |
| 515 | |
| 516 | return wp_get_theme()->get( 'AuthorURI' ); |
| 517 | } |
| 518 | |
| 519 | public function get_theme_template() { |
| 520 | |
| 521 | return wp_get_theme()->get( 'Template' ); |
| 522 | } |
| 523 | |
| 524 | public function get_theme_version() { |
| 525 | |
| 526 | return wp_get_theme()->get( 'Version' ); |
| 527 | } |
| 528 | |
| 529 | public function get_theme_textdomain() { |
| 530 | |
| 531 | return wp_get_theme()->get( 'TextDomain' ); |
| 532 | } |
| 533 | |
| 534 | public function get_theme_domainpath() { |
| 535 | |
| 536 | return wp_get_theme()->get( 'DomainPath' ); |
| 537 | } |
| 538 | |
| 539 | public function get_plugins() { |
| 540 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 541 | |
| 542 | return get_plugins(); |
| 543 | } |
| 544 | |
| 545 | public function get_post_custom_keys( $post_id ) { |
| 546 | |
| 547 | return get_post_custom_keys( $post_id ); |
| 548 | } |
| 549 | |
| 550 | public function get_bloginfo( $show = '', $filter = 'raw' ) { |
| 551 | |
| 552 | return get_bloginfo( $show, $filter ); |
| 553 | } |
| 554 | |
| 555 | public function version_compare_naked( $version1, $version2, $operator = null ) { |
| 556 | return $this->version_compare( $this->get_naked_version( $version1 ), $this->get_naked_version( $version2 ), $operator ); |
| 557 | } |
| 558 | |
| 559 | public function get_naked_version( $version ) { |
| 560 | |
| 561 | $elements = explode( '.', str_replace( '..', '.', preg_replace( '/([^0-9\.]+)/', '.$1.', str_replace( array( '-', '_', '+' ), '.', trim( $version ) ) ) ) ); |
| 562 | |
| 563 | $naked_elements = array( '0', '0', '0' ); |
| 564 | |
| 565 | $elements_count = 0; |
| 566 | foreach ( $elements as $element ) { |
| 567 | if ( $elements_count === 3 || ! is_numeric( $element ) ) { |
| 568 | break; |
| 569 | } |
| 570 | $naked_elements[ $elements_count ] = $element; |
| 571 | $elements_count ++; |
| 572 | } |
| 573 | |
| 574 | return implode( $naked_elements ); |
| 575 | } |
| 576 | |
| 577 | public function has_filter( $tag, $function_to_check = false ) { |
| 578 | return has_filter( $tag, $function_to_check ); |
| 579 | } |
| 580 | |
| 581 | public function add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { |
| 582 | return add_action( $tag, $function_to_add, $priority, $accepted_args ); |
| 583 | } |
| 584 | |
| 585 | public function get_current_screen() { |
| 586 | return get_current_screen(); |
| 587 | } |
| 588 | |
| 589 | public function get_query_var( $var, $default = '' ) { |
| 590 | return get_query_var( $var, $default ); |
| 591 | } |
| 592 | |
| 593 | public function get_queried_object() { |
| 594 | return get_queried_object(); |
| 595 | } |
| 596 | |
| 597 | public function get_raw_post_data() { |
| 598 | $raw_post_data = @file_get_contents( 'php://input' ); |
| 599 | if ( ! $raw_post_data && array_key_exists( 'HTTP_RAW_POST_DATA', $GLOBALS ) ) { |
| 600 | $raw_post_data = $GLOBALS['HTTP_RAW_POST_DATA']; |
| 601 | } |
| 602 | |
| 603 | return $raw_post_data; |
| 604 | } |
| 605 | |
| 606 | public function wp_verify_nonce( $nonce, $action = -1 ) { |
| 607 | return wp_verify_nonce( $nonce, $action ); |
| 608 | } |
| 609 | |
| 610 | public function did_action( $action ) { |
| 611 | return did_action( $action ); |
| 612 | } |
| 613 | |
| 614 | public function current_action() { |
| 615 | return current_action(); |
| 616 | } |
| 617 | |
| 618 | public function get_wp_post_types_global() { |
| 619 | global $wp_post_types; |
| 620 | return $wp_post_types; |
| 621 | } |
| 622 | |
| 623 | public function get_wp_xmlrpc_server() { |
| 624 | global $wp_xmlrpc_server; |
| 625 | |
| 626 | return $wp_xmlrpc_server; |
| 627 | } |
| 628 | |
| 629 | public function get_wp_taxonomies() { |
| 630 | global $wp_taxonomies; |
| 631 | |
| 632 | return $wp_taxonomies; |
| 633 | } |
| 634 | |
| 635 | public function get_category_link( $category_id ) { |
| 636 | return get_category_link( $category_id ); |
| 637 | } |
| 638 | |
| 639 | public function is_wp_error( $thing ) { |
| 640 | return is_wp_error( $thing ); |
| 641 | } |
| 642 | |
| 643 | public function get_backtrace( $limit = 0, $provide_object = false, $ignore_args = true ) { |
| 644 | $options = false; |
| 645 | |
| 646 | if ( version_compare( $this->phpversion(), '5.3.6' ) < 0 ) { |
| 647 | $options = $provide_object; |
| 648 | } else { |
| 649 | if ( $provide_object ) { |
| 650 | $options |= DEBUG_BACKTRACE_PROVIDE_OBJECT; |
| 651 | } |
| 652 | if ( $ignore_args ) { |
| 653 | $options |= DEBUG_BACKTRACE_IGNORE_ARGS; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | if ( version_compare( $this->phpversion(), '5.4.0' ) >= 0 ) { |
| 658 | $debug_backtrace = debug_backtrace( $options, $limit ); |
| 659 | } elseif ( version_compare( $this->phpversion(), '5.2.4' ) >= 0 ) { |
| 660 | $debug_backtrace = debug_backtrace(); |
| 661 | } else { |
| 662 | $debug_backtrace = debug_backtrace( $options ); |
| 663 | } |
| 664 | |
| 665 | if ( $debug_backtrace ) { |
| 666 | array_shift( $debug_backtrace ); |
| 667 | } |
| 668 | return $debug_backtrace; |
| 669 | } |
| 670 | |
| 671 | public function get_wp_filesystem_direct() { |
| 672 | global $wp_filesystem; |
| 673 | |
| 674 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 675 | |
| 676 | if ( ! $wp_filesystem ) { |
| 677 | WP_Filesystem(); |
| 678 | } |
| 679 | |
| 680 | require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; |
| 681 | require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; |
| 682 | |
| 683 | return new WP_Filesystem_Direct( null ); |
| 684 | } |
| 685 | |
| 686 | public function get_admin_notices() { |
| 687 | global $wpml_admin_notices; |
| 688 | |
| 689 | if ( ! $wpml_admin_notices ) { |
| 690 | $wpml_admin_notices = new WPML_Notices( new WPML_Notice_Render() ); |
| 691 | $wpml_admin_notices->init_hooks(); |
| 692 | } |
| 693 | |
| 694 | return $wpml_admin_notices; |
| 695 | } |
| 696 | |
| 697 | public function get_twig_environment( $loader, $environment_args ) { |
| 698 | return new Twig_Environment( $loader, $environment_args ); |
| 699 | } |
| 700 | |
| 701 | public function get_twig_loader_filesystem( $template_paths ) { |
| 702 | return new Twig_Loader_Filesystem( $template_paths ); |
| 703 | } |
| 704 | |
| 705 | public function get_twig_loader_string() { |
| 706 | return new Twig_Loader_String(); |
| 707 | } |
| 708 | |
| 709 | public function is_a_REST_request() { |
| 710 | return defined( 'REST_REQUEST' ) && REST_REQUEST; |
| 711 | } |
| 712 | } |
| 713 |