Пример #1
0
 /**
  * Form method
  *
  * @param  mixed $instance
  * @return void
  */
 public function form($instance)
 {
     // PHPLeague_Tools
     $tools = new PHPLeague_Tools();
     // Get all leagues in the database
     global $wpdb;
     $leagues = $wpdb->get_results($wpdb->prepare("SELECT id, name, year FROM {$wpdb->league} ORDER BY year DESC, name ASC", ARRAY_A));
     // Get leagues list
     $leagues_list = array();
     foreach ($leagues as $item) {
         $year = (int) $item->year;
         $leagues_list[$item->name][$item->id] = $year . '/' . substr($year + 1, 2);
     }
     // Display the dropdown list with selected league
     echo $tools->select(esc_attr($this->get_field_name('league_id')), $leagues_list, (int) $instance['league_id'], array('id' => esc_attr($this->get_field_id('league_id'))));
 }
Пример #2
0
 /**
  * Uninstall plugin method
  *
  * @param  none
  * @return void
  */
 public static function uninstall()
 {
     global $wpdb;
     // PHPLeague tables
     $tables = array($wpdb->fixture, $wpdb->league, $wpdb->club, $wpdb->country, $wpdb->match, $wpdb->table_cache, $wpdb->team, $wpdb->player, $wpdb->player_team, $wpdb->player_data, $wpdb->table_chart, $wpdb->table_predi);
     // Delete each table one by one
     foreach ($tables as $table) {
         $wpdb->query('DROP TABLE IF EXISTS ' . $table . ';');
     }
     // Delete the versions in the options table
     delete_option('phpleague_version');
     delete_option('phpleague_db_version');
     // Delete the PHPLeague directory and sub-directories
     PHPLeague_Tools::manage_directory(WP_PHPLEAGUE_UPLOADS_PATH, 'delete');
     PHPLeague_Tools::manage_directory(WP_PHPLEAGUE_UPLOADS_PATH . 'logo_big/', 'delete');
     PHPLeague_Tools::manage_directory(WP_PHPLEAGUE_UPLOADS_PATH . 'logo_mini/', 'delete');
     PHPLeague_Tools::manage_directory(WP_PHPLEAGUE_UPLOADS_PATH . 'players/', 'delete');
 }
Пример #3
0
if (file_exists($root . '/wp-load.php')) {
    require_once $root . '/wp-load.php';
} else {
    die;
}
require_once ABSPATH . '/wp-admin/admin.php';
// check for rights
if (!current_user_can('phpleague')) {
    die;
}
// Load PHPLeague tools
// tim modified - 1
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/libs/phpleague-tools.php';
//require_once ABSPATH.'/wp-content/plugins/phpleague/libs/phpleague-tools.php';
// tim modified - 0
$tools = new PHPLeague_Tools();
// Database stuffs
global $wpdb;
// Get leagues
$leagues = $wpdb->get_results($wpdb->prepare("SELECT id, name, year FROM {$wpdb->league} ORDER BY year DESC, name ASC"));
// Get clubs
$clubs = $wpdb->get_results($wpdb->prepare("SELECT id, name FROM {$wpdb->club} ORDER BY name ASC"));
// Get fixtures
$fixtures = $wpdb->get_results($wpdb->prepare("SELECT l.id as league_id, l.name, l.year, f.number, f.id as fixture_id FROM {$wpdb->league} l INNER JOIN {$wpdb->fixture} f ON f.id_league = l.id ORDER BY l.year DESC, l.name ASC"));
// Fixtures list
$fixtures_list = array();
foreach ($fixtures as $item) {
    $year = (int) $item->year;
    $fixtures_list[$item->name . ' ' . $year . '/' . substr($year + 1, 2)][$item->fixture_id] = $item->number;
}
// Get the website url
 /**
  * Constructor
  *
  * @param  none
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
 }
Пример #5
0
 /**
  * Creates a select form input.
  *
  * @param   string   input name
  * @param   array    available options
  * @param   mixed    selected option string, or an array of selected options
  * @param   array    html attributes
  * @return  string
  */
 public function select($name, array $options = NULL, $selected = NULL, array $attributes = NULL)
 {
     // Set the input name
     $attributes['name'] = $name;
     if (is_array($selected)) {
         $attributes['multiple'] = 'multiple';
     }
     if (!is_array($selected)) {
         if ($selected === NULL) {
             $selected = array();
         } else {
             $selected = array((string) $selected);
         }
     }
     if (empty($options)) {
         // There are no options
         $options = '';
     } else {
         foreach ($options as $value => $name) {
             if (is_array($name)) {
                 // Create a new optgroup
                 $group = array('label' => $value);
                 // Create a new list of options
                 $_options = array();
                 foreach ($name as $_value => $_name) {
                     // Force value to be string
                     $_value = (string) $_value;
                     // Create a new attribute set for this option
                     $option = array('value' => $_value);
                     if (in_array($_value, $selected)) {
                         $option['selected'] = 'selected';
                     }
                     // Change the option to the HTML string
                     $_options[] = '<option' . PHPLeague_Tools::attributes($option) . '>' . esc_html($_name) . '</option>';
                 }
                 // Compile the options into a string
                 $_options = "\n" . implode("\n", $_options) . "\n";
                 $options[$value] = '<optgroup' . PHPLeague_Tools::attributes($group) . '>' . $_options . '</optgroup>';
             } else {
                 // Force value to be string
                 $value = (string) $value;
                 // Create a new attribute set for this option
                 $option = array('value' => $value);
                 if (in_array($value, $selected)) {
                     $option['selected'] = 'selected';
                 }
                 // Change the option to the HTML string
                 $options[$value] = '<option' . PHPLeague_Tools::attributes($option) . '>' . esc_html($name) . '</option>';
             }
         }
         // Compile the options into a single string
         $options = "\n" . implode("\n", $options) . "\n";
     }
     return '<select' . PHPLeague_Tools::attributes($attributes) . '>' . $options . '</select>';
 }