define_constants(); $this->includes(); $this->init_hooks(); } /** * Hook into actions and filters. * @since 1.0 */ private function init_hooks() { register_activation_hook( __FILE__, array( $this, 'admin_activation_notice' ) ); add_action( 'admin_notices', array( $this, 'admin_hook_notice' ) ); add_filter('acf/fields/flexible_content/layout_title', array( $this, 'acf_fclt' ), 10, 4); } /** * Define acf_fcl Constants. */ private function define_constants() { $this->define( 'FCL_ABSURL', plugins_url( '/', __FILE__ ) ); $this->define( 'FCL_ABSPATH', dirname( __FILE__ ) . '/' ); $this->define( 'FCL_VERSION', $this->version ); } /** * Define constant if not already set. * * @param string $name * @param string|bool $value */ private function define( $name, $value ) { if ( ! defined( $name ) ) { define( $name, $value ); } } /** * What type of request is this? * * @param string $type admin, ajax, cron or frontend. * @return bool */ private function is_request( $type ) { switch ( $type ) { case 'admin' : return is_admin(); case 'ajax' : return defined( 'DOING_AJAX' ); case 'cron' : return defined( 'DOING_CRON' ); case 'frontend' : return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ); } } /** * Include required core files used in admin. */ public function includes() { if ( $this->is_request( 'admin' ) ) { include_once( FCL_ABSPATH . 'includes/class-meta-boxes.php' ); include_once( FCL_ABSPATH . 'includes/class-menus.php' ); include_once( FCL_ABSPATH . 'includes/class-admin-page.php' ); } } /** * Add Notice if exist error when plugin activation. */ public function admin_activation_notice() { add_action( 'admin_notices', array( $this, 'admin_hook_notice' ) ); } /** * Add Notice if exist error. */ public function admin_hook_notice() { if ( ! function_exists('acf_get_field_groups') ) { global $pagenow; if ( $pagenow == 'plugins.php' ) : ?>
Error: Plugin ACF Flexible Content Layout Thumbnail can not work without plugin Advanced Custom Fields PRO.
Advanced Custom Fields PRO plugin is not active, please activate the plugin!', 'error' ); ?>