# wt-security/2.4.12/src/Common.php

WebTotem Security, version 2.4.12. 134 lines.

- Page: https://pluginprobe.com/plugins/wt-security/2.4.12/code/src/Common.php
- Raw: https://pluginprobe.com/plugins/wt-security/2.4.12/raw/src/Common.php
- Modified: 2022-08-23T09:46:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wt-security/2.4.12/code/src/Common.php#L10-L20`.

```php
<?php

if (!defined('WEBTOTEM_INIT') || WEBTOTEM_INIT !== true) {
	if (!headers_sent()) {
		header('HTTP/1.1 403 Forbidden');
	}
	die("Protected By WebTotem!");
}

if (defined('WEBTOTEM')) {

  /**
   * Remove the WordPress generator meta-tag from the source code.
   */
  remove_action('wp_head', 'wp_generator');

  /**
   * Define which javascript and css files will be loaded in the header of the
   * plugin pages.
   */
  add_action('admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);

	/** Login Page */
	add_action('login_enqueue_scripts', 'WebTotemInterface::loginEnqueueScripts');

	/** Add authenticate filter */
	add_filter('authenticate', 'WebTotemInterface::wt_authenticate', 25, 3);

	/** Execute pre-checks before every page */
	add_action('init', 'WebTotemInterface::startupChecks'); //wp_loaded

	/** Add site or new sites if it is multisite */
	add_action( 'wp_insert_site', 'WebTotemInterface::addNewSite' );

	/** Attach HTTP request handlers for the AJAX requests */
	add_action('wp_ajax_wtotem_ajax', 'wtotem_ajax_callback');
	add_action('wp_ajax_nopriv_wtotem_ajax', 'wtotem_public_ajax_callback');

	/** Hide or show WP version */
	if (WebTotemOption::getPluginSettings('hide_wp_version')) {
		add_filter('update_feedback', 'WebTotemInterface::restoreReadmeWhenUpdating');
	}

	/** Define role of current user */
	//add_action('init', 'WebTotem::getUserRole');

	/**  */
	add_action( 'wp', 'webtotem_add_cron' );
	add_action( 'webtotem_daily_cron', 'dailyCron' );

	function webtotem_add_cron() {
		if( ! wp_next_scheduled( 'webtotem_daily_cron' ) ) {
			wp_schedule_event( time(), 'daily', 'webtotem_daily_cron' );
		}
	}

  /**
   * List an associative array with the sub-pages of this plugin.
   *
   * @return array List of sub-pages of this plugin.
   */
  function wtotemPages() {
	  if( WebTotem::isMultiSite() ) {
		  $pages['wtotem_all_sites'] = [ 'title' =>  __('All sites', 'wtotem'), 'slug' => 'wtotem'];
	  }
		$slug = WebTotem::isMultiSite() ? 'wtotem_' : 'wtotem';

	  $pages['wtotem_dashboard'] = [ 'title' =>  __('Dashboard', 'wtotem'), 'slug' => $slug];
	  $pages['wtotem_firewall']  = [ 'title' =>  __('Firewall', 'wtotem'), 'slug' => $slug];
	  if(!WebTotem::isMultiSite() or is_super_admin()) {
		  $pages['wtotem_antivirus'] = [ 'title' =>  __('Antivirus', 'wtotem'), 'slug' => $slug];
		  $pages['wtotem_settings']  = [ 'title' =>  __('Settings', 'wtotem'), 'slug' => $slug];
	  }
	  $pages['wtotem_reports']   = [ 'title' =>  __('Reports', 'wtotem'), 'slug' => $slug];
	  $pages['wtotem_documentation'] = [ 'title' =>  __('Documentation', 'wtotem'), 'slug' => 'wtotem'];

    return $pages;
  }

  if (function_exists('add_action')) {
      /**
       * Display extension menu and submenu items in the correct interface.
       *
       * @return void
       */
      function wtotemAddMenu() {

	      $page = ! WebTotemOption::isActivated() ? 'activation' : ( WebTotem::isMultiSite() ? 'all_sites' : 'dashboard' );

        add_menu_page(
            __('WebTotem Security', 'wtotem'),
            __('WebTotem Security', 'wtotem'),
            'manage_options',
            'wtotem',
            'wtotem_' . $page . '_page',
            WebTotem::getImagePath('logo_17x17_w.png')
        );

        if(WebTotemOption::isActivated()){
	        $pages = wtotemPages();
          foreach ($pages as $sub_page_function => $sub_page) {
              add_submenu_page(
	              $sub_page['slug'],
	              $sub_page['title'],
	              $sub_page['title'],
	              'manage_options',
                $sub_page_function,
                $sub_page_function . '_page'
              );
          }

        } else {
	        add_submenu_page(
		        'wtotem',
		        __('Activation', 'wtotem'),
		        __('Activation', 'wtotem'),
		        'manage_options',
		        'wtotem_activation',
		        'wtotem_activation_page'
	        );
        }
      }

      /* Attach HTTP request handlers for the internal plugin pages */
	    if(WebTotem::isMultiSite()){
		    add_action('network_admin_menu', 'wtotemAddMenu');
	    }
	    add_action('admin_menu', 'wtotemAddMenu');


  }

}

```
