File: //proc/2301933/cwd/wp-content/plugins/ottar-core/main.php
<?php
/*
Plugin Name: Ottar Core
Description: Plugin that adds all post types needed by our theme
Author: Edge Themes
Version: 1.2.1
*/
require_once 'load.php';
add_action( 'after_setup_theme', array( OttarCore\CPT\PostTypesRegister::getInstance(), 'register' ) );
if ( ! function_exists( 'ottar_core_activation' ) ) {
/**
* Triggers when plugin is activated. It calls flush_rewrite_rules
* and defines ottar_edge_action_core_on_activate action
*/
function ottar_core_activation() {
do_action( 'ottar_edge_action_core_on_activate' );
OttarCore\CPT\PostTypesRegister::getInstance()->register();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'ottar_core_activation' );
}
if ( ! function_exists( 'ottar_core_text_domain' ) ) {
/**
* Loads plugin text domain so it can be used in translation
*/
function ottar_core_text_domain() {
load_plugin_textdomain( 'ottar-core', false, OTTAR_CORE_REL_PATH . '/languages' );
}
add_action( 'plugins_loaded', 'ottar_core_text_domain' );
}
if ( ! function_exists( 'ottar_core_version_class' ) ) {
/**
* Adds plugins version class to body
*
* @param $classes
*
* @return array
*/
function ottar_core_version_class( $classes ) {
$classes[] = 'ottar-core-' . OTTAR_CORE_VERSION;
return $classes;
}
add_filter( 'body_class', 'ottar_core_version_class' );
}
if ( ! function_exists( 'ottar_core_theme_installed' ) ) {
/**
* Checks whether theme is installed or not
* @return bool
*/
function ottar_core_theme_installed() {
return defined( 'EDGE_ROOT' );
}
}
if ( ! function_exists( 'ottar_core_is_woocommerce_installed' ) ) {
/**
* Function that checks if woocommerce is installed
* @return bool
*/
function ottar_core_is_woocommerce_installed() {
return function_exists( 'is_woocommerce' );
}
}
if ( ! function_exists( 'ottar_core_is_woocommerce_integration_installed' ) ) {
//is Edge Woocommerce Integration installed?
function ottar_core_is_woocommerce_integration_installed() {
return defined( 'OTTAR_CHECKOUT_INTEGRATION' );
}
}
if ( ! function_exists( 'ottar_core_is_revolution_slider_installed' ) ) {
function ottar_core_is_revolution_slider_installed() {
return class_exists( 'RevSliderFront' );
}
}
if ( ! function_exists( 'ottar_core_is_wpml_installed' ) ) {
/**
* Function that checks if WPML plugin is installed
* @return bool
*
* @version 0.1
*/
function ottar_core_is_wpml_installed() {
return defined( 'ICL_SITEPRESS_VERSION' );
}
}
if ( ! function_exists( 'ottar_core_theme_menu' ) ) {
/**
* Function that generates admin menu for options page.
* It generates one admin page per options page.
*/
function ottar_core_theme_menu() {
if ( ottar_core_theme_installed() ) {
global $ottar_edge_Framework;
ottar_edge_init_theme_options();
$page_hook_suffix = add_menu_page(
esc_html__( 'Ottar Options', 'ottar-core' ), // The value used to populate the browser's title bar when the menu page is active
esc_html__( 'Ottar Options', 'ottar-core' ), // The text of the menu in the administrator's sidebar
'administrator', // What roles are able to access the menu
EDGE_OPTIONS_SLUG, // The ID used to bind submenu items to this menu
array(
$ottar_edge_Framework->getSkin(),
'renderOptions'
), // The callback function used to render this menu
$ottar_edge_Framework->getSkin()->getSkinURI() . '/assets/img/admin-logo-icon.png', // Icon For menu Item
100 // Position
);
foreach ( $ottar_edge_Framework->edgtfOptions->adminPages as $key => $value ) {
$slug = "";
if ( ! empty( $value->slug ) ) {
$slug = "_tab" . $value->slug;
}
$subpage_hook_suffix = add_submenu_page(
EDGE_OPTIONS_SLUG,
esc_html__( 'Ottar Options - ', 'ottar-core' ) . $value->title, // The value used to populate the browser's title bar when the menu page is active
$value->title, // The text of the menu in the administrator's sidebar
'administrator', // What roles are able to access the menu
EDGE_OPTIONS_SLUG . $slug, // The ID used to bind submenu items to this menu
array( $ottar_edge_Framework->getSkin(), 'renderOptions' )
);
add_action( 'admin_print_scripts-' . $subpage_hook_suffix, 'ottar_edge_enqueue_admin_scripts' );
add_action( 'admin_print_styles-' . $subpage_hook_suffix, 'ottar_edge_enqueue_admin_styles' );
};
add_action( 'admin_print_scripts-' . $page_hook_suffix, 'ottar_edge_enqueue_admin_scripts' );
add_action( 'admin_print_styles-' . $page_hook_suffix, 'ottar_edge_enqueue_admin_styles' );
}
}
add_action( 'admin_menu', 'ottar_core_theme_menu' );
}
if ( ! function_exists( 'ottar_core_theme_menu_backup_options' ) ) {
/**
* Function that generates admin menu for options page.
* It generates one admin page per options page.
*/
function ottar_core_theme_menu_backup_options() {
if ( ottar_core_theme_installed() ) {
global $ottar_edge_Framework;
$slug = "_backup_options";
$page_hook_suffix = add_submenu_page(
EDGE_OPTIONS_SLUG,
esc_html__( 'Ottar Options - Backup Options', 'ottar-core' ), // The value used to populate the browser's title bar when the menu page is active
esc_html__( 'Backup Options', 'ottar-core' ), // The text of the menu in the administrator's sidebar
'administrator', // What roles are able to access the menu
EDGE_OPTIONS_SLUG . $slug, // The ID used to bind submenu items to this menu
array( $ottar_edge_Framework->getSkin(), 'renderBackupOptions' )
);
add_action( 'admin_print_scripts-' . $page_hook_suffix, 'ottar_edge_enqueue_admin_scripts' );
add_action( 'admin_print_styles-' . $page_hook_suffix, 'ottar_edge_enqueue_admin_styles' );
}
}
add_action( 'admin_menu', 'ottar_core_theme_menu_backup_options' );
}
if ( ! function_exists( 'ottar_core_theme_admin_bar_menu_options' ) ) {
/**
* Add a link to the WP Toolbar
*/
function ottar_core_theme_admin_bar_menu_options( $wp_admin_bar ) {
if ( ottar_core_theme_installed() && current_user_can( 'edit_theme_options' ) ) {
global $ottar_edge_Framework;
$args = array(
'id' => 'ottar-admin-bar-options',
'title' => sprintf( '<span class="ab-icon dashicons-before dashicons-admin-generic"></span> %s', esc_html__( 'Ottar Options', 'ottar-core' ) ),
'href' => esc_url( admin_url( 'admin.php?page=' . EDGE_OPTIONS_SLUG ) )
);
$wp_admin_bar->add_node( $args );
foreach ( $ottar_edge_Framework->edgtfOptions->adminPages as $key => $value ) {
$suffix = ! empty( $value->slug ) ? '_tab' . $value->slug : '';
$args = array(
'id' => 'ottar-admin-bar-options-' . $suffix,
'title' => $value->title,
'parent' => 'ottar-admin-bar-options',
'href' => esc_url( admin_url( 'admin.php?page=' . EDGE_OPTIONS_SLUG . $suffix ) )
);
$wp_admin_bar->add_node( $args );
};
}
}
add_action( 'admin_bar_menu', 'ottar_core_theme_admin_bar_menu_options', 999 );
}