Refine admin overview page
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
/*!
|
||||
Adapted from SlickMap CSS by Matt Everson of Astuteo, LLC
|
||||
http://astuteo.com/slickmap
|
||||
|
||||
Version 1.1
|
||||
Copyright (c) 2009 Astuteo, LLC http://astuteo.com
|
||||
*/
|
||||
|
||||
.sp-overview-wrap {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.sp-sitemap {
|
||||
margin: 40px 0;
|
||||
float: left;
|
||||
@@ -25,10 +37,7 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
NUMBER OF COLUMNS: Adjust .sp-sitemap li to set the number
|
||||
of columns required in your site map. The default is
|
||||
4 columns (25%). 5 columns would be 20%, 6 columns would
|
||||
be 16.6%, etc.
|
||||
Number of Columns
|
||||
------------------------------------------------------------ */
|
||||
|
||||
.sp-sitemap li {
|
||||
@@ -92,6 +101,27 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
}
|
||||
.sp-sitemap li a.button {
|
||||
white-space: normal;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.sp-sitemap li a.action {
|
||||
white-space: normal;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding: 10px 28px;
|
||||
}
|
||||
.sp-sitemap li a.button span {
|
||||
position: absolute;
|
||||
left: 9px;
|
||||
top: 9px;
|
||||
}
|
||||
.sp-sitemap li a.button span.dashicons-plus {
|
||||
left: 12px;
|
||||
top: 12px;
|
||||
}
|
||||
.sp-sitemap li a.button-primary span {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +131,7 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
|
||||
/* -------- Top Level --------- */
|
||||
|
||||
.sp-sitemap #sp-primary .sp-home {
|
||||
.sp-sitemap .sp-primary .sp-home {
|
||||
display: block;
|
||||
float: none;
|
||||
background: #f1f1f1 url('../images/slickmap/L1-left.png') center bottom no-repeat;
|
||||
@@ -109,7 +139,7 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
z-index: 2;
|
||||
padding: 0 0 30px 0;
|
||||
}
|
||||
.sp-sitemap #sp-primary .sp-breadcrumb {
|
||||
.sp-sitemap .sp-primary .sp-breadcrumb {
|
||||
display: block;
|
||||
float: none;
|
||||
background: #f1f1f1 url('../images/slickmap/vertical-line.png') center bottom repeat-y;
|
||||
@@ -118,66 +148,63 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
padding: 0 0 30px 0;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.sp-sitemap #sp-primary li {
|
||||
.sp-sitemap .sp-primary li {
|
||||
min-width: 149px;
|
||||
float: left;
|
||||
background: url('../images/slickmap/L1-center.png') center top no-repeat;
|
||||
padding: 30px 0;
|
||||
margin-top: -30px;
|
||||
}
|
||||
.sp-sitemap #sp-primary li a.button {
|
||||
.sp-sitemap .sp-primary li a.button {
|
||||
margin: 0 20px 0 0;
|
||||
padding: 10px 0;
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
height: auto;
|
||||
line-height: normal;
|
||||
}
|
||||
.sp-sitemap #sp-primary li:last-child {
|
||||
.sp-sitemap .sp-primary li:last-child {
|
||||
background: url('../images/slickmap/L1-right.png') center top no-repeat;
|
||||
}
|
||||
|
||||
/* -------- Second Level --------- */
|
||||
|
||||
.sp-sitemap #sp-primary li li {
|
||||
.sp-sitemap .sp-primary li li {
|
||||
width: 100%;
|
||||
clear: left;
|
||||
margin-top: 0;
|
||||
padding: 10px 0 0 0;
|
||||
background: url('../images/slickmap/vertical-line.png') center bottom repeat-y;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li:first-child {
|
||||
.sp-sitemap .sp-primary li li:first-child {
|
||||
padding-top: 30px;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li:last-child {
|
||||
.sp-sitemap .sp-primary li li:last-child {
|
||||
background: url('../images/slickmap/vertical-line.png') center bottom repeat-y;
|
||||
}
|
||||
|
||||
/* -------- Third Level --------- */
|
||||
|
||||
.sp-sitemap #sp-primary li li ul {
|
||||
.sp-sitemap .sp-primary li li ul {
|
||||
margin: 10px 0 0 0;
|
||||
width: 100%;
|
||||
float: right;
|
||||
padding: 9px 0 10px 0;
|
||||
background: #f1f1f1 url('../images/slickmap/L3-ul-top.png') center top no-repeat;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li li {
|
||||
.sp-sitemap .sp-primary li li li {
|
||||
background: url('../images/slickmap/L3-center.png') left center no-repeat;
|
||||
padding: 5px 0;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li li a {
|
||||
padding: 5px 0;
|
||||
.sp-sitemap .sp-primary li li li a {
|
||||
width: 80%;
|
||||
float: right;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li li:first-child {
|
||||
.sp-sitemap .sp-primary li li li:first-child {
|
||||
padding: 15px 0 5px 0;
|
||||
background: url('../images/slickmap/L3-li-top.png') left center no-repeat;
|
||||
}
|
||||
.sp-sitemap #sp-primary li li li:last-child {
|
||||
.sp-sitemap .sp-primary li li li:last-child {
|
||||
background: url('../images/slickmap/L3-bottom.png') left center no-repeat;
|
||||
}
|
||||
|
||||
@@ -186,40 +213,39 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
Utility Navigation
|
||||
------------------------------------------------------------ */
|
||||
|
||||
.sp-sitemap #sp-utility {
|
||||
.sp-sitemap .sp-utility {
|
||||
float: right;
|
||||
max-width: 80%;
|
||||
margin-top: -30px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.sp-sitemap #sp-utility li {
|
||||
.sp-sitemap .sp-utility li {
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
width: auto;
|
||||
}
|
||||
.sp-sitemap #sp-utility li a.button {
|
||||
.sp-sitemap .sp-utility li a.button {
|
||||
margin: 0 10px 0 0;
|
||||
padding: 10px 16px;
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
height: auto;
|
||||
line-height: normal;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
.sp-sitemap #sp-utility li a:link:before,
|
||||
.sp-sitemap #sp-utility li a:visited:before {
|
||||
.sp-sitemap .sp-utility li a:link:before,
|
||||
.sp-sitemap .sp-utility li a:visited:before {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
@media screen and ( max-width: 782px ) {
|
||||
.sp-sitemap #sp-primary {
|
||||
.sp-sitemap .sp-primary {
|
||||
clear: both;
|
||||
padding-top: 50px;
|
||||
}
|
||||
.sp-sitemap #sp-utility {
|
||||
.sp-sitemap .sp-utility {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
@@ -29,22 +29,21 @@ class SP_Admin_Assets {
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
|
||||
// Admin styles for SP pages only
|
||||
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
} elseif ( strpos( $screen->id, 'sp-config' ) !== false || strpos( $screen->id, 'sp-status' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'sportspress_page_sp-overview' ) ) ) {
|
||||
if ( strpos( $screen->id, 'sp-overview' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin-slickmap', SP()->plugin_url() . '/assets/css/slickmap.css', array(), '1.1.0' );
|
||||
}
|
||||
|
||||
@@ -96,7 +95,7 @@ class SP_Admin_Assets {
|
||||
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() ) ) {
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sp-config' )) {
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'chosen' );
|
||||
wp_enqueue_script( 'jquery-ui-core' );
|
||||
|
||||
@@ -1,578 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* SportsPress Admin Overview Class.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 1.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Overview' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Overview
|
||||
*/
|
||||
class SP_Admin_Overview {
|
||||
|
||||
private static $settings = array();
|
||||
private static $errors = array();
|
||||
private static $messages = array();
|
||||
|
||||
/**
|
||||
* Include the settings page classes
|
||||
*/
|
||||
public static function get_settings_pages() {
|
||||
if ( empty( self::$settings ) ) {
|
||||
$settings = array();
|
||||
|
||||
include_once( 'class-sp-admin-sports.php' );
|
||||
include_once( 'settings/class-sp-settings-page.php' );
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
||||
|
||||
if ( SP()->mode == 'team' ):
|
||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
||||
endif;
|
||||
|
||||
$settings = apply_filters( 'sportspress_get_settings_pages', $settings );
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-text.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-config.php' );
|
||||
|
||||
self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
|
||||
}
|
||||
return self::$settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the settings
|
||||
*/
|
||||
public static function save() {
|
||||
global $current_section, $current_tab;
|
||||
|
||||
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sportspress-settings' ) )
|
||||
die( __( 'Action failed. Please refresh the page and retry.', 'sportspress' ) );
|
||||
|
||||
// Trigger actions
|
||||
do_action( 'sportspress_settings_save_' . $current_tab );
|
||||
do_action( 'sportspress_update_options_' . $current_tab );
|
||||
do_action( 'sportspress_update_options' );
|
||||
|
||||
self::add_message( __( 'Your settings have been saved.', 'sportspress' ) );
|
||||
|
||||
do_action( 'sportspress_settings_saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message
|
||||
* @param string $text
|
||||
*/
|
||||
public static function add_message( $text ) {
|
||||
self::$messages[] = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error
|
||||
* @param string $text
|
||||
*/
|
||||
public static function add_error( $text ) {
|
||||
self::$errors[] = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output messages + errors
|
||||
*/
|
||||
public static function show_messages() {
|
||||
if ( sizeof( self::$errors ) > 0 ) {
|
||||
foreach ( self::$errors as $error )
|
||||
echo '<div id="message" class="error fade"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
|
||||
} elseif ( sizeof( self::$messages ) > 0 ) {
|
||||
foreach ( self::$messages as $message )
|
||||
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overview page.
|
||||
*
|
||||
* Handles the display of the main sportspress overview page in admin.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function output() {
|
||||
include 'views/html-admin-overview.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting from the settings API.
|
||||
*
|
||||
* @param mixed $option
|
||||
* @return string
|
||||
*/
|
||||
public static function get_option( $option_name, $default = '' ) {
|
||||
// Array value
|
||||
if ( strstr( $option_name, '[' ) ) {
|
||||
|
||||
parse_str( $option_name, $option_array );
|
||||
|
||||
// Option name is first key
|
||||
$option_name = current( array_keys( $option_array ) );
|
||||
|
||||
// Get value
|
||||
$option_values = get_option( $option_name, '' );
|
||||
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
|
||||
if ( isset( $option_values[ $key ] ) )
|
||||
$option_value = $option_values[ $key ];
|
||||
else
|
||||
$option_value = null;
|
||||
|
||||
// Single value
|
||||
} else {
|
||||
$option_value = get_option( $option_name, null );
|
||||
}
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
$option_value = array_map( 'stripslashes', $option_value );
|
||||
elseif ( ! is_null( $option_value ) )
|
||||
$option_value = stripslashes( $option_value );
|
||||
|
||||
return $option_value === null ? $default : $option_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output admin fields.
|
||||
*
|
||||
* Loops though the sportspress 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( 'sportspress_settings_' . sanitize_title( $value['id'] ) );
|
||||
}
|
||||
break;
|
||||
|
||||
// Section Ends
|
||||
case 'sectionend':
|
||||
if ( ! empty( $value['id'] ) ) {
|
||||
do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_end' );
|
||||
}
|
||||
echo '</table>';
|
||||
if ( ! empty( $value['id'] ) ) {
|
||||
do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_after' );
|
||||
}
|
||||
break;
|
||||
|
||||
// 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
|
||||
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
|
||||
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'] ); ?><?php 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 endif; ?> <?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;
|
||||
|
||||
// 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
|
||||
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:
|
||||
do_action( 'sportspress_admin_field_' . $value['type'], $value );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save admin fields.
|
||||
*
|
||||
* Loops though the sportspress options array and outputs each field.
|
||||
*
|
||||
* @access public
|
||||
* @param array $options Opens array to output
|
||||
* @return bool
|
||||
*/
|
||||
public static function save_fields( $options ) {
|
||||
if ( empty( $_POST ) )
|
||||
return false;
|
||||
|
||||
// Options to update will be stored here
|
||||
$update_options = array();
|
||||
|
||||
// Loop options and get values to save
|
||||
foreach ( $options as $value ) {
|
||||
|
||||
if ( ! isset( $value['id'] ) )
|
||||
continue;
|
||||
|
||||
$type = isset( $value['type'] ) ? sanitize_title( $value['type'] ) : '';
|
||||
|
||||
// Get the option name
|
||||
$option_value = null;
|
||||
|
||||
switch ( $type ) {
|
||||
|
||||
// Standard types
|
||||
case 'checkbox' :
|
||||
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$option_value = 'yes';
|
||||
} else {
|
||||
$option_value = 'no';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'textarea' :
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
||||
} else {
|
||||
$option_value = '';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'text' :
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'select' :
|
||||
case 'color' :
|
||||
case 'password' :
|
||||
case 'radio' :
|
||||
|
||||
if ( isset( $_POST[$value['id']] ) ) {
|
||||
$option_value = sanitize_text_field( stripslashes( $_POST[ $value['id'] ] ) );
|
||||
} else {
|
||||
$option_value = '';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Special types
|
||||
case "multiselect" :
|
||||
case "multi_select_countries" :
|
||||
|
||||
// Get countries array
|
||||
if ( isset( $_POST[ $value['id'] ] ) )
|
||||
$selected_countries = array_map( 'sanitize_text_field', array_map( 'stripslashes', (array) $_POST[ $value['id'] ] ) );
|
||||
else
|
||||
$selected_countries = array();
|
||||
|
||||
$option_value = $selected_countries;
|
||||
|
||||
break;
|
||||
|
||||
// Custom handling
|
||||
default :
|
||||
|
||||
do_action( 'sportspress_update_option_' . $type, $value );
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if ( ! is_null( $option_value ) ) {
|
||||
// Check if option is an array
|
||||
if ( strstr( $value['id'], '[' ) ) {
|
||||
|
||||
parse_str( $value['id'], $option_array );
|
||||
|
||||
// Option name is first key
|
||||
$option_name = current( array_keys( $option_array ) );
|
||||
|
||||
// Get old option value
|
||||
if ( ! isset( $update_options[ $option_name ] ) )
|
||||
$update_options[ $option_name ] = get_option( $option_name, array() );
|
||||
|
||||
if ( ! is_array( $update_options[ $option_name ] ) )
|
||||
$update_options[ $option_name ] = array();
|
||||
|
||||
// Set keys and value
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
|
||||
$update_options[ $option_name ][ $key ] = $option_value;
|
||||
|
||||
// Single value
|
||||
} else {
|
||||
$update_options[ $value['id'] ] = $option_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Custom handling
|
||||
do_action( 'sportspress_update_option', $value );
|
||||
}
|
||||
|
||||
// Now save the options
|
||||
foreach( $update_options as $name => $value )
|
||||
update_option( $name, $value );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -20,8 +20,6 @@ function sp_get_screen_ids() {
|
||||
'dashboard',
|
||||
'dashboard_page_sp-about',
|
||||
'toplevel_page_sportspress',
|
||||
'sportspress_page_sp-overview',
|
||||
'sportspress_page_sp-status',
|
||||
'edit-sp_result',
|
||||
'sp_result',
|
||||
'edit-sp_outcome',
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<div class="wrap sportspress">
|
||||
<div class="wrap sportspress sp-overview-wrap">
|
||||
<h2>
|
||||
<?php _e( 'SportsPress', 'sportspress' ); ?>
|
||||
</h2>
|
||||
<div class="sp-sitemap">
|
||||
<?php $hierarchy = sp_post_type_hierarchy(); ?>
|
||||
<?php if ( ! isset( $_GET['type'] ) && ! isset( $_GET['taxonomy'] ) ): ?>
|
||||
|
||||
<?php // Overview ?>
|
||||
<?php $primary_post_types = sp_primary_post_types(); $hierarchy = sp_post_type_hierarchy(); ?>
|
||||
|
||||
<ul id="sp-utility">
|
||||
<?php foreach ( $hierarchy as $post_type => $children ): $object = get_post_type_object( $post_type ); ?>
|
||||
<?php if ( ! isset( $_GET['type'] ) && ! isset( $_GET['taxonomy'] ) ): // Overview ?>
|
||||
|
||||
<ul class="sp-utility">
|
||||
<?php foreach ( $primary_post_types as $post_type ): $object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'type' => $post_type ), 'admin.php' ) ) ); ?>"><?php echo $object->labels->name; ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php $taxonomies = sp_taxonomies(); ?>
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $taxonomies ); ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $taxonomies ); ?>">
|
||||
<li class="sp-home"><a class="button disabled"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<?php foreach ( $taxonomies as $taxonomy ): $object = get_taxonomy( $taxonomy ); ?>
|
||||
<?php foreach ( $taxonomies as $taxonomy ): $object = get_taxonomy( $taxonomy ); $post_types = apply_filters( 'sportspress_sitemap_taxonomy_post_types', $object->object_type, $taxonomy ); ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy ), 'admin.php' ) ) ); ?>"><?php echo $object->labels->name; ?></a>
|
||||
<?php $terms = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => 0, 'orderby' => 'slug' ) ); ?>
|
||||
<ul>
|
||||
@@ -25,9 +25,9 @@
|
||||
<?php foreach ( $terms as $term ): ?>
|
||||
<?php $children = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $term->term_id, 'orderby' => 'slug' ) ); ?>
|
||||
<li>
|
||||
<?php if ( ! $children && sizeof ( $object->object_type ) <= 1 ): ?>
|
||||
<?php if ( sizeof( $object->object_type ) ): foreach ( $object->object_type as $post_type ): ?>
|
||||
<a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
<?php if ( ! $children && sizeof ( $post_types ) <= 1 ): ?>
|
||||
<?php if ( sizeof( $post_types ) ): foreach ( $post_types as $post_type ): ?>
|
||||
<a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a>
|
||||
<?php endforeach; endif; ?>
|
||||
<?php else: ?>
|
||||
<a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $term->term_id ), 'admin.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
@@ -37,12 +37,12 @@
|
||||
<ul>
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<li>
|
||||
<?php if ( sizeof ( $object->object_type ) <= 1 ): ?>
|
||||
<?php if ( sizeof( $object->object_type ) ): foreach ( $object->object_type as $post_type ): ?>
|
||||
<a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<?php if ( sizeof( $post_types ) <= 1 ): ?>
|
||||
<?php if ( sizeof( $post_types ) ): foreach ( $post_types as $post_type ): ?>
|
||||
<a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a>
|
||||
<?php endforeach; endif; ?>
|
||||
<?php else: ?>
|
||||
<a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $child->term_id ), 'admin.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<a class="button wp-ui-text-highlight" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $child->term_id ), 'admin.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
@@ -58,11 +58,13 @@
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php elseif ( ! isset( $_GET['type'] ) ): $taxonomy = $_GET['taxonomy']; $taxonomy_object = get_taxonomy( $_GET['taxonomy'] ); ?>
|
||||
<?php elseif ( ! isset( $_GET['type'] ) ): $taxonomy = $_GET['taxonomy']; $taxonomy_object = get_taxonomy( $taxonomy ); ?>
|
||||
|
||||
<?php $post_types = apply_filters( 'sportspress_sitemap_taxonomy_post_types', $taxonomy_object->object_type, $taxonomy ); ?>
|
||||
|
||||
<?php if ( isset( $_GET['term'] ) ): $term = get_term( $_GET['term'], $taxonomy ); // Posts in term ?>
|
||||
|
||||
<ul id="sp-utility">
|
||||
<ul class="sp-utility">
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'taxonomy' => $taxonomy ), 'edit-tags.php' ) ) ); ?>"><?php echo $taxonomy_object->labels->edit_item; ?></a></li>
|
||||
</ul>
|
||||
|
||||
@@ -70,16 +72,16 @@
|
||||
|
||||
<?php if ( $terms ): // Has children ?>
|
||||
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy ), 'admin.php' ) ) ); ?>"><?php echo $taxonomy_object->labels->name; ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $term->name; ?></a></li>
|
||||
<li><a class="button disabled"><?php _e( 'All', 'sportspress' ); ?></a>
|
||||
<ul>
|
||||
<?php if ( sizeof ( $taxonomy_object->object_type ) ): ?>
|
||||
<?php foreach ( $taxonomy_object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php if ( sizeof ( $post_types ) ): ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -91,13 +93,13 @@
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a>
|
||||
|
||||
<?php if ( sizeof ( $taxonomy_object->object_type ) ): // Has associated post types ?>
|
||||
<?php if ( sizeof ( $post_types ) ): // Has associated post types ?>
|
||||
<ul>
|
||||
<?php foreach ( $taxonomy_object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -105,12 +107,12 @@
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php elseif ( sizeof ( $taxonomy_object->object_type ) ): // Has associated post types ?>
|
||||
<?php elseif ( sizeof ( $post_types ) ): // Has associated post types ?>
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $taxonomy_object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -121,16 +123,7 @@
|
||||
|
||||
<?php else: // No children ?>
|
||||
|
||||
<?php
|
||||
$post_types = array();
|
||||
foreach ( $taxonomy_object->object_type as $post_type ):
|
||||
if ( array_key_exists( $post_type, $hierarchy ) ):
|
||||
$post_types[] = $post_type;
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $post_types ); ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $post_types ); ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy ), 'admin.php' ) ) ); ?>"><?php echo $taxonomy_object->labels->name; ?></a></li>
|
||||
<?php if ( $term->parent ): $parent = get_term( $term->parent, $taxonomy ); ?>
|
||||
@@ -140,7 +133,7 @@
|
||||
<?php if ( sizeof ( $taxonomy_object->object_type ) ): ?>
|
||||
<ul>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
@@ -151,45 +144,49 @@
|
||||
<?php else: // Taxonomy archive ?>
|
||||
|
||||
<?php $terms = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => 0, 'orderby' => 'slug' ) ); ?>
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<?php $object = get_taxonomy( $_GET['taxonomy'] ); ?>
|
||||
<ul class="sp-primary col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $object->labels->name; ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $taxonomy_object->labels->name; ?></a></li>
|
||||
<?php if ( $terms ): ?>
|
||||
<?php foreach ( $terms as $term ): ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $term->term_id ), 'admin.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
<li>
|
||||
<?php if ( sizeof( $post_types ) <= 1 ): $post_type = reset( $post_types ); ?>
|
||||
<a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?><span class="dashicons dashicons-list-view"></span></a>
|
||||
<?php else: ?>
|
||||
<a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $term->term_id ), 'admin.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
<?php endif; ?>
|
||||
<?php $children = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $term->term_id, 'orderby' => 'slug' ) ); ?>
|
||||
<ul>
|
||||
|
||||
<?php if ( $children ): // Has children ?>
|
||||
|
||||
<?php if ( sizeof( $object->object_type ) <= 1 ): ?>
|
||||
<?php if ( sizeof( $post_types ) <= 1 ): ?>
|
||||
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<?php if ( sizeof ( $object->object_type ) ): ?>
|
||||
<?php foreach ( $object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php if ( sizeof ( $post_types ) ): ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ( sizeof ( $taxonomy_object->object_type ) ): ?>
|
||||
<?php foreach ( $taxonomy_object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php if ( sizeof ( $post_types ) ): ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'taxonomy' => $taxonomy, 'term' => $child->term_id ), 'admin.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<?php if ( sizeof ( $object->object_type ) ): ?>
|
||||
<?php if ( sizeof ( $post_types ) ): ?>
|
||||
<ul>
|
||||
<?php foreach ( $object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
@@ -199,10 +196,10 @@
|
||||
|
||||
<?php else: // No children ?>
|
||||
|
||||
<?php if ( sizeof ( $object->object_type ) ): ?>
|
||||
<?php foreach ( $object->object_type as $post_type ): if ( array_key_exists( $post_type, $hierarchy ) ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php endif; endforeach; ?>
|
||||
<?php if ( sizeof ( $post_types ) > 1 ): ?>
|
||||
<?php foreach ( $post_types as $post_type ): $post_object = get_post_type_object( $post_type ); ?>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -211,7 +208,7 @@
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'taxonomy' => $taxonomy ), 'edit-tags.php' ) ) ); ?>"><?php echo $taxonomy_object->labels->add_new_item; ?></a></li>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'taxonomy' => $taxonomy ), 'edit-tags.php' ) ) ); ?>"><?php echo $taxonomy_object->labels->add_new_item; ?><span class="dashicons dashicons-plus"></span></a></li>
|
||||
</ul>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -223,22 +220,22 @@
|
||||
$taxonomies = get_object_taxonomies( $post_type, 'objects' );
|
||||
?>
|
||||
|
||||
<ul id="sp-utility">
|
||||
<ul class="sp-utility">
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type ), 'edit.php' ) ) ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a></li>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type ), 'post-new.php' ) ) ); ?>"><?php echo $post_object->labels->add_new_item; ?></a></li>
|
||||
</ul>
|
||||
|
||||
<?php if ( sizeof( $taxonomies ) || sizeof( sp_array_value( $hierarchy, $post_type ) ) ): // Display taxonomies ?>
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $taxonomies ) + sizeof( sp_array_value( $hierarchy, $post_type ) ); ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $taxonomies ) + sizeof( sp_array_value( $hierarchy, $post_type ) ); ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php foreach ( sp_array_value( $hierarchy, $post_type ) as $secondary_post_type ): $secondary_post_object = get_post_type_object( $secondary_post_type );?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $secondary_post_type ), 'edit.php' ) ) ); ?>"><?php echo $secondary_post_object->labels->name; ?></a>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $secondary_post_type ), 'edit.php' ) ) ); ?>"><?php echo $secondary_post_object->labels->name; ?><span class="dashicons dashicons-list-view"></span></a>
|
||||
<?php $posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => $secondary_post_type ) ); ?>
|
||||
<?php if ( $posts ): ?>
|
||||
<ul>
|
||||
<?php foreach ( $posts as $post ): ?>
|
||||
<li><a class="button" href="<?php echo esc_url( get_edit_post_link( $post->ID ) ); ?>"><?php echo $post->post_title; ?></a></li>
|
||||
<li><a class="button action" href="<?php echo esc_url( get_edit_post_link( $post->ID ) ); ?>"><?php echo $post->post_title; ?><span class="dashicons dashicons-edit wp-ui-text-highlight"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
@@ -250,14 +247,14 @@
|
||||
<?php if ( $terms ): ?>
|
||||
<ul>
|
||||
<?php foreach ( $terms as $term ): ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a>
|
||||
<?php $children = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $term->term_id, 'orderby' => 'slug' ) ); ?>
|
||||
|
||||
<?php if ( $children ): // Has children ?>
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<li><a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?></a></li>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
@@ -274,12 +271,12 @@
|
||||
<?php else: // Display posts ?>
|
||||
|
||||
<?php $posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => $post_type ) ); ?>
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $posts ); ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $posts ); ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<?php if ( $posts ): ?>
|
||||
<?php foreach ( $posts as $post ): ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( get_edit_post_link( $post->ID ) ); ?>"><?php echo $post->post_title; ?></a></li>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( get_edit_post_link( $post->ID ) ); ?>"><?php echo $post->post_title; ?><span class="dashicons dashicons-edit"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<li><a class="button disabled"><?php _e( 'No results found.', 'sportspress' ); ?></a></li>
|
||||
@@ -294,26 +291,26 @@
|
||||
|
||||
<?php $terms = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => 0, 'orderby' => 'slug' ) ); ?>
|
||||
|
||||
<ul id="sp-primary" class="col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<ul class="sp-primary col<?php echo sizeof( $terms ) + 1; ?>">
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview' ), 'admin.php' ) ) ); ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a></li>
|
||||
<li class="sp-breadcrumb"><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-overview', 'type' => $post_type ), 'admin.php' ) ) ); ?>"><?php echo $post_object->labels->name; ?></a></li>
|
||||
<li class="sp-home"><a class="button disabled"><?php echo $taxonomy_object->labels->name; ?></a></li>
|
||||
|
||||
<?php if ( $terms ): foreach ( $terms as $term ): ?>
|
||||
<li><a class="button button-primary" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?></a>
|
||||
<li><a class="button button-primary action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $term->slug ), 'edit.php' ) ) ); ?>"><?php echo $term->name; ?><span class="dashicons dashicons-list-view"></span></a>
|
||||
<?php $children = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $term->term_id, 'orderby' => 'slug' ) ); ?>
|
||||
|
||||
<?php if ( $children ): // Has children ?>
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $children as $child ): ?>
|
||||
<li><a class="button" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?></a>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $child->slug ), 'edit.php' ) ) ); ?>"><?php echo $child->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a>
|
||||
<?php $grandchildren = get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $child->term_id, 'orderby' => 'slug' ) ); ?>
|
||||
|
||||
<?php if ( $grandchildren ): // Has grandchildren ?>
|
||||
<ul>
|
||||
<?php foreach ( $grandchildren as $grandchild ): ?>
|
||||
<li><a class="button wp-ui-text-notification" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $grandchild->slug ), 'edit.php' ) ) ); ?>"><?php echo $grandchild->name; ?></a></li>
|
||||
<li><a class="button action" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => $post_type, $taxonomy => $grandchild->slug ), 'edit.php' ) ) ); ?>"><?php echo $grandchild->name; ?><span class="dashicons dashicons-list-view wp-ui-text-notification"></span></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -35,22 +35,14 @@ if ( ! function_exists( 'sp_post_types' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_post_type_hierarchy - Returns array of SP primary post types
|
||||
* sp_primary_post_types - Returns array of SP primary post types
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists( 'sp_post_type_hierarchy' ) ) {
|
||||
function sp_post_type_hierarchy() {
|
||||
return apply_filters(
|
||||
'sportspress_post_type_hierarchy',
|
||||
array(
|
||||
'sp_event' => array( 'sp_calendar' ),
|
||||
'sp_team' => array( 'sp_table' ),
|
||||
'sp_player' => array( 'sp_list' ),
|
||||
'sp_staff' => array()
|
||||
)
|
||||
);
|
||||
if ( ! function_exists( 'sp_primary_post_types' ) ) {
|
||||
function sp_primary_post_types() {
|
||||
return apply_filters( 'sportspress_primary_post_types', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +54,7 @@ if ( ! function_exists( 'sp_post_type_hierarchy' ) ) {
|
||||
*/
|
||||
if ( ! function_exists( 'sp_secondary_post_types' ) ) {
|
||||
function sp_secondary_post_types() {
|
||||
return apply_filters( 'sportspress_secondary_post_types', array( 'sp_calendar', 'sp_table', 'sp_list' ) );
|
||||
return apply_filters( 'sportspress_secondary_post_types', array_diff( sp_post_types(), sp_primary_post_types() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +82,26 @@ if ( ! function_exists( 'sp_taxonomies' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_post_type_hierarchy - Returns array of SP primary post types
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists( 'sp_post_type_hierarchy' ) ) {
|
||||
function sp_post_type_hierarchy() {
|
||||
return apply_filters(
|
||||
'sportspress_post_type_hierarchy',
|
||||
array(
|
||||
'sp_event' => array( 'sp_calendar' ),
|
||||
'sp_team' => array( 'sp_table' ),
|
||||
'sp_player' => array( 'sp_list' ),
|
||||
'sp_staff' => array()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* is_sp_post_type - Returns true if post is SportsPress post type
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user