class-acf-admin-tool.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit; // Exit if accessed directly
  4. }
  5. if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
  6. class ACF_Admin_Tool {
  7. /** @var string Tool name */
  8. var $name = '';
  9. /** @var string Tool title */
  10. var $title = '';
  11. /** @var string Dashicon slug */
  12. // var $icon = '';
  13. /** @var boolean Redirect form to single */
  14. // var $redirect = false;
  15. /**
  16. * get_name
  17. *
  18. * This function will return the Tool's name
  19. *
  20. * @date 19/10/17
  21. * @since 5.6.3
  22. *
  23. * @param n/a
  24. * @return n/a
  25. */
  26. function get_name() {
  27. return $this->name;
  28. }
  29. /**
  30. * get_title
  31. *
  32. * This function will return the Tool's title
  33. *
  34. * @date 19/10/17
  35. * @since 5.6.3
  36. *
  37. * @param n/a
  38. * @return n/a
  39. */
  40. function get_title() {
  41. return $this->title;
  42. }
  43. /**
  44. * get_url
  45. *
  46. * This function will return the Tool's title
  47. *
  48. * @date 19/10/17
  49. * @since 5.6.3
  50. *
  51. * @param n/a
  52. * @return n/a
  53. */
  54. function get_url() {
  55. return acf_get_admin_tool_url( $this->name );
  56. }
  57. /**
  58. * is_active
  59. *
  60. * This function will return true if the tool is active
  61. *
  62. * @date 19/10/17
  63. * @since 5.6.3
  64. *
  65. * @param n/a
  66. * @return bool
  67. */
  68. function is_active() {
  69. return acf_maybe_get_GET( 'tool' ) === $this->name;
  70. }
  71. /*
  72. * __construct
  73. *
  74. * This function will setup the class functionality
  75. *
  76. * @type function
  77. * @date 27/6/17
  78. * @since 5.6.0
  79. *
  80. * @param n/a
  81. * @return n/a
  82. */
  83. function __construct() {
  84. // initialize
  85. $this->initialize();
  86. }
  87. /**
  88. * initialize
  89. *
  90. * This function will initialize the admin tool
  91. *
  92. * @date 10/10/17
  93. * @since 5.6.3
  94. *
  95. * @param n/a
  96. * @return n/a
  97. */
  98. function initialize() {
  99. /* do nothing */
  100. }
  101. /**
  102. * load
  103. *
  104. * This function is called during the admin page load
  105. *
  106. * @date 10/10/17
  107. * @since 5.6.3
  108. *
  109. * @param n/a
  110. * @return n/a
  111. */
  112. function load() {
  113. /* do nothing */
  114. }
  115. /**
  116. * html
  117. *
  118. * This function will output the metabox HTML
  119. *
  120. * @date 10/10/17
  121. * @since 5.6.3
  122. *
  123. * @param n/a
  124. * @return n/a
  125. */
  126. function html() {
  127. }
  128. /**
  129. * submit
  130. *
  131. * This function will run when the tool's form has been submit
  132. *
  133. * @date 10/10/17
  134. * @since 5.6.3
  135. *
  136. * @param n/a
  137. * @return n/a
  138. */
  139. function submit() {
  140. }
  141. }
  142. endif; // class_exists check