pluginDir . 'the-events-calendar.php', $plugins ) ){ return $actions; } if ( isset( $actions['plugins_page'] ) ) { $actions['plugins_page'] = '' . esc_html__( 'Return to Plugins page' ) . ''; if ( ! current_user_can( 'activate_plugins' ) ){ unset( $actions['plugins_page'] ); } } if ( isset( $actions['updates_page'] ) ) { $actions['updates_page'] = '' . esc_html__( 'Return to WordPress Updates' ) . ''; } return $actions; } public function maybe_redirect() { if ( ! empty( $_POST ) ) { return; // don't interrupt anything the user's trying to do } if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { return; } if ( defined( 'IFRAME_REQUEST' ) && IFRAME_REQUEST ) { return; // probably the plugin update/install iframe } if ( isset( $_GET['tec-welcome-message'] ) || isset( $_GET['tec-update-message'] ) ) { return; // no infinite redirects } if ( isset( $_GET['tec-skip-welcome'] ) ) { return; // a way to skip these checks and } // bail if we aren't activating a plugin if ( ! get_transient( '_tribe_events_activation_redirect' ) ) { return; } delete_transient( '_tribe_events_activation_redirect' ); if ( ! current_user_can( Tribe__Settings::instance()->requiredCap ) ){ return; } if ( $this->showed_update_message_for_current_version() ) { return; } // the redirect might be intercepted by another plugin, but // we'll go ahead and mark it as viewed right now, just in case // we end up in a redirect loop // see #31088 $this->log_display_of_message_page(); if ( $this->is_new_install() ) { $this->redirect_to_welcome_page(); } /* * TODO: determine if we wish to keep the update splash screen in the future else { $this->redirect_to_update_page(); } */ } /** * Have we shown the welcome/update message for the current version? * * @return bool */ protected function showed_update_message_for_current_version() { $message_version_displayed = Tribe__Settings_Manager::get_option( 'last-update-message' ); if ( empty( $message_version_displayed ) ) { return false; } if ( version_compare( $message_version_displayed, Tribe__Events__Main::VERSION, '<' ) ) { return false; } return true; } protected function log_display_of_message_page() { Tribe__Settings_Manager::set_option( 'last-update-message', Tribe__Events__Main::VERSION ); } /** * The previous_ecp_versions option will be empty or set to 0 * if the current version is the first version to be installed. * * @return bool * @see Tribe__Events__Main::maybeSetTECVersion() */ protected function is_new_install() { $previous_versions = Tribe__Settings_Manager::get_option( 'previous_ecp_versions' ); return empty( $previous_versions ) || ( end( $previous_versions ) == '0' ); } protected function redirect_to_welcome_page() { $url = $this->get_message_page_url( 'tec-welcome-message' ); wp_safe_redirect( $url ); exit(); } protected function redirect_to_update_page() { $url = $this->get_message_page_url( 'tec-update-message' ); wp_safe_redirect( $url ); exit(); } protected function get_message_page_url( $slug ) { $settings = Tribe__Settings::instance(); // get the base settings page url $url = apply_filters( 'tribe_settings_url', add_query_arg( array( 'post_type' => Tribe__Events__Main::POSTTYPE, 'page' => $settings->adminSlug, ), admin_url( 'edit.php' ) ) ); $url = esc_url_raw( add_query_arg( $slug, 1, $url ) ); return $url; } public function register_page() { if ( isset( $_GET['tec-welcome-message'] ) ) { $this->disable_default_settings_page(); add_action( 'tribe_events_page_' . Tribe__Settings::$parent_slug, array( $this, 'display_welcome_page' ) ); } elseif ( isset( $_GET['tec-update-message'] ) ) { $this->disable_default_settings_page(); add_action( 'tribe_events_page_' . Tribe__Settings::$parent_slug, array( $this, 'display_update_page' ) ); } } protected function disable_default_settings_page() { remove_action( 'tribe_events_page_' . Tribe__Settings::$parent_slug, array( Tribe__Settings::instance(), 'generatePage' ) ); } public function display_welcome_page() { do_action( 'tribe_settings_top' ); echo '