<?php if ( ! defined( 'ABSPATH' ) ) exit;
* @subpackage Admin/Welcome
* @copyright Copyright (c) 2014, WP Ninjas
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
* A general class for About and Credits page.
* @var string The capability users should have to view the page
public $minimum_capability = 'manage_options';
public $display_version = NF_PLUGIN_VERSION;
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menus') );
add_action( 'admin_head', array( $this, 'admin_head' ) );
add_action( 'admin_init', array( $this, 'welcome' ) );
$this->header_text = sprintf( __( 'Welcome to Ninja Forms %s', 'ninja-forms' ), $this->display_version );
$this->header_desc = sprintf( __( 'Thank you for updating! Ninja Forms %s makes form building easier than ever before!', 'ninja-forms' ), $this->display_version );
* Register the Dashboard Pages which are later hidden but these pages
* are used to render the Welcome and Credits pages.
public function admin_menus() {
__( 'Welcome to Ninja Forms', 'ninja-forms' ),
__( 'Welcome to Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
array( $this, 'about_screen' )
__( 'Ninja Forms Changelog', 'ninja-forms' ),
__( 'Ninja Forms Changelog', 'ninja-forms' ),
$this->minimum_capability,
array( $this, 'changelog_screen' )
__( 'Getting started with Ninja Forms', 'ninja-forms' ),
__( 'Getting started with Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
array( $this, 'getting_started_screen' )
__( 'The people who build Ninja Forms', 'ninja-forms' ),
__( 'The people who build Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
array( $this, 'credits_screen' )
* Hide Individual Dashboard Pages
public function admin_head() {
remove_submenu_page( 'index.php', 'nf-about' );
remove_submenu_page( 'index.php', 'nf-changelog' );
remove_submenu_page( 'index.php', 'nf-getting-started' );
remove_submenu_page( 'index.php', 'nf-credits' );
// Ensures style is only on welcome page
if ((isset($_GET['page'])) && ($_GET['page']=='nf-about' || $_GET['page']=='nf-getting-started' || $_GET['page']=='nf-credits' || $_GET['page']=='nf-changelog')){
// Badge for welcome page
$badge_url = NF_PLUGIN_URL . 'assets/images/nf-badge.png';
<style type="text/css" media="screen">
background: url('<?php echo $badge_url; ?>') no-repeat;
.nf-welcome-screenshots {
margin-left: 10px!important;
.about-wrap .feature-section {
$selected = isset( $_GET['page'] ) ? $_GET['page'] : 'nf-about';
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $selected == 'nf-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'nf-about' ), 'index.php' ) ) ); ?>">
<?php _e( "What's New", 'ninja-forms' ); ?>
<a class="nav-tab <?php echo $selected == 'nf-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'nf-getting-started' ), 'index.php' ) ) ); ?>">
<?php _e( 'Getting Started', 'ninja-forms' ); ?>
<a class="nav-tab <?php echo $selected == 'nf-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'nf-credits' ), 'index.php' ) ) ); ?>">
<?php _e( 'Credits', 'ninja-forms' ); ?>
public function about_screen() {
<div class="wrap about-wrap">
<h1><?php echo $this->header_text; ?></h1>
<div class="about-text"><?php echo $this->header_desc; ?></div>
<div class="nf-badge"><?php printf( __( 'Version %s', 'ninja-forms' ), $this->display_version ); ?></div>
<div class="about-overview">
<iframe width="640" height="360" src="//www.youtube.com/embed/todRiV7Cel0" frameborder="0" allowfullscreen></iframe>
<h2 class="about-headline-callout"><?php _e( 'A simplified and more powerful form building experience.', 'ninja-forms' );?></h2>
<div class="feature-section col two-col">
<img src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-builder.png'; ?>">
<h4><?php _e( 'New Builder Tab', 'ninja-forms' );?></h4>
<p><?php _e( 'When creating and editing forms, go directly to the section that matters most.', 'ninja-forms' ); ?></p>
<div class="col-2 last-feature">
<img src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-field-settings.png'; ?>">
<h4><?php _e( 'Better Organized Field Settings', 'ninja-forms' );?></h4>
<p><?php printf( __( 'The most common settings are shown immediately, while other, non-essential, settings are tucked away inside expandable sections.', 'ninja-forms' ), admin_url( 'edit.php?post_type=download&page=nf-settings&tab=misc' ) ); ?></p>
<div class="feature-section col three-col">
<img src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-emails-actions.png'; ?>">
<h4><?php _e( 'Improved clarity', 'ninja-forms' );?></h4>
<p><?php _e( 'Along with the "Build Your Form" tab, we\'ve removed "Notifications" in favor of "Emails & Actions." This is a much clearer indication of what can be done on this tab.', 'ninja-forms' ); ?></p>
<img src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-nuke-option.png'; ?>">
<h4><?php _e( 'Remove all Ninja Forms data', 'ninja-forms' );?></h4>
<p><?php _e( 'We\'ve added the option to remove all Ninja Forms data (submissions, forms, fields, options) when you delete the plugin. We call it the nuclear option.', 'ninja-forms' ); ?></p>
<div class="col-3 last-feature">
<img src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-licenses.png'; ?>">
<h4><?php _e( 'Better license management', 'ninja-forms' );?></h4>
<p><?php _e( 'Deactivate Ninja Forms extension licenses individually or as a group from the settings tab.', 'ninja-forms' ); ?></p>
<div class="feature-section col two-col">
<h4><?php _e( 'More to come', 'ninja-forms' ); ?></h4>
<p><?php _e( 'The interface updates in this version lay the groundwork for some great improvements in the future. Version 3.0 will build on these changes to make Ninja Forms an even more stable, powerful, and user-friendly form builder.', 'ninja-forms' ); ?></p>
<div class="col-2 last-feature">
<h4><?php _e( 'Documentation', 'ninja-forms' );?></h4>
<p><?php _e( 'Take a look at our in-depth Ninja Forms documentation below.', 'ninja-forms' ); ?></p>
<a href="<?php echo esc_url( 'http://docs.ninjaforms.com/?utm_medium=plugin&utm_source=welcome-screen&utm_campaign=Ninja+Forms+Welcome&utm_content=Ninja+Forms+Docs' ); ?>"><?php _e( 'Ninja Forms Documentation', 'ninja-forms' ); ?></a> ·
<a href="<?php echo esc_url( 'https://ninjaforms.com/contact/?utm_medium=plugin&utm_source=welcome-screen&utm_campaign=Ninja+Forms+Welcome&utm_content=Ninja+Forms+Support' ); ?>"><?php _e( 'Get Support', 'ninja-forms' ); ?></a>
<div class="return-to-dashboard">
<a href="<?php echo esc_url( admin_url( 'index.php?page=ninja-forms' ) ); ?>"><?php _e( 'Return to Ninja Forms', 'ninja-forms' ); ?></a> ·
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'nf-changelog' ), 'index.php' ) ) ); ?>"><?php _e( 'View the Full Changelog', 'ninja-forms' ); ?></a>
* Render Changelog Screen
public function changelog_screen() {
list( $display_version ) = explode( '-', NF_PLUGIN_VERSION );
<div class="wrap about-wrap">
<h1><?php echo $this->header_text; ?></h1>
<div class="about-text"><?php echo $this->header_desc; ?></div>
<div class="nf-badge"><?php printf( __( 'Version %s', 'ninja-forms' ), $this->display_version ); ?></div>
<h3><?php _e( 'Full Changelog', 'ninja-forms' );?></h3>
<div class="feature-section">
<?php echo $this->parse_readme(); ?>
<div class="return-to-dashboard">
<a href="<?php echo esc_url( admin_url( 'index.php?page=ninja-forms' ) ); ?>"><?php _e( 'Go to Ninja Forms', 'ninja-forms' ); ?></a>
* Render Getting Started Screen
public function getting_started_screen() {
list( $display_version ) = explode( '-', NF_PLUGIN_VERSION );
<div class="wrap about-wrap">
<h1><?php echo $this->header_text; ?></h1>
<div class="about-text"><?php echo $this->header_desc; ?></div>
<div class="nf-badge"><?php printf( __( 'Version %s', 'ninja-forms' ), $this->display_version ); ?></div>
<p class="about-description"><?php _e( 'Use the tips below to get started using Ninja Forms. You will be up and running in no time!', 'ninja-forms' ); ?></p>
<div class="feature-section">
<h4><?php _e( 'All About Forms', 'ninja-forms' );?></h4>
<img style="width: 500px; height: 292px;" src="<?php echo NF_PLUGIN_URL . 'assets/images/screenshots/ss-new-form.png'; ?>" class="nf-welcome-screenshots">
<p><?php printf( __( 'The Forms menu is your access point for all things Ninja Forms. We\'ve already created your first %scontact form%s so that you have an example. You can also create your own by clicking %sAdd New%s.', 'ninja-forms' ), '<a href="admin.php?page=ninja-forms&tab=builder&form_id=1">', '</a>', '<a href="admin.php?page=ninja-forms&tab=builder&form_id=new">', '</a>' ); ?></p>
<h4><?php _e( 'Build Your Form', 'ninja-forms' );?></h4>
<p><?php _e( 'This is where you\'ll build your form by adding fields and dragging them into the order you want them to appear. Each field will have an assortment of options such as label, label position, and placeholder.', 'ninja-forms' );?></p>
<h4><?php _e( 'Emails & Actions', 'ninja-forms' );?></h4>
<p><?php _e( 'If you would like for your form to notify you via email when a user clicks submit, you can set those up on this tab. You can create an unlimited number of emails, including emails sent to the user who filled out the form.', 'ninja-forms' );?></p>
<h4><?php _e( 'Settings', 'ninja-forms' );?></h4>
<p><?php _e( 'This tab hold general form settings, such as title and submission method, as well as display settings like hiding a form when it is successfully completed.', 'ninja-forms' );?></p>
<h3><?php _e( 'Displaying Your Form', 'ninja-forms' );?></h3>
<div class="feature-section col two-col">
<h4><?php _e( 'Append to Page', 'ninja-forms' );?></h4>
<p><?php _e( 'Under Basic Form Behavior in the Form Settings you can easily select a page that you would like the form automatically appended to the end of that page\'s content. A similiar option is avaiable in every content edit screen in its sidebar.', 'ninja-forms' ); ?></p>
<div class="col-2 last-feature">
<h4><?php _e( 'Shortcode', 'ninja-forms' );?></h4>
<p><?php printf( __( 'Place %s in any area that accepts shortcodes to display your form anywhere you like. Even in the middle of your page or posts content.', 'ninja-forms' ), '[ninja_form id=1]' ); ?></p>
<div class="feature-section col two-col">
<h4><?php _e( 'Ninja Forms Widget', 'ninja-forms' );?></h4>
<p><?php printf( __( 'Ninja Forms provides a widget that you can place in any widgetized area of your site and select exactly which form you would like displayed in that space.', 'ninja-forms' ), admin_url( 'edit.php?post_type=download&page=nf-settings&tab=misc' ) ); ?></p>
<div class="col-2 last-feature">
<h4><?php _e( 'Template Function', 'ninja-forms' );?></h4>
<p><?php printf( __( 'Ninja Forms also comes with a simple template function that can be placed directly into a php template file. %s', 'ninja-forms' ), '<code>if( function_exists( \'ninja_forms_display_form\' ) ){ ninja_forms_display_form( 1 ); }</code>' ); ?></p>
<h3><?php _e( 'Need Help?', 'ninja-forms' );?></h3>
<div class="feature-section col two-col">
<h4><?php _e( 'Growing Documentation', 'ninja-forms' );?></h4>
<p><?php printf( __( 'Documentation is available covering everything from %sTroubleshooting%s to our %sDeveloper API%s. New Documents are always being added.', 'ninja-forms' ), '<a href="http://docs.ninjaforms.com/customer/portal/articles/2045713-troubleshooting-ninja-forms/?utm_medium=plugin&utm_source=welcome-screen&utm_campaign=Ninja+Forms+Welcome&utm_content=Ninja+Forms+Docs">', '</a>', '<a href="http://docs.ninjaforms.com/customer/portal/topics/798123-developer-api/articles/?utm_medium=plugin&utm_source=welcome-screen&utm_campaign=Ninja+Forms+Welcome&utm_content=Ninja+Forms+Docs">', '</a>' ); ?></p>
<div class="col-2 last-feature">
<h4><?php _e( 'Best Support in the Business', 'ninja-forms' );?></h4>
<p><?php printf( __( 'We do all we can to provide every Ninja Forms user with the best support possible. If you encounter a problem or have a question, %splease contact us%s.', 'ninja-forms' ), '<a href="https://ninjaforms.com/contact/?utm_medium=plugin&utm_source=welcome-screen&utm_campaign=Ninja+Forms+Welcome&utm_content=Ninja+Forms+Support">', '</a>' ); ?></p>
public function credits_screen() {
list( $display_version ) = explode( '-', NF_PLUGIN_VERSION );
<div class="wrap about-wrap">
<h1><?php printf( __( 'Welcome to Ninja Forms %s', 'ninja-forms' ), $display_version ); ?></h1>
<div class="about-text"><?php printf( __( 'Thank you for updating to the latest version! Ninja Forms %s is primed to make your experience managing submissions an enjoyable one!', 'ninja-forms' ), $display_version ); ?></div>
<div class="nf-badge"><?php printf( __( 'Version %s', 'ninja-forms' ), $display_version ); ?></div>
<p class="about-description"><?php _e( 'Ninja Forms is created by a worldwide team of developers who aim to provide the #1 WordPress community form creation plugin.', 'ninja-forms' ); ?></p>
<?php echo $this->contributors(); ?>
* Parse the NF readme.txt file
* @return string $readme HTML formatted readme file
public function parse_readme() {
$file = file_exists( NF_PLUGIN_DIR . 'readme.txt' ) ? NF_PLUGIN_DIR . 'readme.txt' : null;
$readme = '<p>' . __( 'No valid changelog was found.', 'ninja-forms' ) . '</p>';
$readme = file_get_contents( $file );
$readme = nl2br( esc_html( $readme ) );
$readme = explode( '== Changelog ==', $readme );
$readme = end( $readme );
$readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme );
$readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme );
$readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme );
$readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme );
$readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme );
* Render Contributors List
* @uses NF_Welcome::get_contributors()
* @return string $contributor_list HTML formatted list of all the contributors for NF
public function contributors() {
$contributors = $this->get_contributors();
if ( empty( $contributors ) )
$contributor_list = '<ul class="wp-people-group">';
foreach ( $contributors as $contributor ) {
$contributor_list .= '<li class="wp-person">';
$contributor_list .= sprintf( '<a href="%s" title="%s">',
esc_url( 'https://github.com/' . $contributor->login ),
esc_html( sprintf( __( 'View %s', 'ninja-forms' ), $contributor->login ) )
$contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) );
$contributor_list .= '</a>';
$contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) );
$contributor_list .= '</a>';
$contributor_list .= '</li>';
$contributor_list .= '</ul>';
return $contributor_list;
* Retreive list of contributors from GitHub.
* @return array $contributors List of contributors
public function get_contributors() {
$contributors = get_transient( 'nf_contributors' );
if ( false !== $contributors )