Last active
November 7, 2018 19:31
-
-
Save feliciaceballos/ef9dada5cfc51dc1584a947ef642273a to your computer and use it in GitHub Desktop.
Create the WPMU DEV Forminator Recent Submissions Dashboard Widget, Verifying User Permissions
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 | |
/** | |
* Setup permissions here if needed | |
* | |
* @return bool | |
*/ | |
public function user_allowed() { | |
return true; | |
} | |
/** | |
* Default options of widget | |
* | |
* @return array | |
*/ | |
private function get_default_options() { | |
return array( | |
'id' => $this->id, | |
'limit' => $this->limit, | |
); | |
} | |
/** | |
* Widget display callback | |
*/ | |
public function display() { | |
// 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 { | |
// Get widget options | |
$options = $this->get_options( $this->get_default_options() ); | |
$this->id = $options['id']; | |
$this->limit = $options['limit']; | |
// Get submissions | |
$this->get_submissions(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment