Skip to content

Commit

Permalink
Prevent issues with ACF time picker (#111)
Browse files Browse the repository at this point in the history
* Prevent undefined index notice.

Signed-off-by: Mark Chouinard <[email protected]>

* Use post title for tokens

$title undefined

Signed-off-by: Mark Chouinard <[email protected]>

* Only enqueue assets for tsml_meeting.

Signed-off-by: Mark Chouinard <[email protected]>

* Change tsml_assets hook so we can check post type

Signed-off-by: Mark Chouinard <[email protected]>

* Check $post_type is set.

Signed-off-by: Mark Chouinard <[email protected]>

* Quiet PHP notice with @ instead of not rendering when not set

Signed-off-by: Mark Chouinard <[email protected]>
  • Loading branch information
machouinard authored Apr 24, 2020
1 parent 1e4b647 commit a611e4d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion includes/admin_meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ function tsml_move_author_meta_box() {
add_meta_box('authordiv', __('Editor', '12-step-meeting-list'), 'post_author_meta_box', 'tsml_meeting', 'side', 'default');
}

// Hook tsml_assets where we can check $post_type
add_action( 'admin_print_scripts-post.php', 'tsml_assets' );
add_action( 'admin_print_scripts-post-new.php', 'tsml_assets' );

//edit page
add_action('admin_init', 'tsml_admin_init');
function tsml_admin_init() {

tsml_assets();
// tsml_assets();

This comment has been minimized.

Copy link
@wokat

wokat May 2, 2020

Contributor

@machouinard @tech2serve This breaks styles on at least the location detail, I believe...

This comment has been minimized.

Copy link
@wokat

wokat May 2, 2020

Contributor

Ah, nevermind, missed the context..


add_meta_box('info', __('Meeting Information', '12-step-meeting-list'), 'tsml_meeting_box', 'tsml_meeting', 'normal', 'low');

Expand Down
2 changes: 1 addition & 1 deletion includes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function tsml_ajax_groups() {
'contact_3_phone' => @$group_custom['contact_3_phone'][0],
'last_contact' => @$group_custom['last_contact'][0],
'notes' => $group->post_content,
'tokens' => tsml_string_tokens($title),
'tokens' => tsml_string_tokens($group->post_title),
'type' => 'group',
);
}
Expand Down
6 changes: 5 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ function tsml_alert($message, $type='success') {
//function: enqueue assets for public or admin page
//used: in templates and on admin_edit.php
function tsml_assets() {
global $tsml_street_only, $tsml_programs, $tsml_strings, $tsml_program, $tsml_google_maps_key, $tsml_mapbox_key, $tsml_google_overrides, $tsml_distance_units, $tsml_defaults, $tsml_language, $tsml_columns, $tsml_nonce;
global $post_type, $tsml_street_only, $tsml_programs, $tsml_strings, $tsml_program, $tsml_google_maps_key, $tsml_mapbox_key, $tsml_google_overrides, $tsml_distance_units, $tsml_defaults, $tsml_language, $tsml_columns, $tsml_nonce;

// TODO: verify this doesn't cause any other issues
if ( isset( $post_type ) && 'tsml_meeting' !== $post_type ) {

This comment has been minimized.

Copy link
@wokat

wokat May 2, 2020

Contributor

@machouinard breaks styles on at least location detail.. what should this achieve?

return;
}
//google maps api
if ($tsml_google_maps_key) {
wp_enqueue_script('google_maps_api', '//maps.googleapis.com/maps/api/js?key=' . $tsml_google_maps_key);
Expand Down
2 changes: 1 addition & 1 deletion templates/archive-meetings.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ function tsml_body_class($classes)
break;

case 'distance': ?>
<td class="distance" data-sort="<?php echo $meeting['distance'] ?>"><?php echo $meeting['distance'] ?></td>
<td class="distance" data-sort="<?php echo @$meeting['distance'] ?>"><?php echo $meeting['distance'] ?></td>

This comment has been minimized.

Copy link
@wokat

wokat May 2, 2020

Contributor

@machouinard Incomplete: I believe the @ error suppression only works on the expression it precedes...

<?php
break;

Expand Down

0 comments on commit a611e4d

Please sign in to comment.