Нет описания

general.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit; // Exit if accessed directly
  7. }
  8. /**
  9. * Gets the current admin screen post type.
  10. *
  11. * @return bool|string
  12. */
  13. function pum_typenow() {
  14. if ( ! empty ( $GLOBALS['typenow'] ) ) {
  15. return $GLOBALS['typenow'];
  16. }
  17. // when editing pages, $typenow isn't set until later!
  18. // try to pick it up from the query string
  19. if ( ! empty( $_GET['post_type'] ) ) {
  20. return sanitize_text_field( $_GET['post_type'] );
  21. } elseif ( ! empty( $_GET['post'] ) && $_GET['post'] > 0 ) {
  22. $post = get_post( $_GET['post'] );
  23. } elseif ( ! empty( $_POST['post_ID'] ) && $_POST['post_ID'] > 0 ) {
  24. $post = get_post( $_POST['post_ID'] );
  25. }
  26. return isset( $post ) && is_object( $post ) && $post->ID > 0 ? $post->post_type : false;
  27. }
  28. /**
  29. * Generates an Popup Maker admin URL based on the given type.
  30. *
  31. * @since 1.7.0
  32. *
  33. * @param string $type Optional. Type of admin URL. Accepts 'tools', 'settings'. Default empty
  34. * @param array $query_args Optional. Query arguments to append to the admin URL. Default empty array.
  35. *
  36. * @return string Constructed admin URL.
  37. */
  38. function pum_admin_url( $type = '', $query_args = array() ) {
  39. $page = '';
  40. $whitelist = PUM_Admin_Pages::$pages;
  41. if ( in_array( $type, $whitelist, true ) ) {
  42. $page = "pum-{$type}";
  43. }
  44. $admin_query_args = array_merge( array( 'page' => $page ), $query_args );
  45. $url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
  46. /**
  47. * Filters the Popup Maker admin URL.
  48. *
  49. * @param string $url Admin URL.
  50. * @param string $type Admin URL type.
  51. * @param array $query_args Query arguments originally passed to pum_admin_url().
  52. */
  53. return apply_filters( 'pum_admin_url', $url, $type, $query_args );
  54. }
  55. /**
  56. * @return array
  57. */
  58. function pum_support_assist_args() {
  59. return array(
  60. // Forces the dashboard to force logout any users.
  61. 'nouser' => true,
  62. 'fname' => wp_get_current_user()->first_name,
  63. 'lname' => wp_get_current_user()->last_name,
  64. 'email' => wp_get_current_user()->user_email,
  65. 'url' => home_url(),
  66. );
  67. }