<?php
/**
 *
 * @link              https://bowdenworks.com
 * @since             1.0.0
 * @package           BwWinner
 *
 * @wordpress-plugin
 * Plugin Name:       Bowden Works Winner Plugin
 * Plugin URI:        https://bowdenworks.com
 * Version:           1.0.0
 * Author:            Bowden Works
 * Author URI:        https://bowdenworks.com
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       bw-winner
 */

namespace BwWinner;

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

define( __NAMESPACE__ . '\PLUGIN_NAME', 'MyStudio' );
define( __NAMESPACE__ . '\PLUGIN_VERSION', '1.0.0' );

define( __NAMESPACE__ . '\PLUGIN_PATH', trailingslashit( __DIR__ ) );
define( __NAMESPACE__ . '\PLUGIN_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );

// should the tables and data added by this plugin be removed from the site when the plugin is removed?
define( __NAMESPACE__ . '\UNINSTALL_DROP_TABLES', false );

// should the tables and data added by this plugin be removed from the site when the plugin is deactivated
define( __NAMESPACE__ . '\DEACTIVATE_DROP_TABLES', false );

// The code that runs during plugin activation.
register_activation_hook( __FILE__, __NAMESPACE__ . '\activate' );
function activate( $network_wide ) {
	require_once PLUGIN_PATH . 'includes/class-activator.php';
	Activator::activate( $network_wide );
}

// The code that runs during plugin deactivation.
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate' );
function deactivate() {
	require_once PLUGIN_PATH . 'includes/class-deactivator.php';
	Deactivator::deactivate();
}

// Begins execution of the plugin.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-bw-winner.php';
new Bw_Winner();

// Fix a long-standing issue with ACF, where fields sometimes aren't shown
// in previews (ie. from Preview > Open in new tab).
if ( class_exists( 'acf_revisions' ) )
{
	// Reference to ACF's <code>acf_revisions</code> class
	// We need this to target its method, acf_revisions::acf_validate_post_id
	$acf_revs_cls = \acf()->revisions;

	// This hook is added the ACF file: includes/revisions.php:36 (in ACF PRO v5.11)
	remove_filter( 'acf/validate_post_id', array( $acf_revs_cls, 'acf_validate_post_id', 10 ) );
}
