/home/vianto5/heredit.mx/wp-content/plugins/wpforms/src/Pro/Admin/Entries/Overview
Edit: /home/vianto5/heredit.mx/wp-content/plugins/wpforms/src/Pro/Admin/Entries/Overview/Page.php (10004B)
screen_options_id = 'wpforms_entries_overview_screen_options';
// Define screen options config.
$this->screen_options = [
'pagination' => [
'heading' => esc_html__( 'Pagination', 'wpforms' ),
'options' => [
[
'label' => esc_html__( 'Number of forms per page:', 'wpforms' ),
'option' => 'per_page',
'default' => wpforms()->obj( 'entry' )->get_count_per_page(),
'type' => 'number',
'args' => [
'min' => 1,
'max' => 999,
'step' => 1,
'maxlength' => 3,
],
],
],
],
'view' => [
'heading' => esc_html__( 'View', 'wpforms' ),
'options' => [
[
'label' => esc_html__( 'Show form templates', 'wpforms' ),
'option' => 'show_form_templates',
'default' => true,
'type' => 'checkbox',
'checked' => true,
],
],
],
];
$allow = $this->is_allowed();
$this->init_screen_options( $allow );
if ( $allow ) {
$this->hooks();
}
}
/**
* Determine if the class is allowed to load.
*
* @since 1.8.2
*
* @return bool
*/
private function is_allowed() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
return wpforms_is_admin_page( 'entries' ) && empty( $_GET['form_id'] ) && empty( $_GET['entry_id'] );
}
/**
* Hooks.
*
* @since 1.8.2
*/
private function hooks() {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
add_action( 'current_screen', [ $this, 'init_overview_table' ] );
add_filter( 'wpforms_entries_list_default_screen_option_args', [ $this, 'screen_option' ] );
add_action( 'wpforms_admin_page', [ $this, 'output' ] );
add_action( 'wpforms_pro_admin_entries_overview_page_output_before', [ $this, 'output_top_bar' ] );
add_action( 'wpforms_pro_admin_entries_overview_page_output_before', [ $this, 'output_chart' ] );
add_filter( 'wpforms_entries_per_page', [ $this, 'get_per_page_option' ] );
}
/**
* Get the "per_page" option for the overview page.
*
* @since 1.8.8
*
* @return int
*/
public function get_per_page_option() {
return get_user_option( $this->screen_options_id . '_pagination_per_page' );
}
/**
* Enqueue scripts and styles.
*
* @since 1.8.2
*/
public function enqueue_assets() {
$min = wpforms_get_min_suffix();
wp_enqueue_style(
'wpforms-flatpickr',
WPFORMS_PLUGIN_URL . 'assets/lib/flatpickr/flatpickr.min.css',
[],
'4.6.9'
);
wp_enqueue_script(
'wpforms-flatpickr',
WPFORMS_PLUGIN_URL . 'assets/lib/flatpickr/flatpickr.min.js',
[ 'jquery' ],
'4.6.9',
true
);
wp_enqueue_script(
'wpforms-chart',
WPFORMS_PLUGIN_URL . 'assets/lib/chart.min.js',
[ 'moment' ],
'4.5.1',
true
);
wp_enqueue_script(
'wpforms-chart-adapter-moment',
WPFORMS_PLUGIN_URL . 'assets/lib/chartjs-adapter-moment.min.js',
[ 'moment', 'wpforms-chart' ],
'1.0.1',
true
);
wp_enqueue_script(
'wpforms-admin-entries-overview',
WPFORMS_PLUGIN_URL . "assets/pro/js/admin/entries/entries-overview{$min}.js",
[ 'jquery', 'wpforms-flatpickr', 'wpforms-chart' ],
WPFORMS_VERSION,
true
);
$admin_l10n = [
'settings' => $this->get_chart_settings(),
'locale' => sanitize_key( wpforms_get_language_code() ),
'date_format' => sanitize_text_field( Datepicker::get_wp_date_format_for_momentjs() ),
'delimiter' => Datepicker::TIMESPAN_DELIMITER,
'i18n' => [
'label' => esc_html__( 'Entries', 'wpforms' ),
],
];
wp_localize_script(
'wpforms-admin-entries-overview', // Script handle the data will be attached to.
'wpforms_admin_entries_overview', // Name for the JavaScript object.
$admin_l10n
);
}
/**
* Base class for displaying a list of forms in an HTML table.
*
* @since 1.8.2
*/
public function init_overview_table() {
$this->timespan = Datepicker::process_timespan();
$this->overview_table = new Table();
// Timespans should be initialized early because the "screen options" needs to be filled in before the rendered page content.
$this->overview_table->set_timespans( $this->timespan );
}
/**
* Update "per_page" label for the overview page.
*
* @since 1.8.2
*
* @param array $args Screen option arguments.
*
* @return array
*/
public function screen_option( $args ) {
$args['label'] = esc_html__( 'Number of forms per page:', 'wpforms' );
return $args;
}
/**
* Handles output of the overview page.
*
* @since 1.8.2
*/
public function output() {
// In the event that the overview table has not yet been initialized, leave early.
if ( ! $this->overview_table ) {
return;
}
?>
timespan );
?>
'entries',
'total_items' => esc_html__( 'Total Entries', 'wpforms' ),
'notice' => [
'heading' => esc_html__( 'No entries for selected period', 'wpforms' ),
'description' => esc_html__( 'Please select a different period or check back later.', 'wpforms' ),
],
],
true
);
}
/**
* Get the user's preference for showing form templates.
*
* @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 the user’s preferences for displaying of the graph.
*
* @since 1.8.2
*
* @return array
*/
private function get_chart_settings() {
$user_id = get_current_user_id();
$graph_style = get_user_meta( $user_id, 'wpforms_dash_widget_graph_style', true );
$color_scheme = get_user_meta( $user_id, 'wpforms_dash_widget_color_scheme', true );
$active_form_id = get_user_meta( $user_id, 'wpforms_dash_widget_active_form_id', true );
$active_form = empty( $active_form_id ) ? false : wpforms()->obj( 'form' )->get( $active_form_id );
return [
'active_form_id' => $active_form instanceof WP_Post && $active_form->post_status === 'publish' ? $active_form->ID : '',
'graph_style' => $graph_style ? absint( $graph_style ) : 2, // Line.
'color_scheme' => $color_scheme ? absint( $color_scheme ) : 1, // WPForms.
];
}
/**
* Get the current view page URL.
*
* @since 1.8.2
*
* @return string
*/
private function get_current_screen_url() {
return add_query_arg(
[
'page' => 'wpforms-entries',
],
admin_url( 'admin.php' )
);
}
}