/home/altere25/public_html/wp-content/plugins/formidable/classes/models
Edit: /home/altere25/public_html/wp-content/plugins/formidable/classes/models/FrmSolution.php (21621B)
plugin_slug ) ) {
return;
}
add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 );
add_action( 'admin_init', array( $this, 'redirect' ), 9999 );
if ( empty( $this->plugin_file ) ) {
$this->plugin_file = $this->plugin_slug . '.php';
}
}
/**
* Register all WP hooks.
*
* @since 4.06.02
*
* @return void
*/
public function load_hooks() {
// If user is in admin ajax or doing cron, return.
if ( wp_doing_cron() ) {
return;
}
add_filter( 'frm_add_settings_section', array( $this, 'add_settings' ) );
if ( wp_doing_ajax() ) {
return;
}
// If user cannot manage_options, return.
if ( ! current_user_can( 'frm_change_settings' ) && ! FrmAppHelper::is_formidable_admin() ) {
return;
}
add_filter( 'plugin_action_links_' . $this->plugin_slug . '/' . $this->plugin_file, array( $this, 'plugin_links' ) );
add_action( 'admin_menu', array( $this, 'register' ) );
add_action( 'admin_head', array( $this, 'hide_menu' ) );
}
public function plugin_links( $links ) {
if ( ! $this->is_complete() ) {
$settings = '
' . __( 'Setup', 'formidable' ) . '';
array_unshift( $links, $settings );
}
return $links;
}
/**
* Register the pages to be used for the Welcome screen (and tabs).
*
* These pages will be removed from the Dashboard menu, so they will
* not actually show. Sneaky, sneaky.
*
* @since 4.06.02
*
* @return void
*/
public function register() {
// Getting started - shows after installation.
add_dashboard_page(
esc_html( $this->page_title() ),
esc_html( $this->page_title() ),
'frm_change_settings',
$this->page,
array( $this, 'output' )
);
}
/**
* Removed the dashboard pages from the admin menu.
*
* This means the pages are still available to us, but hidden.
*
* @since 4.06.02
*
* @return void
*/
public function hide_menu() {
remove_submenu_page( 'index.php', $this->page );
}
/**
* @return string
*
* @psalm-return ''
*/
protected function plugin_name() {
return '';
}
/**
* @return string
*/
protected function page_title() {
return __( 'Welcome to Formidable Forms', 'formidable' );
}
/**
* @return string
*/
protected function page_description() {
return __( 'Follow the steps below to get started.', 'formidable' );
}
/**
* Welcome screen redirect.
*
* This function checks if a new install or update has just occurred. If so,
* then we redirect the user to the appropriate page.
*
* @since 4.06.02
*
* @return void
*/
public function redirect() {
$current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
if ( $current_page === $this->page ) {
// Prevent endless loop.
return;
}
// Only do this for single site installs.
if ( isset( $_GET['activate-multi'] ) || is_network_admin() ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return;
}
// Check if we should consider redirection.
if ( ! $this->is_current_plugin() ) {
return;
}
delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
// Initial install.
wp_safe_redirect( $this->settings_link() );
exit;
}
/**
* @return string
*/
protected function settings_link() {
return admin_url( 'index.php?page=' . $this->page );
}
/**
* Add page to global settings.
*/
public function add_settings( $sections ) {
wp_enqueue_style( 'formidable-pro-fields' );
$sections[ $this->plugin_slug ] = array(
'class' => $this,
'function' => 'settings_page',
'name' => $this->plugin_name(),
'icon' => $this->icon,
'ajax' => true,
);
return $sections;
}
/*
* Output for global settings.
*/
/**
* @return void
*/
public function settings_page() {
$steps = $this->get_steps_data();
if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
// Redirect to the welcome page if install hasn't been done.
$url = $this->settings_link();
echo '';
return;
}
$all_imported = $this->is_complete( 'all' );
$step = $steps['import'];
$step['label'] = '';
$step['nested'] = true;
if ( $steps['complete']['current'] ) {
// Always show this step in settings.
$step['current'] = true;
$new_class = $all_imported ? ' button frm_hidden' : '';
$step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
}
if ( $all_imported ) {
$step['description'] = __( 'The following form(s) have been created.', 'formidable' );
}
$this->show_app_install( $step );
if ( ! $all_imported ) {
$step = $steps['complete'];
$step['current'] = false;
$step['button_class'] .= ' frm_grey disabled';
$this->show_page_links( $step );
}
}
/**
* Getting Started screen. Shows after first install.
*
* @return void
*/
public function output() {
FrmAppHelper::include_svg();
$this->css();
$class = FrmAppHelper::pro_is_installed() ? 'pro' : 'lite';
echo '
';
$this->header();
$this->main_content();
echo '
';
}
/**
* Heading section.
*
* @return void
*/
protected function header() {
$size = array(
'height' => 90,
'width' => 90,
);
?>
'Install',
'style' => 'width:30px;height:30px;margin:0 35px;',
)
);
FrmAppHelper::icon_by_class(
'frmfont frm_wordpress_icon',
array(
'aria-label' => 'WordPress',
'style' => 'width:90px;height:90px;',
)
);
?>
page_title() ); ?>
page_description() ); ?>
get_steps_data();
$this->license_box( $steps['license'] );
if ( isset( $steps['plugin'] ) ) {
$this->show_plugin_install( $steps['plugin'] );
}
$this->show_app_install( $steps['import'] );
$this->show_page_links( $steps['complete'] );
}
protected function get_steps_data() {
$pro_installed = FrmAppHelper::pro_is_connected();
$steps = array(
'license' => array(
'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
'button_label' => __( 'Connect an Account', 'formidable' ),
'current' => empty( $pro_installed ),
'complete' => $pro_installed,
'num' => 1,
),
'plugin' => array(
'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
'button_label' => __( 'Install & Activate', 'formidable' ),
'current' => false,
'complete' => false,
'num' => 2,
),
'import' => array(
'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
'button_label' => __( 'Create Now', 'formidable' ),
'complete' => $this->is_complete(),
'num' => 3,
),
'complete' => array(
'label' => __( 'Customize Your New Pages', 'formidable' ),
'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
'button_label' => __( 'View Page', 'formidable' ),
'complete' => false,
'num' => 4,
),
);
$this->adjust_plugin_install_step( $steps );
$has_current = false;
foreach ( $steps as $k => $step ) {
// Set the current step.
if ( ! isset( $step['current'] ) ) {
if ( $step['complete'] ) {
$steps[ $k ]['current'] = false;
} else {
$steps[ $k ]['current'] = ! $has_current;
$has_current = true;
}
} elseif ( $step['current'] ) {
$has_current = true;
}
// Set disabled buttons.
$class = isset( $step['button_class'] ) ? $step['button_class'] : '';
$class .= ' button-primary frm-button-primary';
if ( ! $steps[ $k ]['current'] ) {
$class .= ' frm_grey disabled';
}
$steps[ $k ]['button_class'] = $class;
}//end foreach
return $steps;
}
/**
* @param array $steps
*
* @return void
*/
protected function adjust_plugin_install_step( &$steps ) {
$plugins = $this->required_plugins();
if ( empty( $plugins ) ) {
unset( $steps['plugin'] );
$steps['import']['num'] = 2;
$steps['complete']['num'] = 3;
return;
}
$missing = array();
$rel = array();
foreach ( $plugins as $plugin_key ) {
$plugin = FrmAddonsController::install_link( $plugin_key );
if ( $plugin['status'] === 'active' ) {
continue;
}
if ( isset( $plugin['url'] ) ) {
$rel[] = $plugin['url'];
} else {
// Add-on is required but not allowed.
$missing[] = $plugin_key;
}
}
if ( empty( $rel ) && empty( $missing ) ) {
$steps['plugin']['complete'] = true;
} elseif ( ! empty( $missing ) ) {
$steps['plugin']['error'] = sprintf(
/* translators: %1$s: Plugin name */
esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
implode( ', ', $missing )
);
} else {
$steps['plugin']['links'] = $rel;
$steps['plugin']['button_class'] = 'frm-solution-multiple ';
}
if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
$steps['plugin']['current'] = true;
}
}
/**
* @return void
*/
protected function step_top( $step ) {
$section_class = empty( $step['current'] ) ? 'frm_grey' : '';
?>
step_top( $step );
if ( $step['complete'] ) {
?>
step_bottom( $step );
}
/**
* @return void
*/
protected function show_plugin_install( $step ) {
$this->step_top( $step );
if ( ! isset( $step['error'] ) ) {
$rel = isset( $step['links'] ) ? $step['links'] : array();
?>
step_bottom( $step );
}
/**
* @return void
*/
protected function show_app_install( $step ) {
$is_complete = $step['complete'];
if ( ! empty( $this->form_options() ) && ! $is_complete ) {
$step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
}
$this->step_top( $step );
$api = new FrmFormApi();
$addons = $api->get_api_info();
$id = $this->download_id();
$has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
if ( ! $step['current'] ) {
?>
step_bottom( $step );
return;
}
if ( ! $has_file ) {
echo '
' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '
';
} elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) {
echo '
' . esc_html__( 'Looks like you may not have a current subscription for this solution. Please check your account.', 'formidable' ) . '
';
} else {
$xml = $addons[ $id ]['beta']['package'];
if ( is_array( $xml ) ) {
$xml = reset( $xml );
}
if ( isset( $step['nested'] ) ) {
echo '