/home/techb158/dev.aleamaralawal.com/wp-content/plugins/wpforms-lite/src/Admin/Forms
Edit: /home/techb158/dev.aleamaralawal.com/wp-content/plugins/wpforms-lite/src/Admin/Forms/Page.php (9263B)
screen_options_id = 'wpforms_forms_overview_screen_options';
$this->screen_options = [
'pagination' => [
'heading' => esc_html__( 'Pagination', 'wpforms-lite' ),
'options' => [
[
'label' => esc_html__( 'Number of forms per page:', 'wpforms-lite' ),
'option' => 'per_page',
'default' => wpforms()->obj( 'form' )->get_count_per_page(),
'type' => 'number',
'args' => [
'min' => 1,
'max' => 999,
'step' => 1,
'maxlength' => 3,
],
],
],
],
'view' => [
'heading' => esc_html__( 'View', 'wpforms-lite' ),
'options' => [
[
'label' => esc_html__( 'Show form templates', 'wpforms-lite' ),
'option' => 'show_form_templates',
'default' => true,
'type' => 'checkbox',
'checked' => true,
],
],
],
];
$this->init_screen_options( wpforms_is_admin_page( 'overview' ) );
$this->hooks();
}
/**
* Hooks.
*
* @since 1.8.6
*/
private function hooks() {
// Reset columns settings.
add_filter( 'manage_toplevel_page_wpforms-overview_columns', [ $this, 'screen_settings_columns' ] );
// Rewrite forms per page value from Form Overview page screen options.
add_filter( 'wpforms_forms_per_page', [ $this, 'get_wpforms_forms_per_page' ] );
}
/**
* Check if the template visibility option is enabled.
*
* @since 1.8.8
*
* @return bool
*/
public function overview_show_form_templates() {
return get_user_option( $this->screen_options_id . '_view_show_form_templates' );
}
/**
* Get forms per page value from Form Overview page screen options.
*
* @since 1.8.8
*
* @return int
*/
public function get_wpforms_forms_per_page() {
return get_user_option( $this->screen_options_id . '_pagination_per_page' );
}
/**
* Determine if the user is viewing the overview page, if so, party on.
*
* @since 1.8.6
*/
public function init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
// Only load if we are actually on the overview page.
if ( ! wpforms_is_admin_page( 'overview' ) ) {
return;
}
// Avoid recursively include _wp_http_referer in the REQUEST_URI.
$this->remove_referer();
add_action( 'current_screen', [ $this, 'init_overview_table' ], 5 );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueues' ] );
add_action( 'wpforms_admin_page', [ $this, 'output' ] );
add_action( 'wpforms_admin_page', [ $this, 'field_column_setting' ] );
/**
* Fires after the form overview page initialization.
*
* @since 1.0.0
*/
do_action( 'wpforms_overview_init' ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
}
/**
* Init overview table class.
*
* @since 1.8.6
*/
public function init_overview_table() {
$this->overview_table = ListTable::get_instance();
}
/**
* Remove previous `_wp_http_referer` variable from the REQUEST_URI.
*
* @since 1.8.6
*/
private function remove_referer() {
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
}
}
/**
* Add per-page screen option to the Forms table.
*
* @since 1.8.6
*
* @depecated 1.8.8 Use HasScreenOptions trait instead.
*/
public function screen_options() {
_deprecated_function( __METHOD__, '1.8.8 of the WPForms plugin' );
}
/**
* Filter screen settings columns data.
*
* @since 1.8.6
*
* @param array $columns Columns.
*
* @return array
* @noinspection PhpMissingParamTypeInspection
*/
public function screen_settings_columns( $columns ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
return [];
}
/**
* Enqueue assets for the overview page.
*
* @since 1.8.6
*/
public function enqueues() {
$min = wpforms_get_min_suffix();
wp_enqueue_script(
'wpforms-htmx',
WPFORMS_PLUGIN_URL . 'assets/lib/htmx.min.js',
[],
WPFORMS_VERSION,
true
);
wp_enqueue_script(
'wpforms-admin-forms-overview',
WPFORMS_PLUGIN_URL . "assets/js/admin/forms/overview{$min}.js",
[ 'jquery', 'underscore', 'wpforms-htmx' ],
WPFORMS_VERSION,
true
);
wp_enqueue_style(
'wpforms-admin-list-table-ext',
WPFORMS_PLUGIN_URL . "assets/css/admin-list-table-ext{$min}.css",
[],
WPFORMS_VERSION
);
wp_enqueue_script(
'wpforms-admin-list-table-ext',
WPFORMS_PLUGIN_URL . "assets/js/admin/share/list-table-ext{$min}.js",
[ 'jquery', 'jquery-ui-sortable', 'underscore', 'wpforms-admin', 'wpforms-multiselect-checkboxes' ],
WPFORMS_VERSION,
true
);
/**
* Fires after enqueue the forms overview page assets.
*
* @since 1.0.0
*/
do_action( 'wpforms_overview_enqueue' ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
}
/**
* Determine if it is an empty state.
*
* @since 1.8.6
*/
private function is_empty_state() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
return empty( $this->overview_table->items ) &&
! isset( $_GET['search']['term'] ) &&
! isset( $_GET['status'] ) &&
! isset( $_GET['tags'] ) &&
array_sum( wpforms()->obj( 'forms_views' )->get_count() ) === 0;
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}
/**
* Build the output for the overview page.
*
* @since 1.8.6
*/
public function output() {
?>
get_columns_multiselect();
}
/**
* Get columns multiselect menu.
*
* @since 1.8.6
*
* @return string HTML menu markup.
*/
private function get_columns_multiselect(): string {
$columns = Columns::get_columns();
$selected_keys = Columns::get_selected_columns_keys();
$options = '';
$html = '
';
foreach ( $columns as $column ) {
$selected = in_array( $column->get_id(), $selected_keys, true ) ? 'selected' : '';
$disabled = $column->is_readonly() ? 'disabled="true"' : '';
$options .= sprintf( '
', esc_attr( $column->get_id() ), $selected, $disabled, esc_html( $column->get_label() ) );
}
return sprintf( $html, $options );
}
}