/home/techb158/on-time-movers.com/wp-content/plugins/wpforms/src/Pro/Admin/Pages
Edit: /home/techb158/on-time-movers.com/wp-content/plugins/wpforms/src/Pro/Admin/Pages/Addons.php (11161B)
allow_load() || $is_loaded ) {
return;
}
$this->can_install = wpforms_can_install( 'addon' );
$this->license_type = wpforms_get_license_type();
$this->init_addons();
$this->hooks();
$is_loaded = true;
}
/**
* Hooks.
*
* @since 1.6.7
*/
public function hooks() {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueues' ] );
add_action( 'admin_notices', [ $this, 'notices' ] );
add_action( 'wpforms_admin_page', [ $this, 'output' ] );
}
/**
* Init addons data.
*
* @since 1.6.7
*/
public function init_addons() {
$this->refresh = ! empty( $_GET['wpforms_refresh_addons'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->addons = wpforms()->get( 'addons' )->get_all( $this->refresh );
}
/**
* Enqueue assets for the addons page.
*
* @since 1.6.7
*/
public function enqueues() {
// JavaScript.
wp_enqueue_script(
'listjs',
WPFORMS_PLUGIN_URL . 'assets/lib/list.min.js',
[ 'jquery' ],
'1.5.0'
);
}
/**
* Build the output for the plugin addons page.
*
* @since 1.6.7
*/
public function output() {
// The last attempt to obtain the addons data.
if ( empty( $this->addons ) ) {
$this->init_addons();
}
?>
';
return;
}
echo '
';
if ( ! empty( $this->license_type ) ) {
if ( ! $this->refresh ) {
echo '
' .
sprintf(
wp_kses(
/* translators: %s - refresh addons page URL. */
__( 'Improve your forms with our premium addons. Missing an addon that you think you should be able to see? Click the Refresh Addons button above.', 'wpforms' ),
[
'a' => [
'href' => [],
],
]
),
esc_url_raw( add_query_arg( [ 'wpforms_refresh_addons' => '1' ] ) )
) .
'
';
}
echo '
' . esc_html__( 'Available Addons', 'wpforms' ) . '
';
}
echo '
';
$this->print_addons_list();
echo '
';
echo '
';
echo '
';
}
/**
* Notices.
*
* @since 1.6.7
*/
public function notices() {
$errors = wpforms()->license->get_errors();
if ( empty( $this->addons ) ) {
\WPForms\Admin\Notice::error( esc_html__( 'There was an issue retrieving Addons for this site. Please click on the button above to refresh.', 'wpforms' ) );
return;
}
if ( ! empty( $errors ) ) {
\WPForms\Admin\Notice::error( esc_html__( 'In order to get access to Addons, you need to resolve your license key errors.', 'wpforms' ) );
return;
}
if ( $this->refresh ) {
\WPForms\Admin\Notice::success( esc_html__( 'Addons have successfully been refreshed.', 'wpforms' ) );
}
if ( empty( $this->license_type ) ) {
\WPForms\Admin\Notice::error(
sprintf(
wp_kses( /* translators: %s - WPForms plugin settings URL. */
__( 'To access addons please enter and activate your WPForms license key in the plugin ';
foreach ( $addons as $id => $addon ) {
$addon = (array) $addon;
if ( ! $this->is_allow_to_show( $addon['license'], $type_show ) ) {
continue;
}
$this->print_addon( $addon );
if ( ! empty( $this->addons[ $id ] ) ) {
unset( $this->addons[ $id ] );
}
}
echo '
';
}
/**
* Print addon.
*
* @since 1.6.7
*
* @param array $addon Addon information.
*/
private function print_addon( $addon ) {
$addon = wpforms()->get( 'addons' )->get_addon( $addon['slug'] );
$image = ! empty( $addon['icon'] ) ? $addon['icon'] : 'sullie.png';
$url = add_query_arg(
[
'utm_source' => 'WordPress',
'utm_campaign' => 'plugin',
'utm_medium' => 'addons',
'utm_content' => $addon['title'],
],
! empty( $addon['status'] ) && $addon['status'] === 'active' && $addon['plugin_allow'] ? $addon['doc_url'] : $addon['page_url']
);
if ( $addon['slug'] === 'wpforms-stripe' ) {
$addon['recommended'] = true;
}
echo wpforms_render( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'admin/addons-item',
[
'addon' => $addon,
'status_label' => $this->get_addon_status_label( $addon['status'] ),
'image' => WPFORMS_PLUGIN_URL . 'assets/images/' . $image,
'url' => $url,
'button' => $this->get_addon_button_html( $addon ),
'recommended' => isset( $addon['recommended'] ) ? $addon['recommended'] : false,
],
true
);
}
/**
* Get addon button HTML.
*
* @since 1.6.7
*
* @param array $addon Prepared addon data.
*
* @return string
*/
private function get_addon_button_html( $addon ) {
if ( $addon['action'] === 'upgrade' || $addon['action'] === 'license' || ! $addon['plugin_allow'] ) {
return sprintf(
'