<?php

/**
 * Plugin Name: Mediabay - Rewrited
 * Plugin URI:  https://inoby.sk
 * Description: Get organized with thousands of images. Organize media into folders.
 * Version:     1.5
 * Author:      inoby
 * Author URI:  https://inoby.sk
 * Text Domain: mediabay
 * License:     GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 * Domain Path: /languages
 */


if (! defined('ABSPATH')) {
	exit;
}


define('MEDIABAY__FILE__', __FILE__);
define('MEDIABAY_FOLDER', 'mediabay_wpfolder');
define('MEDIABAY_VERSION', '1.4');
define('MEDIABAY_PATH', get_template_directory() . '/plugins/mediabay/');
define('MEDIABAY_URL', get_template_directory_uri() . '/plugins/mediabay/');
define('MEDIABAY_ASSETS_URL', MEDIABAY_URL . 'assets/');
define('MEDIABAY_TEXT_DOMAIN', 'mediabay');
define('MEDIABAY_PLUGIN_BASE', 'theme-embedded/mediabay');
define('MEDIABAY_PLUGIN_NAME', 'Mediabay');



function mediabay_plugins_loaded_theme()
{
	// include main plugin file
	include_once(MEDIABAY_PATH . 'inc/plugin.php');

	// načítanie prekladov priamo z plugin priečinka
	$locale = determine_locale();
	$mofile = MEDIABAY_PATH . 'languages/mediabay-' . $locale . '.mo';
	if (file_exists($mofile)) {
		load_textdomain(MEDIABAY_TEXT_DOMAIN, $mofile);
	}
}

add_action('after_setup_theme', 'mediabay_plugins_loaded_theme');

//The grid view for the Media Library requires JavaScript - fix
function mediabay_admin_footer_script_theme()
{
	$screen = get_current_screen();
	if ($screen && $screen->base === 'upload') {
		wp_enqueue_script('mediabay-admin-footer-script', MEDIABAY_URL . 'assets/js/mediabay-admin-footer.js', array('jquery'), MEDIABAY_VERSION, true);
	}
}

add_action('admin_footer', 'mediabay_admin_footer_script_theme');
