This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get instance | |
* | |
* @return Forminator_Submissions_Dash_Widget | |
*/ | |
public static function get_instance() { | |
if ( is_null( self::$instance ) ) { | |
self::$instance = new self(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add prerequisites if needed | |
*/ | |
public function __construct() { | |
} | |
/** | |
* Register the dashboard widget | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Configure Widget | |
* Configure form id and entries limit | |
*/ | |
public function configure() { | |
// Check if user allowed to view the widget | |
if ( ! $this->user_allowed() ) { | |
echo esc_html( __( 'You are not allowed to view this widget content' ) ); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Update widget options | |
* | |
* @param array $options | |
* | |
* @return bool | |
*/ | |
public function update_options( $options = array() ) { | |
//Fetch all dashboard widget options from the db... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get widget Options | |
* | |
* @param array $default | |
* | |
* @return array | |
*/ | |
public function get_options( $default = array() ) { | |
//Fetch ALL dashboard widget options from the db... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get Form detail and its submissions | |
* | |
* @return bool | |
*/ | |
protected function get_submissions() { | |
// Check if we have configured form ID | |
if ( empty( $this->id ) ) { | |
echo esc_html( __( 'Please configure which form to display its submissions.' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Render Form Submissions table on html widget | |
* | |
* @param Forminator_Custom_Form_Model $form | |
* @param Forminator_Form_Entry_Model[] $entries | |
*/ | |
public function render_form_submissions( $form, $entries ) { | |
$field_labels = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Forminator Dashboard Widget | |
* Version: 1.0 | |
* Plugin URI: https://premium.wpmudev.org/project/forminator/ | |
* Description: Display latest form submissions as Dashboard Widget | |
* Author: WPMU DEV | |
* Author URI: http://premium.wpmudev.org | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Forminator_Submissions_Dash_Widget { | |
private static $instance = null; // Here we store class instance | |
private $id = null; // Form ID that we will retrieve submissions from | |
private $limit = 5; // Number of displayed submissions in widget | |
public function __construct() { | |
// Construct method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get class instance | |
* We will need that to instantiate our plugin class | |
*/ | |
public static function get_instance() { | |
if ( is_null( self::$instance ) ) { | |
self::$instance = new self(); | |
} | |
return self::$instance; |