plugin_path = WPCF7_PRO_REDIRECT_BASE_PATH; $this->version = WPCF7_PRO_REDIRECT_PLUGIN_VERSION; $this->load_dependencies(); $this->init_plugin_dependencies(); $this->post_types(); $this->add_action_hooks(); $this->add_ajax_hooks(); } /** * Create instances of all required objects */ public function init_plugin_dependencies() { $this->wpcf_settings = new WPCF7r_Settings(); $this->wpcf7_redirect = new WPCF7r_Form_Helper(); $this->wpcf7_utils = new WPCF7r_Utils(); $this->wpcf7_submission = new WPCF7r_Submission(); $this->wpcf7_user_panel = new WPCF7R_User(); } /** * Register the post type required for the action managment */ public function post_types() { new WPCF7R_Post_Types(); } /** * Get a singelton */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Some general plugin hooks */ public function add_action_hooks() { // display banner on the redirect settings page // the banner will be used to the premium version // add_action( 'before_redirect_settings_tab_title' , array( $this->wpcf7_utils , 'get_banner' ) , 10 );. add_action( 'before_settings_fields', array( $this->wpcf7_utils, 'show_admin_notices' ), 10 ); add_action( 'admin_notices', array( $this, 'show_admin_notices' ), 10 ); add_action( 'admin_init', array( $this, 'dismiss_admin_notice' ) ); // form submission hook. add_action( 'wpcf7_before_send_mail', array( $this->wpcf7_submission, 'handle_valid_actions' ) ); // validation actions. add_filter( 'wpcf7_validate', array( $this->wpcf7_submission, 'handle_validation_actions' ), 10, 2 ); // handle contact form response. add_filter( 'wpcf7_feedback_response', array( $this->wpcf7_submission, 'manipulate_cf7_response_object' ), 10, 2 ); add_action( 'init', function() { if ( ! is_admin() ) { // handle form rendering. add_filter( 'wpcf7_contact_form_properties', array( $this->wpcf7_utils, 'render_actions_elements' ), 10, 2 ); } } ); // support for browsers that does not support ajax. add_action( 'wpcf7_submit', array( $this->wpcf7_submission, 'non_ajax_redirection' ) ); // add_action( 'after_plugin_row_' . WPCF7_PRO_REDIRECT_BASE_NAME , array( $this->wpcf7_utils , 'license_details_message' ), 10, 2 ); // handle form duplication. add_action( 'wpcf7_after_create', array( $this->wpcf7_utils, 'duplicate_form_support' ) ); // handle form deletion. add_action( 'before_delete_post', array( $this->wpcf7_utils, 'delete_all_form_actions' ) ); // catch submission for early $_POST manupulations. add_action( 'wpcf7_contact_form', array( $this->wpcf7_submission, 'after_cf7_object_created' ) ); // handle poppup preview. add_action( 'init', array( $this->wpcf7_utils, 'show_action_preview' ) ); // handle affiliate extensions. add_action( 'init', array( $this, 'start_affiliate_extensions' ) ); // add filter by form on leads list. if ( class_exists( 'WPCF7R_Leads_Manager' ) && class_exists( 'WPCF7R_Action_Save_Lead' ) ) { add_action( 'restrict_manage_posts', array( 'WPCF7R_Leads_Manager', 'add_form_filter' ) ); add_filter( 'parse_query', array( 'WPCF7R_Leads_Manager', 'filter_request_query' ), 10 ); add_action( 'admin_init', array( 'WPCF7R_Leads_Manager', 'admin_init_scripts' ) ); add_action( 'admin_init', array( 'WPCF7R_Leads_Manager', 'export_current_filtered_view' ), 10, 2 ); } } /** * Initialize affiliate extensions */ public function start_affiliate_extensions() { } /** * Dismiss admin notice * * @return void */ public function dismiss_admin_notice() { if ( isset( $_REQUEST['dismiss-cf7r-notices'] ) ) { delete_option( 'wpcf7_redirect_notifications' ); } } /** * Display admin notifications * * @return void */ public function show_admin_notices() { $notices = get_option( 'wpcf7_redirect_notifications' ); add_action( 'admin_footer', function() { ?> $notice ) : ?>