WordPress.org

Making WordPress.org


Ignore:
Timestamp:
12/11/2014 07:39:05 PM (7 years ago)
Author:
obenland
Message:

WP.org Themes: Revamped modal layout and responsive styles.

See https://wordpress.slack.com/archives/meta/p1418066438000006
See #745.

File:
1 edited

Legend:

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

    r1021 r1034  
    11<?php
     2
    23/**
    34 * WP.org Themes' functions and definitions.
     
    1516
    1617function wporg_themes_setup() {
     18    global $themes_allowedtags, $theme_field_defaults;
     19
    1720//  load_theme_textdomain( 'wporg-themes', get_template_directory() . '/languages' );
    1821    add_theme_support( 'automatic-feed-links' );
     
    2225        'primary' => __( 'Primary Menu', 'wporg-themes' ),
    2326    ) );
    24    
     27
    2528    add_theme_support( 'html5', array(
    2629        'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
    2730    ) );
     31
     32    $themes_allowedtags = array(
     33        'a'       => array( 'href' => array(), 'title' => array(), 'target' => array() ),
     34        'abbr'    => array( 'title' => array() ),
     35        'acronym' => array( 'title' => array() ),
     36        'code'    => array(),
     37        'pre'     => array(),
     38        'em'      => array(),
     39        'strong'  => array(),
     40        'div'     => array(),
     41        'p'       => array(),
     42        'ul'      => array(),
     43        'ol'      => array(),
     44        'li'      => array(),
     45        'h1'      => array(),
     46        'h2'      => array(),
     47        'h3'      => array(),
     48        'h4'      => array(),
     49        'h5'      => array(),
     50        'h6'      => array(),
     51        'img'     => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
     52    );
     53
     54    $theme_field_defaults = array(
     55        'description'  => true,
     56        'sections'     => false,
     57        'tested'       => true,
     58        'requires'     => true,
     59        'rating'       => true,
     60        'downloaded'   => true,
     61        'downloadlink' => true,
     62        'last_updated' => true,
     63        'homepage'     => true,
     64        'tags'         => true,
     65        'num_ratings'  => true,
     66    );
    2867}
    2968add_action( 'after_setup_theme', 'wporg_themes_setup' );
     
    4786        'themes'   => false,
    4887        'settings' => array(
     88            'isMobile'   => wp_is_mobile(),
    4989            'isInstall'  => true,
    5090            'canInstall' => false,
     
    70110
    71111/**
     112 * @param  object $args
     113 * @param  string $action
     114 *
     115 * @return array
     116 */
     117function wporg_themes_api_args( $args, $action ) {
     118    if ( 'query_themes' == $action ) {
     119        $args->per_page = 30;
     120        $args->fields['parent'] = true;
     121        $args->fields['tags']   = true;
     122    }
     123
     124    return $args;
     125}
     126add_filter( 'themes_api_args', 'wporg_themes_api_args', 10, 2 );
     127
     128/**
    72129 * Removes Core's built-in query-themes handler, so we can safely add ours later on.
    73130 */
     
    113170add_action( 'wp_ajax_nopriv_query-themes', 'wporg_themes_query_themes' );
    114171
     172function wporg_themes_theme_info() {
     173    global $themes_allowedtags;
     174
     175    $args  = wp_unslash( $_REQUEST );
     176    $theme = themes_api( 'theme_information', array( 'slug' => $args['slug'] ) );
     177
     178    if ( is_wp_error( $theme ) ) {
     179        wp_send_json_error();
     180    }
     181
     182    $theme->name        = wp_kses( $theme->name,        $themes_allowedtags );
     183    $theme->author      = wp_kses( $theme->author,      $themes_allowedtags );
     184    $theme->version     = wp_kses( $theme->version,     $themes_allowedtags );
     185    $theme->description = wp_kses( $theme->description, $themes_allowedtags );
     186    $theme->num_ratings = number_format_i18n( $theme->num_ratings );
     187    $theme->preview_url = set_url_scheme( $theme->preview_url );
     188
     189    wp_send_json_success( $theme );
     190}
     191add_action( 'wp_ajax_theme-info',        'wporg_themes_theme_info' );
     192add_action( 'wp_ajax_nopriv_theme-info', 'wporg_themes_theme_info' );
     193
    115194/**
    116195 * Include view templates in the footer.
Note: See TracChangeset for help on using the changeset viewer.