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.
*
* @access public
* @since 1.4
* @return void
*/
public function admin_menus() {
// About Page
add_dashboard_page(
__( 'Welcome to Ninja Forms', 'ninja-forms' ),
__( 'Welcome to Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
'nf-about',
array( $this, 'about_screen' )
);
// Changelog Page
add_dashboard_page(
__( 'Ninja Forms Changelog', 'ninja-forms' ),
__( 'Ninja Forms Changelog', 'ninja-forms' ),
$this->minimum_capability,
'nf-changelog',
array( $this, 'changelog_screen' )
);
// Getting Started Page
add_dashboard_page(
__( 'Getting started with Ninja Forms', 'ninja-forms' ),
__( 'Getting started with Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
'nf-getting-started',
array( $this, 'getting_started_screen' )
);
// Credits Page
add_dashboard_page(
__( 'The people who build Ninja Forms', 'ninja-forms' ),
__( 'The people who build Ninja Forms', 'ninja-forms' ),
$this->minimum_capability,
'nf-credits',
array( $this, 'credits_screen' )
);
}
/**
* Hide Individual Dashboard Pages
*
* @access public
* @since 1.4
* @return void
*/
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';
?>
header_text; ?>
header_desc; ?>
display_version ); ?>
tabs(); ?>
header_text; ?>
header_desc; ?>
display_version ); ?>
tabs(); ?>
header_text; ?>
header_desc; ?>
display_version ); ?>
tabs(); ?>
if( function_exists( \'ninja_forms_display_form\' ) ){ ninja_forms_display_form( 1 ); }' ); ?>
tabs(); ?>
contributors(); ?>
' . __( 'No valid changelog was found.', 'ninja-forms' ) . '';
} else {
$readme = file_get_contents( $file );
$readme = nl2br( esc_html( $readme ) );
$readme = explode( '== Changelog ==', $readme );
$readme = end( $readme );
$readme = preg_replace( '/`(.*?)`/', '\\1
', $readme );
$readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' \\1', $readme );
$readme = preg_replace( '/[\040]\*(.*?)\*/', ' \\1', $readme );
$readme = preg_replace( '/= (.*?) =/', '\\1
', $readme );
$readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '\\1', $readme );
}
return $readme;
}
/**
* Render Contributors List
*
* @since 1.4
* @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 ) )
return '';
$contributor_list = '';
return $contributor_list;
}
/**
* Retreive list of contributors from GitHub.
*
* @access public
* @since 1.4
* @return array $contributors List of contributors
*/
public function get_contributors() {
$contributors = get_transient( 'nf_contributors' );
if ( false !== $contributors )
return $contributors;
$response = wp_remote_get( 'https://api.github.com/repos/wpninjas/ninja-forms/contributors?&per_page=100', array( 'sslverify' => false ) );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return array();
$contributors = json_decode( wp_remote_retrieve_body( $response ) );
if ( ! is_array( $contributors ) )
return array();
set_transient( 'nf_contributors', $contributors, 3600 );
return $contributors;
}
/**
* Sends user to the Welcome page on first activation of NF as well as each
* time NF is upgraded to a new version
*
* @access public
* @since 1.4
* @global $nf_options Array of all the NF Options
* @return void
*/
public function welcome() {
global $nf_options;
// Bail if no activation redirect
if ( ! get_transient( '_nf_activation_redirect' ) )
return;
// Delete the redirect transient
delete_transient( '_nf_activation_redirect' );
// Bail if activating from network, or bulk
if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
return;
$upgrade = get_option( 'nf_version_upgraded_from' );
if( ! $upgrade ) { // First time install
wp_safe_redirect( admin_url( 'index.php?page=nf-getting-started' ) ); exit;
} else { // Update
wp_safe_redirect( admin_url( 'index.php?page=nf-about' ) ); exit;
}
}
}
new NF_Welcome();