Add gravity flow demo

This commit is contained in:
Almira Krdzic
2018-06-28 10:02:07 +02:00
parent 1b5076bf2f
commit 12a5066018
1106 changed files with 317603 additions and 4720 deletions

View File

@@ -0,0 +1,142 @@
<?php
/**
* Gravity Flow Installation Wizard: Completion Step
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Class Gravity_Flow_Installation_Wizard_Step_Complete
*/
class Gravity_Flow_Installation_Wizard_Step_Complete extends Gravity_Flow_Installation_Wizard_Step {
/**
* The step name.
*
* @var string
*/
protected $_name = 'complete';
/**
* Displays the content for this step.
*/
public function display() {
$url = admin_url( 'admin.php?page=gf_edit_forms&view=settings&subview=gravityflow&id=' );
$forms = GFFormsModel::get_forms();
?>
<script>
(function($) {
$(document).ready(function () {
$('#add_workflow_step').click(function(){
window.location.href = <?php echo json_encode( $url ); ?> + $('#form_id').val();
return false;
})
});
})( jQuery );
</script>
<style>
.circle{
background: #808080;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
color: #ffffff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 5px;
text-align: center;
width: 1.6em;
}
</style>
<p>
<?php
esc_html_e( 'Congratulations! Now you can set up your first workflow.', 'gravityflow' );
?>
</p>
<?php
if ( ! empty( $forms ) ) : ?>
<h4>
<span class="circle">1</span>
<?php
esc_html_e( 'Select a Form to use for your Workflow', 'gravityflow' );
?>
</h4>
<p>
<select id="form_id">
<?php
foreach ( $forms as $form ) {
printf( '<option value="%d">%s</option>', $form->id, $form->title );
}
?>
</select>
</p>
<h4>
<span class="circle">2</span>
<?php
esc_html_e( 'Add Workflow Steps in the Form Settings', 'gravityflow' );
?>
</h4>
<p>
<a id="add_workflow_step" class="button button-primary" href="#" ><?php esc_html_e( 'Add Workflow Steps', 'gravityflow' )?></a>
</p>
<br />
<p>
<?php
$url = admin_url( 'admin.php?page=gf_new_form' );
$open_a_tag = sprintf( '<a href="%s">', $url );
printf( esc_html__( "Don't have a form you want to use for the workflow? %sCreate a Form%s and add your steps in the Form Settings later.", 'gravityflow' ), $open_a_tag, '</a>' );
?>
</p>
<?php
else :
?>
<p>
<?php
$url = admin_url( 'admin.php?page=gf_new_form' );
$open_a_tag = sprintf( '<a href="%s">', $url );
printf( esc_html__( '%sCreate a Form%s and then add your Workflow steps in the Form Settings.', 'gravityflow' ), $open_a_tag, '</a>' );
?>
</p>
<?php
endif;
?>
<?php
}
/**
* Returns the title for this step.
*
* @return string
*/
public function get_title() {
return esc_html__( 'Installation Complete', 'gravityflow' );
}
/**
* Returns the next button label.
*
* @return string
*/
public function get_next_button_text() {
return '';
}
/**
* Returns the previous button label.
*
* @return string
*/
public function get_previous_button_text() {
return '';
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* Gravity Flow Installation Wizard: License Key Step
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Class Gravity_Flow_Installation_Wizard_Step_License_Key
*/
class Gravity_Flow_Installation_Wizard_Step_License_Key extends Gravity_Flow_Installation_Wizard_Step {
/**
* Is this step required?
*
* @var bool
*/
public $required = true;
/**
* The step name.
*
* @var string
*/
protected $_name = 'license_key';
/**
* Displays the content for this step.
*/
public function display() {
if ( ! $this->license_key && defined( 'GRAVITY_FLOW_LICENSE_KEY' ) ) {
$this->license_key = GRAVITY_FLOW_LICENSE_KEY;
}
?>
<p>
<?php echo sprintf( esc_html__( 'Enter your Gravity Flow License Key below. Your key unlocks access to automatic updates and support. You can find your key in your purchase receipt or by logging into the %sGravity Flow%s site.', 'gravityflow' ), '<a href="http://www.gravityflow.io">', '</a>' ); ?>
</p>
<div>
<input type="text" class="regular-text" id="license_key" value="<?php echo esc_attr( $this->license_key ); ?>" name="license_key" placeholder="<?php esc_attr_e( 'Enter Your License Key', 'gravityflow' ); ?>" />
<?php
$key_error = $this->validation_message( 'license_key', false );
if ( $key_error ) {
echo $key_error;
}
?>
</div>
<?php
$message = $this->validation_message( 'accept_terms', false );
if ( $message || $key_error || $this->accept_terms ) {
?>
<p>
<?php esc_html_e( "If you don't enter a valid license key, you will not be able to update Gravity Flow when important bug fixes and security enhancements are released. This can be a serious security risk for your site.", 'gravityflow' ); ?>
</p>
<div>
<label>
<input type="checkbox" id="accept_terms" value="1" <?php checked( 1, $this->accept_terms ); ?> name="accept_terms" />
<?php esc_html_e( 'I understand the risks', 'gravityflow' ); ?> <span class="gfield_required">*</span>
</label>
<?php echo $message ?>
</div>
<?php
}
}
/**
* Returns the title for this step.
*
* @return string
*/
public function get_title() {
return esc_html__( 'License Key', 'gravityflow' );
}
/**
* Validates the posted values for this step.
*
* @param array $posted_values The posted values.
*
* @return bool
*/
public function validate( $posted_values ) {
$valid_key = true;
$terms_accepted = true;
$license_key = rgar( $posted_values, 'license_key' );
if ( empty( $license_key ) ) {
$message = esc_html__( 'Please enter a valid license key.', 'gravityflow' ) . '</span>';
$this->set_field_validation_result( 'license_key', $message );
$valid_key = false;
} else {
$license_info = gravity_flow()->activate_license( $license_key );
if ( empty( $license_info ) || $license_info->license !== 'valid' ) {
$message = "&nbsp;<i class='fa fa-times gf_keystatus_invalid'></i> <span class='gf_keystatus_invalid_text'>" . __( 'Invalid or Expired Key : Please make sure you have entered the correct value and that your key is not expired.', 'gravityflow' ) . '</span>';
$this->set_field_validation_result( 'license_key', $message );
$valid_key = false;
}
}
$accept_terms = rgar( $posted_values, 'accept_terms' );
if ( ! $valid_key && ! $accept_terms ) {
$this->set_field_validation_result( 'accept_terms', __( 'Please accept the terms.', 'gravityflow' ) );
$terms_accepted = false;
}
$valid = $valid_key || ( ! $valid_key && $terms_accepted );
return $valid;
}
/**
* Installs the license key, if supplied.
*/
public function install() {
if ( $this->license_key ) {
$gravityflow = gravity_flow();
$settings = $gravityflow->get_app_settings();
$settings['license_key'] = $this->license_key;
gravity_flow()->update_app_settings( $settings );
}
}
/**
* Returns the previous button label.
*
* @return string
*/
public function get_previous_button_text() {
return '';
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* Gravity Flow Installation Wizard: Workflow Pages Step
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Class Gravity_Flow_Installation_Wizard_Step_Pages
*/
class Gravity_Flow_Installation_Wizard_Step_Pages extends Gravity_Flow_Installation_Wizard_Step {
/**
* The step name.
*
* @var string
*/
protected $_name = 'pages';
/**
* Displays the content for this step.
*/
public function display() {
if ( $this->workflow_pages == '' ) {
// First run.
$this->workflow_pages = 'admin';
};
echo '<p>' . esc_html__( "Gravity Flow can be accessed from both the front end of your site and from the built-in WordPress admin pages (Workflow menu). If you want to use your site styles, or if you want to use the one-click approval links, then you'll need to add some pages to your site.", 'gravityflow' ) . '</p>';
echo '<p>' . sprintf( esc_html__( 'Would you like to create custom inbox, status, and submit pages now? The pages will contain the %s[gravityflow] shortcode%s enabling assignees to interact with the workflow from the front end of the site.', 'gravityflow' ), '<a href="http://docs.gravityflow.io/article/36-the-shortcode" target="_blank">', '</a>' ) . '</p>';
?>
<div>
<label>
<input type="radio" value="admin" <?php checked( 'admin', $this->workflow_pages ); ?> name="workflow_pages"/>
<?php esc_html_e( 'No, use the WordPress Admin (Workflow menu).', 'gravityflow' ); ?>
</label>
</div>
<div>
<label>
<input type="radio" value="custom" <?php checked( 'custom', $this->workflow_pages ); ?> name="workflow_pages"/>
<?php esc_html_e( 'Yes, create inbox, status, and submit pages now.', 'gravityflow' ); ?>
</label>
</div>
<?php
}
/**
* Returns the title for this step.
*
* @return string
*/
public function get_title() {
return esc_html__( 'Workflow Pages', 'gravityflow' );
}
/**
* Configures the plugin settings with the custom page IDs.
*/
public function install() {
if ( $this->workflow_pages == 'custom' ) {
$settings = gravity_flow()->get_app_settings();
$settings['inbox_page'] = $this->create_page( 'inbox' );
$settings['status_page'] = $this->create_page( 'status' );
$settings['submit_page'] = $this->create_page( 'submit' );
gravity_flow()->update_app_settings( $settings );
}
}
/**
* Creates a new page containing the gravityflow shortcode for the specified page type.
*
* @param string $page The page type: inbox, status, or submit.
*
* @return int|string|WP_Error
*/
public function create_page( $page ) {
$post = array(
'post_title' => $this->get_page_title( $page ),
'post_content' => sprintf( '[gravityflow page="%s"]', $page ),
'post_excerpt' => $this->get_page_title( $page ),
'post_status' => 'publish',
'post_type' => 'page',
);
$post_id = wp_insert_post( $post );
return $post_id ? $post_id : '';
}
/**
* Return page title for the specified page type.
*
* @param string $page The page type: inbox, status, or submit.
*
* @return string
*/
public function get_page_title( $page ) {
$titles = array(
'inbox' => esc_html__( 'Workflow Inbox', 'gravityflow' ),
'status' => esc_html__( 'Workflow Status', 'gravityflow' ),
'submit' => esc_html__( 'Submit a Workflow Form', 'gravityflow' ),
);
return $titles[ $page ];
}
}

View File

@@ -0,0 +1,144 @@
<?php
/**
* Gravity Flow Installation Wizard: Updates Step
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Class Gravity_Flow_Installation_Wizard_Step_Updates
*/
class Gravity_Flow_Installation_Wizard_Step_Updates extends Gravity_Flow_Installation_Wizard_Step {
/**
* The step name.
*
* @var string
*/
protected $_name = 'updates';
/**
* Displays the content for this step.
*/
function display() {
if ( $this->background_updates == '' ) {
// First run.
$this->background_updates = 'enabled';
};
?>
<p>
<?php
esc_html_e( 'Gravity Flow will download important bug fixes, security enhancements and plugin updates automatically. Updates are extremely important to the security of your WordPress site.', 'gravityflow' );
?>
</p>
<p>
<?php
esc_html_e( 'This feature is activated by default unless you opt to disable it below. We only recommend disabling background updates if you intend on managing updates manually. A valid license is required for background updates.', 'gravityflow' );
?>
</p>
<div>
<label>
<input type="radio" id="background_updates_enabled" value="enabled" <?php checked( 'enabled', $this->background_updates ); ?> name="background_updates"/>
<?php esc_html_e( 'Keep background updates enabled', 'gravityflow' ); ?>
</label>
</div>
<div>
<label>
<input type="radio" id="background_updates_disabled" value="disabled" <?php checked( 'disabled', $this->background_updates ); ?> name="background_updates"/>
<?php esc_html_e( 'Turn off background updates', 'gravityflow' ); ?>
</label>
</div>
<div id="accept_terms_container" style="display:none;">
<div style="background: #fff none repeat scroll 0 0;box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);padding: 1px 12px;border-left: 4px solid #dd3d36;margin: 5px 0 15px;display: inline-block;">
<h3><i class="fa fa-exclamation-triangle gf_invalid"></i> <?php _e( 'Are you sure?', 'gravityflow' ); ?>
</h3>
<p>
<strong><?php esc_html_e( 'By disabling background updates your site may not get critical bug fixes and security enhancements. We only recommend doing this if you are experienced at managing a WordPress site and accept the risks involved in manually keeping your WordPress site updated.', 'gravityflow' ); ?></strong>
</p>
</div>
<label>
<input type="checkbox" id="accept_terms" value="1" <?php checked( 1, $this->accept_terms ); ?> name="accept_terms"/>
<?php esc_html_e( 'I Understand and Accept the Risk', 'gravityflow' ); ?> <span class="gfield_required">*</span>
</label>
<?php $this->validation_message( 'accept_terms' ); ?>
</div>
<script>
(function($) {
$(document).ready(function() {
$('#accept_terms_container').toggle($('#background_updates_disabled').is(':checked'));
$('#background_updates_disabled').click(function(){
$("#accept_terms_container").slideDown();
});
$('#background_updates_enabled').click(function(){
$("#accept_terms_container").slideUp();
});
})
})(jQuery);
</script>
<?php
}
/**
* Returns the title for this step.
*
* @return string
*/
function get_title() {
return esc_html__( 'Background Updates', 'gravityflow' );
}
/**
* Validates the posted values for this step.
*
* @param array $posted_values The posted values.
*
* @return bool
*/
function validate( $posted_values ) {
$valid = true;
if ( $this->background_updates == 'disabled' && empty( $this->accept_terms ) ) {
$this->set_field_validation_result( 'accept_terms', esc_html__( 'Please accept the terms.', 'gravityflow' ) );
$valid = false;
}
return $valid;
}
/**
* Returns the summary content.
*
* @param bool $echo Indicates if the summary should be echoed.
*
* @return string
*/
function summary( $echo = true ) {
$html = $this->background_updates !== 'disabled' ? esc_html__( 'Enabled', 'gravityflow' ) . '&nbsp;<i class="fa fa-check gf_valid"></i>' : esc_html__( 'Disabled', 'gravityflow' ) . '&nbsp;<i class="fa fa-times gf_invalid"></i>' ;
if ( $echo ) {
echo $html;
}
return $html;
}
/**
* Configures the plugin settings with the value of the background_updates setting.
*/
function install() {
$gravityflow = gravity_flow();
$settings = $gravityflow->get_app_settings();
$settings['background_updates'] = $this->background_updates !== 'disabled';
gravity_flow()->update_app_settings( $settings );
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Gravity Flow Installation Wizard: Welcome Step
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* Class Gravity_Flow_Installation_Wizard_Step_Welcome
*/
class Gravity_Flow_Installation_Wizard_Step_Welcome extends Gravity_Flow_Installation_Wizard_Step {
/**
* The step name.
*
* @var string
*/
protected $_name = 'welcome';
/**
* Displays the content for this step.
*/
function display() {
esc_html_e( "Click the 'Get Started' button to complete your installation.", 'gravityflow' );
?>
<?php
}
/**
* Returns the next button label.
*
* @return string
*/
function get_next_button_text() {
return esc_html__( 'Get Started', 'gravityflow' );
}
/**
* Returns the title for this step.
*
* @return string
*/
function get_title() {
return esc_html__( 'Welcome', 'gravityflow' );
}
}

View File

@@ -0,0 +1,281 @@
<?php
/**
* Gravity Flow Installation Wizard
*
* @package GravityFlow
* @subpackage Classes/Gravity_Flow_Installation_Wizard
* @copyright Copyright (c) 2015-2018, Steven Henty S.L.
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
/**
* An abstract class used as the base for all installation wizard steps.
*
* Class Gravity_Flow_Installation_Wizard_Step
*/
abstract class Gravity_Flow_Installation_Wizard_Step extends stdClass {
/**
* The step name.
*
* @var string
*/
protected $_name = '';
/**
* The field validation results.
*
* @var array
*/
protected $_field_validation_results = array();
/**
* The validation summary.
*
* @var string
*/
protected $_validation_summary = '';
/**
* The step values.
*
* @var array
*/
private $_step_values;
/**
* Gravity_Flow_Installation_Wizard_Step constructor.
*
* @param array $values The step values.
*
* @throws Exception When the step name has not been set.
*/
public function __construct( $values = array() ) {
if ( empty( $this->_name ) ) {
throw new Exception( 'Name not set' );
}
$this->_step_values = $values;
}
/**
* Returns the step name.
*
* @return string
*/
public function get_name() {
return $this->_name;
}
/**
* Compares the supplied key against the current step name.
*
* @param string $key The step name.
*
* @return bool
*/
public function is( $key ) {
return $key == $this->get_name();
}
/**
* Returns the step title.
*
* @return string
*/
public function get_title() {
return '';
}
/**
* Sets the value for the specified property.
*
* @param string $key The property key.
* @param mixed $value The property value.
*/
public function __set( $key, $value ) {
$this->_step_values[ $key ] = $value;
}
/**
* Determines if the specified property has been defined.
*
* @param string $key The property key.
*
* @return bool
*/
public function __isset( $key ) {
return isset( $this->_step_values[ $key ] );
}
/**
* Deletes the specified property.
*
* @param string $key The property key.
*/
public function __unset( $key ) {
unset( $this->_step_values[ $key ] );
}
/**
* Returns the specified property or an empty string for an undefined property.
*
* @param string $key The property key.
*
* @return mixed
*/
public function &__get( $key ) {
if ( ! isset( $this->_step_values[ $key ] ) ) {
$this->_step_values[ $key ] = '';
}
return $this->_step_values[ $key ];
}
/**
* Returns the values for the current step.
*
* @return array
*/
public function get_values() {
return $this->_step_values;
}
/**
* Override to display content for this step.
*/
public function display() {
}
/**
* Override to validate the posted values for this step.
*
* @param array $posted_values The posted values.
*
* @return bool
*/
public function validate( $posted_values ) {
// Assign $this->_validation_result;.
return true;
}
/**
* Returns the validation result for the specified property or an empty string for an undefined property.
*
* @param string $key The property key.
*
* @return mixed
*/
public function get_field_validation_result( $key ) {
if ( ! isset( $this->_field_validation_results[ $key ] ) ) {
$this->_field_validation_results[ $key ] = '';
}
return $this->_field_validation_results[ $key ];
}
/**
* Set the field validation result for the specified property.
*
* @param string $key The property key.
* @param string $text The validation result.
*/
public function set_field_validation_result( $key, $text ) {
$this->_field_validation_results[ $key ] = $text;
}
/**
* Set the validation summary property.
*
* @param string $text The validation summary.
*/
public function set_validation_summary( $text ) {
$this->_validation_summary = $text;
}
/**
* Returns the validation summary property.
*
* @return string
*/
public function get_validation_summary() {
return $this->_validation_summary;
}
/**
* Return the markup for the validation message.
*
* @param string $key The property key.
* @param bool $echo Indicates if the message should be echoed.
*
* @return string
*/
public function validation_message( $key, $echo = true ) {
$message = '';
$validation_result = $this->get_field_validation_result( $key );
if ( ! empty( $validation_result ) ) {
$message = sprintf( '<div class="validation_message">%s</div>', $validation_result );
}
if ( $echo ) {
echo $message;
}
return $message;
}
/**
* Override to determine if the current step has been completed.
*/
public function is_complete() {
}
/**
* Returns the next button label.
*
* @return string
*/
public function get_next_button_text() {
return __( 'Next', 'gravityflow' );
}
/**
* Returns the previous button label.
*
* @return string
*/
public function get_previous_button_text() {
return __( 'Back', 'gravityflow' );
}
/**
* Update the step options in the database and class property.
*
* @param array $values The step values.
*/
public function update( $values ) {
update_option( 'gravityflow_installation_wizard_' . $this->get_name(), $values );
$this->_step_values = $values;
}
/**
* Override to return summary content.
*
* @param bool $echo Indicates if the summary should be echoed.
*
* @return string
*/
public function summary( $echo = true ) {
return '';
}
/**
* Override to perform actions when the installation wizard is completing.
*/
public function install() {
// Do something.
}
/**
* Deletes this steps values from the database.
*/
public function flush_values() {
delete_option( 'gravityflow_installation_wizard_' . $this->get_name() );
}
}

View File

@@ -0,0 +1,2 @@
<?php
//Nothing to see here