/** * Register/queue frontend scripts. * * @access public * @return void */ public function load_scripts() { global $typenow; // Scripts wp_enqueue_script('jquery'); wp_enqueue_script('jquery-datatables', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/jquery.dataTables.min.js', array('jquery'), '1.10.4', true); wp_enqueue_script('jquery-countdown', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/jquery.countdown.min.js', array('jquery'), '2.0.2', true); wp_enqueue_script('sportspress', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/sportspress.js', array('jquery'), SP()->version, true); // Localize scripts wp_localize_script('sportspress', 'localized_strings', array('days' => __('days', 'sportspress'), 'hrs' => __('hrs', 'sportspress'), 'mins' => __('mins', 'sportspress'), 'secs' => __('secs', 'sportspress'), 'previous' => __('Previous', 'sportspress'), 'next' => __('Next', 'sportspress'))); // Theme styles $theme = wp_get_theme(); $this->theme = $theme->stylesheet; $dir = scandir(SP()->plugin_path() . '/assets/css/themes'); $files = array(); if ($dir) { foreach ($dir as $key => $value) { if (preg_replace('/\\.[^.\\s]{3,4}$/', '', $value) == $this->theme) { add_filter('sportspress_enqueue_styles', array($this, 'add_theme_styles')); break; } } } // CSS Styles wp_enqueue_style('dashicons'); $enqueue_styles = $this->get_styles(); if ($enqueue_styles) { add_action('wp_print_scripts', array($this, 'custom_css'), 30); foreach ($enqueue_styles as $handle => $args) { wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']); } } }
/** * Output the metabox */ public static function output($post) { wp_nonce_field('prosports_save_data', 'prosports_meta_nonce'); $the_format = get_post_meta($post->ID, 'sp_format', true); ?> <div id="post-formats-select"> <?php foreach (SP()->formats->list as $key => $format) { ?> <input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?> " value="<?php echo $key; ?> " <?php checked(true, $key == 'list' && !$the_format || $the_format == $key); ?> > <label for="post-format-<?php echo $key; ?> " class="post-format-icon post-format-<?php echo $key; ?> "><?php echo $format; ?> </label><br> <?php } ?> </div> <?php }
/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column, $post_id) { switch ($column) { case 'sp_player': $players = array_filter(get_post_meta($post_id, 'sp_player')); echo sizeof($players); break; case 'sp_league': echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'prosports'); break; case 'sp_season': echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'prosports'); break; case 'sp_team': $teams = (array) get_post_meta($post_id, 'sp_team', false); $teams = array_filter($teams); if (empty($teams)) { echo __('All', 'prosports'); } else { foreach ($teams as $team_id) { if (!$team_id) { continue; } $team = get_post($team_id); if ($team) { echo $team->post_title . '<br>'; } } } break; case 'sp_layout': echo sp_array_value(SP()->formats->list, get_post_meta($post_id, 'sp_format', true), '—'); break; } }
/** * Constructor */ public function __construct() { $this->id = 'staff'; $this->label = __('Staff', 'sportspress'); $this->template = 'staff'; $this->templates = SP()->templates->staff; add_filter('sportspress_settings_tabs_array', array($this, 'add_settings_page'), 20); add_action('sportspress_settings_' . $this->id, array($this, 'output')); add_action('sportspress_admin_field_staff_layout', array($this, 'layout_setting')); add_action('sportspress_settings_save_' . $this->id, array($this, 'save')); }
/** * Constructor */ public function __construct() { $this->id = 'events'; $this->label = __('Events', 'sportspress'); $this->template = 'event'; $this->templates = SP()->templates->event; add_filter('sportspress_settings_tabs_array', array($this, 'add_settings_page'), 20); add_action('sportspress_settings_' . $this->id, array($this, 'output')); add_action('sportspress_admin_field_current_mode', array($this, 'current_mode_setting')); add_action('sportspress_admin_field_delimiter', array($this, 'delimiter_setting')); add_action('sportspress_admin_field_event_layout', array($this, 'layout_setting')); add_action('sportspress_settings_save_' . $this->id, array($this, 'save')); }
/** * Returns nationalities * * @access public * @return array */ public function nationalities() { $nationalities = get_post_meta($this->ID, 'sp_nationality', false); if (empty($nationalities)) { return array(); } foreach ($nationalities as $nationality) { if (2 == strlen($nationality)) { $legacy = SP()->countries->legacy; $nationality = strtolower($nationality); $nationality = sp_array_value($legacy, $nationality, null); } } return $nationalities; }
/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column, $post_id) { switch ($column) { case 'sp_league': echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'sportspress'); break; case 'sp_season': echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'sportspress'); break; case 'sp_rounds': echo get_post_meta($post_id, 'sp_rounds', true); break; case 'sp_layout': echo sp_array_value(SP()->formats->tournament, get_post_meta($post_id, 'sp_format', true), '—'); break; } }
public static function get_preset($id) { $json_data = @file_get_contents(SP()->plugin_path() . '/presets/' . $id . '.json', true); if ($json_data) { return json_decode($json_data, true); } $dir = scandir(SP()->plugin_path() . '/presets'); if ($dir) { foreach ($dir as $key => $value) { if (substr($value, 0, 1) !== '.' && strpos($value, '.') === false) { $json_data = @file_get_contents(SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true); if ($json_data) { return json_decode($json_data, true); } } } } }
/** * Install SP */ public function install() { $this->remove_roles(); $this->create_roles(); // Register post types include_once 'class-sp-post-types.php'; SP_Post_types::register_post_types(); SP_Post_types::register_taxonomies(); $this->create_options(); // Queue upgrades $current_version = get_option('sportspress_version', null); // Update version update_option('sportspress_version', SP()->version); // Check if pages are needed if (!get_option('sportspress_sport')) { update_option('_sp_needs_welcome', 1); } // Flush rules after install flush_rewrite_rules(); // Redirect to welcome screen set_transient('_sp_activation_redirect', 1, 60 * 60); }
/** * Register/queue frontend scripts. * * @access public * @return void */ public function load_scripts() { global $typenow; // Scripts wp_enqueue_script('jquery'); wp_enqueue_script('jquery-datatables', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/jquery.dataTables.min.js', array('jquery'), '1.10.4', true); wp_enqueue_script('jquery-countdown', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/jquery.countdown.min.js', array('jquery'), '2.0.2', true); wp_enqueue_script('sportspress', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/sportspress.js', array('jquery'), SP()->version, true); if (is_singular('sp_event') || is_tax('sp_venue')) { wp_enqueue_script('google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true); wp_enqueue_script('sp-maps', plugin_dir_url(SP_PLUGIN_FILE) . 'assets/js/sp-maps.js', array('jquery', 'google-maps'), time(), true); wp_localize_script('sp-maps', 'vars', array('map_type' => strtoupper(get_option('sportspress_map_type', 'ROADMAP')), 'zoom' => get_option('sportspress_map_zoom', 15))); } // Localize scripts wp_localize_script('sportspress', 'localized_strings', array('days' => __('days', 'sportspress'), 'hrs' => __('hrs', 'sportspress'), 'mins' => __('mins', 'sportspress'), 'secs' => __('secs', 'sportspress'), 'previous' => __('Previous', 'sportspress'), 'next' => __('Next', 'sportspress'))); // Theme styles $theme = wp_get_theme(); $this->theme = $theme->stylesheet; $dir = scandir(SP()->plugin_path() . '/assets/css/themes'); $files = array(); if ($dir) { foreach ($dir as $key => $value) { if (preg_replace('/\\.[^.\\s]{3,4}$/', '', $value) == $this->theme) { add_filter('sportspress_enqueue_styles', array($this, 'add_theme_styles')); break; } } } // CSS Styles wp_enqueue_style('dashicons'); $enqueue_styles = $this->get_styles(); if ($enqueue_styles) { add_action('wp_print_scripts', array($this, 'custom_css'), 30); foreach ($enqueue_styles as $handle => $args) { wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']); } } }
/** * Add widgets. * * @return array */ public function include_widgets() { include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-list.php'; include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-gallery.php'; }
/** * Enqueue scripts */ public function admin_scripts() { global $wp_query, $post; $screen = get_current_screen(); // Register scripts wp_register_script('chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array('jquery'), '1.1.0', true); wp_register_script('jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array('jquery'), '1.3', true); wp_register_script('jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array('jquery'), '1.02', true); wp_register_script('jquery-countdown', SP()->plugin_url() . '/assets/js/jquery.countdown.min.js', array('jquery'), '2.0.2', true); wp_register_script('jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array('jquery'), '1.1', true); wp_register_script('google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places'); wp_register_script('jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array('jquery', 'google-maps'), '0.1.6', true); wp_register_script('sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array('jquery', 'google-maps', 'jquery-locationpicker'), SP_VERSION, true); wp_register_script('sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array('jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable'), SP_VERSION, true); wp_register_script('sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array('jquery'), SP_VERSION, true); // SportsPress admin pages if (in_array($screen->id, sp_get_screen_ids()) || strpos($screen->id, 'sportspress-config')) { wp_enqueue_script('jquery'); wp_enqueue_script('chosen'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('jquery-ui-droppable'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-tiptip'); wp_enqueue_script('jquery-caret'); wp_enqueue_script('jquery-countdown'); wp_enqueue_script('jquery-fitvids'); wp_enqueue_script('sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array('jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown', 'jquery-fitvids'), SP_VERSION, true); $strings = array('none' => __('None', 'sportspress'), 'remove_text' => __('— Remove —', 'sportspress'), 'days' => __('days', 'sportspress'), 'hrs' => __('hrs', 'sportspress'), 'mins' => __('mins', 'sportspress'), 'secs' => __('secs', 'sportspress'), 'displaying_posts' => html_entity_decode(__('Displaying %s–%s of %s', 'sportspress'))); // Localize scripts wp_localize_script('sportspress-admin', 'localized_strings', $strings); } if (in_array($screen->id, array('widgets'))) { wp_enqueue_script('sportspress-admin-widgets'); } // Edit venue pages if (in_array($screen->id, array('edit-sp_venue'))) { wp_enqueue_script('google-maps'); wp_enqueue_script('jquery-locationpicker'); wp_enqueue_script('sportspress-admin-locationpicker'); } // Edit equation if (in_array($screen->id, array('sp_column', 'sp_statistic'))) { wp_enqueue_script('sportspress-admin-equationbuilder'); } }
<?php /** * Admin functions for the tournaments post type * * @author ProSports * @category Admin * @package ProSports_Tournaments * @version 1.4 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!class_exists('SP_Admin_CPT')) { include SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt.php'; } if (!class_exists('SP_Admin_CPT_Tournament')) { /** * SP_Admin_CPT_Tournament Class */ class SP_Admin_CPT_Tournament extends SP_Admin_CPT { /** * Constructor */ public function __construct() { $this->type = 'sp_tournament'; // Admin Columns add_filter('manage_edit-sp_tournament_columns', array($this, 'edit_columns'));
function sp_solve($equation, $vars, $precision = 0, $default = '-') { if ($equation == null) { return $default; } if (strpos($equation, '$gamesback') !== false) { // Return placeholder return $default; } elseif (strpos($equation, '$streak') !== false) { // Return direct value return sp_array_value($vars, 'streak', $default); } elseif (strpos($equation, '$last5') !== false) { // Return imploded string $last5 = sp_array_value($vars, 'last5', array(0)); if (array_sum($last5) > 0) { return implode('-', $last5); } else { return $default; } } elseif (strpos($equation, '$last10') !== false) { // Return imploded string $last10 = sp_array_value($vars, 'last10', array(0)); if (array_sum($last10) > 0) { return implode('-', $last10); } else { return $default; } } elseif (strpos($equation, '$homerecord') !== false) { // Return imploded string $homerecord = sp_array_value($vars, 'homerecord', array(0)); return implode('-', $homerecord); } elseif (strpos($equation, '$awayrecord') !== false) { // Return imploded string $awayrecord = sp_array_value($vars, 'awayrecord', array(0)); return implode('-', $awayrecord); } // Remove unnecessary variables from vars before calculating unset($vars['gamesback']); unset($vars['streak']); unset($vars['last5']); unset($vars['last10']); if (sp_array_value($vars, 'eventsplayed', 0) <= 0) { return $default; } // Equation Operating System if (!class_exists('phpStack')) { include_once SP()->plugin_path() . '/includes/libraries/class-phpstack.php'; } if (!class_exists('eqEOS')) { include_once SP()->plugin_path() . '/includes/libraries/class-eqeos.php'; } $eos = new eqEOS(); // Remove spaces from equation $equation = str_replace(' ', '', $equation); // Create temporary equation replacing operators with spaces $temp = str_replace(array('+', '-', '*', '/', '(', ')'), ' ', $equation); // Check if each variable part is in vars $parts = explode(' ', $temp); foreach ($parts as $key => $value) { if (substr($value, 0, 1) == '$') { if (!array_key_exists(preg_replace("/[^a-z0-9_]/", '', $value), $vars)) { return 0; } } } // Remove space between equation parts $equation = str_replace(' ', '', $equation); // Initialize Subequations $subequations = array($equation); // Find all equation parts contained in parentheses if (preg_match_all('~\\((.*?)\\)~', $equation, $results)) { foreach (sp_array_value($results, 1, array()) as $result) { if (!empty($result)) { $subequations[] = $result; } } } // Initialize subequation $subequation = $equation; // Check each subequation separated by division foreach ($subequations as $subequation) { while ($pos = strpos($subequation, '/')) { $subequation = substr($subequation, $pos + 1); // Make sure paretheses match if (substr_count($subequation, '(') === substr_count($subequation, ')')) { // Return zero if denominator is zero if ($eos->solveIF($subequation, $vars) == 0) { return 0; } } } } // Return solution return number_format($eos->solveIF(str_replace(' ', '', $equation), $vars), $precision, '.', ''); }
function sp_get_template($path) { $template = SP()->plugin_dir("templates/" . $path); require_once $template; }
/** * Output admin fields. * * Loops though the prosports options array and outputs each field. * * @access public * @param array $options Opens array to output */ public static function output_fields($options) { foreach ($options as $value) { if (!isset($value['type'])) { continue; } if (!isset($value['id'])) { $value['id'] = ''; } if (!isset($value['title'])) { $value['title'] = isset($value['name']) ? $value['name'] : ''; } if (!isset($value['class'])) { $value['class'] = ''; } if (!isset($value['css'])) { $value['css'] = ''; } if (!isset($value['default'])) { $value['default'] = ''; } if (!isset($value['desc'])) { $value['desc'] = ''; } if (!isset($value['desc_tip'])) { $value['desc_tip'] = false; } if (!isset($value['placeholder'])) { $value['placeholder'] = ''; } // Custom attribute handling $custom_attributes = array(); if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { foreach ($value['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; } } // Description handling if ($value['desc_tip'] === true) { $description = ''; $tip = $value['desc']; } elseif (!empty($value['desc_tip'])) { $description = $value['desc']; $tip = $value['desc_tip']; } elseif (!empty($value['desc'])) { $description = $value['desc']; $tip = ''; } else { $description = $tip = ''; } if ($description && in_array($value['type'], array('textarea', 'radio'))) { $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>'; } elseif ($description && in_array($value['type'], array('checkbox'))) { $description = wp_kses_post($description); } elseif ($description) { $description = '<span class="description">' . wp_kses_post($description) . '</span>'; } if ($tip && in_array($value['type'], array('checkbox'))) { $tip = '<p class="description">' . $tip . '</p>'; } elseif ($tip) { $tip = '<img class="help_tip" data-tip="' . esc_attr($tip) . '" src="' . SP()->plugin_url() . '/assets/images/help.png" height="16" width="16" />'; } // Switch based on type switch ($value['type']) { // Section Titles case 'title': if (!empty($value['title'])) { echo '<h3>' . esc_html($value['title']) . '</h3>'; } if (!empty($value['desc'])) { echo wpautop(wptexturize(wp_kses_post($value['desc']))); } echo '<table class="form-table">' . "\n\n"; if (!empty($value['id'])) { do_action('prosports_settings_' . sanitize_title($value['id'])); } break; // Section Ends // Section Ends case 'sectionend': if (!empty($value['id'])) { do_action('prosports_settings_' . sanitize_title($value['id']) . '_end'); } echo '</table>'; if (!empty($value['id'])) { do_action('prosports_settings_' . sanitize_title($value['id']) . '_after'); } break; // Standard text inputs and subtypes like 'number' // Standard text inputs and subtypes like 'number' case 'text': case 'email': case 'number': case 'color': case 'password': $type = $value['type']; $class = ''; $option_value = self::get_option($value['id'], $value['default']); if ($value['type'] == 'color') { $type = 'text'; $value['class'] .= 'colorpick'; $description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>'; } ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="<?php echo esc_attr($type); ?> " style="<?php echo esc_attr($value['css']); ?> " value="<?php echo esc_attr($option_value); ?> " placeholder="<?php echo esc_attr($value['placeholder']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description; ?> </td> </tr><?php break; // Textarea // Textarea case 'textarea': $option_value = self::get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <?php echo $description; ?> <textarea name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> ><?php echo esc_textarea($option_value); ?> </textarea> </td> </tr><?php break; // Select boxes // Select boxes case 'select': case 'multiselect': $option_value = self::get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <select name="<?php echo esc_attr($value['id']); if ($value['type'] == 'multiselect') { echo '[]'; } ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="chosen-select<?php if (is_rtl()) { ?> chosen-rtl<?php } ?> <?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php if ($value['type'] == 'multiselect') { echo 'multiple="multiple"'; } ?> > <?php foreach ($value['options'] as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array($option_value)) { selected(in_array($key, $option_value), true); } else { selected($option_value, $key); } ?> ><?php echo $val; ?> </option> <?php } ?> </select> <?php echo $description; ?> </td> </tr><?php break; // Select boxes with optgroup // Select boxes with optgroup case 'groupselect': $option_value = self::get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <select name="<?php echo esc_attr($value['id']); if ($value['type'] == 'multiselect') { echo '[]'; } ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="chosen-select<?php if (is_rtl()) { ?> chosen-rtl<?php } ?> <?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php if ($value['type'] == 'multiselect') { echo 'multiple="multiple"'; } ?> > <?php foreach ($value['options'] as $group => $options) { ?> <optgroup label="<?php _e($group, 'prosports'); ?> "> <?php foreach ($options as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array($option_value)) { selected(in_array($key, $option_value), true); } else { selected($option_value, $key); } ?> ><?php echo $val; ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <?php echo $description; ?> </td> </tr><?php break; // Select sport // Select sport case 'sport': $option_value = self::get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <select name="<?php echo esc_attr($value['id']); if ($value['type'] == 'multiselect') { echo '[]'; } ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="chosen-select<?php if (is_rtl()) { ?> chosen-rtl<?php } ?> <?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php if ($value['type'] == 'multiselect') { echo 'multiple="multiple"'; } ?> > <?php foreach ($value['options'] as $group => $options) { ?> <optgroup label="<?php _e($group, 'prosports'); ?> "> <?php foreach ($options as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array($option_value)) { selected(in_array($key, $option_value), true); } else { selected($option_value, $key); } ?> ><?php echo $val; ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <?php echo $description; ?> <p> <label> <input type="checkbox" name="add_sample_data" id="add_sample_data" <?php checked(sp_array_value($value, 'welcome')); ?> > <?php _e('Install demo content', 'prosports'); ?> </label> </p> </td> </tr><?php break; // Radio inputs // Radio inputs case 'radio': $option_value = self::get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <fieldset> <?php echo $description; ?> <ul> <?php foreach ($value['options'] as $key => $val) { ?> <li> <label><input name="<?php echo esc_attr($value['id']); ?> " value="<?php echo $key; ?> " type="radio" style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php checked($key, $option_value); ?> /> <?php echo $val; ?> </label> </li> <?php } ?> </ul> </fieldset> </td> </tr><?php break; // Checkbox input // Checkbox input case 'checkbox': $option_value = self::get_option($value['id'], $value['default']); $visbility_class = array(); if (!isset($value['hide_if_checked'])) { $value['hide_if_checked'] = false; } if (!isset($value['show_if_checked'])) { $value['show_if_checked'] = false; } if ($value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') { $visbility_class[] = 'hidden_option'; } if ($value['hide_if_checked'] == 'option') { $visbility_class[] = 'hide_options_if_checked'; } if ($value['show_if_checked'] == 'option') { $visbility_class[] = 'show_options_if_checked'; } if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) { ?> <tr valign="top" class="<?php echo esc_attr(implode(' ', $visbility_class)); ?> "> <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> </th> <td class="forminp forminp-checkbox"> <fieldset> <?php } else { ?> <fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?> "> <?php } if (!empty($value['title'])) { ?> <legend class="screen-reader-text"><span><?php echo esc_html($value['title']); ?> </span></legend> <?php } ?> <label for="<?php echo $value['id']; ?> "> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="checkbox" value="1" <?php checked($option_value, 'yes'); ?> <?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description; ?> </label> <?php echo $tip; ?> <?php if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) { ?> </fieldset> </td> </tr> <?php } else { ?> </fieldset> <?php } break; // Default: run an action // Default: run an action default: do_action('prosports_admin_field_' . $value['type'], $value); break; } } }
public static function ical_feed() { $feed_template = SP()->plugin_path() . '/feeds/ical.php'; load_template($feed_template); }
/** * Enqueue scripts */ public function admin_scripts() { wp_enqueue_script('sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array('jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown'), SP_VERSION, true); }
/** * Add widgets. * * @return array */ public function include_widgets() { include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-league-table.php'; }
/** * Output the player list. * * @access public * @subpackage List * @return void */ function sportspress_output_player_list() { $id = get_the_ID(); $format = get_post_meta($id, 'sp_format', true); if (array_key_exists($format, SP()->formats->list)) { sp_get_template('player-' . $format . '.php', array('id' => $id)); } else { sp_get_template('player-list.php', array('id' => $id)); } }
/** * Add widgets. * * @return array */ public function include_widgets() { include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-calendar.php'; include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-list.php'; include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-blocks.php'; }
/** * Save settings */ public function save() { foreach (SP()->modules->data as $sections => $modules) { foreach ($modules as $id => $module) { $name = 'sportspress_load_' . $id . '_module'; update_option($name, isset($_POST[$name]) ? 'yes' : 'no'); } } flush_rewrite_rules(); }
/** * Include widgets. */ public function includes() { include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-staff.php'; do_action('sportspress_widgets'); }
/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column, $post_id) { switch ($column) { case 'sp_league': echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'prosports'); break; case 'sp_season': echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'prosports'); break; case 'sp_venue': echo get_the_terms($post_id, 'sp_venue') ? the_terms($post_id, 'sp_venue') : __('All', 'prosports'); break; case 'sp_team': $teams = (array) get_post_meta($post_id, 'sp_team', false); $teams = array_filter($teams); if (empty($teams)) { echo __('All', 'prosports'); } else { $current_team = get_post_meta($post_id, 'sp_current_team', true); foreach ($teams as $team_id) { if (!$team_id) { continue; } $team = get_post($team_id); if ($team) { echo $team->post_title; if ($team_id == $current_team) { echo '<span class="dashicons dashicons-yes" title="' . __('Current Team', 'prosports') . '"></span>'; } echo '<br>'; } } } break; case 'sp_events': $calendar = new SP_Calendar($post_id); echo sizeof($calendar->data()); break; case 'sp_layout': echo sp_array_value(SP()->formats->calendar, get_post_meta($post_id, 'sp_format', true), '—'); break; } }
/** * Into text/links shown on all about pages. * * @access private * @return void */ private function intro() { // Flush after upgrades if (!empty($_GET['sp-updated']) || !empty($_GET['sp-installed'])) { flush_rewrite_rules(); } // Drop minor version if 0 $major_version = substr(SP()->version, 0, 3); ?> <h2 class="sp-welcome-logo"><?php echo apply_filters('sportspress_logo', '<img src="' . plugin_dir_url(SP_PLUGIN_FILE) . 'assets/images/welcome/sportspress' . (class_exists('SportsPress_Pro') ? '-pro' : '') . '.png" alt="' . __('SportsPress', 'sportspress') . '">'); ?> </h2> <div class="sp-badge"><?php printf(__('Version %s', 'sportspress'), SP()->version); ?> </div> <div class="about-text sp-about-text"> <?php if (!empty($_GET['sp-installed'])) { $message = __('Thanks, all done!', 'sportspress'); } elseif (!empty($_GET['sp-updated'])) { $message = __('Thank you for updating to the latest version!', 'sportspress'); } else { $message = __('Thanks for installing!', 'sportspress'); } printf(__('%s SportsPress %s has lots of refinements we think you’ll love.', 'sportspress'), $message, $major_version); ?> </div> <p class="sportspress-actions"> <a href="<?php echo admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php')); ?> " class="button button-primary"><?php _e('Settings', 'sportspress'); ?> </a> <a href="<?php echo esc_url(apply_filters('sportspress_docs_url', 'http://tboy.co/docs', 'sportspress')); ?> " class="docs button button-primary"><?php _e('Docs', 'sportspress'); ?> </a> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/plugins/sportspress" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites." data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </p> <h2 class="nav-tab-wrapper"> <a class="nav-tab <?php if ($_GET['page'] == 'sp-about') { echo 'nav-tab-active'; } ?> " href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sp-about'), 'index.php'))); ?> "> <?php _e('Get Started', 'sportspress'); ?> </a><a class="nav-tab <?php if ($_GET['page'] == 'sp-credits') { echo 'nav-tab-active'; } ?> " href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sp-credits'), 'index.php'))); ?> "> <?php _e('Credits', 'sportspress'); ?> </a><a class="nav-tab <?php if ($_GET['page'] == 'sp-translators') { echo 'nav-tab-active'; } ?> " href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sp-translators'), 'index.php'))); ?> "> <?php _e('Translators', 'sportspress'); ?> </a> </h2> <?php }
function sportspress_gettext($translated_text, $untranslated_text, $domain = null) { global $typenow; if (is_admin()) { if (is_sp_config_type($typenow)) { switch ($untranslated_text) { case 'Excerpt': $translated_text = __('Description', 'sportspress'); break; case 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>': $translated_text = __('The description is not prominent by default; however, some themes may show it.', 'sportspress'); break; case 'Slug': $translated_text = in_array($typenow, array('sp_column', 'sp_statistic')) ? __('Key', 'sportspress') : __('Variable', 'sportspress'); break; case 'Featured Image': $translated_text = __('Icon', 'sportspress'); break; case 'Set Featured Image': $translated_text = __('Select Icon', 'sportspress'); break; case 'Set featured image': $translated_text = __('Add icon', 'sportspress'); break; case 'Remove featured image': $translated_text = __('Remove icon', 'sportspress'); break; } } if (is_sp_post_type($typenow)) { switch ($untranslated_text) { case 'Author': $translated_text = __('User', 'sportspress'); break; } } if (in_array($typenow, array('sp_player', 'sp_staff'))) { switch ($untranslated_text) { case 'Featured Image': $translated_text = __('Photo', 'sportspress'); break; case 'Set Featured Image': $translated_text = __('Select Photo', 'sportspress'); break; case 'Set featured image': $translated_text = __('Add photo', 'sportspress'); break; case 'Remove featured image': $translated_text = __('Remove photo', 'sportspress'); break; } } if (in_array($typenow, array('sp_team'))) { switch ($untranslated_text) { case 'Featured Image': $translated_text = __('Logo', 'sportspress'); break; case 'Set Featured Image': $translated_text = __('Select Logo', 'sportspress'); break; case 'Set featured image': $translated_text = __('Add logo', 'sportspress'); break; case 'Remove featured image': $translated_text = __('Remove logo', 'sportspress'); break; } } if (in_array($typenow, array('sp_event'))) { switch ($untranslated_text) { case 'Publish <b>immediately</b>': $translated_text = __('Date/Time:', 'sportspress') . ' <b>' . __('Now', 'sportspress') . '</b>'; break; } } } else { if ($domain == 'sportspress') { if (!empty(SP()->text[$translated_text])) { $translated_text = SP()->text[$translated_text]; } } elseif (!current_theme_supports('sportspress') && $untranslated_text == 'Archives' && is_tax('sp_venue')) { $slug = get_query_var('sp_venue'); if ($slug) { $venue = get_term_by('slug', $slug, 'sp_venue'); $translated_text = $venue->name; } } } return $translated_text; }
/** * Admin edit table */ public static function table($data = array(), $checked = array()) { ?> <div class="sp-data-table-container"> <table class="widefat sp-data-table sp-team-list-table sp-select-all-range"> <thead> <tr> <th class="check-column"><input class="sp-select-all" type="checkbox"></th> <th class="column-list"> <?php _e('Player List', 'sportspress'); ?> </th> <th class="column-players"> <?php _e('Players', 'sportspress'); ?> </th> <th class="column-league"> <?php _e('Competition', 'sportspress'); ?> </th> <th class="column-season"> <?php _e('Season', 'sportspress'); ?> </th> <th class="column-layout"> <?php _e('Layout', 'sportspress'); ?> </th> </tr> </thead> <tbody> <?php if (is_array($data)) { if (sizeof($data) > 0) { $i = 0; foreach ($data as $list) { $players = array_filter(get_post_meta($list->ID, 'sp_player')); $format = get_post_meta($list->ID, 'sp_format', true); ?> <tr class="sp-row sp-post<?php if ($i % 2 == 0) { echo ' alternate'; } ?> "> <td> <input type="checkbox" name="sp_list[]" id="sp_list_<?php echo $list->ID; ?> " value="<?php echo $list->ID; ?> " <?php checked(in_array($list->ID, $checked)); ?> > </td> <td> <a href="<?php echo get_edit_post_link($list->ID); ?> "> <?php echo $list->post_title; ?> </a> </td> <td><?php echo sizeof($players); ?> </td> <td><?php echo get_the_terms($list->ID, 'sp_league') ? the_terms($list->ID, 'sp_league') : '—'; ?> </td> <td><?php echo get_the_terms($list->ID, 'sp_season') ? the_terms($list->ID, 'sp_season') : '—'; ?> </td> <td><?php echo sp_array_value(SP()->formats->list, $format, '—'); ?> </td> </tr> <?php $i++; } } else { ?> <tr class="sp-row alternate"> <td colspan="6"> <?php _e('No results found.', 'sportspress'); ?> </td> </tr> <?php } } else { ?> <tr class="sp-row alternate"> <td colspan="6"> <?php printf(__('Select %s', 'sportspress'), __('Details', 'sportspress')); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php }
* @author ProSports * @package ProSports/Templates * @version 1.1 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!isset($id)) { $id = get_the_ID(); } $team = new SP_Team($id); $lists = $team->lists(); foreach ($lists as $list) { $id = $list->ID; $grouping = get_post_meta($id, 'sp_grouping', true); if ($grouping == 0 && sizeof($lists) > 1) { ?> <h4 class="sp-table-caption"><?php echo $list->post_title; ?> </h4> <?php } $format = get_post_meta($id, 'sp_format', true); if (array_key_exists($format, SP()->formats->list)) { sp_get_template('player-' . $format . '.php', array('id' => $id)); } else { sp_get_template('player-list.php', array('id' => $id)); } }
* @package ProSports_Staff_Directories * @version 1.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!isset($id)) { $id = get_the_ID(); } $args = array('post_type' => 'sp_directory', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_key' => 'sp_team', 'meta_value' => $id); $directories = get_posts($args); $checked = (array) get_post_meta($id, 'sp_directory'); foreach ($directories as $directory) { $id = $directory->ID; if (!in_array($id, $checked)) { continue; } ?> <h4 class="sp-table-caption"><?php echo $directory->post_title; ?> </h4> <?php $format = get_post_meta($id, 'sp_format', true); if (array_key_exists($format, SP()->formats->directory)) { sp_get_template('staff-' . $format . '.php', array('id' => $id), 'staff-' . $format, SP_STAFF_DIRECTORIES_DIR . 'templates/'); } else { sp_get_template('staff-list.php', array('id' => $id), 'staff-list', SP_STAFF_DIRECTORIES_DIR . 'templates/'); } }
} foreach ($scanned_files as $plugin_name => $files) { foreach ($files as $file) { if (file_exists(get_stylesheet_directory() . '/' . $file)) { $theme_file = get_stylesheet_directory() . '/' . $file; } elseif (file_exists(get_stylesheet_directory() . '/prosports/' . $file)) { $theme_file = get_stylesheet_directory() . '/prosports/' . $file; } elseif (file_exists(get_template_directory() . '/' . $file)) { $theme_file = get_template_directory() . '/' . $file; } elseif (file_exists(get_template_directory() . '/prosports/' . $file)) { $theme_file = get_template_directory() . '/prosports/' . $file; } else { $theme_file = false; } if ($theme_file) { $core_version = $this->get_file_version(SP()->plugin_path() . '/templates/' . $file); $theme_version = $this->get_file_version($theme_file); if ($core_version && (empty($theme_version) || version_compare($theme_version, $core_version, '<'))) { $found_files[$plugin_name][] = sprintf(__('<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'prosports'), basename($theme_file), $theme_version ? $theme_version : '-', $core_version); } else { $found_files[$plugin_name][] = sprintf('<code>%s</code>', basename($theme_file)); } } } } if ($found_files) { foreach ($found_files as $plugin_name => $found_plugin_files) { ?> <td><?php _e('Template Overrides', 'prosports'); ?>