diff --git a/modules/acf/src/plugin.php b/modules/acf/src/plugin.php index c7e6f41e..b4afec86 100644 --- a/modules/acf/src/plugin.php +++ b/modules/acf/src/plugin.php @@ -13,9 +13,10 @@ class acf_qtranslate_plugin { */ public function __construct() { add_action( 'plugins_loaded', array( $this, 'init' ), 3 ); - add_action( 'after_setup_theme', array( $this, 'init' ), - 10 ); + add_action( 'after_setup_theme', array( $this, 'init' ), -10 ); add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); - add_action( 'admin_footer', array( $this, 'admin_footer' ), - 10 ); + add_action( 'admin_footer', array( $this, 'admin_footer' ), -10 ); + add_action( 'admin_head', array( $this, 'admin_head' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); @@ -32,19 +33,12 @@ public function __construct() { * @return void */ public function init() { - static $plugin_loaded; - - if ( ! $plugin_loaded && $this->acf_enabled() && $this->qtranslatex_enabled() ) { - // setup qtranslate fields for ACF 5 + static $plugin_loaded = false; + if ( ! $plugin_loaded && $this->acf_enabled() ) { if ( $this->acf_major_version() === 5 ) { require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/acf.php'; $this->acf = new acf_qtranslate_acf_5( $this ); } - - // setup qtranslatex integration - require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/qtranslatex.php'; - new acf_qtranslate_qtranslatex( $this, $this->acf ); - $plugin_loaded = true; } } @@ -80,13 +74,6 @@ public function acf_major_version() { return (int) $this->acf_version(); } - /** - * Check if qTranslate-X is enabled - */ - public function qtranslatex_enabled() { - return function_exists( 'qtranxf_getLanguage' ); - } - /** * Get the active language * @@ -140,6 +127,37 @@ public function admin_footer() { get_plugin_setting( 'show_language_tabs' ); + if ( ! $show_language_tabs ) { + ?> + + get_plugin_setting( 'translate_standard_field_types' ); + if ( $translate_standard_field_types ) { + ?> + + acf = $acf; - $this->plugin = $plugin; - - add_action( 'admin_head', array( $this, 'admin_head' ) ); - } - - /** - * Add additional styles and scripts to head - */ - public function admin_head() { - // Hide the language tabs if they shouldn't be displayed - $show_language_tabs = $this->plugin->get_plugin_setting( 'show_language_tabs' ); - if ( ! $show_language_tabs ) { - ?> - - plugin->get_plugin_setting( 'translate_standard_field_types' ); - if ( $translate_standard_field_types ) { - ?> - -