hooks(); $this->acfg_include_files(); } /** * Initialize. */ public function hooks() { add_action( 'admin_enqueue_scripts', array( $this, 'acfg_admin_scripts' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'acfg_front_scripts' ) ); } /** * Check ACF is active or not. */ public function acfg_validate_depencency() { if ( ! class_exists( 'ACF' ) ) { add_action( 'admin_notices', array( $this, 'acfg_validate_depencency_msg' ) ); return; } } /** * Displays an admin notice when Advanced Custom Fields (or its Secure Custom Fields successor) is missing or inactive. */ public function acfg_validate_depencency_msg() { $screen = get_current_screen(); if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { return; } include_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugin = 'advanced-custom-fields/acf.php'; $plugin_pro = 'advanced-custom-fields-pro/acf.php'; $plugin_scf = 'secure-custom-fields/secure-custom-fields.php'; $installed_plugins = get_plugins(); if ( isset( $installed_plugins[ $plugin ] ) || isset( $installed_plugins[ $plugin_pro ] ) || isset( $installed_plugins[ $plugin_scf ] ) ) { // Check if a supported plugin is installed. if ( ! current_user_can( 'activate_plugins' ) ) { return; } if ( isset( $installed_plugins[ $plugin_pro ] ) ) { $activate_plugin = $plugin_pro; $activate_label = __( 'Activate ACF Pro Now', 'acf-on-the-go' ); } elseif ( isset( $installed_plugins[ $plugin ] ) ) { $activate_plugin = $plugin; $activate_label = __( 'Activate ACF Now', 'acf-on-the-go' ); } else { $activate_plugin = $plugin_scf; $activate_label = __( 'Activate Secure Custom Fields Now', 'acf-on-the-go' ); } $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $activate_plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $activate_plugin ); $message = '
' . __( 'ACF on the Go', 'acf-on-the-go' ) . '' . __( ' Plugin not working because you need to activate the Advanced Custom Fields or Secure Custom Fields plugin.', 'acf-on-the-go' ) . '
'; $message .= '' . sprintf( '%s', esc_url( $activation_url ), $activate_label ) . '
'; } else { if ( ! current_user_can( 'install_plugins' ) ) { return; } $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=secure-custom-fields' ), 'install-plugin_secure-custom-fields' ); $message = '' . __( 'ACF on the Go', 'acf-on-the-go' ) . '' . __( ' Plugin not working because you need to install the Advanced Custom Fields or Secure Custom Fields plugin', 'acf-on-the-go' ) . '
'; $message .= '' . sprintf( '%s', esc_url( $install_url ), __( 'Install Secure Custom Fields Now', 'acf-on-the-go' ) ) . '
'; } echo '' . wp_kses_post( $message ) . '