Making WordPress.org


Ignore:
Timestamp:
03/22/2017 07:23:39 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Support Theme: Add "Search this forum" form to plugin- and theme-specific views.

Use the plugin or theme name as intext parameter in the search query passed to Google.

See #7.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r5159 r5163  
    259259
    260260    return in_array( $view_id, wporg_support_get_compat_views() );
     261}
     262
     263/**
     264 * Get current plugin or theme object in plugin- or theme-specific views.
     265 *
     266 * @return object|null Plugin or theme object on success, null on failure.
     267 */
     268function wporg_support_get_compat_object() {
     269    if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) {
     270        return null;
     271    }
     272
     273    $object          = null;
     274    $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance();
     275
     276    if ( ! empty( $plugin_instance->plugins->plugin ) ) {
     277        $object = $plugin_instance->plugins->plugin;
     278
     279        /* translators: %s: link to plugin support or review forum */
     280        $object->prefixed_title = sprintf( __( 'Plugin: %s', 'wporg-forums' ), $object->post_title );
     281        $object->type           = 'plugin';
     282    } elseif ( ! empty( $plugin_instance->themes->theme ) ) {
     283        $object = $plugin_instance->themes->theme;
     284
     285        /* translators: %s: link to theme support or review forum */
     286        $object->prefixed_title = sprintf( __( 'Theme: %s', 'wporg-forums' ), $object->post_title );
     287        $object->type           = 'theme';
     288    }
     289
     290    return $object;
    261291}
    262292
Note: See TracChangeset for help on using the changeset viewer.