settings = array( 'plugin' => 'ACF Companion Lite', 'this_acf_version' => 0, 'min_acf_version' => '5.6.3', 'version' => '1.0.0', 'url' => plugin_dir_url( __FILE__ ), 'path' => plugin_dir_path( __FILE__ ), ); //Get the absolute path of the directory that contains the file. define('ACF_C_LITE_PLUGIN_PATH', __FILE__ ); // Set text domain load_plugin_textdomain( 'acf-c-lite', false, dirname( plugin_basename(__FILE__) ) . '/languages/' ); // Add the 'acf_or_die' function (defined below) that checks if ACF is installed add_action( 'admin_init', array($this, 'acf_or_die'), 11); // Adds some CSS to the admin pages that ACF is on add_action('acf/input/admin_enqueue_scripts', array( $this, 'acf_c_lite_admin_scripts_styles' ) ); } } /** * Let's make sure ACF Pro is installed & activated * If not, we give notice and kill the activation of ACF Companion Lite. * Also works if ACF Pro is deactivated. * * @since 1.0.0 * @version 1.0.0 */ function acf_or_die() { // If the 'acf' class (defined by ACF) DOES NOT exist or if the class 'acf_c' DOES exist then do this. if ( (!class_exists('acf')) || (class_exists('acf_c')) ) { $this->kill_plugin(); // Otherwise check the version of ACF. } else { $this->settings['this_acf_version'] = acf()->settings['version']; if ( version_compare( $this->settings['this_acf_version'], $this->settings['min_acf_version'], '<' ) ) { $this->kill_plugin(); } } } /** * Deactivate plugin if ACF isn't installed (or ver too old). * * @since 1.0.0 * @version 1.0.0 */ function kill_plugin() { deactivate_plugins( plugin_basename( __FILE__ ) ); if ( isset( $_GET['activate'] ) ) { unset( $_GET['activate'] ); } add_action( 'admin_notices', array($this, 'acf_dependent_plugin_notice') ); } /** * Display notice. * * @since 1.0.0 * @version 1.0.0 */ function acf_dependent_plugin_notice() { // If the 'acf' class (defined by ACF) DOES NOT exist othen display this message. if (!class_exists('acf')) { echo sprintf( __('%s requires ACF %s or higher to be installed and activated. %sDismiss This Notice%s', 'acf-c-lite'), '
' . $this->settings['plugin'], $this->settings['min_acf_version'], '
' . sprintf( __('%1$s requires ACF v%2$s or higher to be installed and activated.', 'acf-c-lite'), $this->settings['plugin'], . '
', '', '', $this->settings['plugin'], '