Plugin Directory

Changeset 893871


Ignore:
Timestamp:
04/15/2014 10:12:24 PM (12 years ago)
Author:
dtelepathy
Message:

Committing after merging in the jsonp branch.

Location:
filament/branches/redesign
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • filament/branches/redesign

  • filament/branches/redesign/filament.php

    r893849 r893871  
    44Plugin URI: http://filament.io/
    55Description: Install & manage all your Web apps from a single place. Connect your website to Filament with this plugin, and never bug your developers again!
    6 Version: 1.1.0
     6Version: 1.2.0
    77Author: dtelepathy
    88Author URI: http://www.dtelepathy.com/
     
    3131    var $slug = "filament";
    3232    var $menu_hooks = array();
    33     var $version = '1.1.0';
     33    var $version = '1.2.0';
    3434
    3535    /**
     
    9797    }
    9898
    99 
    10099    /**
    101100     * Define the admin menu options for this plugin
     
    132131     */
    133132    public function ajax_taxonomy_structure() {
    134         header( 'Content-type: application/json' );
     133        $header = "application/json";
     134
     135        if( isset( $_REQUEST['callback'] ) ) {
     136          $callback = preg_replace( "/([^A-Za-z0-9_\$\.]+)/", "", $_REQUEST['callback'] );
     137          $header =  "application/javascript";
     138        }
     139
     140        header( 'Content-type: ' . $header );
    135141
    136142        $structure = array(
     
    142148        $post_types = wp_cache_get( 'post_types', $this->slug );
    143149        if( !$post_types ) {
    144             $post_types = get_post_types( array( 'public' => true ) );
     150            $post_types = array();
     151            $post_type_slugs = get_post_types( array( 'public' => true ) );
     152
     153            foreach( $post_type_slugs as $post_type_slug ) $post_types[] = get_post_type_object( $post_type_slug );
     154
    145155            wp_cache_set( 'post_types', $post_types, $this->slug, 3600 );
    146156        }
     
    158168        }
    159169
    160         $structure['post_types'] = array_values( $post_types );
    161         foreach( $categories as $category ) $structure['categories'][] = $category->slug;
    162         foreach( $tags as $tag ) $structure['tags'][] = $tag->slug;
    163 
    164         exit( json_encode( $structure ) );
     170        foreach( $post_types as $post_type ) $structure['post_types'][$post_type->name] = $post_type->label;
     171        foreach( $categories as $category ) $structure['categories'][$category->slug] = $category->name;
     172        foreach( $tags as $tag ) $structure['tags'][$tag->slug] = $tag->name;
     173
     174        $data = json_encode( $structure );
     175
     176        if( isset( $callback ) && !empty( $callback ) ) {
     177            $data = "$callback($data)";
     178        }
     179
     180        exit( $data );
    165181    }
    166182
  • filament/branches/redesign/readme.txt

    r887038 r893871  
    4747
    4848== Changelog ==
     49= 1.2.0 =
     50* Modify AJAX end-point to respond to JSONP requests with a _REQUEST['callback'] parameter
     51* Restructure post_types structure in AJAX end-point response to respond with a key/value pair of name and label
     52* Plugin UI redesign
     53
    4954= 1.1.0 =
    5055* Add save messaging to admin view
Note: See TracChangeset for help on using the changeset viewer.