149 lines
4.1 KiB
Plaintext
149 lines
4.1 KiB
Plaintext
<?php
|
|
/*
|
|
* Plugin Name: SIGE Manager
|
|
* Plugin URI: https://www.sige.ita.br/
|
|
* Description: Tools to organize SIGE Event
|
|
* Version: 0.1
|
|
* Author: andrekuros
|
|
* Author URI: https://www.sige.ita.br/
|
|
*/
|
|
add_action('admin_menu', 'sige_setup_menu');
|
|
|
|
function sige_setup_menu(){
|
|
add_menu_page( 'SIGE Manager', 'SIGE Manager', 'manage_options', 'sige-manager', 'test_init' );
|
|
}
|
|
|
|
function test_init(){
|
|
echo "<h1>SIGE MANAGER</h1>";
|
|
|
|
// General check for user permissions.
|
|
if (!current_user_can('manage_options')) {
|
|
wp_die( __('You do not have sufficient pilchards to access this page.') );
|
|
}
|
|
|
|
// Start building the page
|
|
|
|
echo '<div class="wrap">';
|
|
echo '<h2>Incrições</h2>';
|
|
|
|
//Menu de Opções
|
|
<form action="<? bloginfo('url'); ?>" method="get">
|
|
<select name="page_id" id="page_id">
|
|
<?php
|
|
global $post;
|
|
$args = array( 'numberposts' => -1);
|
|
$posts = get_posts($args);
|
|
foreach( $posts as $post ) : setup_postdata($post); ?>
|
|
<option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<input type="submit" name="submit" value="view" />
|
|
</form>
|
|
|
|
// Check whether the button has been pressed AND also check the nonce
|
|
if (isset($_POST['test_button']) && check_admin_referer('test_button_clicked')) {
|
|
// the button has been pressed AND we've passed the security check
|
|
test_button_action();
|
|
}
|
|
|
|
echo '<form action="options-general.php?page=sige-manager" method="post">';
|
|
|
|
// this is a WordPress security feature - see: https://codex.wordpress.org/WordPress_Nonces
|
|
wp_nonce_field('test_button_clicked');
|
|
echo '<input type="hidden" value="true" name="test_button" />';
|
|
submit_button('Lista de Inscritos');
|
|
echo '</form>';
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
function test_button_action()
|
|
{
|
|
echo '<div id="message" class="updated fade"><p>'
|
|
.'The "Lista de Inscritos" button was clicked.' . '</p></div>';
|
|
|
|
echo "Call Function button clicked" ;
|
|
|
|
// Add Lisa's user id, 14, in an array.
|
|
$exclude_list = array( 14 );
|
|
|
|
$args = array(
|
|
'role' => 'mini1',
|
|
'exclude' => $exclude_list
|
|
);
|
|
|
|
// Custom query.
|
|
$my_user_query = new WP_User_Query( $args );
|
|
|
|
// Get query results.
|
|
$editors = $my_user_query->get_results();
|
|
|
|
// Check for editors
|
|
if ( ! empty( $editors ) ) {
|
|
|
|
echo '<ul class="editors-list">';
|
|
|
|
// Loop over editors.
|
|
foreach ( $editors as $editor ) {
|
|
|
|
// Get each editor's data.
|
|
$editor_info = get_userdata( $editor->ID );
|
|
|
|
// Show editor's name.
|
|
//echo '<li>' . $editor_info->display_name . '</li>';
|
|
}
|
|
echo '</ul>';
|
|
|
|
} else {
|
|
|
|
// Display "no editors found" message.
|
|
echo __( 'No editors found!', 'tutsplus' );
|
|
|
|
}
|
|
global $wpdb;
|
|
//$results = get_all_tables_names('arzam_posts');
|
|
|
|
//$results =get_some_data( 'gabrieldietzsch@gmail.com' );
|
|
$results = get_all_emails();
|
|
//global $wpdb;
|
|
//$results = $wpdb->tables();
|
|
// Loop over editors.
|
|
foreach ( $results as $res ) {
|
|
|
|
// Get each editor's data.
|
|
//$editor_info = get_userdata( $editor->ID );
|
|
//var_dump($res);
|
|
echo $res->value . '<br>';
|
|
|
|
//print_r($res);
|
|
//echo '<br>';
|
|
//$properties = get_object_vars($res);
|
|
//print_r($properties);
|
|
|
|
// Show editor's name.
|
|
//echo '<li>' . $editor_info->display_name . '</li>';
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_some_data( $value ){
|
|
global $wpdb;
|
|
$sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}cf7_vdata_entry WHERE value = %s ", $value );
|
|
return $wpdb->get_results( $sql );
|
|
}
|
|
|
|
function get_all_tables_names($value ){
|
|
global $wpdb;
|
|
$sql = $wpdb->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = %s", $value);
|
|
return $wpdb->get_results( $sql );
|
|
}
|
|
|
|
function get_all_emails(){
|
|
global $wpdb;
|
|
$sql = "SELECT * FROM {$wpdb->prefix}cf7_vdata_entry WHERE cf7_id = 4745 AND NAME ='email'\n"
|
|
. "ORDER BY `arzam_cf7_vdata_entry`.`cf7_id` ASC;";
|
|
return $wpdb->get_results( $sql );
|
|
}
|
|
?> |