Edit File by line

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