plugin install
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Splash_Page;
|
||||
|
||||
use Gravity_Forms\Gravity_Forms\Config\GF_Config_Service_Provider;
|
||||
use Gravity_Forms\Gravity_Forms\Splash_Page\Config\GF_Splash_Page_Config;
|
||||
use Gravity_Forms\Gravity_Forms\GF_Service_Container;
|
||||
use Gravity_Forms\Gravity_Forms\GF_Service_Provider;
|
||||
use Gravity_Forms\Gravity_Forms\Splash_Page_Template_Tags\GF_Splash_Page_Template_Tags;
|
||||
|
||||
/**
|
||||
* Class Splash_Page_Service_Provider
|
||||
*
|
||||
* Service provider for the splash page.
|
||||
*
|
||||
* @package Gravity_Forms\Gravity_Forms\Splash_Page;
|
||||
*/
|
||||
class GF_Splash_Page_Service_Provider extends GF_Service_Provider {
|
||||
const SPLASH_PAGE = 'splash_page';
|
||||
const SPLASH_PAGE_TEMPLATE_TAGS = 'splash_page_template_tags';
|
||||
|
||||
/**
|
||||
* Register services to the container.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param GF_Service_Container $container
|
||||
*/
|
||||
public function register( GF_Service_Container $container ) {
|
||||
require_once( plugin_dir_path( __FILE__ ) . 'class-gf-splash-page-template-tags.php' );
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/class-gf-splash-page.php' );
|
||||
|
||||
$this->splash_page( $container );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize any actions or hooks.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param GF_Service_Container $container
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init( GF_Service_Container $container ) {
|
||||
|
||||
add_action( 'admin_enqueue_scripts', function () use ( $container ) {
|
||||
$container->get( self::SPLASH_PAGE )->splash_page_styles();
|
||||
} );
|
||||
|
||||
add_filter( 'admin_body_class', function ( $classes ) use ( $container ) {
|
||||
return $container->get( self::SPLASH_PAGE )->body_class( $classes );
|
||||
}, 10, 1 );
|
||||
|
||||
add_filter( 'admin_title', function ( $title ) use ( $container ) {
|
||||
return $container->get( self::SPLASH_PAGE )->admin_title( $title );
|
||||
}, 10, 1 );
|
||||
|
||||
add_filter( 'gform_system_status_menu', function ( $subviews ) use ( $container ) {
|
||||
return $container->get( self::SPLASH_PAGE )->system_status_link( $subviews );
|
||||
}, 10, 1 );
|
||||
|
||||
add_action( 'gform_system_status_page_about', function () use ( $container ) {
|
||||
$container->get( self::SPLASH_PAGE )->about_page();
|
||||
} );
|
||||
|
||||
add_action( 'gform_post_upgrade', function ( $version, $from_db_version, $force_upgrade ) use ( $container ) {
|
||||
$container->get( self::SPLASH_PAGE )->set_upgrade_transient( $version, $from_db_version, $force_upgrade );
|
||||
}, 10, 3 );
|
||||
|
||||
add_action( 'admin_footer', function () use ( $container ) {
|
||||
echo $container->get( self::SPLASH_PAGE )->about_page_modal();
|
||||
}, 10, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Splash Page services.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param GF_Service_Container $container
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function splash_page( GF_Service_Container $container ) {
|
||||
$container->add( self::SPLASH_PAGE_TEMPLATE_TAGS, function () {
|
||||
return new GF_Splash_Page_Template_Tags();
|
||||
} );
|
||||
|
||||
$container->add( self::SPLASH_PAGE, function () use ( $container ) {
|
||||
$tags = $container->get( self::SPLASH_PAGE_TEMPLATE_TAGS );
|
||||
|
||||
return new GF_Splash_Page( $tags );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* Creates the template parts for use on the splash page
|
||||
*
|
||||
* @package Gravity_Forms\Gravity_Forms\Splash_Page
|
||||
*/
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Splash_Page_Template_Tags;
|
||||
|
||||
use \GFForms;
|
||||
use \GFCommon;
|
||||
|
||||
/**
|
||||
* Class GF_Splash_Page_Template_Tags
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* Template tags for displaying content on the splash page.
|
||||
*/
|
||||
class GF_Splash_Page_Template_Tags {
|
||||
|
||||
/**
|
||||
* Display a headline.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $args Associative array of arguments with key and value.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function headline( $args ) {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'container_classes' => '',
|
||||
'text' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$classes = "gform-splash__section gform-splash__section--headline {$args['container_classes']}";
|
||||
|
||||
return "<div class='{$classes}'><h2>{$args['text']}</h2></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display text next to an image.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $args Associative array of arguments with key and value.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function text_and_image( $args ) {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'container_classes' => '',
|
||||
'image' => array(),
|
||||
'image_placement' => '',
|
||||
'text' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$image_html = $this->build_image_html( $args['image'] );
|
||||
$classes = "gform-splash__section gform-splash__section--text-and-image gform-splash__section--image-{$args['image_placement']} {$args['container_classes']}";
|
||||
|
||||
return "<div class='{$classes}'><div class='gform-splash-text'>{$args['text']}</div><div class='gform-splash-image-wrapper'>{$image_html}</div></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a full-width image.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $args Associative array of arguments with key and value.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function full_width_image( $args ) {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'container_classes' => '',
|
||||
'image' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$image_html = $this->build_image_html( $args['image'] );
|
||||
$classes = "gform-splash__section gform-splash__section--full-width-image {$args['container_classes']}";
|
||||
|
||||
return "<div class='{$classes}'>{$image_html}</div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display full-width text.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $args Associative array of arguments with key and value.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function full_width_text( $args ) {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'container_classes' => '',
|
||||
'text' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$classes = "gform-splash__section gform-splash__section--full-width-text {$args['container_classes']}";
|
||||
|
||||
return "<div class='{$classes}'>{$args['text']}</div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display text in equal-width columns.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $args Associative array of arguments with key and value.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function equal_columns( $args ) {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'container_classes' => '',
|
||||
'columns' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$classes = "gform-splash__section gform-splash__section--columns {$args['container_classes']}";
|
||||
|
||||
$columns_html = '<div class="columns">';
|
||||
foreach ( $args['columns'] as $column ) {
|
||||
$columns_html .= "<div class='column'><div class='column-contents'>{$column}</div></div>";
|
||||
}
|
||||
$columns_html .= '</div>';
|
||||
|
||||
return "<div class='{$classes}'>{$columns_html}</div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an array of image attributes and turn it into an HTML <img> tag.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param string|array $image Either the image URL as a string, or an array of image attributes.
|
||||
*
|
||||
* @return string HTML that will be displayed
|
||||
*/
|
||||
public function build_image_html( $image ) {
|
||||
if ( is_array( $image ) ) {
|
||||
$attrs = '';
|
||||
foreach ( $image as $attr => $value ) {
|
||||
$attrs .= $attr . '="' . $value . '" ';
|
||||
}
|
||||
$image_html = '<div class="gform-splash-image"><img ' . $attrs . '/></div>';
|
||||
} else {
|
||||
$image_html = '<div class="gform-splash-image"><img src="' . $image . '"></div>';
|
||||
}
|
||||
return $image_html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/**
|
||||
* Displays a splash page when a user updates to a new version.
|
||||
*
|
||||
* @package Gravity_Forms\Gravity_Forms\Splash_Page
|
||||
*/
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Splash_Page;
|
||||
|
||||
use \GFForms;
|
||||
use \GFCommon;
|
||||
use \Gravity_Forms\Gravity_Forms\Splash_Page_Template_Tags;
|
||||
|
||||
/**
|
||||
* Class GF_Splash_Page
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* Displays a splash page when a user updates to a new version.
|
||||
*/
|
||||
class GF_Splash_Page {
|
||||
|
||||
/**
|
||||
* The latest version that has a splash page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $about_version;
|
||||
|
||||
/**
|
||||
* The class that generates template tags.
|
||||
*
|
||||
* @var Splash_Page_Template_Tags\GF_Splash_Page_Template_Tags
|
||||
*/
|
||||
protected $tags;
|
||||
|
||||
/**
|
||||
* The directory where splash page images are stored.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $img_dir;
|
||||
|
||||
/**
|
||||
* GF_Splash_Page_Constructor
|
||||
*
|
||||
* @param Splash_Page_Template_Tags\GF_Splash_Page_Template_Tags $tags
|
||||
*/
|
||||
public function __construct( $tags ) {
|
||||
$this->about_version = '2.8';
|
||||
|
||||
$this->tags = $tags;
|
||||
|
||||
$this->img_dir = 'https://cdn.gravity.com/gravityforms/about-page/2.8/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditional test for if we're on the splash page.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_splash_page() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
return ( 'forms_page_gf_system_status' === $screen->base ) && ( 'about' === rgget( 'subview' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue splash page styles.
|
||||
*
|
||||
* @since 2.6
|
||||
*/
|
||||
public function splash_page_styles() {
|
||||
if ( ! $this->should_display() && ! $this->is_splash_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'gform_admin' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a body class to the splash page.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param $classes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body_class( $classes ) {
|
||||
if ( $this->is_splash_page() ) {
|
||||
$classes .= ' toplevel_page_gf_splash';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add "About" to the title tag.
|
||||
*
|
||||
* If you add a submenu page without a parent page, it doesn't get a title, so we need to add one manually.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param $title
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function admin_title( $title ) {
|
||||
if ( $this->is_splash_page() ) {
|
||||
$title = __( 'About', 'gravityforms' ) . ' ' . $this->about_version . ' - Gravity Forms';
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a transient if we need to show the splash page.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param $version
|
||||
* @param $from_db_version
|
||||
* @param $force_upgrade
|
||||
*/
|
||||
public function set_upgrade_transient( $version, $from_db_version, $force_upgrade ) {
|
||||
if ( $force_upgrade ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $this->need_splash_page( $from_db_version, GFForms::$version, $this->about_version ) ) {
|
||||
set_transient( 'gf_updated', $this->about_version );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether we need to display a splash page.
|
||||
*
|
||||
* If the old version is earlier than $this->about_version, and the new version is the same or later than $this->about_version,
|
||||
* we need to show the splash page.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param $old_version
|
||||
* @param $new_version
|
||||
* @param $about_version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function need_splash_page( $old_version, $new_version, $about_version ) {
|
||||
$old_version = implode( '.', array_slice( preg_split( '/[.-]/', $old_version ), 0, 2 ) );
|
||||
$new_version = implode( '.', array_slice( preg_split( '/[.-]/', $new_version ), 0, 2 ) );
|
||||
return version_compare( $old_version, $about_version, '<' ) && $new_version >= $about_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a link to the splash page in the system status menu.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $subviews
|
||||
*/
|
||||
public function system_status_link( $subviews ) {
|
||||
$subviews[19] = array(
|
||||
'name' => 'about',
|
||||
'label' => sprintf( __( 'About %s', 'gravityforms' ), $this->about_version ),
|
||||
);
|
||||
|
||||
return $subviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the splash page.
|
||||
*
|
||||
* @since 2.6
|
||||
*/
|
||||
public function about_page() {
|
||||
if ( get_transient( 'gf_updated' ) ) {
|
||||
delete_transient( 'gf_updated' );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include __DIR__ . '/gf_splash.php';
|
||||
echo ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the splash page as a modal.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function about_page_modal() {
|
||||
if ( ! $this->should_display() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->about_page();
|
||||
$markup = ob_get_clean();
|
||||
|
||||
return sprintf( '<script type="text/template" data-js="gf-splash-template">%s</script>', $markup );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the splash page should display.
|
||||
*
|
||||
* @since 2.6
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function should_display() {
|
||||
return $this->about_version == get_transient( 'gf_updated' ) && GFForms::is_gravity_page() && GFCommon::current_user_can_any( GFCommon::all_caps() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<article class="gform-splash" data-js="gform-splash-page">
|
||||
<header class="gform-splash__header">
|
||||
<img class="gform-logo" src="<?php echo esc_url( GFCommon::get_base_url() ); ?>/images/logos/gravity-logo-white.svg" alt="Gravity Forms"/>
|
||||
<h1><?php esc_html_e( 'Edit Forms with Ease in Gravity Forms 2.8!', 'gravityforms' ); ?></h1>
|
||||
<p><?php esc_html_e( 'The new Compact View makes it a cinch to edit long forms!', 'gravityforms' ); ?></p>
|
||||
<a class="gform-button gform-button--size-height-xxl gform-button--white gform-button--width-auto gform-button--icon-trailing" href="<?php echo esc_url( admin_url( 'admin.php?page=gf_new_form' ) ); ?>" title="<?php esc_attr_e( 'Get started with a new form', 'gravityforms' ); ?>">
|
||||
<span class="gform-button__text gform-button__text--inactive gform-typography--size-text-md"><?php esc_html_e( 'Get Started', 'gravityforms' ); ?></span>
|
||||
<span class="gform-common-icon gform-common-icon--arrow-narrow-right gform-button__icon"></span>
|
||||
</a>
|
||||
<div class="gform-reviews">
|
||||
<a href="https://www.g2.com/products/gravity-forms/reviews" title="<?php esc_html_e( 'Read reviews of Gravity Forms on G2', 'gravityforms' ); ?>">
|
||||
<img src="<?php echo $this->img_dir . 'g2.svg'; ?>" alt="<?php esc_attr_e( 'G2 logo', 'gravityforms' ); ?>">
|
||||
<span class="gform-reviews__stars">
|
||||
<span class="gform-common-icon gform-common-icon--star"></span>
|
||||
<span class="gform-common-icon gform-common-icon--star"></span>
|
||||
<span class="gform-common-icon gform-common-icon--star"></span>
|
||||
<span class="gform-common-icon gform-common-icon--star"></span>
|
||||
<span class="gform-common-icon gform-common-icon--star"></span>
|
||||
</span>
|
||||
200+ <?php esc_html_e( '4.7 Stars', 'gravityforms' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="gform-splash__body">
|
||||
<?php
|
||||
$text = '<h3>' . __( 'Form Editor Compact View', 'gravityforms' ) . '</h3>
|
||||
<p>' . __( 'Our new compact view makes it easier than ever to edit your forms! If you have long forms, you no longer have to scroll for ages to find the field you’re looking for. The compact view gives you a bird’s eye view of your form, so you can quickly find the fields you need to edit.', 'gravityforms' ) . ' <a href="https://docs.gravityforms.com/compact-view/" title="' . __( 'Read more about Compact View', 'gravityforms' ) . '" target="_blank">' . __( 'Read More', 'gravityforms' ) . '</a></p>';
|
||||
$image = array(
|
||||
'src' => $this->img_dir . 'compact-view.png',
|
||||
'alt' => __( 'Screenshot of the compact view in Gravity Forms 2.8', 'gravityforms' ),
|
||||
);
|
||||
|
||||
echo wp_kses_post(
|
||||
$this->tags->equal_columns(
|
||||
array(
|
||||
'columns' => array(
|
||||
$this->tags->build_image_html( $image ),
|
||||
$text,
|
||||
),
|
||||
'container_classes' => 'column--vertical-center',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$style_icon = $this->tags->build_image_html(
|
||||
array(
|
||||
'src' => $this->img_dir . 'icon-swatch.png',
|
||||
'alt' => __( 'Icon of color swatches', 'gravityforms' ),
|
||||
'width' => '48px',
|
||||
'height' => '48px',
|
||||
'class' => 'image--width-auto',
|
||||
)
|
||||
);
|
||||
$db_icon = $this->tags->build_image_html(
|
||||
array(
|
||||
'src' => $this->img_dir . 'icon-db.png',
|
||||
'alt' => __( 'Icon of a database', 'gravityforms' ),
|
||||
'width' => '48px',
|
||||
'height' => '48px',
|
||||
'class' => 'image--width-auto',
|
||||
)
|
||||
);
|
||||
$col1text = $style_icon . '<h4>' . __( 'Orbital Form Styling', 'gravityforms' ) . '</h4>
|
||||
<p>' . __( 'You might have noticed that we recently added a new setting so that you can use the beautiful and customizable Orbital form theme everywhere on your site, including shortcodes! Soon you’ll see Orbital in more places, and you’ll find more ways to customize it.', 'gravityforms' ) . ' <a href="https://docs.gravityforms.com/block-themes-and-style-settings/" title="' . __( 'Read more about styling your forms', 'gravityforms' ) . '" target="_blank">' . __( 'Read More', 'gravityforms' ) . '</a></p>';
|
||||
$col2text = $db_icon . '<h4>' . __( 'Performance Improvements', 'gravityforms' ) . '</h4>
|
||||
<p>' . __( 'We are always striving to improve the performance of Gravity Forms. In this release, you’ll notice smaller CSS files so that you don’t have to sacrifice performance to have good-looking forms.', 'gravityforms' ) . '</p>';
|
||||
echo wp_kses_post(
|
||||
$this->tags->equal_columns(
|
||||
array(
|
||||
'columns' => array(
|
||||
$col1text,
|
||||
$col2text,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<footer class="gform-splash__footer">
|
||||
<h4>
|
||||
<?php esc_html_e( 'Ready to get started?', 'gravityforms' ); ?>
|
||||
</h4>
|
||||
<p>
|
||||
<?php esc_html_e( 'We believe there\'s a better way to manage your data and forms. Are you ready to create a form? Let\'s go!', 'gravityforms' ); ?>
|
||||
</p>
|
||||
<a class="gform-button gform-button--size-height-xxl gform-button--white gform-button--width-auto gform-button--icon-trailing" href="<?php echo esc_url( admin_url( 'admin.php?page=gf_new_form' ) ); ?>" title="<?php esc_attr_e( 'Get started with a new form', 'gravityforms' ); ?>">
|
||||
<span class="gform-button__text gform-button__text--inactive gform-typography--size-text-md"><?php esc_html_e( 'Get Started', 'gravityforms' ); ?></span>
|
||||
<span class="gform-common-icon gform-common-icon--arrow-narrow-right gform-button__icon"></span>
|
||||
</a>
|
||||
</footer>
|
||||
|
||||
<div class="gform-splash__background gform-splash__background-one"></div>
|
||||
<div class="gform-splash__background gform-splash__background-two"></div>
|
||||
<div class="gform-splash__background gform-splash__background-three"></div>
|
||||
<div class="gform-splash__background gform-splash__background-four"></div>
|
||||
<div class="gform-splash__background gform-splash__background-five"></div>
|
||||
<div class="gform-splash__background gform-splash__background-six"></div>
|
||||
<div class="gform-splash__background gform-splash__background-seven"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</article>
|
||||
Reference in New Issue
Block a user