Permalink
Browse files

Add new widgets and update media features.

Add Webcomic Print, Scheduled Webcomics, and Webcomic Transcripts Link
widgets. Also streamline media features.
  • Loading branch information...
1 parent f02da52 commit acec6628e3fd4103c0e4435bbde99fd8a471fdfd Michael Sisk committed Aug 5, 2013
Showing with 789 additions and 302 deletions.
  1. +8 −12 -/js/admin-widgets.js
  2. +13 −9 -/php/media.php
  3. +768 −281 -/php/widgets.php
View
@@ -3,14 +3,15 @@ jQuery( function( $ ) {
/** Remove the webcomic image. */
$( document ).on( 'click', '.webcomic-image-x', function() {
- $e = $( this );
+ var $e = $( this );
$.get( url, {
id: 0,
- field: $e.data( 'field' ),
+ name: $e.data( 'name' ),
+ target: $e.data( 'target' ),
webcomic_admin_ajax: $e.data( 'callback' )
}, function( data ) {
- $( $e.data( 'target' ) ).html( data );
+ $( $e.closest( $e.data( 'target' ) ) ).html( data );
} );
} );
} );
@@ -25,13 +26,7 @@ jQuery( function( $ ) {
e.preventDefault();
- if ( frame ) {
- frame.open();
-
- return;
- }
-
- frame = wp.media.frames.webcomicPoster = wp.media( {
+ frame = wp.media.frames.webcomicWidgetImage = wp.media( {
title: $e.data( 'title' ),
library: {
type: 'image'
@@ -44,10 +39,11 @@ jQuery( function( $ ) {
frame.on( 'select', function() {
$.get( $( '[data-webcomic-admin-url]' ).data( 'webcomic-admin-url' ), {
id: frame.state().get( 'selection' ).first().id,
- field: $e.data( 'field' ),
+ name: $e.data( 'name' ),
+ target: $e.data( 'target' ),
webcomic_admin_ajax: $e.data( 'callback' )
}, function( data ) {
- $( $e.data( 'target' ) ).html( data );
+ $( $e.closest( $e.data( 'target' ) ) ).html( data );
} );
} );
View
@@ -398,21 +398,25 @@ public function media_row_actions( $actions, $attachment ) {
public function display_media_states( $states ) {
global $post;
- if ( $type = get_post_meta( $post->ID, '_wp_attachment_context', true ) and preg_match( '/^(webcomic-donation|(purchase-)?webcomic(-(collection|storyline|character))?-link|webcomic\d+(_(storyline|character)))?$/', $type ) ) {
+ if ( $type = get_post_meta( $post->ID, '_wp_attachment_context', true ) and preg_match( '/^(widget-webcomic-print|widget-webcomic-donation|widget-(purchase-)?webcomic(-(collection|storyline|character|transcripts))?-link|webcomic\d+(_(storyline|character)))?$/', $type ) ) {
$type = explode( '_', $type );
- if ( 'webcomic-donation' === $type[ 0 ] ) {
- $states[] = __( 'Webcomic Donation Image', 'webcomic' );
- } elseif ( 'webcomic-link' === $type[ 0 ] ) {
+ if ( 'widget-webcomic-print' === $type[ 0 ] ) {
+ $states[] = __( 'Webcomic Print Image', 'webcomic' );
+ } elseif ( 'widget-webcomic-link' === $type[ 0 ] ) {
$states[] = __( 'Webcomic Link Image', 'webcomic' );
- } elseif ( 'purchase-webcomic-link' === $type[ 0 ] ) {
+ } elseif ( 'widget-webcomic-donation' === $type[ 0 ] ) {
+ $states[] = __( 'Webcomic Donation Image', 'webcomic' );
+ } elseif ( 'widget-purchase-webcomic-link' === $type[ 0 ] ) {
$states[] = __( 'Purchase Webcomic Link Image', 'webcomic' );
- } elseif ( 'webcomic-collection-link' === $type[ 0 ] ) {
- $states[] = __( 'Webcomic Collection Link Image', 'webcomic' );
- } elseif ( 'webcomic-storyline-link' === $type[ 0 ] ) {
+ } elseif ( 'widget-webcomic-storyline-link' === $type[ 0 ] ) {
$states[] = __( 'Webcomic Storyline Link Image', 'webcomic' );
- } elseif ( 'webcomic-character-link' === $type[ 0 ] ) {
+ } elseif ( 'widget-webcomic-character-link' === $type[ 0 ] ) {
$states[] = __( 'Webcomic Character Link Image', 'webcomic' );
+ } elseif ( 'widget-webcomic-collection-link' === $type[ 0 ] ) {
+ $states[] = __( 'Webcomic Collection Link Image', 'webcomic' );
+ } elseif ( 'widget-webcomic-transcripts-link' === $type[ 0 ] ) {
+ $states[] = __( 'Webcomic Transcripts Link Image', 'webcomic' );
} elseif ( empty( $type[ 1 ] ) ) {
$states[] = sprintf( __( '%s Poster', 'webcomic' ), esc_html( self::$config[ 'collections' ][ $type[ 0 ] ][ 'name' ] ) );
} elseif ( 'storyline' === $type[ 1 ] ) {
Oops, something went wrong.

0 comments on commit acec662

Please sign in to comment.