name. * * @var array */ private $inactive = array(); /** * Get the instance. * * @return PingPush */ public static function instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Constructor. */ private function __construct() { PingPush_Logger::maybe_install(); PingPush_Queue::init(); // Event labels are translated, so register them on init (WordPress 6.7+ warns about // translations loaded earlier). Priority 1 keeps us ahead of plugins acting on init. add_action( 'init', array( $this, 'boot_events' ), 1 ); if ( is_admin() ) { new PingPush_Settings(); new PingPush_Importer(); } } /** * Load integrations and register events. */ public function boot_events() { $this->load_integrations(); /** * Register custom events with PingPush_Events::register() and trigger them * with PingPush_Events::trigger(). */ do_action( 'pingpush_register_events' ); } /** * Integration classes, keyed by file. * * @return array */ private function integration_map() { return array( 'class-pingpush-event-core.php' => 'PingPush_Event_Core', 'class-pingpush-event-cf7.php' => 'PingPush_Event_CF7', 'class-pingpush-event-wpforms.php' => 'PingPush_Event_WPForms', 'class-pingpush-event-gravityforms.php' => 'PingPush_Event_GravityForms', 'class-pingpush-event-fluentforms.php' => 'PingPush_Event_FluentForms', 'class-pingpush-event-elementor-forms.php' => 'PingPush_Event_Elementor_Forms', 'class-pingpush-event-ninjaforms.php' => 'PingPush_Event_NinjaForms', 'class-pingpush-event-forminator.php' => 'PingPush_Event_Forminator', 'class-pingpush-event-formidable.php' => 'PingPush_Event_Formidable', 'class-pingpush-event-woocommerce.php' => 'PingPush_Event_WooCommerce', 'class-pingpush-event-edd.php' => 'PingPush_Event_EDD', 'class-pingpush-event-custom-hook.php' => 'PingPush_Event_Custom_Hook', ); } /** * Load integrations. */ private function load_integrations() { require_once PINGPUSH_DIR . 'includes/events/class-pingpush-integration.php'; require_once PINGPUSH_DIR . 'includes/events/class-pingpush-form-integration.php'; foreach ( $this->integration_map() as $file => $class ) { require_once PINGPUSH_DIR . 'includes/events/' . $file; if ( ! class_exists( $class ) ) { continue; } if ( ! $class::is_available() ) { $this->inactive[ $class ] = $class::name(); continue; } $integration = new $class(); $integration->register_events(); $integration->hooks(); $this->integrations[ $class ] = $integration; } } /** * Names of supported plugins that are not active. * * @return string[] */ public function inactive_integrations() { return array_values( $this->inactive ); } /** * Activation. */ public static function activate() { PingPush_Logger::install(); add_option( PINGPUSH_OPTION, PingPush_Settings::defaults(), '', false ); if ( ! wp_next_scheduled( 'pingpush_check_updates' ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'twicedaily', 'pingpush_check_updates' ); } } /** * Deactivation. */ public static function deactivate() { wp_clear_scheduled_hook( 'pingpush_check_updates' ); wp_unschedule_hook( PingPush_Queue::HOOK ); if ( function_exists( 'as_unschedule_all_actions' ) ) { as_unschedule_all_actions( PingPush_Queue::HOOK, array(), PingPush_Queue::GROUP ); } } }