Advertisement
Guest User

WordPress theme function.php

a guest
Jan 12th, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. /* Security */
  4.  
  5.     defined( 'ABSPATH' ) or die('Not so fast! Go back to where you came from, it\'s only downhill from here.');
  6.  
  7.     //this might be redundant
  8.     if ( !function_exists( 'add_action' )){
  9.         echo "No Go";
  10.         exit;
  11.     }
  12. /* End: Security */
  13.  
  14.  
  15.  
  16. final class Init {
  17.  
  18.     private static function get_services()
  19.     {
  20.         return [
  21.             cleanWP::class,
  22.             adminPanel::class
  23.         ];
  24.     }
  25.  
  26.     public static function register_services()
  27.     {
  28.  
  29.         require_once( get_stylesheet_directory() . '/inc/whiteLabel.php');
  30.         require_once(get_stylesheet_directory() . '/inc/adminPanel.php');
  31.  
  32.  
  33.         foreach ( self::get_services() as $class ) {
  34.             $service = self::instantiate( $class );
  35.             if ( method_exists( $service, 'register' ) ) {
  36.                 $service->register();
  37.             }
  38.         }
  39.     }
  40.  
  41.     private static function instantiate( $class )
  42.     {
  43.         $service = new $class();
  44.  
  45.         return $service;
  46.     }
  47.  
  48. }
  49.  
  50.  
  51.  
  52. if ( function_exists('add_action') && class_exists('Init')){
  53.     global $wp_admin_bar;
  54.     Init::register_services();
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement