-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 305: Add action link to edit Stream Settings #317
Conversation
This reverts commit 62f94dc.
That one was tricky! |
@@ -217,14 +218,20 @@ public static function action_links( $links, $record ) { | |||
array( 2 => $submenu_slug ) | |||
); | |||
|
|||
if ( ! empty( $found_submenus ) ) { | |||
if ( ! empty( $found_submenus ) || $record->context === 'wp_stream' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powelski Yoda style needed here.
cf. http://make.wordpress.org/core/handbook/coding-standards/php/#yoda-conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 45fad36
@powelski Sorry, this doesn't appear to be working for me. There is no action link displayed. |
@fjarrett Please make sure once again - I checked it again now and it works fine for me. What needs to be noticed, settings of Stream will be highlighted (after clicking action link) since this update. Previously, we saved only option name in meta, which is |
@powelski I just still can't see the action link appearing at all here. |
Conflicts: connectors/settings.php
$field_name = get_stream_meta( $record->ID, 'option', true ); | ||
$text = sprintf( __( 'Edit %s Settings', 'stream' ), $context_labels[$record->context] ); | ||
|
||
$url = apply_filters( 'wp_stream_action_link_url', admin_url( $submenu_slug ), $record ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fjarrett I checked on my updated environment and it didn't work for me to. I applied one small fix - now it should work for you. |
In addition, capabilities required to view particular settings page will automatically be checked before displaying links - this will occur for wp_stream capability as well and any other capability assigned to any menu page in future. |
@powelski Great! This is working nicely for me. Now we have to ensure backwards compatibility with past Stream Settings records, can this be achieved with an upgrade routine? |
@powelski I have this in the master branch and now the feature is not working. The action link will not display. |
@fjarrett Are you sure you have proper capabilities? Make sure you can access Stream Settings page in standard way. |
@powelski Yes, I'm sure of it. That's how I'm creating new records is by accessing the Stream > Settings page and making changes. |
@powelski OK I figured it out. It seems that dd8df71 and ff88ed8 were both overwritten by a1bc6aa in Not sure what to do here myself, I think you will need to look into it and make the correct changes. Please do so directly in the I think this is the code that is needed: if ( ! empty( $found_submenus ) || 'wp_stream' === $record->context ) {
$target_submenu = array_pop( $found_submenus );
if ( ! is_array( $target_submenu ) || current_user_can( $target_submenu[1] ) ) {
$text = sprintf( __( 'Edit %s Settings', 'stream' ), $context_labels[ $record->context ] );
$url = apply_filters( 'wp_stream_action_link_url', admin_url( $submenu_slug ), $record );
$field_name = get_stream_meta( $record->ID, 'option_key', true );
if ( '' === $field_name ) {
$field_name = get_stream_meta( $record->ID, 'option', true );
}
if ( '' !== $field_name ) {
$url = sprintf( '%s#%s%s', rtrim( preg_replace( '/#.*/', '', $url ), '/' ), self::HIGHLIGHT_FIELD_URL_HASH_PREFIX, $field_name );
}
$links[ $text ] = $url;
}
} |
Fix #305