class-simple-job-board.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. /**
  3. * Simple_Job_Board Class
  4. *
  5. * The file that defines the core plugin class
  6. *
  7. * A class definition that includes attributes and functions used across both the
  8. * public-facing side of the site and the admin area.
  9. *
  10. * @link https://wordpress.org/plugins/simple-job-board
  11. * @since 1.0.0
  12. *
  13. * @package Simple_Job_Board
  14. * @subpackage Simple_Job_Board/includes
  15. * @author PressTigers <support@presstigers.com>
  16. */
  17. class Simple_Job_Board
  18. {
  19. /**
  20. * The loader that's responsible for maintaining and registering all hooks that power
  21. * the plugin.
  22. *
  23. * @since 1.0.0
  24. * @access protected
  25. * @var Simple_Job_Board_Loader $loader Maintains and registers all hooks for the plugin.
  26. */
  27. protected $loader;
  28. /**
  29. * The unique identifier of this plugin.
  30. *
  31. * @since 1.0.0
  32. * @access protected
  33. * @var string $simple_job_board The string used to uniquely identify this plugin.
  34. */
  35. protected $simple_job_board;
  36. /**
  37. * The current version of the plugin.
  38. *
  39. * @since 1.0.0
  40. * @access protected
  41. * @var string $version The current version of the plugin.
  42. */
  43. protected $version;
  44. /**
  45. * Define the core functionality of the plugin.
  46. *
  47. * Set the plugin name and the plugin version that can be used throughout the plugin.
  48. * Load the dependencies, define the locale, and set the hooks for the admin area and
  49. * the public-facing side of the site.
  50. *
  51. * @since 1.0.0
  52. */
  53. public function __construct()
  54. {
  55. $this->simple_job_board = 'simple-job-board';
  56. $this->version = '2.6.0';
  57. $this->load_dependencies();
  58. $this->set_locale();
  59. $this->define_admin_hooks();
  60. $this->define_public_hooks();
  61. }
  62. /**
  63. * Load the required dependencies for this plugin.
  64. *
  65. * Include the following files that make up the plugin:
  66. *
  67. * - Simple_Job_Board_Loader. Orchestrates the hooks of the plugin.
  68. * - Simple_Job_Board_i18n. Defines internationalization functionality.
  69. * - Simple_Job_Board_Admin. Defines all hooks for the admin area.
  70. * - Simple_Job_Board_Public. Defines all hooks for the public side of the site.
  71. *
  72. * Create an instance of the loader which will be used to register the hooks
  73. * with WordPress.
  74. *
  75. * @since 1.0.0
  76. * @access private
  77. */
  78. private function load_dependencies()
  79. {
  80. /**
  81. * The class responsible for orchestrating the actions and filters of the
  82. * core plugin.
  83. */
  84. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-simple-job-board-loader.php';
  85. /**
  86. * The class responsible for defining internationalization functionality
  87. * of the plugin.
  88. */
  89. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-simple-job-board-i18n.php';
  90. /**
  91. * The class responsible for defining all actions that occur in the admin area.
  92. */
  93. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-simple-job-board-admin.php';
  94. /**
  95. * The class responsible for defining all actions that occur in the public-facing
  96. * side of the site.
  97. */
  98. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-simple-job-board-public.php';
  99. $this->loader = new Simple_Job_Board_Loader();
  100. }
  101. /**
  102. * Define the locale for this plugin for internationalization.
  103. *
  104. * Uses the Simple_Job_Board_i18n class in order to set the domain and to register the hook
  105. * with WordPress.
  106. *
  107. * @since 1.0.0
  108. * @access private
  109. */
  110. private function set_locale()
  111. {
  112. $plugin_i18n = new Simple_Job_Board_i18n();
  113. $plugin_i18n->set_domain( $this->get_simple_job_board() );
  114. $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
  115. }
  116. /**
  117. * Register all of the hooks related to the admin area functionality
  118. * of the plugin.
  119. *
  120. * @since 1.0.0
  121. * @access private
  122. */
  123. private function define_admin_hooks()
  124. {
  125. $plugin_admin = new Simple_Job_Board_Admin( $this->get_simple_job_board(), $this->get_version() );
  126. $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
  127. $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
  128. }
  129. /**
  130. * Register all of the hooks related to the public-facing functionality
  131. * of the plugin.
  132. *
  133. * @since 1.0.0
  134. * @access private
  135. */
  136. private function define_public_hooks()
  137. {
  138. $plugin_public = new Simple_Job_Board_Public( $this->get_simple_job_board(), $this->get_version() );
  139. $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
  140. $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
  141. }
  142. /**
  143. * Run the loader to execute all of the hooks with WordPress.
  144. *
  145. * @since 1.0.0
  146. */
  147. public function run()
  148. {
  149. $this->loader->run();
  150. }
  151. /**
  152. * The name of the plugin used to uniquely identify it within the context of
  153. * WordPress and to define internationalization functionality.
  154. *
  155. * @since 1.0.0
  156. * @return string The name of the plugin.
  157. */
  158. public function get_simple_job_board()
  159. {
  160. return $this->simple_job_board;
  161. }
  162. /**
  163. * The reference to the class that orchestrates the hooks with the plugin.
  164. *
  165. * @since 1.0.0
  166. * @return Simple_Job_Board_Loader Orchestrates the hooks of the plugin.
  167. */
  168. public function get_loader()
  169. {
  170. return $this->loader;
  171. }
  172. /**
  173. * Retrieve the version number of the plugin.
  174. *
  175. * @since 1.0.0
  176. * @return string The version number of the plugin.
  177. */
  178. public function get_version()
  179. {
  180. return $this->version;
  181. }
  182. }