Making WordPress.org


Ignore:
Timestamp:
05/20/2016 05:16:55 PM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Paint roller work is done, let's bring out the brushes.

Props mapk, hugobaeta.
See #1719.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins
Files:
2 edited

Legend:

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

    • Property svn:ignore set to
      node_modules
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php

    r3009 r3193  
    11<?php
     2/**
     3 * Plugin Directory functions and definitions.
     4 *
     5 * @link https://developer.wordpress.org/themes/basics/theme-functions/
     6 *
     7 * @package WordPressdotorg\Plugin_Directory\Theme
     8 */
     9
    210namespace WordPressdotorg\Plugin_Directory\Theme;
     11use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    312
    413/**
    5  * WP.org Themes' functions and definitions.
     14 * Sets up theme defaults and registers support for various WordPress features.
    615 *
    7  * @package wporg-plugins
     16 * Note that this function is hooked into the after_setup_theme hook, which
     17 * runs before the init hook. The init hook is too late for some features, such
     18 * as indicating support for post thumbnails.
    819 */
     20function setup() {
    921
    10 function wporg_plugins_setup() {
    11     global $themes_allowedtags;
     22    // Add default posts and comments RSS feed links to head.
     23    add_theme_support( 'automatic-feed-links' );
    1224
    13     load_theme_textdomain( 'wporg-plugins' );
     25    // This theme uses wp_nav_menu() in one location.
     26    register_nav_menus( array(
     27        'primary' => esc_html__( 'Primary', 'wporg-plugins' ),
     28    ) );
    1429
    15     include_once __DIR__ . '/template-tags.php';
     30    /*
     31     * Switch default core markup for search form, comment form, and comments
     32     * to output valid HTML5.
     33     */
     34    add_theme_support( 'html5', array(
     35        'search-form',
     36        'comment-form',
     37        'comment-list',
     38        'gallery',
     39        'caption',
     40    ) );
    1641
    17     add_theme_support( 'html5', array(
    18         'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
     42    // Set up the WordPress core custom background feature.
     43    add_theme_support( 'custom-background', apply_filters( 'wporg_plugins_custom_background_args', array(
     44        'default-color' => 'ffffff',
     45        'default-image' => '',
     46    ) ) );
     47}
     48add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' );
     49
     50/**
     51 * Set the content width in pixels, based on the theme's design and stylesheet.
     52 *
     53 * Priority 0 to make it available to lower priority callbacks.
     54 *
     55 * @global int $content_width
     56 */
     57function content_width() {
     58    $GLOBALS['content_width'] = apply_filters( 'wporg_plugins_content_width', 640 );
     59}
     60add_action( 'after_setup_theme', __NAMESPACE__ . '\content_width', 0 );
     61
     62/**
     63 * Register widget area.
     64 *
     65 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
     66 */
     67function widgets_init() {
     68
     69    register_sidebar( array(
     70        'name'          => esc_html__( 'Front Page Sidebar', 'wporg-plugins' ),
     71        'id'            => 'sidebar-front-page',
     72        'description'   => esc_html__( 'Appears on the bottom of the front page.', 'wporg-plugins' ),
     73        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     74        'after_widget'  => '</div>',
     75        'before_title'  => '<h4 class="widget-title">',
     76        'after_title'   => '</h4>',
    1977    ) );
    2078
    2179    register_sidebar( array(
    22         'name'          => 'Single Plugin View Sidebar',
    23         'id'            => 'single-plugin-sidebar',
     80        'name'          => esc_html__( 'Sidebar', 'wporg-plugins' ),
     81        'id'            => 'sidebar-1',
     82        'description'   => esc_html__( 'Add widgets here.', 'wporg-plugins' ),
    2483        'before_widget' => '<div id="%1$s" class="widget %2$s">',
    2584        'after_widget'  => '</div>',
     85        'before_title'  => '<h3 class="widget-title">',
     86        'after_title'   => '</h3>',
    2687    ) );
    27 
    28     // No need for canonical lookups
    29     remove_action( 'template_redirect', __NAMESPACE__ . '\wp_old_slug_redirect' );
    3088}
    31 add_action( 'after_setup_theme', __NAMESPACE__ . '\wporg_plugins_setup' );
     89add_action( 'widgets_init', __NAMESPACE__ . '\widgets_init' );
    3290
    3391/**
    3492 * Enqueue scripts and styles.
    3593 */
    36 function wporg_plugins_scripts() {
    37     $script_debug = true || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
    38     $suffix       = $script_debug ? '' : '.min';
     94function scripts() {
     95    wp_enqueue_style( 'wporg-plugins-style', get_template_directory_uri() . '/css/style.css' );
    3996
    40     // Concatenates core scripts when possible.
    41     if ( ! $script_debug ) {
    42         $GLOBALS['concatenate_scripts'] = true;
    43     }
     97    wp_enqueue_script( 'wporg-plugins-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
    4498
    45     $stylesheet = get_stylesheet_uri();
    46     if ( is_rtl() ) {
    47 //      $stylesheet = str_replace( '.css', '-rtl.css', $stylesheet ); // TODO, not being generated yet
    48     }
    49     wp_enqueue_style( 'wporg-plugins', $stylesheet, array(), time() );
     99    wp_enqueue_script( 'wporg-plugins-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
     100}
     101add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\scripts' );
    50102
    51     // No Jetpack styles needed.
    52     add_filter( 'jetpack_implode_frontend_css', '__return_false' );
     103/**
     104 * Don't split plugin content in the front-end.
     105 */
     106function content() {
     107    remove_filter( 'the_content', array( Plugin_Directory::instance(), 'filter_post_content_to_correct_page' ), 1 );
    53108}
    54 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\wporg_plugins_scripts' );
     109add_action( 'template_redirect', __NAMESPACE__ . '\content' );
    55110
    56 function wporg_plugins_body_class( $classes ) {
    57     $classes[] = 'plugins-directory';
    58     return $classes;
    59 }
    60 add_filter( 'body_class', __NAMESPACE__ . '\wporg_plugins_body_class' );
     111/**
     112 * Custom template tags for this theme.
     113 */
     114require get_template_directory() . '/inc/template-tags.php';
     115
     116/**
     117 * Customizer additions.
     118 */
     119require get_template_directory() . '/inc/customizer.php';
Note: See TracChangeset for help on using the changeset viewer.