HEX
Server: Apache
System: Linux vps75080.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: reachcon (1003)
PHP: 7.2.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/reachcon/www/wp-content/themes/omada-theme-6/omada.php
<?php
$omadaVersion = '6.2.0';
class OmadaTheme {
	public $args=array(
		'async'=>array(
			'jquery'=>false,
			'omada'=>false // if jquery=true omada is forced to true
		),
		'support'=>array(
			'active' => false,
			'email' => array( 
				'label'=>'Email Support',
				'href'=>'info@omadamarketing.com'
			),
			'website' => array(
				'label'=>'Omada Website',
				'href'=>'https://www.omadamarketing.com'
			),
			'phone' => array(
				'label'=>'715-393-5102',
				'href'=>'7153935102' // Phone number with numbers only
			)
		),
		'theme'=>true,
		'footerText'=>'Omada Theme - Powered by <a href="https://www.omadamarketing.com/" target="_blank">Omada Marketing</a>',
		// Advanced search adds your custom fieds to the search terms.  Please list all the post types you wish to include
		'advancedSearch'=>array( 'post', 'page', 'staff', 'testimonials' ),
		'gutenberg'=>array( // post types to load gutenberg blocks
			'page',
			'post'
		),
		'omadaMenus'=>array(
			'options'=>true,
			'design'=>true,
			'dev'=>true
		),
		// DNS PREFETCH FOR GOOGLE FONTS - default theme fonts loaded locally rather than from google so we turn it off.
		'prefetchDNS'=>false, 
		'restAPI'=>false, // Include JSON REST API
		'googleMapsAPIKey'=>'',
		'youtubeOembed'=>'&modestbranding=1&showinfo=0&rel=0',
		'postRevisions' => 10, // Set how many revisions are stored in the database for each post/page
		'postThumbnails' => array( 'width'=>600, 'height'=>9999 ),
		'automatic-feed-links' => false, // disable feed links
		'displayEmojis' => false,
		'themeEditor' => false, // show theme editor - reduces security
		'excerptLength' => 50, // Fifty Words
		'excerptMoreLink' => true, // Replace ... with More link
		'blogPostLabels'=>array(
			'postMenu'=>'Blog Post',
			'postCreate'=>'Add Post',
			'name'=>'Posts',
			'singular_name'=>'Post',
			'add_new'=>'Add Post',
			'add_new_item'=>'Add New Post',
			'edit_item'=>'Edit Post',
			'new_item'=>'New Post',
			'view_item'=>'View Post',
			'search_items'=>'Search Posts',
			'not_found'=>'No Posts found',
			'not_found_in_trash'=>'No Posts found in Trash'
		),
		'adminBarRemove'=> array( // remove the following items from the admin top bar
			'comments', // Comments
			'themes',   // Themes
			'customize',// Customizer - Not used by this theme
		),
		'plugins' => array( 
			'categories'=>array( // add categories to the media system
				'enable' => true
			),
			'seo'=>array(  /////***************************This system needs to be finished - currently loading from construct below
				'enable' => true,
				'autoJSONLD' => true,
				'customPostTypes'=>array(),
				'remove'=>array(),
				// The following is an array of post types you do not want displayed in the sitemap list
				'removeSitemaps'=>array(
					'omada_footer',
					'omada_header',
					'omada_ads',
					'omada_calendar',
					'omada_slideshow',
					'omada_gallery'
				)
			),
			'ads'=>array( 
				'enable'=>true,
				'displayMenu'=>true,
				'widget'=>true, 
				'remove'=>array(),
				'acf'=>'',
			),
			'calendar'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'widget'=>true, 
				'remove'=>array(), 
				'acf'=>'',
				'block'=>true
			),
			'forms'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'acf'=>'',
				'block'=>true
			),
			'gallery'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'acf'=>'',
				'block'=>true,
				'albumblock'=>true
			),
			'slideshow'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'acf'=>'',
				'block'=>true
			),
			'staff'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'remove'=>array(), 
				'acf'=>'', 
				'slug'=>'staff',
				'block'=>true,
				'postsPerPage'=>8,
			),
			'testimonials'=>array( 
				'enable'=>true, 
				'displayMenu'=>true,
				'remove'=> array(), 
				'acf'=>'', 
				'slug'=>'testimonials',
				'block'=>true,
				'postsPerPage'=>6
			),
			'duplicate'=>array( // Adds the Duplicate post function to posts pages
				'enable'=>true,
				'reject'=>array()// array of post type slugs to remove duplicate link from
			)
		),
		// A full list of widgets can be found in /inc/widgets/widgets.php
		'widgets'=>array( 
			'WP_Widget_Pages' => true, // Pages Widget
			'WP_Widget_Calendar' => true, // Calendar Widget
			'WP_Widget_Archives' => true, // Archives Widget
			'WP_Widget_Links' => false, // Links Widget
			'WP_Widget_Media_Audio' => true, // Audio Player Media Widget 
			'WP_Widget_Media_Image' => true, // Image Media Widget 
			'WP_Widget_Media_Video' => true, // Video Media Widget 
			'WP_Widget_Meta' => false, // Meta Widget
			'WP_Widget_Search' => true, // Search Widget
			'WP_Widget_Text' => true, // Text Widget
			'WP_Widget_Categories' => true, // Categories Widget
			'WP_Widget_Recent_Posts' => true, // Recent Posts Widget
			'WP_Widget_Recent_Comments' => false, // Recent Comments Widget
			'WP_Widget_RSS' => false, // RSS Widget
			'WP_Widget_Tag_Cloud' => false, // Tag Cloud Widget
			'WP_Nav_Menu_Widget' => true, // Menus Widget
			'WP_Widget_Custom_HTML' => true, // Custom HTML Widget
		),
		// A list of all shortcodes can be found in /inc/shortcodes/shortcodes.php
		'removeShortcodes'=>array( ),
		'commentBlock'=>array( // This system allows you to block comments and pingbacks from post types.
			'attachment',
		),
		'security'=>array(
			'htaccess'=>array(
				/*******************************************************
				** LOOK AT A NEW FILTER OR HOOK FOR THIS SYSTEM.
				** CURRENTLY LOADS EVERY TIME YOU LOAD AN ADMIN PAGE.
				**/
				'indexing'=>true,
				'config'=>true,
				'htaccess'=>true, // create htaccess file and all settings below
				'apiRequests'=>true, // turn off api requests
				'apiAuthor'=>true, // remove the author from api feeds
				'includes'=>true, // secure the includes folder
				// This system needs individual htaccess files created for it. 
				// Modify this system later.
				// 'preventPHP'=>true,
				'spamQuery'=>true, // prevent known spam queries
				'spamRequests'=>true, // prevent spam requests
				'spamReferrers'=>true, // prevent access from known spam referrers
				'spamRequestStrings'=>true, // prevent access using know spam strings
				'spamAgents'=>true, // prevent access from known spam bots
				'cacheControl'=>true, // proper cache control headers
				'modDeflate'=>true, // gzip compression
			),
			// Lock login to specific countries by IP
			// array of country codes (Capitalized) or false to disable.
			'loginLock'=> array('US')
		),
		'blocks'=>array(
			// Common
				'core/paragraph'=>true,
				'core/image'=>false,
				'core/heading'=>true,
				'core/subhead'=>true,
				'core/gallery'=>false,
				'core/list'=>true,
				'core/quote'=>true,
				'core/audio'=>false,
				'core/cover-image'=>true,
				'core/file'=>true,
				'core/video'=>true,
			
			// Formatting
				'core/table'=>true,
				'core/verse'=>true,
				'core/code'=>true,
				'core/freeform'=>true,
				'core/html'=>true,
				'core/preformatted'=>true,
				'core/pullquote'=>true,

			// Layout Elements
				'core/button'=>true,
				'core/text-columns'=>false,// — Columns
				'core/more'=>true,
				'core/nextpage'=>true, // — Page break
				'core/separator'=>true,
				'core/spacer'=>true,
				
			// Widgets
				'core/shortcode'=>true,
				'core/archives'=>true,
				'core/categories'=>true,
				'core/latest-comments'=>true,
				'core/latest-posts'=>true,
			
			// Embeds
				'core/embed'=>false,
				'core-embed/twitter'=>false,
				'core-embed/youtube'=>false,
				'core-embed/facebook'=>false,
				'core-embed/instagram'=>false,
				'core-embed/wordpress'=>false,
				'core-embed/soundcloud'=>false,
				'core-embed/spotify'=>false,
				'core-embed/flickr'=>false,
				'core-embed/vimeo'=>false,
				'core-embed/animoto'=>false,
				'core-embed/cloudup'=>false,
				'core-embed/collegehumor'=>false,
				'core-embed/dailymotion'=>false,
				'core-embed/funnyordie'=>false,
				'core-embed/hulu'=>false,
				'core-embed/imgur'=>false,
				'core-embed/issuu'=>false,
				'core-embed/kickstarter'=>false,
				'core-embed/meetup-com'=>false,
				'core-embed/mixcloud'=>false,
				'core-embed/photobucket'=>false,
				'core-embed/polldaddy'=>false,
				'core-embed/reddit'=>false,
				'core-embed/reverbnation'=>false,
				'core-embed/screencast'=>false,
				'core-embed/scribd'=>false,
				'core-embed/slideshare'=>false,
				'core-embed/smugmug'=>false,
				'core-embed/speaker'=>false,
				'core-embed/ted'=>false,
				'core-embed/tumblr'=>false,
				'core-embed/videopress'=>false,
				'core-embed/wordpress-tv'=>false,
				
			// Omada Blocks
				'omada/accordion'=>true,
				'omada/calendar'=>true,
				'omada/cards'=>true,
				'omada/classiceditor'=>true,
				'omada/customfeed'=>true,
				'omada/flipbook'=>true,
				'omada/form'=>true,
				'omada/omadagallery'=>true,
				'omada/album'=>true,
				'omada/htmleditor'=>true,
				'omada/omadaimage'=>true,
				'omada/omadaimageheader'=>true,
				'omada/omadamenu'=>true,
				'omada/omadarow'=>true,
				'omada/slideshow'=>true,
				'omada/tabs'=>true,
				'omada/youtube'=>true,
		),
		// Add Post Types to the search - You can add your custom post types into the search by adding them to the array below.
		'searchPostTypes'=>array( 'post', 'page' ),
		// Display Feed Links
		'feedLinks'=>false,
	);
	public $formSettings=array(
		'emailHeader' => '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body style="background:#ccc;padding:20px 0px;"><div class="callout" style="width:90%;max-width:600px;margin:0 auto;padding:15px;background:ghostwhite;border-radius:12px;"><table width="100%">',
		'emailFooter' => '</table></div></body></html>'
	);
	public $omadaScripts=array('f');
	public $omadaCalendar=0;
	public $omadaGoogleCalendar=0;
	public $activePostTypes=array();
	public $dir='';
	public $uri='';
	public $version='6.2.0';
	
	// Construct
	public function __construct($args=array()){
		$this->dir=get_template_directory();
		$this->uri=get_template_directory_uri();
		if(is_array($args) && count($args)>0){  $this->args = array_replace_recursive($this->args, $args); }
		
		add_action( 'after_setup_theme', array($this,'themeSetup') );
		
		// Prefetch DNS
		remove_action('wp_head', 'wp_resource_hints', 2);
		add_action('wp_head', array($this,'stb_dns_prefetch'), 0);
		
		// Load Security Class
		$this->omadaSecurity();
		// Handle Theme Updates
		$this->omadaUpdates();
		
		
		// CRATE QUERY VARS - MUST BE RUN BEFORE PRE_GET_POSTS BELOW
		add_filter( 'query_vars', function( $query_vars ) { 
			array_push($query_vars,'combine','fontLoc','fontFace','fontType','favicon');
			return $query_vars; 
		});
		
		// CREATE VIRTUAL PAGES - Files
		add_filter( 'generate_rewrite_rules', function( $wp_rewrite ){
			// Get url structure for dev mode
				// Front End
				$uri = str_replace(home_url(),'',get_stylesheet_directory_uri());
				$uri = substr($uri,1);
				// Back End
				$adminuri = str_replace(home_url(),'',get_template_directory_uri());
				$adminuri = substr($adminuri,1);
			
			$feed_rules = array(
				// FavIcon forward
					$uri.'/favicon.ico' => 'index.php?favicon=$matches[1]',
				// Fonts for Dev Mode
					$uri.'/fonts/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=1&fontFace=$matches[1]&fontType=$matches[2]',
					$uri.'/fontawesome/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=2&fontFace=$matches[1]&fontType=$matches[2]',
					$adminuri.'/inc/css/fontawesome/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=2&fontFace=$matches[1]&fontType=$matches[2]',
				// Fonts for Non Dev Mode
					'css/fonts/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=1&fontFace=$matches[1]&fontType=$matches[2]',
					'css/fontawesome/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=2&fontFace=$matches[1]&fontType=$matches[2]',
					'css/?$' => 'index.php?combine=css', // Combine CSS File
					'js/?$' => 'index.php?combine=js', // Combine JS File
					'jquery/?$' => 'index.php?combine=jquery', // Combine JS File
				// Sitemap Redirect
					$uri.'/sitemap.xml' => $uri.'/wp-sitemap.xml'
			);
			$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
			return $wp_rewrite->rules;
		} );
		
		// ADD TEMPLATES TO VIRTUAL PAGES
		add_action( 'template_redirect', function(){
			
			$favicon = get_query_var( 'favicon' );
			if($favicon){
				require( get_template_directory().'/inc/core/layout/favicon.php');
				die;
			}
			
			$combine = get_query_var( 'combine' );
			if($combine){
				if($combine=='css'){ require( get_template_directory().'/inc/css/combine.php'); }
				elseif($combine=='js'){ require( get_template_directory().'/inc/js/combine.php'); }
				elseif($combine=='jquery'){ require( get_template_directory().'/inc/js/jquery.min.js'); }
				die;
			}
			
			$fontFace = get_query_var( 'fontFace' );
			$fontLoc = get_query_var( 'fontLoc' );
			$fontType = get_query_var( 'fontType' );
			if($fontFace!='' && $fontType!='' && $fontLoc!=''){
				
				if($fontLoc==1){ $file = get_stylesheet_directory().'/fonts/'.$fontFace.'.'.$fontType;}
				else{ $file = get_template_directory().'/inc/css/fonts/'.$fontFace.'.'.$fontType;}
				if(file_exists($file)){
					
					header('Connection: keep-alive');
					switch(strtolower($fontType)){
						case 'eot' :
							header('Content-Type: application/vnd.ms-fontobject');
							break;
						case 'svg' :
							header('Content-Type: image/svg+xml');
							break;
						case 'ttf' :
							header('Content-Type: font/ttf');
							break;
						case 'woff' :
							header('Content-Type: font/woff');
							break;
						case 'woff2' :
							header('Content-Type: font/woff2');
							break;
					}
					readfile($file);
				}else{
					echo 'The following font is missing:'.$file;
				}
				die;
			}
		});
		
		
		// ADD TRASH VERIFICATION FUNCTION
		add_action( 'admin_enqueue_scripts', function(){
			wp_enqueue_script( 'trash-confirmation', get_template_directory_uri().'/inc/js/trash-confirm.js', array(), '1.0' );
		});
		
		// ADD HEADER AND FOOTER TO MENUBAR
		add_action('admin_bar_menu', function($admin_bar){
			if(!is_admin()){
				global $post;
				$h = get_field('omada_header_selection',$post->ID);
				$f = get_field('omada_footer_selection',$post->ID);
				$header = ( $h ) ? $h->ID : get_field('omada_default_header','option');
				$footer = ( $f ) ? $f->ID : get_field('omada_default_footer','option');
				$hlink = admin_url('post.php?post='.$header.'&action=edit');
				$flink = admin_url('post.php?post='.$footer.'&action=edit');
				$admin_bar->add_menu( array('id' => 'page-layouts', 'title' => 'Design Elements', 'href' => '#' ));
				$admin_bar->add_menu( array('id' => 'edit-this-header', 'parent' => 'page-layouts', 'title' => 'Header', 'href'  => $hlink ));
				$admin_bar->add_menu( array('id' => 'edit-this-footer', 'parent' => 'page-layouts', 'title' => 'Footer', 'href'  => $flink ));
			}
		}, 100);
		
		
		// Load ACF and Fields
		$this->installACFPro($this->args);
		
		// Install Plugins
		$this->omadaPlugins($this->args);
		
		// Install Blocks
		$this->omadaBlocks($this->args);
		
		// LOAD HEADER & FOOTER POST TYPES
		require($this->dir.'/inc/core/install/install.php');
		
		// Remove unwanted default widgets
		add_action( 'widgets_init', array($this,'removeUnwantedWidgets') );
		
		// Prevent Comments for attachments
		add_action( 'init', array($this,'omadaRemoveComments') );
		
		// Remove stupid wordpress logo and links// REMOVE LOGO FROM MENU BAR
		add_action('admin_bar_menu', array($this,'remove_from_admin_bar'), 999);
				
		// Install SEO Plugin
		if($this->args['plugins']['seo']['enable']){ add_filter( 'wp_title', array($this,'omadaSEOTitle'), 10, 2 ); }
		
		if(is_admin()){
			// REMOVE WP EVENTS AND NEWS FROM DASHBOARD
			add_action('admin_menu', array($this,'removeDashboardItems'));
			
			// ADD CUSTOM STYLES FOR ADMIN AREA
			//////////////////////////////////////////////////////////////////////////////////////////////////////////////
			// SOME OF THIS MAY BE REMOVED IF WE CAN NOT ADD THE SAME SHORTCODE SYSTEMS.
			add_action('admin_head', array($this,'customAdminStyles'));
			
			// RESTRICT REVISIONS COUNT
			add_filter( 'wp_revisions_to_keep', function(){return $this->args['postRevisions'];}, 10, 2 );
			
			// Load stylesheets for editor
			add_action('enqueue_block_editor_assets', array($this, 'gutenbergStylesheets'));
			
			// Load Other admin styles
			add_action( 'admin_enqueue_scripts', array($this,'adminScriptsStyles'));
			
			// MOVE MENU ITEMS
			add_action('admin_menu', array($this,'moveMenusWidgets'),999);
			
			// SET BLOG LABELS
			$this->setBlogLabels();
			
			// ADD CUSTOM POST TYPES TO THE DASHBOARD PAGE
			add_filter( 'dashboard_glance_items', array($this,'customGlanceItems'), 10, 1 );
			
			// HIDE / DISPLAY ADMIN MENU ITEMS
			add_action( 'admin_menu', array($this,'hideDisplayMenuItems'), 999 );			
			
		}else{
			// FRONTEND ONLY FUNCTIONS
			
			// lOAD OMADA JQUERY VERSION
			add_action('wp_enqueue_scripts', array($this,'modifyJquery'));
			add_action('admin_enqueue_scripts', array($this,'modifyJquery'));
			
			// Repair Script tags for HTML5 -  Remove type attribute
			add_filter('script_loader_tag', array($this,'removeTypeAttributes'),10,2);
			
			// REMOVE EXCESSIVE BODY CLASSES
			add_filter( 'body_class', array($this,'omadaBodyClass') );
			
			if($this->args['feedLinks']==false){ add_action( 'after_setup_theme', array($this,'removeFeedLinks') ); }
			
			if($this->args['restAPI']==false){ add_action( 'after_setup_theme', array($this,'removeJsonApi' )); }
			
			if($this->args['excerptMoreLink']==true){ add_filter( 'excerpt_more', array($this,'excerptMoreLink') ); }
			
		}
		
		// SET EXCERPT LENGTH
		add_filter( 'excerpt_length', array($this,'setExcerptLength'), 999 );
		
		// BLOCK COMMENTS AND PINGBACKS BY POST TYPES - CHANGED IN ARGS
		add_filter( 'comments_open', array($this,'preventCommentByPostType'), 10 , 2 );
		
		// IMPROVE OEMBED SYSTEM FOR YOUTUBE
		add_filter( 'oembed_result', array($this,'modifyYoutubeOembed'), 10, 3 );
		
		// DISPLAY LOGO ON LOGIN PAGE
		$omada_logo = get_field('omada_logo','option');
		if($omada_logo!=''){ 
			add_action('login_footer', array($this,'omada_login_script'));
			add_action('login_enqueue_scripts',array($this,'omada_login_jquery')); 
		}
		
		// LOAD HEADER & FOOTER POST TYPES
		require($this->dir.'/inc/core/layout/layout.php');
		
		// CLIENT SYSTEM
		require($this->dir.'/inc/plugins/client/client.php');
		
		// MENU SYSTEMS - Must run after ACF
		require($this->dir.'/inc/core/layout/menus.php');
		
		// LOAD SHORTCODES
		require($this->dir.'/inc/shortcodes/shortcodes.php');
		$sc = new omadaShortcodes($this->args);
		
		// LOAD WIDGETS
		require($this->dir.'/inc/widgets/widgets.php');
		$widgets = new omadaWidgets($this->args);
		
		// DEV SYSTEMS
		require($this->dir.'/inc/core/dev/dev.php');
		
		// HELP SYSTEMS
		require($this->dir.'/inc/core/help/help.php');
		
		// SITEMAPS
		require($this->dir.'/inc/plugins/sitemaps/sitemaps.php');
		$sitemaps = new omadaSitemaps($this->args);
		
		// ROBOTS.TXT FILE SYSTEM
		require($this->dir.'/inc/plugins/robots/robots.php');
		
		// Remove Unneeded Tags from the head.
		remove_action('wp_head', 'wp_generator');         // Remove Generator Tag
		remove_action('wp_head', 'rsd_link');             // Remove EditURI
		remove_action('wp_head', 'wlwmanifest_link');     // Remove wlwmanifest
		remove_action('wp_head', 'wp_shortlink_wp_head'); // Remove Shortlink
		
		// REMOVE ITEMS FROM ADMIN BAR
		add_action('admin_bar_menu', array($this,'removeAdminBarItems'), 999);
		
		// ADD ITEMS TO ADMIN BAR
		add_action('admin_bar_menu', array($this,'addAdminBarItems'), 999);
		
		// OMADA COLOR SCHEME & STYLE
		if($this->args['theme']){
			// FORCE OMADA COLOR SCHEME
			add_filter( 'get_user_option_admin_color', function($result){ return 'omada';} );
			
			// HIDE WORDPRESS COLOR SCHEMES
			remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
			
			// LOAD CUSTOM COLOR SCHEME
			add_action('admin_init', function() {
				$child = get_stylesheet_directory_uri().'/css/colors.css';
				$dir = (file_exists($child)) ? $child : get_template_directory_uri().'/inc/core/style/colors.css';
				wp_admin_css_color( 'omada', __( 'Omada' ), $dir, array( '#2a486b', '#3f556f', '#4c6b8f', '#f1f1f1' ) );
			});

			// FORCE USER TO USE OMADA THEME ON REGISTER
			add_action('user_register', function($user_id) {
				$args = array( 'ID' => $user_id, 'admin_color' => 'omada' );
				wp_update_user( $args );
			});

			// ENQUEUE THE NEW ADMIN STYLES
			add_action( 'admin_enqueue_scripts', 'omada_theme_design' );
			add_action( 'login_enqueue_scripts', 'omada_theme_design' );
			function omada_theme_design() {
				$childcss = get_stylesheet_directory_uri().'/css/omada.css';
				$css = (file_exists($childcss))? $childcss : get_template_directory_uri().'/inc/core/style/omada.css' ;
			  	$childjs = get_stylesheet_directory_uri().'/js/omada.js';
				$js = (file_exists($childcss))? $childcss : get_template_directory_uri().'/inc/core/style/omada.js' ;
			  	$version = wp_get_theme()->parent()->get('Version');
				wp_enqueue_style( 'omada-admin-style', $css, array(), $version );
				wp_enqueue_script( 'omada-admin-script', $js, array( 'jquery' ), $version );
				
				if ( $GLOBALS['pagenow'] === 'wp-login.php' ) {
					$logincss = get_stylesheet_directory_uri().'/css/login.css';
					$css = (file_exists($logincss))? $logincss : get_template_directory_uri().'/inc/core/style/login.css' ;
					wp_enqueue_style( 'omada-login-style', $css, array(), $version );
				}
			}
			
			// REMOVE HYPHEN BEFORE POST STATUS AND MOVE IT BEFORE TITLE
			add_filter( 'display_post_states', function( $post_states ){
				global $pagenow;
				if($pagenow != 'nav-menus.php'){
					if(!empty($post_states)){ 
						$state_count = count($post_states); 
						foreach ( $post_states as $state ){ echo "<span class='post-state'>$state</span>"; } 
					}
				}
			},10,2);
			
		} // End theme check
		
		// FOOTER TEXT Change
		add_filter('admin_footer_text', function($text){ return $this->args['footerText']; });
		
		// GET RID OF HOWDY
		add_filter( 'gettext', function( $translating ){ return str_ireplace(  'Howdy', 'Welcome',  $translating ); });
		
    }
	
	// OMADA THEME SETUP
	public function themeSetup(){
		load_theme_textdomain( 'omada', $this->dir . '/languages' );
		add_theme_support('html5');
		if($this->args['automatic-feed-links']){
			add_theme_support( 'automatic-feed-links' );
		}
		if($this->args['postThumbnails']){
			add_theme_support( 'post-thumbnails' );
			set_post_thumbnail_size( $this->args['postThumbnails']['width'], $this->args['postThumbnails']['height'] );
		}
		// ENABLE SHORTCODES IN WIDGETS
		add_filter('widget_text', 'do_shortcode');
		
		// CREATE TOPBAR MENU
		add_filter( 'wp_page_menu_args', array($this,'omadaDefaultMenus') );
		
		// EMOJI SUPPORT
		if($this->args['displayEmojis']==false){ 
			remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
			remove_action( 'wp_print_styles', 'print_emoji_styles' );
		}
	}
	
	// INSTALL STYLESHEET FOR GUTENBERG
	public function gutenbergStylesheets(){
		/****** Go through all the stylesheets **/
		if(is_child_theme()){$style=$this->uri.'/style.css';}else{$style='style.css';}
		//wp_enqueue_style( 'style-gutenberg', $style, false, '6.0.0', 'all' );
		wp_enqueue_style( 'fontawesome', get_template_directory_uri().'/inc/css/font-awesome.min.css', false, '4.0', 'all' );
	}
	
	// LOAD OTHER ADMIN SCRIPTS AND STYLES
	public function adminScriptsStyles(){
		wp_enqueue_style( 'font_awesome',get_template_directory_uri().'/inc/css/font-awesome.min.css' );
	}
	
	// INSTALL ACF PRO AND REMOVE FREE VERSION
	private function installACFPro($args){
		require_once( $this->dir.'/inc/acf/acf.php');
		new omadaACF($args);
	}
	
	// INSTALL ACF Blocks
	private function omadaBlocks($args){ 
		require_once($this->dir.'/inc/plugins/blocks/blocks.php');
		new omadaBlocks($args);
	}
	
	// LOAD ACF FIELDS
	public function loadACFFields($pl,$rejectFields=array(),$args=array()){
		// Get ACF File
		if( isset($this->args['plugins'][$pl]['acf']) && $this->args['plugins'][$pl]['acf']!='' ){ $file = $this->args['plugins'][$pl]['acf'];
		}else{ $file = __DIR__ . '/inc/plugins/'.$pl.'/acf.json'; }
		
		// Get Rejected Fields
		if(isset($this->args['plugins'][$pl]['remove']) && is_array($this->args['plugins'][$pl]['remove']) && count($this->args['plugins'][$pl]['remove'])>0 ){ $rejectfields=$this->args['plugins'][$pl]['remove']; }else{ $rejectfields=array(); }
		
		// Check if rejected fields is an array
		if(!is_array($rejectfields)){$rejectfields=array();}
		
		$this->createFromACFImport($file,$rejectFields,array(),$args);
	}
	
	public function createFromACFImport($file,$rejectfields=array(),$replace=array(),$args=array()){
		if(file_exists($file)){ 
			$fg = @file_get_contents($file);
			if($fg){
				if(!empty($replace)){ foreach($replace as $k=>$v){ $fg = str_replace($k,$v,$fg); } }
				$fieldGroups = json_decode($fg,true);
				if(is_array($fieldGroups)){
					foreach($fieldGroups as $group){
						$title = $group['title'];
						if(!in_array($title,$rejectfields)){
							// Add Custom Post Types to SEO Options
							if($title=="SEO Tools" && isset($args['customPostTypes'])){
								$addedSEO=$args['customPostTypes'];
								if(is_array($addedSEO) && count($addedSEO)>0){
									foreach($addedSEO as $x){ 
										$group['location'][] = array(array('param'=>'post_type','operator'=>'==','value'=>$x));
									}
								}
							}
							acf_add_local_field_group($group);
						}
					}
				}
			}
		}
	}
	
	// OMADA SECURITY SYSTEM
	private function omadaSecurity(){
		require($this->dir.'/inc/core/security/security.php');
	}
	
	// INSTALL OMADA UPDATES
	private function omadaUpdates(){ 
		require($this->dir.'/inc/core/update/update.php'); 
	}
	
	// MODIFY WORDPRESS DEFAULT SCRIPTS AND DEFAULT GUTENBERG INCLUDES
	public function modifyJquery(){
		// REMOVE GUTENBERG
		wp_deregister_style( 'wp-block-library');
		wp_deregister_style( 'wp-block-library-theme' );
		wp_deregister_style( 'thickbox' );
		wp_deregister_script( 'thickbox' );
		
		// FIX JQUERY
		wp_deregister_script('jquery');
		wp_register_script('jquery', $this->uri.'/inc/js/jquery.min.js', false);
		wp_enqueue_script('jquery');
	}
	
	// CREATE DEFAULT MENUS
	public function omadaDefaultMenus( $args ) { 
		if(!isset( $args['topbar'])){$args['topbar'] = true;} 
		return $args; 
	}
	
	// OMADA SEO TITLE
	public function omadaSEOTitle($title, $sep){
		global $post,$paged,$page;
		
		$pid=$post->ID;
		if( is_home() && !is_front_page() ){ $pid = get_option( 'page_for_posts' ); }
		if(get_field('seo_title',$pid)){ 
			return get_field('seo_title',$pid); 
		}else{
			if(is_feed()){return $title;}
			// Add the site name.
			$title .= get_bloginfo( 'name', 'display' );
			// Add the site description for the home/front page.
			$site_description = get_bloginfo( 'description', 'display' );
			if($site_description && (is_home() || is_front_page())){$title = "$title $sep $site_description";}
			// Add a page number if necessary.
			if($paged >= 2 || $page >= 2){$title="$title $sep ".sprintf( __('Page %s','omada'),max($paged,$page));}
			return $title;
		}
	}
	
	// OMADA SEO DESCRIPTION
	public function omadaSEODesc(){
		if(get_field('seo_description')){ return get_field('seo_description'); }
		else{
			global $post;
			if (!is_single()) { return; }
			$meta = strip_shortcodes(strip_tags($post->post_content));
			$meta = substr(str_replace(array("\n", "\r", "\t"), ' ', $meta),0,125);
			return $meta;
		}
	}
	
	// REMOVE COMMENTS
	public function omadaRemoveComments(){
		remove_post_type_support('attachment', 'comments'); // prevent comments on files.
	}

	// MOVE MENUS AND WIDGETS TO THEME DESIGN
	public function moveMenusWidgets() {
		global $submenu;
		if(current_user_can('edit_theme_options')){
			$submenu['omada_design'][] = array( 'Menus', 'manage_options', 'nav-menus.php' );
			$submenu['omada_design'][] = array( 'Sidebars/Widgets', 'manage_options', 'widgets.php' );
		}
		unset($submenu['themes.php'][7]);
		unset($submenu['themes.php'][10]);
	}

	// CREATE FAVICON
	public function buildFavicon(){
		$favicon = get_field("omada_favicon","option");
		$hDefault = '<link rel="icon" href="data:;base64,iVBORw0KGgo=">';
		if(!empty($favicon)){	
			return '<link rel="icon" type="'.$favicon['mime_type'].'" href="'.home_url().'/favicon.ico" />';
		}else{ return $hDefault; } // Set Blank to prevent the seo error
	}
	
	// CUSTOM ADMIN STYLES
	public function customAdminStyles(){
		echo '<style>
			/* HIDE CUSTOMIZER */
			.hide-if-no-customize{display:none!important;}
			
			/* TinyMCE UPDATES */
			#TB_window { width:90%!important; margin-left:-45%!important; }
			#TB_iframeContent{ width:100%!important; }
			
			.fontawesome select,.menu-item-bar .menu-item-title,.menu-item-settings .edit-menu-item-title{font-family:"Font Awesome 5 Free", -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif!important;}
			
			.fontawesome select option[value*="--solid"]{font-weight:bold;}
			.fontawesome select option[value*="--brand"]{font-family: "Font Awesome 5 Brands";}
			
			#post-preview, #view-post-btn{display: none;}
			.mce-edit-area{padding-left:10px;padding-right:10px;}
			
			.fa-question-circle:before{ font-family: "Font Awesome 5 Free"; }
			
			/* Hide Staff bio label and resize editor */
			div[data-name="bio"]:before,div[data-name="bio"] .acf-label{ display:none!important; }
			div[data-name="bio"] .acf-input{ width:100%!important; }
		</style>';
	}
	
	// INSTALL OMADA PLUGINS
	private function omadaPlugins(){
		$plList = array('seo','duplicate','ads','calendar','codeblock','forms','gallery','slideshow','staff','testimonials','categories');
		foreach($plList as $pl){
			if(array_key_exists($pl,$this->args['plugins']) && $this->args['plugins'][$pl]['enable']===true){
				require($this->dir.'/inc/plugins/'.$pl.'/'.$pl.'.php');
				$class = 'omada'.ucwords($pl);
				new $class($this->args['plugins'][$pl],$this->args);
			}
		}
	}

	// SET BLOG POST LABELS
	private function setBlogLabels(){
		if(current_user_can('edit_posts')){
			// Rename the sidebar menu items
			add_action( 'admin_menu', array($this,'revcon_change_post_label'));
			// Change all the labels inside the post pages.
			add_action( 'init', array($this,'change_post_type_labels'));
		}
	}
		public function revcon_change_post_label() {
			global $menu; global $submenu;
			$menu[5][0] = 'Blog';
			$submenu['edit.php'][5][0] = $this->args['blogPostLabels']['postMenu'];
			$submenu['edit.php'][10][0] = $this->args['blogPostLabels']['postCreate'];
		}
		public function change_post_type_labels() {
			global $wp_post_types;
			$postLabels = $wp_post_types['post']->labels;
			$postLabels->name = $this->args['blogPostLabels']['name'];
			$postLabels->singular_name = $this->args['blogPostLabels']['singular_name'];
			$postLabels->add_new = $this->args['blogPostLabels']['add_new'];
			$postLabels->add_new_item = $this->args['blogPostLabels']['add_new_item'];
			$postLabels->edit_item = $this->args['blogPostLabels']['edit_item'];
			$postLabels->new_item = $this->args['blogPostLabels']['new_item'];
			$postLabels->view_item = $this->args['blogPostLabels']['view_item'];
			$postLabels->search_items = $this->args['blogPostLabels']['search_items'];
			$postLabels->not_found = $this->args['blogPostLabels']['not_found'];
			$postLabels->not_found_in_trash = $this->args['blogPostLabels']['not_found_in_trash'];
		}
	
	// REMOVE TYPE ATTRIBUTE FROM SCRIPT TAGS - HTML5 COMPLIANCE
	// AND ADD ASYNC TO JQUERY IF IN SETTINGS
	public function removeTypeAttributes($tag, $handle){
		global $pagenow;
		
		// Remove type attribute
		$tag = str_replace("type='text/javascript' ", '', $tag);
		if(!is_user_logged_in()){
			// Add async if turned on
			if('jquery' == $handle && $this->args['async']['jquery']){ $tag = str_replace( ' src', ' async="async" src', $tag ); }
			// Add defer to core js if user is not logged in.
			if('omadaCoreJS'==$handle && ($this->args['async']['jquery'] || $this->args['async']['omada'])){ 
				if(!is_user_logged_in()){ return str_replace( ' src', ' async="async" src', $tag ); } 
			}
		}
		// Clean Output
		if($pagenow!='wp-login.php'){return str_replace("'", '"', $tag);}
		else{return $tag;}
	}
	
	// ADD CUSTOM POST TYPES TO THE DASHBOARD PAGE
	public function customGlanceItems( $items = array() ) {
		$post_types = $this->activePostTypes;
		if(is_array($post_types) && count($post_types)>0){
			foreach( $post_types as $type ) {
				if( ! post_type_exists( $type ) ) continue;
				$num_posts = wp_count_posts( $type );
				if( $num_posts ) {
					$published = intval( $num_posts->publish );
					$post_type = get_post_type_object( $type );
					$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'your_textdomain' );
					$text = sprintf( $text, number_format_i18n( $published ) );
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
						$items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n";
					}else{ $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n"; }
				}
			}
		}
		return $items;
	}

	// HIDE-DISPLAY ADMIN MENU ITMES
	public function hideDisplayMenuItems(){
		if(get_field('omada_menu_blog', 'option')=='0'){remove_menu_page( 'edit.php' );}//Posts
		if(get_field('omada_menu_media', 'option')=='0'){remove_menu_page( 'upload.php' );}//Media
		if(get_field('omada_menu_pages', 'option')=='0'){remove_menu_page( 'edit.php?post_type=page' );}//Pages
		if(get_field('omada_menu_comments', 'option')=='0'){remove_menu_page( 'edit-comments.php' );}//Comments
		if(get_field('omada_menu_appearance', 'option')=='0'){remove_menu_page( 'themes.php' );}//Appearance
		if(get_field('omada_menu_plugins', 'option')=='0'){remove_menu_page( 'plugins.php' );}//Plugins
		if(get_field('omada_menu_users', 'option')=='0'){remove_menu_page( 'users.php' );}//Users
		if(get_field('omada_menu_tools', 'option')=='0'){remove_menu_page( 'tools.php' );}//Tools
		if(get_field('omada_menu_settings', 'option')=='0'){remove_menu_page( 'options-general.php' );}//Settings
		if(get_field('omada_menu_links', 'option')=='0'){remove_menu_page('link-manager.php');}//hide links
		if(get_field('omada_menu_tags', 'option')=='0'){remove_submenu_page( 'edit.php', 'edit-tags.php' );} //hide tags
	}
	
	// DISPLAY LOGO ON LOGIN PAGE
	// DISPLAY THE LOGO ON ADMIN PAGE
	public function omada_login_script(){ 
		$image = get_field('omada_logo','option'); 
		if( !empty($image) ){ 
			echo '<script> jQuery(function(){ var img = \'<img src="'.$image['url'].'" />\'; jQuery(\'#login h1\').html(img); }); </script>';
		} 
	}
	public function omada_login_jquery(){ 
		wp_enqueue_script( 'jquery' );
		echo'<style type="text/css">#login{padding:2% 0 0 !important;}#login h1 img,.login h1 img{background:none;padding-bottom:30px;max-width:320px;}</style>';
	}	
	
	// PREFETCH GOOGLE GONTS APIS
	public function stb_dns_prefetch(){
		if($this->args['prefetchDNS']){
			echo '<meta http-equiv="x-dns-prefetch-control" content="on">'."\n".
			'<link rel="dns-prefetch" href="//fonts.googleapis.com" />'."\n".
			'<link rel="dns-prefetch" href="//fonts.gstatic.com" />'."\n";
		}
	}

	// UNREGISTER UNWANTED WIDGETS
	public function removeUnwantedWidgets(){
		if(isset($this->args['widgets']) && is_array($this->args['widgets']) ){
			foreach($this->args['widgets'] as $k=>$v){ if($v==false){ unregister_widget($k); } }
		}
	}
	
	// HIDE DASHBOARD WIDGETS
	public function removeDashboardItems(){ 
		remove_meta_box('dashboard_primary', 'dashboard', 'core'); 
	}
	
	// IMPROVE THE BODY CLASS BY REMOVING A TON OF WORTHLESS CLASSES
	public function omadaBodyClass() { 
		$block=array('tabs','accordion','menu','callout');
		$classes = array();
		$pn = get_post_field( 'post_name', get_post() );
		if(!in_array($pn,$block)){ $classes[] = get_post_field( 'post_name', get_post() ); }
		return $classes; 
	}
	
	// PREVENT PINGBACKS AND COMMENTS BY POST TYPE
	public function preventCommentByPostType( $open, $post_id ){
		$post = get_post( $post_id ); 
		if(is_array($this->args['commentBlock']) && in_array($post->post_type, $this->args['commentBlock'])){ return false; }
		else{ return $open; }
	}
	
	// REMOVE FEED LINKS FROM HEAD TAGS
	public function removeFeedLinks(){ 
		remove_action( 'wp_head', 'feed_links_extra', 3 ); 
		remove_action( 'wp_head', 'feed_links', 2 ); 
	}
	
	// REMOVE JSON API
	public function removeJsonApi(){
		// Remove the REST API lines from the HTML Header
		remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
		remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );

		// Remove the REST API endpoint.
		remove_action( 'rest_api_init', 'wp_oembed_register_route' );

		// Turn off oEmbed auto discovery.
		add_filter( 'embed_oembed_discover', '__return_false' );

		// Don't filter oEmbed results.
		remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );

		// Remove oEmbed discovery links.
		remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );

		// Remove oEmbed-specific JavaScript from the front-end and back-end.
		remove_action( 'wp_head', 'wp_oembed_add_host_js' );

		// Filters for WP-API version 1.x
		add_filter('json_enabled', '__return_false');
		add_filter('json_jsonp_enabled', '__return_false');

		// Filters for WP-API version 2.x
		add_filter('rest_enabled', '__return_false');
		add_filter('rest_jsonp_enabled', '__return_false');
	}
	
	// IMPROVE OEMBED YOUTUBE VIDEOS
	public function modifyYoutubeOembed( $html, $url, $args ) {
		// Improve Youtube videos
		$newhtml = str_replace( '?feature=oembed', '?feature=oembed'.$this->args['youtubeOembed'], $html );
		// Improve Video Videos
		$newhtml = str_replace( '?dnt=1', '?dnt=1&portrait=0&byline=0', $html);
		// Add LazyLoad to oembed links
		if(!is_admin()){$newhtml = str_replace( ' src="', 'class="lazy" data-src="',$newhtml);}
		return $newhtml;
	}
	
	// SET EXCERPT LENGTH
	public function setExcerptLength( $length ){ return $this->args['excerptLength']; }
	
	// CHANGE THE ... AFTER EXCERPT TO A LINK TO READ MORE.
	public function excerptMoreLink( $more ) {
		return sprintf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( '... Read More', 'omada' ) );
	}
	
	// REMOVE ITEMS FROM ADMIN TOPBAR
	public function removeAdminBarItems($wp_adminbar) {
		if(is_array($this->args['adminBarRemove']) && count($this->args['adminBarRemove'])>0){
			foreach($this->args['adminBarRemove'] as $item){ $wp_adminbar->remove_node($item); }
		}
	}
	
	// ADD ITEMS TO ADMIN TOPBAR
	public function addAdminBarItems($wp_admin_bar) {
		if($this->args['support']['active']==true){
			$wp_admin_bar->add_node(
				array(
					'id'=>'supportMenu',
					'title'=>'<span class="ab-icon far fa-question-circle"></span><span class="ab-label">Customer Support</span>',
					'href'=>'#'
				)
			);
			if($this->args['support']['website']){$wp_admin_bar->add_node(array('id'=>'supportWebsite','title'=>$this->args['support']['website']['label'],'href'=>$this->args['support']['website']['href'],'parent'=>'supportMenu'));}
			if($this->args['support']['email']){$wp_admin_bar->add_node(array('id'=>'supportEmail','title'=>$this->args['support']['email']['label'],'href'=>'mailto:'.$this->args['support']['email']['href'],'parent'=>'supportMenu'));}
			if($this->args['support']['phone']){$wp_admin_bar->add_node(array('id'=>'supportPhone','title'=>$this->args['support']['phone']['label'],'href'=>'tel:'.$this->args['support']['phone']['href'],'parent'=>'supportMenu'));}
		}
	}
	
	// REMOVE STUPID WORDPRESS LOGO AND LINKS
	public function remove_from_admin_bar($wp_admin_bar){ $wp_admin_bar->remove_node('wp-logo'); }
}