Avoid loading ALL teams at the first step of creating a League Table

This commit is contained in:
savvasha
2019-02-08 13:03:30 +02:00
parent af2c537e4c
commit 5020512242

View File

@@ -19,12 +19,17 @@ class SP_Meta_Box_Table_Data {
* Output the metabox * Output the metabox
*/ */
public static function output( $post ) { public static function output( $post ) {
global $pagenow;
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_table' == get_post_type() ) {
self::table( );
}else{
$table = new SP_League_Table( $post ); $table = new SP_League_Table( $post );
list( $columns, $usecolumns, $data, $placeholders, $merged ) = $table->data( true ); list( $columns, $usecolumns, $data, $placeholders, $merged ) = $table->data( true );
$adjustments = $table->adjustments; $adjustments = $table->adjustments;
$highlight = get_post_meta( $table->ID, 'sp_highlight', true ); $highlight = get_post_meta( $table->ID, 'sp_highlight', true );
self::table( $table->ID, $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight ); self::table( $table->ID, $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight );
} }
}
/** /**
* Save meta box data * Save meta box data
@@ -39,7 +44,7 @@ class SP_Meta_Box_Table_Data {
/** /**
* Admin edit table * Admin edit table
*/ */
public static function table( $id, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) { public static function table( $id = 0, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) {
if ( is_array( $usecolumns ) ) if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns ); $usecolumns = array_filter( $usecolumns );