Forum Replies Created

Viewing 15 replies - 16 through 30 (of 35 total)
  • Maybe something is wrong in this fix? Because in my case it worked in the past.

    https://github.com/ThemeBoy/SportsPress/commit/201a7ccc9edf35a3374b86173d10b912ff8360b6

    I can confirm the first issue.

    This is my schedule: https://eishockey-arena.de/blog/calendar/spielplan-20162017/

    The first match is published and link correctly to https://eishockey-arena.de/blog/event/9228/

    But the second match, which is in the future links to https://eishockey-arena.de/event/9231/ which is wrong because there is /blog/ missing between the root url and event

    • This reply was modified 8 years, 4 months ago by sagund07.
    Thread Starter sagund07

    (@sagund07)

    Hey,

    already tried this. The problem only occurs if I mix up offense and defense stats in the calculation.

    If I use “eventsplayed” – “games played as a goalie” in the defense section it works properly. It only messes up when I try to calculate an offense stat by using a defense stat.

    Some other examples for testing purposes
    “fieldname”(field set as offense, defense or both categories)

    “any offense field”(offense) = “eventsplayed”(both) + “any defense stat”(defense) the result is 0 => incorrect

    “any defense field”(defense) = “eventsplayed”(both) + “any defense stat”(defense) the result is correct

    BUT VICE VERSA
    “any defense field”(defense) = “eventsplayed”(both) + “any offense stat”(offense) the result is correct => the problem only occurs in the offense section. In defense I can mix up offense and defense stats.

    Thread Starter sagund07

    (@sagund07)

    Update 2.1.2 fixed it ??

    Thread Starter sagund07

    (@sagund07)

    @rochesterj Any news on this one?

    • This reply was modified 8 years, 5 months ago by sagund07.
    • This reply was modified 8 years, 5 months ago by sagund07.
    Thread Starter sagund07

    (@sagund07)

    Sure.

    These are my Box Score Settings in the Settings -> Events Section

    View post on imgur.com

    And when editing an event I can select the single columns, which I want to show on the specific events page.

    View post on imgur.com

    But when saving an event, the selected columns won’t be saved. Instead all columns will be “unchecked” again and on the events frontend page still all columns will be displayed and not only the ones I want to show.

    I hope it is easier to understand now ??

    Hey,

    the problem is the separation of player performance and player statistics. On player profile pages the first columns are always the player performance columns followed by the player statistics columns.

    I handled it by hiding all player performance columns and adding those columns to the player statistics.

    Example:

    Hide all Player performance columns (change visibility):
    goals
    redcards
    yellowcards

    Add the same columns to Player Statistic and adjust the order:
    GP (equation = eventsplayed)
    *ADD G (equation = goals)
    *ADD Red (equation = redcards)
    *ADD Yellow (equation = yellowcards)

    And so on.

    • This reply was modified 8 years, 5 months ago by sagund07.
    Thread Starter sagund07

    (@sagund07)

    Okay I fixed it myself. Maybe you can take my fix for next updates.

    File: includes/api/class-sp-rest-api.php

    Added code in line 153

    register_rest_field( 'sp_event',
    	'offense',
    	array(
    		'get_callback'    => 'SP_REST_API::get_post_meta_recursive',
    		'update_callback' => 'SP_REST_API::update_post_meta_recursive',
    		'schema'          => array(
    			'description'     => __( 'Offense', 'sportspress' ),
    			'type'            => 'array',
    			'context'         => array( 'view', 'edit' ),
    			'arg_options'     => array(
    				'sanitize_callback' => 'rest_sanitize_request_arg',
    			),
    		),
    	)
    );
    		
    register_rest_field( 'sp_event',
    	'defense',
    	array(
    		'get_callback'    => 'SP_REST_API::get_post_meta_recursive',
    		'update_callback' => 'SP_REST_API::update_post_meta_recursive',
    		'schema'          => array(
    			'description'     => __( 'Defense', 'sportspress' ),
    			'type'            => 'array',
    			'context'         => array( 'view', 'edit' ),
    			'arg_options'     => array(
    				'sanitize_callback' => 'rest_sanitize_request_arg',
    			),
    		),
    	)
    );

    and in line 759

    'offense' => 'sp_offense',
    'defense' => 'sp_defense',
    • This reply was modified 8 years, 5 months ago by sagund07.
    • This reply was modified 8 years, 5 months ago by sagund07.
    Thread Starter sagund07

    (@sagund07)

    I’ve got another question.

    Is it intended that the “events” scheme in wp-json/sportspress/v2/teams/teamid contains all events of a league and not only the events of the specific team?

    Maybe an example for better understanding:

    I have four teams

    a) Test1 with the ID 1111
    b) Test2 with the ID 1112
    c) Test3 with the ID 1113
    d) Test4 with the ID 1114

    and two events

    1) Test1 vs Test2 ID: 2221
    2) Test3 vs Test4 ID: 2222

    When I call wp-json/sportspress/v2/teams/1111 (which should give me the data of Test1) the “events” scheme contains the events 2221 (correctly) AND 2222 which seems to be not correct, because Test1 is not part of event 2222. Could it be a bug or do I have an error in reasoning?

    Thread Starter sagund07

    (@sagund07)

    Thanks!

    Is there a list of all available (sportspress) filters?
    I can’t find them in the guide. I only found the available scheme.

    The format depends on your wordpress settings.

    For 24h format you have to set the time format in the wordpress settings to G:i

    If you do not want to change your wordpress settings I can have a look at the code if I can adjust it manually.

    Edit:

    Just replace the get_option( ‘time_format’ ) with ‘G:i’

    The new code is

    .date_i18n(get_option( 'date_format' ) . ' ' . 'G:i', strtotime( $tourny->{ 'start-at' } ) + ( get_option( 'gmt_offset' ) * 3600 )).'<br />'

    Not without modification.

    Open up class-challonge-widget.php in the challonge plugin folder.

    Go to line 210 and add the following code after line 210:

    .date_i18n(get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),strtotime( $tourny->{ 'start-at' } )+ ( get_option( 'gmt_offset' ) * 3600 )).'<br />'

    After that the code should look like this:

    $ret .= '<br /><span class="challonge-info">'
        .date_i18n(get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),strtotime( $tourny->{ 'start-at' } )+ ( get_option( 'gmt_offset' ) * 3600 )).'<br />'
        . esc_html( $lnk->participants_count ) . '/' . $lnk->signup_cap
        . ' | ' . esc_html( ucwords( str_replace( '_', ' ', $tourny->state ) ) )
      . '</span>';
    $ret .= '</li>';

    Bear in mind that this modification will be overwritten after a plugin update.

    Ok I found the real reason. The problem is the
    $pmisc[0] == $this->oLnk->usrkey

    In php any string converted to a boolean will be “true”. The == operator checks if the value of both sides equals each other regardless of the type. In this case we compare any string with the boolean true, which always will be true. To bypass this problem we can use === which works almost like == just with respect to the type. So besides the value both types must match each other, too.

    By changing the code to $pmisc[0] === $this->oLnk->usrkey the elseif statement wont be exceuted if the user is not logged in.

    Source: https://stackoverflow.com/questions/80646/how-do-the-php-equality-double-equals-and-identity-triple-equals-comp

    I fixed it by adding an additional elseif statement. Would be nice if you can have a look at it.

    if ( empty( $pmisc[0] ) ) {
        $this->oLnk->all_have_misc = false;
    } elseif ( $this->oLnk->usrkey === true ){
        $this->oLnk->signed_up = false;
    } elseif ( $pmisc[0] == $this->oLnk->usrkey ) {
        $this->oLnk->signed_up = true;
        $this->oLnk->participant_id = (int) $participant->id;
        $this->oLnk->misc = $pmisc;
        $this->oLnk->reported_scores = ( ! empty( $pmisc[1] ) && in_array( $pmisc[1], array( 'w', 'l', 't' ) ) );
    }

    I found out that $this->oLnk->signed_up in class-challonge-ajax.php has the wrong value. It must be “false” to show the signup button but in the following code it gets set to “true”.

    The error must be in $pmisc[0] because elseif statement is executed in this if clause

    if ( empty( $pmisc[0] ) ) {
        $this->oLnk->all_have_misc = false;
    } elseif ( $pmisc[0] == $this->oLnk->usrkey ) {
        $this->oLnk->signed_up = true;
        $this->oLnk->participant_id = (int) $participant->id;
        $this->oLnk->misc = $pmisc;
        $this->oLnk->reported_scores = ( ! empty( $pmisc[1] ) && in_array( $pmisc[1], array( 'w', 'l', 't' ) ) );
    }
Viewing 15 replies - 16 through 30 (of 35 total)