Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../src/Lite/Admin
File: DashboardWidget.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Lite\Admin;
[2] Fix | Delete
[3] Fix | Delete
use WPForms\Admin\Blocks\Links;
[4] Fix | Delete
use WPForms\Admin\Dashboard\Widget;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Dashboard Widget shows a chart and the form entries stats in WP Dashboard.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 1.5.0
[10] Fix | Delete
*/
[11] Fix | Delete
class DashboardWidget extends Widget {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Widget settings.
[15] Fix | Delete
*
[16] Fix | Delete
* @since 1.5.0
[17] Fix | Delete
*
[18] Fix | Delete
* @var array
[19] Fix | Delete
*/
[20] Fix | Delete
public $settings;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Init class.
[24] Fix | Delete
*
[25] Fix | Delete
* @since 1.5.5
[26] Fix | Delete
*/
[27] Fix | Delete
public function init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
[28] Fix | Delete
[29] Fix | Delete
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
[30] Fix | Delete
/**
[31] Fix | Delete
* Allow disabling the widget.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 1.5.1
[34] Fix | Delete
*
[35] Fix | Delete
* @param bool $load Should the widget be loaded?
[36] Fix | Delete
*/
[37] Fix | Delete
if ( ! apply_filters( 'wpforms_admin_dashboardwidget', true ) ) {
[38] Fix | Delete
return;
[39] Fix | Delete
}
[40] Fix | Delete
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
[41] Fix | Delete
[42] Fix | Delete
add_action( 'wpforms_process_complete', [ static::class, 'clear_widget_cache' ] );
[43] Fix | Delete
add_action( 'admin_init', [ $this, 'admin_init' ] );
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Admin init class.
[48] Fix | Delete
*
[49] Fix | Delete
* @since 1.8.3
[50] Fix | Delete
*/
[51] Fix | Delete
public function admin_init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
[52] Fix | Delete
[53] Fix | Delete
// This widget should be displayed for certain high-level users only.
[54] Fix | Delete
if ( ! wpforms_current_user_can( 'view_forms' ) ) {
[55] Fix | Delete
return;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
add_action( 'wpforms_create_form', [ static::class, 'clear_widget_cache' ] );
[59] Fix | Delete
add_action( 'wpforms_save_form', [ static::class, 'clear_widget_cache' ] );
[60] Fix | Delete
add_action( 'wpforms_delete_form', [ static::class, 'clear_widget_cache' ] );
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Clear cache after Lite plugin deactivation.
[64] Fix | Delete
*
[65] Fix | Delete
* Also triggered when the user upgrades the plugin to the Pro version.
[66] Fix | Delete
* After activation of the Pro version, the cache will be cleared.
[67] Fix | Delete
*/
[68] Fix | Delete
add_action( 'deactivate_wpforms-lite/wpforms.php', [ static::class, 'clear_widget_cache' ] );
[69] Fix | Delete
[70] Fix | Delete
if ( ! $this->is_dashboard_page() && ! $this->is_dashboard_widget_ajax_request() ) {
[71] Fix | Delete
return;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$this->settings();
[75] Fix | Delete
$this->hooks();
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Filterable widget settings.
[80] Fix | Delete
*
[81] Fix | Delete
* @since 1.5.0
[82] Fix | Delete
*/
[83] Fix | Delete
public function settings() {
[84] Fix | Delete
[85] Fix | Delete
// phpcs:disable WPForms.Comments.PHPDocHooks.RequiredHookDocumentation, WPForms.PHP.ValidateHooks.InvalidHookName
[86] Fix | Delete
[87] Fix | Delete
$this->settings = [
[88] Fix | Delete
[89] Fix | Delete
// Number of forms to display in the forms' list before the "Show More" button appears.
[90] Fix | Delete
'forms_list_number_to_display' => apply_filters( 'wpforms_dash_widget_forms_list_number_to_display', 5 ),
[91] Fix | Delete
[92] Fix | Delete
// Allow results caching to reduce a DB load.
[93] Fix | Delete
'allow_data_caching' => apply_filters( 'wpforms_dash_widget_allow_data_caching', true ),
[94] Fix | Delete
[95] Fix | Delete
// Transient lifetime in seconds. Defaults to the end of a current day.
[96] Fix | Delete
'transient_lifetime' => apply_filters( 'wpforms_dash_widget_transient_lifetime', strtotime( 'tomorrow' ) - time() ),
[97] Fix | Delete
[98] Fix | Delete
// Determine if the forms with no entries should appear in a forms' list.
[99] Fix | Delete
// Once switched, the effect applies after cache expiration.
[100] Fix | Delete
'display_forms_list_empty_entries' => apply_filters( 'wpforms_dash_widget_display_forms_list_empty_entries', true ),
[101] Fix | Delete
];
[102] Fix | Delete
[103] Fix | Delete
// phpcs:enable WPForms.Comments.PHPDocHooks.RequiredHookDocumentation, WPForms.PHP.ValidateHooks.InvalidHookName
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Widget hooks.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 1.5.0
[110] Fix | Delete
*/
[111] Fix | Delete
public function hooks() {
[112] Fix | Delete
[113] Fix | Delete
$widget_slug = static::SLUG;
[114] Fix | Delete
[115] Fix | Delete
add_action( 'admin_enqueue_scripts', [ $this, 'widget_scripts' ] );
[116] Fix | Delete
add_action( 'wp_dashboard_setup', [ $this, 'widget_register' ] );
[117] Fix | Delete
add_action( 'admin_init', [ $this, 'hide_widget' ] );
[118] Fix | Delete
add_action( "wp_ajax_wpforms_{$widget_slug}_save_widget_meta", [ $this, 'save_widget_meta_ajax' ] );
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Load widget-specific scripts.
[123] Fix | Delete
*
[124] Fix | Delete
* @since 1.5.0
[125] Fix | Delete
*
[126] Fix | Delete
* @param string $hook_suffix The current admin page.
[127] Fix | Delete
*/
[128] Fix | Delete
public function widget_scripts( $hook_suffix ) {
[129] Fix | Delete
[130] Fix | Delete
if ( $hook_suffix !== 'index.php' ) {
[131] Fix | Delete
return;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
$min = wpforms_get_min_suffix();
[135] Fix | Delete
[136] Fix | Delete
wp_enqueue_style(
[137] Fix | Delete
'wpforms-dashboard-widget',
[138] Fix | Delete
WPFORMS_PLUGIN_URL . "assets/css/dashboard-widget{$min}.css",
[139] Fix | Delete
[],
[140] Fix | Delete
WPFORMS_VERSION
[141] Fix | Delete
);
[142] Fix | Delete
[143] Fix | Delete
wp_enqueue_script(
[144] Fix | Delete
'wpforms-chart',
[145] Fix | Delete
WPFORMS_PLUGIN_URL . 'assets/lib/chart.min.js',
[146] Fix | Delete
[ 'moment' ],
[147] Fix | Delete
'4.4.4',
[148] Fix | Delete
true
[149] Fix | Delete
);
[150] Fix | Delete
[151] Fix | Delete
wp_enqueue_script(
[152] Fix | Delete
'wpforms-dashboard-widget',
[153] Fix | Delete
WPFORMS_PLUGIN_URL . "assets/lite/js/admin/dashboard-widget{$min}.js",
[154] Fix | Delete
[ 'jquery', 'wpforms-chart' ],
[155] Fix | Delete
WPFORMS_VERSION,
[156] Fix | Delete
true
[157] Fix | Delete
);
[158] Fix | Delete
[159] Fix | Delete
wp_localize_script(
[160] Fix | Delete
'wpforms-dashboard-widget',
[161] Fix | Delete
'wpforms_dashboard_widget',
[162] Fix | Delete
[
[163] Fix | Delete
'nonce' => wp_create_nonce( 'wpforms_' . static::SLUG . '_nonce' ),
[164] Fix | Delete
'slug' => static::SLUG,
[165] Fix | Delete
'show_more_html' => esc_html__( 'Show More', 'wpforms-lite' ) . '<span class="dashicons dashicons-arrow-down"></span>',
[166] Fix | Delete
'show_less_html' => esc_html__( 'Show Less', 'wpforms-lite' ) . '<span class="dashicons dashicons-arrow-up"></span>',
[167] Fix | Delete
'i18n' => [
[168] Fix | Delete
'entries' => esc_html__( 'Entries', 'wpforms-lite' ),
[169] Fix | Delete
],
[170] Fix | Delete
// Adapter for Chart.js to use Moment.js for date formatting.
[171] Fix | Delete
'adapter_path' => WPFORMS_PLUGIN_URL . 'assets/lib/chartjs-adapter-moment.min.js?ver=1.0.1',
[172] Fix | Delete
]
[173] Fix | Delete
);
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Register the widget.
[178] Fix | Delete
*
[179] Fix | Delete
* @since 1.5.0
[180] Fix | Delete
*/
[181] Fix | Delete
public function widget_register() {
[182] Fix | Delete
[183] Fix | Delete
global $wp_meta_boxes;
[184] Fix | Delete
[185] Fix | Delete
$widget_key = 'wpforms_reports_widget_lite';
[186] Fix | Delete
[187] Fix | Delete
wp_add_dashboard_widget(
[188] Fix | Delete
$widget_key,
[189] Fix | Delete
esc_html__( 'WPForms', 'wpforms-lite' ),
[190] Fix | Delete
[ $this, 'widget_content' ]
[191] Fix | Delete
);
[192] Fix | Delete
[193] Fix | Delete
// Attempt to place the widget at the top.
[194] Fix | Delete
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
[195] Fix | Delete
$widget_instance = [ $widget_key => $normal_dashboard[ $widget_key ] ];
[196] Fix | Delete
[197] Fix | Delete
unset( $normal_dashboard[ $widget_key ] );
[198] Fix | Delete
[199] Fix | Delete
$sorted_dashboard = array_merge( $widget_instance, $normal_dashboard );
[200] Fix | Delete
[201] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
[202] Fix | Delete
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Load widget content.
[207] Fix | Delete
*
[208] Fix | Delete
* @since 1.5.0
[209] Fix | Delete
*/
[210] Fix | Delete
public function widget_content() {
[211] Fix | Delete
[212] Fix | Delete
$forms = wpforms()->obj( 'form' )->get( '', [ 'fields' => 'ids' ] );
[213] Fix | Delete
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
[214] Fix | Delete
$no_graph_class = $hide_graph ? 'wpforms-dash-widget-no-graph' : '';
[215] Fix | Delete
[216] Fix | Delete
echo '<div class="wpforms-dash-widget wpforms-lite ' . esc_attr( $no_graph_class ) . '">';
[217] Fix | Delete
[218] Fix | Delete
if ( empty( $forms ) ) {
[219] Fix | Delete
$this->widget_content_no_forms_html();
[220] Fix | Delete
} else {
[221] Fix | Delete
$this->widget_content_html( $hide_graph );
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
Links::render(
[225] Fix | Delete
[
[226] Fix | Delete
'docs' => [
[227] Fix | Delete
'medium' => 'dashboard-widget',
[228] Fix | Delete
'content' => 'docs',
[229] Fix | Delete
],
[230] Fix | Delete
]
[231] Fix | Delete
);
[232] Fix | Delete
[233] Fix | Delete
$plugin = $this->get_recommended_plugin();
[234] Fix | Delete
$hide_recommended = $this->widget_meta( 'get', 'hide_recommended_block' );
[235] Fix | Delete
[236] Fix | Delete
if (
[237] Fix | Delete
! empty( $plugin ) &&
[238] Fix | Delete
! empty( $forms ) &&
[239] Fix | Delete
! $hide_recommended
[240] Fix | Delete
) {
[241] Fix | Delete
$this->recommended_plugin_block_html( $plugin );
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
echo '</div><!-- .wpforms-dash-widget -->';
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
/**
[248] Fix | Delete
* Widget content HTML if a user has no forms.
[249] Fix | Delete
*
[250] Fix | Delete
* @since 1.5.0
[251] Fix | Delete
*/
[252] Fix | Delete
public function widget_content_no_forms_html() {
[253] Fix | Delete
[254] Fix | Delete
$create_form_url = add_query_arg( 'page', 'wpforms-builder', admin_url( 'admin.php' ) );
[255] Fix | Delete
$learn_more_url = 'https://wpforms.com/docs/creating-first-form/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=dashboardwidget';
[256] Fix | Delete
[257] Fix | Delete
?>
[258] Fix | Delete
<div class="wpforms-dash-widget-block wpforms-dash-widget-block-no-forms">
[259] Fix | Delete
<img class="wpforms-dash-widget-block-sullie-logo" src="<?php echo esc_url( WPFORMS_PLUGIN_URL . 'assets/images/sullie.png' ); ?>" alt="<?php esc_attr_e( 'Sullie the WPForms mascot', 'wpforms-lite' ); ?>">
[260] Fix | Delete
<h2><?php esc_html_e( 'Create Your First Form to Start Collecting Leads', 'wpforms-lite' ); ?></h2>
[261] Fix | Delete
<p><?php esc_html_e( 'You can use WPForms to build contact forms, surveys, payment forms, and more with just a few clicks.', 'wpforms-lite' ); ?></p>
[262] Fix | Delete
[263] Fix | Delete
<?php if ( wpforms_current_user_can( 'create_forms' ) ) : ?>
[264] Fix | Delete
<a href="<?php echo esc_url( $create_form_url ); ?>" class="button button-primary">
[265] Fix | Delete
<?php esc_html_e( 'Create Your Form', 'wpforms-lite' ); ?>
[266] Fix | Delete
</a>
[267] Fix | Delete
<?php endif; ?>
[268] Fix | Delete
[269] Fix | Delete
<a href="<?php echo esc_url( $learn_more_url ); ?>" class="button" target="_blank" rel="noopener noreferrer">
[270] Fix | Delete
<?php esc_html_e( 'Learn More', 'wpforms-lite' ); ?>
[271] Fix | Delete
</a>
[272] Fix | Delete
</div>
[273] Fix | Delete
<?php
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
/**
[277] Fix | Delete
* Widget content HTML.
[278] Fix | Delete
*
[279] Fix | Delete
* @since 1.5.0
[280] Fix | Delete
* @since 1.7.4 Added hide graph parameter.
[281] Fix | Delete
*
[282] Fix | Delete
* @param bool $hide_graph Whether the graph is hidden.
[283] Fix | Delete
*/
[284] Fix | Delete
public function widget_content_html( $hide_graph = false ) {
[285] Fix | Delete
[286] Fix | Delete
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
[287] Fix | Delete
/**
[288] Fix | Delete
* Filters the content before the Dashboard Widget Chart block container (for Lite).
[289] Fix | Delete
*
[290] Fix | Delete
* @since 1.7.4
[291] Fix | Delete
*
[292] Fix | Delete
* @param string $chart_block_before Chart block before markup.
[293] Fix | Delete
*/
[294] Fix | Delete
echo apply_filters( 'wpforms_lite_admin_dashboard_widget_content_html_chart_block_before', '' );
[295] Fix | Delete
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
[296] Fix | Delete
[297] Fix | Delete
if ( ! $hide_graph ) :
[298] Fix | Delete
?>
[299] Fix | Delete
[300] Fix | Delete
<div class="wpforms-dash-widget-chart-block-container">
[301] Fix | Delete
[302] Fix | Delete
<div class="wpforms-dash-widget-block wpforms-dash-widget-chart-block">
[303] Fix | Delete
<canvas id="wpforms-dash-widget-chart" width="400" height="300"></canvas>
[304] Fix | Delete
</div>
[305] Fix | Delete
[306] Fix | Delete
<div class="wpforms-dash-widget-block-upgrade">
[307] Fix | Delete
<div class="wpforms-dash-widget-modal">
[308] Fix | Delete
<a href="#" class="wpforms-dash-widget-dismiss-chart-upgrade">
[309] Fix | Delete
<span class="dashicons dashicons-no-alt"></span>
[310] Fix | Delete
</a>
[311] Fix | Delete
<h2><?php esc_html_e( 'View all Form Entries inside the WordPress Dashboard', 'wpforms-lite' ); ?></h2>
[312] Fix | Delete
<p><?php esc_html_e( 'Form entries reports are not available.', 'wpforms-lite' ); ?>
[313] Fix | Delete
<?php esc_html_e( 'Form entries are not stored in Lite.', 'wpforms-lite' ); ?>
[314] Fix | Delete
<?php esc_html_e( 'Upgrade to Pro and get access to the reports.', 'wpforms-lite' ); ?></p>
[315] Fix | Delete
<p>
[316] Fix | Delete
<a href="<?php echo esc_url( wpforms_admin_upgrade_link( 'dashboard-widget', 'upgrade-to-pro' ) ); ?>" class="wpforms-dash-widget-upgrade-btn" target="_blank" rel="noopener noreferrer">
[317] Fix | Delete
<?php esc_html_e( 'Upgrade to WPForms Pro', 'wpforms-lite' ); ?>
[318] Fix | Delete
</a>
[319] Fix | Delete
</p>
[320] Fix | Delete
</div>
[321] Fix | Delete
</div>
[322] Fix | Delete
[323] Fix | Delete
</div>
[324] Fix | Delete
[325] Fix | Delete
<?php endif; ?>
[326] Fix | Delete
[327] Fix | Delete
<div class="wpforms-dash-widget-block wpforms-dash-widget-block-title">
[328] Fix | Delete
<h3><?php esc_html_e( 'Total Entries by Form', 'wpforms-lite' ); ?></h3>
[329] Fix | Delete
<div class="wpforms-dash-widget-settings">
[330] Fix | Delete
<?php
[331] Fix | Delete
$this->timespan_select_html( 0, false );
[332] Fix | Delete
$this->widget_settings_html( false );
[333] Fix | Delete
?>
[334] Fix | Delete
</div>
[335] Fix | Delete
</div>
[336] Fix | Delete
[337] Fix | Delete
<div id="wpforms-dash-widget-forms-list-block" class="wpforms-dash-widget-block wpforms-dash-widget-forms-list-block">
[338] Fix | Delete
<?php $this->forms_list_block(); ?>
[339] Fix | Delete
</div>
[340] Fix | Delete
[341] Fix | Delete
<?php
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Forms list block.
[346] Fix | Delete
*
[347] Fix | Delete
* @since 1.5.0
[348] Fix | Delete
*/
[349] Fix | Delete
public function forms_list_block() {
[350] Fix | Delete
[351] Fix | Delete
$forms = $this->get_entries_count_by_form();
[352] Fix | Delete
[353] Fix | Delete
if ( empty( $forms ) ) {
[354] Fix | Delete
$this->forms_list_block_empty_html();
[355] Fix | Delete
} else {
[356] Fix | Delete
$this->forms_list_block_html( $forms );
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
/**
[361] Fix | Delete
* Empty forms list block HTML.
[362] Fix | Delete
*
[363] Fix | Delete
* @since 1.5.0
[364] Fix | Delete
*/
[365] Fix | Delete
public function forms_list_block_empty_html() {
[366] Fix | Delete
[367] Fix | Delete
?>
[368] Fix | Delete
<p class="wpforms-error wpforms-error-no-data-forms-list">
[369] Fix | Delete
<?php esc_html_e( 'No entries were submitted yet.', 'wpforms-lite' ); ?>
[370] Fix | Delete
</p>
[371] Fix | Delete
<?php
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
/**
[375] Fix | Delete
* Forms list block HTML.
[376] Fix | Delete
*
[377] Fix | Delete
* @since 1.5.0
[378] Fix | Delete
*
[379] Fix | Delete
* @param array $forms Forms to display in the list.
[380] Fix | Delete
*/
[381] Fix | Delete
public function forms_list_block_html( $forms ) {
[382] Fix | Delete
[383] Fix | Delete
// Number of forms to display in the forms' list before the "Show More" button appears.
[384] Fix | Delete
$show_forms = $this->settings['forms_list_number_to_display'];
[385] Fix | Delete
[386] Fix | Delete
?>
[387] Fix | Delete
<table id="wpforms-dash-widget-forms-list-table" cellspacing="0">
[388] Fix | Delete
<?php foreach ( array_values( $forms ) as $key => $form ) : ?>
[389] Fix | Delete
<tr <?php echo $key >= $show_forms ? 'class="wpforms-dash-widget-forms-list-hidden-el"' : ''; ?> data-form-id="<?php echo absint( $form['form_id'] ); ?>">
[390] Fix | Delete
<td><span class="wpforms-dash-widget-form-title"><?php echo esc_html( $form['title'] ); ?></span></td>
[391] Fix | Delete
<td><?php echo absint( $form['count'] ); ?></td>
[392] Fix | Delete
</tr>
[393] Fix | Delete
<?php endforeach; ?>
[394] Fix | Delete
</table>
[395] Fix | Delete
[396] Fix | Delete
<?php if ( count( $forms ) > $show_forms ) : ?>
[397] Fix | Delete
<button type="button" id="wpforms-dash-widget-forms-more" class="wpforms-dash-widget-forms-more" title="<?php esc_html_e( 'Show all forms', 'wpforms-lite' ); ?>">
[398] Fix | Delete
<?php esc_html_e( 'Show More', 'wpforms-lite' ); ?> <span class="dashicons dashicons-arrow-down"></span>
[399] Fix | Delete
</button>
[400] Fix | Delete
<?php endif; ?>
[401] Fix | Delete
[402] Fix | Delete
<?php
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
[406] Fix | Delete
/**
[407] Fix | Delete
* Recommended plugin block HTML.
[408] Fix | Delete
*
[409] Fix | Delete
* @since 1.5.0
[410] Fix | Delete
* @since 1.7.3 Added plugin parameter.
[411] Fix | Delete
*
[412] Fix | Delete
* @param array $plugin Plugin data.
[413] Fix | Delete
*/
[414] Fix | Delete
public function recommended_plugin_block_html( $plugin = [] ) {
[415] Fix | Delete
[416] Fix | Delete
if ( ! $plugin ) {
[417] Fix | Delete
return;
[418] Fix | Delete
}
[419] Fix | Delete
[420] Fix | Delete
$install_url = wp_nonce_url(
[421] Fix | Delete
self_admin_url( 'update.php?action=install-plugin&plugin=' . rawurlencode( $plugin['slug'] ) ),
[422] Fix | Delete
'install-plugin_' . $plugin['slug']
[423] Fix | Delete
);
[424] Fix | Delete
[425] Fix | Delete
?>
[426] Fix | Delete
<div class="wpforms-dash-widget-block wpforms-dash-widget-recommended-plugin-block">
[427] Fix | Delete
<span class="wpforms-dash-widget-recommended-plugin">
[428] Fix | Delete
<span class="recommended"><?php esc_html_e( 'Recommended Plugin:', 'wpforms-lite' ); ?></span>
[429] Fix | Delete
<strong><?php echo esc_html( $plugin['name'] ); ?></strong>
[430] Fix | Delete
<span class="sep">-</span>
[431] Fix | Delete
<span class="action-links">
[432] Fix | Delete
<?php if ( wpforms_can_install( 'plugin' ) ) { ?>
[433] Fix | Delete
<a href="<?php echo esc_url( $install_url ); ?>"><?php esc_html_e( 'Install', 'wpforms-lite' ); ?></a>
[434] Fix | Delete
<span class="sep sep-vertical">&vert;</span>
[435] Fix | Delete
<?php } ?>
[436] Fix | Delete
<a href="<?php echo esc_url( $plugin['more'] ); ?>?utm_source=wpformsplugin&utm_medium=link&utm_campaign=wpformsdashboardwidget"><?php esc_html_e( 'Learn More', 'wpforms-lite' ); ?></a>
[437] Fix | Delete
</span>
[438] Fix | Delete
</span>
[439] Fix | Delete
<button type="button" class="wpforms-dash-widget-dismiss-icon" title="<?php esc_html_e( 'Dismiss', 'wpforms-lite' ); ?>" data-field="hide_recommended_block">
[440] Fix | Delete
<span class="dashicons dashicons-no-alt"></span>
[441] Fix | Delete
</button>
[442] Fix | Delete
</div>
[443] Fix | Delete
<?php
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
/**
[447] Fix | Delete
* The welcome block HTML.
[448] Fix | Delete
*
[449] Fix | Delete
* @since 1.8.7
[450] Fix | Delete
* @deprecated 1.9.7
[451] Fix | Delete
*/
[452] Fix | Delete
public function welcome_block_html() {
[453] Fix | Delete
[454] Fix | Delete
return '';
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
/**
[458] Fix | Delete
* Get entries count grouped by form.
[459] Fix | Delete
* Main point of entry to fetch form entry count data from DB.
[460] Fix | Delete
* Cache the result.
[461] Fix | Delete
*
[462] Fix | Delete
* @since 1.5.0
[463] Fix | Delete
*
[464] Fix | Delete
* @return array
[465] Fix | Delete
*/
[466] Fix | Delete
public function get_entries_count_by_form(): array {
[467] Fix | Delete
[468] Fix | Delete
// Allow results caching to reduce a DB load.
[469] Fix | Delete
$allow_caching = $this->settings['allow_data_caching'];
[470] Fix | Delete
$transient_name = 'wpforms_dash_widget_lite_entries_by_form';
[471] Fix | Delete
[472] Fix | Delete
if ( $allow_caching ) {
[473] Fix | Delete
$cache = get_transient( $transient_name );
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* Filters the cache to clear or alter its data.
[477] Fix | Delete
*
[478] Fix | Delete
* @since 1.5.0
[479] Fix | Delete
*
[480] Fix | Delete
* @param mixed $cache The cache content.
[481] Fix | Delete
*/
[482] Fix | Delete
$cache = apply_filters( 'wpforms_dash_widget_lite_cached_data', $cache ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
// is_array() detects cached empty searches.
[486] Fix | Delete
if ( $allow_caching && is_array( $cache ) ) {
[487] Fix | Delete
return $cache;
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
$forms = wpforms()->obj( 'form' )->get( '', [ 'fields' => 'ids' ] );
[491] Fix | Delete
[492] Fix | Delete
if ( empty( $forms ) || ! is_array( $forms ) ) {
[493] Fix | Delete
return [];
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
$result = [];
[497] Fix | Delete
[498] Fix | Delete
foreach ( $forms as $form_id ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function