<?php
/* Instagram Feed support functions
------------------------------------------------------------------------------- */

// Theme init priorities:
// 9 - register other filters (for installer, etc.)
if (!function_exists('writer_ancora_trx_updater_theme_setup')) {
    add_action( 'writer_ancora_action_before_init_theme', 'writer_ancora_trx_updater_theme_setup', 1 );
    function writer_ancora_trx_updater_theme_setup() {
        if (is_admin()) {
            add_filter( 'writer_ancora_filter_required_plugins',		'writer_ancora_trx_updater_required_plugins' );
        }
    }
}

// Filter to add in the required plugins list
if ( !function_exists( 'writer_ancora_trx_updater_required_plugins' ) ) {
    function writer_ancora_trx_updater_required_plugins($list=array()) {
        if (in_array('trx_updater', (array)writer_ancora_storage_get('required_plugins'))) {
            $list[] = array(
                'name' 		=> esc_html__('Themerex Updater', 'writer-ancora'),
                'slug' 		=> 'trx_updater',
                'version'   => '1.9.0',
                'source'	=> writer_ancora_get_file_dir('plugins/install/trx_updater.zip'),
                'required' 	=> false
            );
        }
        return $list;
    }
}

// Check if Instagram Feed installed and activated
if ( !function_exists( 'writer_ancora_exists_trx_updater' ) ) {
    function writer_ancora_exists_trx_updater() {
        return defined('TRX_UPDATER_VERSION');
    }
}