<?php

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

class GDATTAdmin {
	private $admin_plugin = false;

	function __construct() {
		add_action( 'after_setup_theme', [ $this, 'load' ] );
	}

	public static function instance() {
		static $instance = false;

		if ( $instance === false ) {
			$instance = new GDATTAdmin();
		}

		return $instance;
	}

	public function load() {
		add_filter( 'plugin_action_links', [ $this, 'plugin_actions' ], 10, 2 );
		add_filter( 'plugin_row_meta', [ $this, 'plugin_links' ], 10, 2 );
	}

	public function plugin_actions( $links, $file ) {
		if ( $file == 'gd-bbpress-attachments/gd-bbpress-attachments.php' ) {
			$settings_link = '<a href="edit.php?post_type=forum&page=gdbbpress_attachments">' . __( 'Settings', 'forumax' ) . '</a>';
			array_unshift( $links, $settings_link );
		}

		return $links;
	}

	public function plugin_links( $links, $file ) {
		if ( $file == 'gd-bbpress-attachments/gd-bbpress-attachments.php' ) {
			$links[] = '<a target="_blank" style="color: #cc0000; font-weight: bold;" href="https://plugins.dev4press.com/gd-bbpress-toolbox/">' . __( 'Upgrade to GD bbPress Toolbox Pro', 'forumax' ) . '</a>';
		}

		return $links;
	}

	public function load_admin_page() {
		$screen = get_current_screen();

		$screen->set_help_sidebar(
			'
            <p><strong>Dev4Press:</strong></p>
            <p><a target="_blank" href="https://www.dev4press.com/">' . __( 'Website', 'forumax' ) . '</a></p>
            <p><a target="_blank" href="https://twitter.com/milangd">' . __( 'On Twitter', 'forumax' ) . '</a></p>
            <p><a target="_blank" href="https://facebook.com/dev4press">' . __( 'On Facebook', 'forumax' ) . '</a></p>'
		);

		$screen->add_help_tab(
			[
				'id'      => 'gdpt-screenhelp-help',
				'title'   => __( 'Get Help', 'forumax' ),
				'content' => '<h5>' . __( 'General Plugin Information', 'forumax' ) . '</h5>
                <p><a href="https://plugins.dev4press.com/gd-bbpress-attachments/" target="_blank">' . __( 'Home Page on Dev4Press.com', 'forumax' ) . '</a> | 
                <a href="https://wordpress.org/plugins/gd-bbpress-attachments/" target="_blank">' . __( 'Home Page on WordPress.org', 'forumax' ) . '</a></p> 
                <h5>' . __( 'Getting Plugin Support', 'forumax' ) . '</h5>
                <p><a href="https://support.dev4press.com/forums/forum/plugins-free/gd-bbpress-attachments/" target="_blank">' . __( 'Support Forum on Dev4Press.com', 'forumax' ) . '</a> | 
                <a href="https://wordpress.org/support/plugin/gd-bbpress-attachments" target="_blank">' . __( 'Support Forum on WordPress.org', 'forumax' ) . '</a> </p>',
			]
		);

		$screen->add_help_tab(
			[
				'id'      => 'gdpt-screenhelp-website',
				'title'   => 'Dev4Press',
				'sfc',
				'content' => '<p>' . __( 'On Dev4Press website you can find many useful plugins, themes and tutorials, all for WordPress. Please, take a few minutes to browse some of these resources, you might find some of them very useful.', 'forumax' ) . '</p>
                <p><a href="https://plugins.dev4press.com/plugins/" target="_blank"><strong>' . __( 'Plugins', 'forumax' ) . '</strong></a> - ' . __( 'We have more than 10 plugins available, some of them are commercial and some are available for free.', 'forumax' ) . '</p>
                <p><a href="https://support.dev4press.com/kb/" target="_blank"><strong>' . __( 'Knowledge Base', 'forumax' ) . '</strong></a> - ' . __( 'Premium and free tutorials for our plugins themes, and many general and practical WordPress tutorials.', 'forumax' ) . '</p>
                <p><a href="https://support.dev4press.com/forums/" target="_blank"><strong>' . __( 'Support Forums', 'forumax' ) . '</strong></a> - ' . __( 'Premium support forum for all with valid licenses to get help. Also, report bugs and leave suggestions.', 'forumax' ) . '</p>',
			]
		);
	}

	public function menu_attachments() {
		$options     = BBPCATTCore::instance()->o;
		$_user_roles = bbpc_bbpress_get_user_roles();

		include BBPCATTACHMENTS_PATH . 'forms/panels.php';
	}
}


