should_load ) { return; } // Include plugin dependency. require_once ABSPATH . 'wp-admin/includes/plugin.php'; /** * Setup constants. */ // Current plugin version. if ( ! defined( 'EDAC_VERSION' ) ) { define( 'EDAC_VERSION', '1.9.1' ); } // Current database version. if ( ! defined( 'EDAC_DB_VERSION' ) ) { define( 'EDAC_DB_VERSION', '1.0.3' ); } // Plugin Folder Path. if ( ! defined( 'EDAC_PLUGIN_DIR' ) ) { define( 'EDAC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); } // Plugin Folder URL. if ( ! defined( 'EDAC_PLUGIN_URL' ) ) { define( 'EDAC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); } // Plugin Root File. if ( ! defined( 'EDAC_PLUGIN_FILE' ) ) { define( 'EDAC_PLUGIN_FILE', __FILE__ ); } // Accessibility New Window Warning Plugin Active. if ( ! defined( 'EDAC_ANWW_ACTIVE' ) ) { define( 'EDAC_ANWW_ACTIVE', is_plugin_active( 'accessibility-new-window-warnings/accessibility-new-window-warnings.php' ) ); } /** * Key Valid. */ define( 'EDAC_KEY_VALID', 'valid' === get_option( 'edacp_license_status' ) ); // Enable EDAC_DEBUG mode. if ( ! defined( 'EDAC_DEBUG' ) ) { define( 'EDAC_DEBUG', false ); } // SVG Icons. define( 'EDAC_SVG_IGNORE_ICON', file_get_contents( __DIR__ . '/assets/images/ignore-icon.svg' ) ); /** * Plugin Activation & Deactivation */ register_activation_hook( __FILE__, 'edac_activation' ); register_deactivation_hook( __FILE__, 'edac_deactivation' ); /* ***************************** CLASS AUTOLOADING *************************** */ if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) { include_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; } if ( class_exists( 'EDAC\Inc\Plugin' ) ) { new Plugin(); } /** * Add simple dom support (need to over ride max file size, if clashes with another install of simple dom there the max file size will be dependednt upon that installation) */ if ( ! defined( 'MAX_FILE_SIZE' ) ) { define( 'MAX_FILE_SIZE', 6000000 ); } if ( ! class_exists( 'simple_html_dom' ) ) { include_once plugin_dir_path( __FILE__ ) . 'includes/simplehtmldom/simple_html_dom.php'; include_once plugin_dir_path( __FILE__ ) . 'includes/classes/class-edac-dom.php'; } /** * Import Resources */ require_once plugin_dir_path( __FILE__ ) . 'includes/deprecated/deprecated.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/activation.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/deactivation.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/helper-functions.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/meta-boxes.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/options-page.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/validate.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/insert.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/purge.php'; /** * Filters and Actions */ add_action( 'add_meta_boxes', 'edac_register_meta_boxes' ); add_action( 'admin_menu', 'edac_add_options_page' ); add_action( 'admin_init', 'edac_register_setting' ); add_action( 'admin_head', 'edac_post_on_load' ); add_filter( 'save_post', 'edac_save_post', 10, 3 ); add_action( 'wp_trash_post', 'edac_delete_post' ); add_action( 'pre_get_posts', 'edac_show_draft_posts' ); if ( is_plugin_active( 'oxygen/functions.php' ) ) { add_action( 'added_post_meta', 'edac_oxygen_builder_save_post', 10, 4 ); add_action( 'updated_post_meta', 'edac_oxygen_builder_save_post', 10, 4 ); } /** * Gets an array of default filters, * and applies the rules `edac_filter_register_rules` filter to it. * * @return array */ function edac_register_rules() { // Use a static variable to avoid multiple calls to the filesystem. static $default_rules = null; if ( ! is_null( $default_rules ) ) { return $default_rules; } // If we got this far, this is the 1st time we called this function. // We need to load the rules from the filesystem, and apply any filters. $default_rules = include __DIR__ . '/includes/rules.php'; $default_rules = apply_filters( 'edac_filter_register_rules', $default_rules ); return $default_rules; } /** * Include Rules * * @return void */ function edac_include_rules_files() { $rules = edac_register_rules(); if ( ! $rules ) { return; } foreach ( $rules as $rule ) { if ( ( array_key_exists( 'ruleset', $rule ) && 'php' === $rule['ruleset'] ) || ( ! array_key_exists( 'ruleset', $rule ) && $rule['slug'] ) ) { require_once plugin_dir_path( __FILE__ ) . 'includes/rules/' . $rule['slug'] . '.php'; } } } add_action( 'init', 'edac_include_rules_files' );