Browse files

Additional clean up to prepare for release

  • Loading branch information...
1 parent 16a5de6 commit 9bcdd0a9b5480ab5e9f41052d0bb677bef67fdcd Michael Sisk committed Aug 7, 2012
View
2 -/php/admin.php
@@ -445,7 +445,7 @@ public function admin_notices() {
}
if ( isset( self::$config[ 'thanks' ] ) ) {
- echo '<div class="updated webcomic"><a href="http://webcomic.nu" target="_blank"><b>&#x2764;</b>', sprintf( __( 'Thank you for using Webcomic %s', 'webcomic' ), self::$version ), '</a></div>';
+ printf( '<div class="updated webcomic"><a href="http://webcomic.nu" target="_blank"><b>&#x2764;</b>%s</a></div>', sprintf( __( 'Thank you for using Webcomic %s', 'webcomic' ), self::$version ) );
unset( self::$config[ 'thanks' ] );
View
38 -/php/config.php
@@ -204,7 +204,7 @@ public function page() {
submit_button( '', 'primary', '', false );
if ( 'webcomic-options' === $page ) {
- printf( '<span class="alignright">%s</span>', sprintf( __( 'Thank you for using %s', 'webcomic' ), sprintf( '<a href="http://webcomic.nu" target="_blank">Webcomic %s</a>', self::$version ) ) );
+ printf( '<span class="alignright">%s</span>', sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">Webcomic %2$s</a>', 'webcomic' ), 'http://webcomic.nu', self::$version ) );
}
?>
</p>
@@ -436,7 +436,7 @@ public function collection_image() {
printf( '<label><input type="checkbox" name="webcomic_detach"> %s</label><br>', __( 'Detach', 'webcomic' ) );
}
- echo '<p class="description">', sprintf( __( 'The poster is a representative image that can be displayed on your site. Posters are uploaded to the Media Library. Maximum upload file size: %s%s', 'webcomic' ), $upload_size, $sizes[ $u ] ), '</p>';
+ printf( '<p class="description">%s</p>', sprintf( __( 'The poster is a representative image that can be displayed on your site. Posters are uploaded to the Media Library. Maximum upload file size: %1$s%2$s', 'webcomic' ), $upload_size, $sizes[ $u ] ) );
}
/** Render the Theme setting.
@@ -1015,7 +1015,7 @@ public function save( $options ) {
}
} else if ( isset( $_POST[ 'webcomic_collection' ] ) ) {
$id = $_POST[ 'webcomic_collection' ];
- $tokens = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', "%{$id}_storyline%", '%author%' );
+ $tokens = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', '%author%', "%{$id}_storyline%" );
$collection = array(
'id' => $id,
'name' => $_POST[ 'webcomic_name' ] ? $_POST[ 'webcomic_name' ] : self::$config[ 'collections' ][ $id ][ 'name' ],
@@ -1161,7 +1161,7 @@ public function section(){}
*/
public static function ajax_slug_preview( $slug, $preview, $collection ) {
$slug = explode( '/', $slug );
- $tokens = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', "%{$collection}_storyline%", '%author%' );
+ $tokens = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', '%author%', "%{$collection}_storyline%" );
$fallback = substr( $preview, 16 );
foreach ( $slug as $k => $v ) {
@@ -1217,17 +1217,21 @@ public static function ajax_twitter_account( $consumer_key, $consumer_secret, $c
$oauth = new TwitterOAuth( $consumer_key, $consumer_secret );
$request = $oauth->getRequestToken( add_query_arg( array( 'webcomic_twitter_oauth' => true, 'webcomic_collection' => $collection ), get_site_url() ) );
- self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'request_token' ] = isset( $request[ 'oauth_token' ] ) ? $request[ 'oauth_token' ] : '';
- self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'request_secret' ] = isset( $request[ 'oauth_token_secret' ] ) ? $request[ 'oauth_token_secret' ] : '';
-
- update_option( 'webcomic_options', self::$config );
-
- printf( '%s<a href="%s"><img src="%s-/img/twitter.png" alt="%s"></a>',
- ( self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_token' ] and self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_secret' ] ) ? __( '<p class="description">Your credentials could not be verified.</p>', 'webcomic' ) : '',
- $oauth->getAuthorizeURL( $request ),
- self::$url,
- __( 'Sign in with Twitter', 'webcomic' )
- );
+ if ( isset( $request[ 'Failed to validate oauth signature and token' ] ) ) {
+ _e( 'Validation error. Please ensure your <a href="https://dev.twitter.com/apps/new" target="_blank">Twitter Application</a> <b>consumer key</b> and <b>consumer secret</b> are entered correctly.', 'webcomic' );
+ } else {
+ self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'request_token' ] = isset( $request[ 'oauth_token' ] ) ? $request[ 'oauth_token' ] : '';
+ self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'request_secret' ] = isset( $request[ 'oauth_token_secret' ] ) ? $request[ 'oauth_token_secret' ] : '';
+
+ update_option( 'webcomic_options', self::$config );
+
+ printf( '%s<a href="%s"><img src="%s-/img/twitter.png" alt="%s"></a>',
+ ( self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_token' ] and self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_secret' ] ) ? __( '<p class="description">Your credentials could not be verified.</p>', 'webcomic' ) : '',
+ $oauth->getAuthorizeURL( $request ),
+ self::$url,
+ __( 'Sign in with Twitter', 'webcomic' )
+ );
+ }
}
} else {
echo '<span class="description">', __( 'Please enter your <a href="https://dev.twitter.com/apps/new" target="_blank">Twitter Application</a> <b>consumer key</b> and <b>consumer secret</b> below.', 'webcomic' ), '</span>';
@@ -1242,9 +1246,9 @@ private function save_sizes() {
if ( isset( $_POST[ 'webcomic_media_sizes' ], $_POST[ 'option_page' ], $_POST[ 'action' ] ) and 'media' === $_POST[ 'option_page' ] and 'update' === $_POST[ 'action' ] and wp_verify_nonce( $_POST[ 'webcomic_media_sizes' ], 'webcomic_media_sizes' ) ) {
if ( $size = sanitize_title( $_POST[ 'webcomic_new_size' ] ) ) {
if ( 'thumb' === $size or 'thumbnail' === $size or 'medium' === $size or 'large' === $size or 'post-thumbnail' === $size ) {
- wp_die( sprintf( __( 'The name "%s" is reserved by WordPress.', 'webcomic' ), $size ), __( 'Error | Webcomic', 'webcomic' ) );
+ wp_die( sprintf( __( 'The name <q>%s</q> is reserved by WordPress.', 'webcomic' ), $size ), __( 'Error | Webcomic', 'webcomic' ) );
} else if ( in_array( $size, get_intermediate_image_sizes() ) ) {
- wp_die( sprintf( __( 'A size with the name "%s" already exists.', 'webcomic' ), $size ), __( 'Error | Webcomic', 'webcomic' ) );
+ wp_die( sprintf( __( 'A size with the name <q>%s</q> already exists.', 'webcomic' ), $size ), __( 'Error | Webcomic', 'webcomic' ) );
} else {
self::$config[ 'sizes' ][ $size ] = array(
'width' => intval( $_POST[ 'webcomic_new_size_width' ] ),
View
28 -/php/help.php
@@ -43,7 +43,6 @@ class WebcomicHelp extends Webcomic {
* @uses WebcomicHelp::characters_adding()
* @uses WebcomicHelp::languages_overview()
* @uses WebcomicHelp::languages_adding()
- * @uses WebcomicHelp::collection_settings_information()
* @uses WebcomicHelp::collection_settings_general()
* @uses WebcomicHelp::collection_settings_transcripts()
* @uses WebcomicHelp::collection_settings_commerce()
@@ -721,21 +720,6 @@ private function languages_adding() {
);
}
- /** Return collection information settings help.
- *
- * @return string
- */
- private function collection_settings_information() {
- return sprintf( '
- <p>%s</p>
- <ul>
- <li>%s</li>
- <li>%s</li>
- <li>%s</li>
- </ul>'
- );
- }
-
/** Return collection general settings help.
*
* @return string
@@ -846,7 +830,7 @@ private function collection_settings_permalinks( $screen ) {
return sprintf( '
<p>%s</p>
<p>%s</p>',
- sprintf( __( 'These settings affect the URL structure of the collection archive, webcomics, storylines, and characters. To the right of each input is an example URL that will update when the slug options are changed. The slug for single webcomics may accept a number of tags, including %%year%%, %%monthnum%%, %%day%%, %%hour%%, %%minute%%, %%second%%, %%post_id%%, %%author%%, and %%%s%%.', 'webcomic' ), "{$screen->post_type}_storyline", "{$screen->post_type}_character" ),
+ sprintf( __( 'These settings affect the URL structure of the collection archive, webcomics, storylines, and characters. To the right of each input is an example URL that will update when the slug options are changed. The slug for single webcomics may accept a number of tags, including %%year%%, %%monthnum%%, %%day%%, %%hour%%, %%minute%%, %%second%%, %%post_id%%, %%author%%, and %%%s%%.', 'webcomic' ), "{$screen->post_type}_storyline" ),
sprintf( __( 'Be careful when modifying permalinks: incorrect settings may result in broken pages. <a href="%s" target="_blank">Read more about permalinks at the WordPress Codex &raquo;</a>', 'webcomic' ), 'http://codex.wordpress.org/Using_Permalinks' )
);
/*
@@ -879,20 +863,20 @@ private function collection_settings_twitter( $screen ) {
<li>%s</li>
<li>%s</li>
</ul>',
- sprintf( __( 'These settings allow you to connect a Twitter account with the collection via a Twitter Application. Anytime a new webcomic is published in this collection a status update will be made to the account you authorize in the format you specify using your Twitter Application. Visit <a href="%s" target="_blank">Twitter Developers</a> to create a new Twitter Application. The optional <strong>Callback URL</strong> setting of your Twitter Application must be set to your site URL:', 'webcomic' ), 'https://dev.twitter.com/apps/new' ),
+ sprintf( __( 'These settings allow you to connect a Twitter account with the collection via a Twitter Application. Anytime a new webcomic is published in this collection a status update will be made to the account you authorize in the format you specify using your Twitter Application. Visit <a href="%s" target="_blank">Twitter Developers</a> to create a new Twitter Application. The optional <strong>Callback URL</strong> setting of your Twitter Application must be set to your site URL:', 'webcomic' ), '//dev.twitter.com/apps/new' ),
home_url(),
__( 'Once created, go to the <strong>Settings</strong> tab for your Twitter Application and ensure that <strong>Read and Write</strong> is selected for <strong>Application Type</strong>. Then return to the <strong>Details</strong> tab and copy the <strong>Consumer Key</strong> and <strong>Consumer Secret</strong> values into their respective fields on this page. If the keys are entered correctly a <strong>Sign in with Twitter</strong> option will appear in the <strong>Authorized Account</strong> area.', 'webcomic' ),
__( 'The <strong>Tweet Format</strong> accepts a number of tags:', 'webcomic' ),
- sprintf( __( '<strong>%%url</strong> - A <a href="%s" target="_blank">shortlink</a> to the webcomic post, or the full permalink of no shortlink is available. Use <strong>%%permalink</strong> to always use the full permalink.', 'webcomic' ), 'http://codex.wordpress.org/Function_Reference/the_shortlink' ),
+ sprintf( __( '<strong>%%url</strong> - A <a href="%s" target="_blank">shortlink</a> to the webcomic post, or the full permalink of no shortlink is available. Use <strong>%%permalink</strong> to always use the full permalink.', 'webcomic' ), '//codex.wordpress.org/Function_Reference/the_shortlink' ),
__( '<strong>%date</strong> - The publish date of the webcomic.', 'webcomic' ),
__( '<strong>%time</strong> - The publish time of the webcomic.', 'webcomic' ),
__( '<strong>%title</strong> - The title of the webcomic.', 'webcomic' ),
__( '<strong>%author</strong> - The display name used by the author that published the webcomic.', 'webcomic' ),
sprintf( __( '<strong>%%site-url</strong> - The URL to your website, %s', 'webcomic' ), home_url() ),
sprintf( __( '<strong>%%site-name</strong> - The name of your website, %s', 'webcomic' ), get_bloginfo( 'name' ) ),
- sprintf( __( '<strong>%%storylines</strong> - The names of all storylines the webcomic is a part of, converted to <a href="%s" target="_blank">hash tags</a>.', 'webcomic' ), 'https://support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
- sprintf( __( '<strong>%%characters</strong> - The names of all characters appearing in the webcomic, converted to <a href="%s" target="_blank">hash tags</a>.', 'webcomic' ), 'https://support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
- sprintf( __( '<strong>%%collection</strong> - The names of the collection, %s, converted to a <a href="%s" target="_blank">hash tag</a>.', 'webcomic' ), self::$config[ 'collections' ][ $screen->post_type ][ 'name' ], 'https://support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
+ sprintf( __( '<strong>%%storylines</strong> - The names of all storylines the webcomic is a part of, converted to <a href="%s" target="_blank">hash tags</a>.', 'webcomic' ), '//support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
+ sprintf( __( '<strong>%%characters</strong> - The names of all characters appearing in the webcomic, converted to <a href="%s" target="_blank">hash tags</a>.', 'webcomic' ), '//support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
+ sprintf( __( '<strong>%%collection</strong> - The names of the collection, %1$s, converted to a <a href="%2$s" target="_blank">hash tag</a>.', 'webcomic' ), self::$config[ 'collections' ][ $screen->post_type ][ 'name' ], '//support.twitter.com/entries/49309-what-are-hashtags-symbols' ),
sprintf( __( '<strong>%%collection-name</strong> - The unhashed collection name, %s.', 'webcomic' ), self::$config[ 'collections' ][ $screen->post_type ][ 'name' ] )
);
/*
View
14 -/php/integrate/feed.php
@@ -0,0 +1,14 @@
+<?php
+/** Basic feed integration.
+ *
+ * @package Webcomic
+ */
+global $post;
+
+$prepend = sprintf( '<p><a href="%s">', get_permalink( $post->ID ) );
+
+foreach ( $attachments as $attachment ) {
+ $prepend .= wp_get_attachment_image( $attachment->ID, $feed_size );
+}
+
+$prepend .= '</a></p>';
View
4 -/php/integrate/loop_end.php
@@ -18,7 +18,7 @@
<h3 id="webcomic-transcripts"><?php sprintf( __( '%s Transcripts', 'webcomic' ), the_title( '', '', false ) ); ?></h3>
<?php foreach ( $transcripts as $post ) { setup_postdata( $post ); ?>
<div class="webcomic-transcript-content"><?php the_content(); ?></div>
- <div class="webcomic-transcript-meta"><?php printf( __( 'Transcribed by %s%s', 'webcomic' ), WebcomicTag::get_webcomic_transcript_authors(), WebcomicTag::get_the_webcomic_transcript_term_list( 0, 'webcomic_language', __( ' in ', 'webcomic' ), __( ', ', 'webcomic' ), __( '', 'webcomic' ) ) ); ?></div>
+ <div class="webcomic-transcript-meta"><?php printf( __( 'Transcribed by %1$s%2$s', 'webcomic' ), WebcomicTag::get_webcomic_transcript_authors(), WebcomicTag::get_the_webcomic_transcript_term_list( 0, 'webcomic_language', __( ' in ', 'webcomic' ), __( ', ', 'webcomic' ), __( '', 'webcomic' ) ) ); ?></div>
<?php wp_reset_postdata(); }
}
@@ -30,5 +30,5 @@
}
webcomic_transcript_form();
- }
+ }
}
View
6 -/php/integrate/the_content.php
@@ -20,11 +20,11 @@
if ( webcomic_prints_available() ) {
$prints = array();
- $prints[] = WebcomicTag::webcomic_print_form( 'domestic', sprintf( __( '%s%s%%total Domestic', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
- $prints[] = WebcomicTag::webcomic_print_form( 'international', sprintf( __( '%s%s%%total International', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
+ $prints[] = WebcomicTag::webcomic_print_form( 'domestic', sprintf( __( '%1$s%2$s%%total Domestic', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
+ $prints[] = WebcomicTag::webcomic_print_form( 'international', sprintf( __( '%1$s%2$s%%total International', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
if ( webcomic_prints_available( 'original' ) ) {
- $prints[] = WebcomicTag::webcomic_print_form( 'original', sprintf( __( '%s%s%%total Original', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
+ $prints[] = WebcomicTag::webcomic_print_form( 'original', sprintf( __( '%1$s%2$s%%total Original', 'webcomic' ), __( '%dec.', 'webcomic' ), __( '%sep,', 'webcomic' ) ) );
}
if ( '_cart' === self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'method' ] ) {
View
7 -/php/integrate/the_excerpt.php
@@ -0,0 +1,7 @@
+<?php
+/** Automagic integration for the_excerpt.
+ *
+ * @package Webcomic
+ * @uses WebcomicTag::the_webcomic()
+ */
+$prepend = sprintf( '<div class="integrated-webcomic"><div class="webcomic-img">%s</div><!-- .webcomic-img --></div><!-- .integrated-webcomic -->', WebcomicTag::the_webcomic( 'medium', 'self' ) );
View
8 -/php/legacy.php
@@ -156,7 +156,7 @@ public function admin_notices() {
return;
}
- printf( '<div class="updated webcomic legacy"><a href="%s"><b>&#x2605;</b> %s &raquo;</a></div>', esc_url( add_query_arg( array( 'page' => 'webcomic-upgrader' ), admin_url( 'tools.php' ) ) ), sprintf( __( 'Upgrading? Let Webcomic Help', 'webcomic' ), self::$version ) );
+ printf( '<div class="updated webcomic legacy"><a href="%s"><b>&#x2605;</b> %s &raquo;</a></div>', esc_url( add_query_arg( array( 'page' => 'webcomic-upgrader' ), admin_url( 'tools.php' ) ) ), __( 'Upgrading? Let Webcomic Help', 'webcomic' ) );
}
}
@@ -208,7 +208,7 @@ public function page() {
<?php if ( isset( $_POST[ 'webcomic_upgrade_status' ] ) and 0 === $_POST[ 'webcomic_upgrade_status' ] ) { ?>
<h3 style="color:green;font-size:larger"><?php _e( "Just one more click!", 'webcomic' ); ?></h3>
- <p><?php printf( __( 'Thanks again for using Webcomic! Clicking <strong>Complete the Upgrade</strong> will remove the Upgrade Webcomic tool, delete any leftover Webcomic %s data, and take you to the administrative dashboard. If you notice any problems with the upgrade please <a href="%s" target="_blank">let the developer know</a>.', 'webcomic' ), self::$config[ 'legacy' ], '//github.com/mgsisk/webcomic/issues' ); ?></p>
+ <p><?php printf( __( 'Thanks again for using Webcomic! Clicking <strong>Complete the Upgrade</strong> will remove the Upgrade Webcomic tool, delete any leftover Webcomic %1$s data, and take you to the administrative dashboard. If you notice any problems with the upgrade please <a href="%2$s" target="_blank">let the developer know</a>.', 'webcomic' ), self::$config[ 'legacy' ], '//github.com/mgsisk/webcomic/issues' ); ?></p>
<form method="post">
<?php wp_nonce_field( 'webcomic_upgrade', 'webcomic_upgrade' ); ?>
<div class="form-wrap">
@@ -235,8 +235,8 @@ public function page() {
<?php } else { ?>
- <p><?php printf( __( 'This tool will attempt to automatically convert your existing Webcomic %s data to Webcomic %s. Depending on the size of your site the upgrade may require multiple steps. If you do not want to upgrade click <strong>Not Interested</strong> to uninstall Webcomic %s.', 'webcomic' ), self::$config[ 'legacy' ], self::$version, self::$version ); ?></p>
- <p style="color:#bc0b0b;font-size:larger"><strong><?php printf( __( 'Upgrades are not reversible. Please <a href="%s" target="_blank">read this</a> and <a href="%s">backup your site</a> before upgrading.', 'webcomic' ), '//github.com/mgsisk/webcomic/Upgrading', esc_url( admin_url( 'export.php' ) ) ); ?></strong></p>
+ <p><?php printf( __( 'This tool will attempt to automatically convert your existing Webcomic %1$s data to Webcomic %2$s. Depending on the size of your site the upgrade may require multiple steps. If you do not want to upgrade click <strong>Not Interested</strong> to uninstall Webcomic %2$s.', 'webcomic' ), self::$config[ 'legacy' ], self::$version ); ?></p>
+ <p style="color:#bc0b0b;font-size:larger"><strong><?php printf( __( 'Upgrades are not reversible and, once begun, should not be stopped. Please <a href="%1$s" target="_blank">read this</a> and <a href="%2$s">backup your site</a> before upgrading.', 'webcomic' ), '//github.com/mgsisk/webcomic/Upgrading', esc_url( admin_url( 'export.php' ) ) ); ?></strong></p>
<form method="post">
<?php wp_nonce_field( 'webcomic_upgrade', 'webcomic_upgrade' ); ?>
<div class="form-wrap">
View
2 -/php/posts.php
@@ -691,7 +691,7 @@ public function transcripts( $post ) {
</tr>',
current_user_can( 'edit_post', $p->ID ) ? sprintf( '<strong><a href="%s" class="row-title">%s</a></strong>', get_edit_post_link( $p->ID ), esc_html( $p->post_title ) ) : sprintf( '<strong>%s</strong>', esc_html( $p->post_title ) ),
$status,
- sprintf( __( 'Submitted on %s at %s by %s (%s)', 'webcomic' ), date( 'Y/n/j', $date ), date( 'g:i a', $date ), $authors, $terms ),
+ sprintf( __( 'Submitted on %1$s at %2$s by %3$s (%4$s)', 'webcomic' ), date( 'Y/n/j', $date ), date( 'g:i a', $date ), $authors, $terms ),
apply_filters( 'the_content', $p->post_content )
);
}
View
90 -/php/tags.php
@@ -1,6 +1,8 @@
<?php
/** Contains the WebcomicTag class and template tag functions.
*
+ * @todo is_webcomic_attachment
+ * @todo is_a_webcomic_attachment
* @package Webcomic
*/
@@ -154,6 +156,19 @@ public static function is_webcomic( $dynamic = false ) {
return ( is_singular( array_keys( self::$config[ 'collections' ] ) ) and ( !$dynamic or 'xmlhttprequest' === strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) ) );
}
+ /** Is the query for a Webcomic-recognized attachment?
+ *
+ * @param mixed $collection Collection ID or an array of these to check.
+ * @return boolean
+ * @uses Webcomic::$config
+ */
+ public static function is_webcomic_attachment( $collection = '' ) {
+ $the_post = get_post();
+ $collection = $collection ? ( array ) $collection : array_keys( self::$config[ 'collections' ] );
+
+ return ( is_attachment() and preg_match( '/^image\//', get_post_mime_type( $the_post ) ) and in_array( get_post_type( $the_post->post_parent ), $collection ) );
+ }
+
/** Is the query for a webcomic-related page?
*
* @param mixed $the_post Post object or ID to check.
@@ -224,6 +239,20 @@ public static function is_a_webcomic( $the_post = false ) {
return in_array( get_post_type( $the_post ), array_keys( self::$config[ 'collections' ] ) );
}
+ /** Is the current post a Webcomic-recognized attachment?
+ *
+ * @param mixed $the_post Post object or ID to check.
+ * @param mixed $collection Collection ID or an array of these to check.
+ * @return boolean
+ * @uses Webcomic::$config
+ */
+ public static function is_a_webcomic_attachment( $the_post = false, $collection = '' ) {
+ $the_post = get_post( $the_post );
+ $collection = $collection ? ( array ) $collection : array_keys( self::$config[ 'collections' ] );
+
+ return ( $the_post and $the_post->post_parent and preg_match( '/^image\//', get_post_mime_type( $the_post ) ) and in_array( get_post_type( $the_post->post_parent ), $collection ) );
+ }
+
/** Does the current webcomic have any transcripts?
*
* @param boolean $pending Does the current webcomic have any transcripts pending review?
@@ -232,7 +261,7 @@ public static function is_a_webcomic( $the_post = false ) {
* @return boolean
*/
public static function have_webcomic_transcripts( $pending = false, $language = '', $the_post = false ) {
- return $the_post = get_post( $the_post ) ? ( boolean ) get_children( array(
+ return ( $the_post = get_post( $the_post ) ) ? ( boolean ) get_children( array(
'post_type' => 'webcomic_transcript',
'post_parent' => $the_post->ID,
'post_status' => $pending ? 'pending' : get_post_stati( array( 'public' => true ) ),
@@ -367,7 +396,7 @@ public static function the_webcomic( $size = 'full', $relative = '', $in_same_te
$output = apply_filters( 'the_webcomic', $output, $the_post, $attachments );
if ( 'self' === $relative ) {
- return sprintf( '<a href="%s">%s</a>', apply_filters( 'the_permalink', get_permalink( $the_post ) ), $output );
+ return sprintf( '<a href="%s" rel="bookmark">%s</a>', apply_filters( 'the_permalink', get_permalink( $the_post ) ), $output );
} else if ( $relative ) {
return self::relative_webcomic_link( '%link', $output, $relative, $in_same_term, $excluded_terms, $taxonomy, $the_post->post_type );
} else {
@@ -1684,7 +1713,7 @@ public static function webcomic_transcript_form( $args = array(), $transcript =
) : '',
'transcript_field' => sprintf( '<p class="webcomic-transcript-content"><label for="webcomic-transcript-content' . $c . '">%s</label><textarea name="webcomic_transcript_content" id="webcomic-transcript-content' . $c . '" rows="10" cols="40" required>%s</textarea></p>',
__( 'Transcript', 'webcomic' ),
- $update_post ? esc_html( $update_post->post_content ) : ''
+ empty( $update_post ) ? '' : esc_html( $update_post->post_content )
),
'must_log_in' => sprintf( '<p class="must-log-in">%s</p>', sprintf( __( 'You must be <a href="%s">logged in</a> to transcribe this webcomic.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $the_post ) ) ) ) ),
'logged_in_as' => sprintf( '<p class="logged-in-as">%s</p>', sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s">Log out?</a>' ), admin_url( 'profile.php' ), $user->display_name, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $the_post ) ) ) ) ),
@@ -1693,7 +1722,7 @@ public static function webcomic_transcript_form( $args = array(), $transcript =
'transcript_notes_success' => sprintf( '<p class="webcomic-transcript-success">%s</p>', __( 'Thank you! Your transcript has been submitted.', 'webcomic' ) ),
'transcript_notes_failure' => sprintf( '<p class="webcomic-transcript-failure">%s</p>', __( 'There was a problem submitting your transcript. Please try again.', 'webcomic' ) ),
'id_form' => "webcomic-transcript-form{$c}",
- 'title_submit' => $update_post ? __( 'Improve %s Transcript', 'webcomic' ) : __( 'Transcribe %s', 'webcomic' ),
+ 'title_submit' => empty( $update_post ) ? __( 'Transcribe %s', 'webcomic' ) : __( 'Improve %s Transcript', 'webcomic' ),
'label_submit' => __( 'Submit Transcript', 'webcomic' ),
'wysiwyg_editor' => false
), $the_post->post_type ) ) );
@@ -1739,7 +1768,7 @@ public static function webcomic_transcript_form( $args = array(), $transcript =
do_action( 'webcomic_transcript_form_after_fields', $the_post->post_type );
}
- echo apply_filters( 'webcomic_transcript_form_field_language', $language_field, $the_post->post_type, $languages, $terms, $update_terms );
+ echo apply_filters( 'webcomic_transcript_form_field_language', $language_field, $the_post->post_type, $languages, $terms, empty( $update_terms ) ? array() : $update_terms );
if ( $wysiwyg_editor ) {
wp_editor( '', "webcomic_transcript_content{$c}", array_merge( array( 'textarea_name' => 'webcomic_transcript_content', 'media_buttons' => false, 'teeny' => true, 'editor_css' => '<style scoped>*{box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box}</style>' ), ( array ) $wysiwyg_editor ) );
@@ -1749,7 +1778,7 @@ public static function webcomic_transcript_form( $args = array(), $transcript =
echo $transcript_notes_after,
apply_filters( 'webcomic_transcript_form_field_submit', sprintf( '<p class="webcomic-transcript-submit"><button type="submit" name="webcomic_transcript_submit">%s</button></p>', esc_html( $label_submit ) ), $the_post->post_type ),
- self::webcomic_transcript_fields( $transcript->ID, $the_post );
+ self::webcomic_transcript_fields( empty( $update_post ) ? 0 : $update_post->ID, $the_post );
do_action( 'webcomic_transcript_form', $the_post );
@@ -2692,6 +2721,28 @@ function is_webcomic( $dynamic = false ) {
}
}
+if ( !function_exists( 'is_webcomic_attachment' ) ) {
+ /** Is the query for a Webcomic-recognized attachment?
+ *
+ * <code>
+ * if ( is_webcomic_attachment() ) {
+ * // this is a Webcomic-recognized attachment
+ * }
+ *
+ * if ( is_webcomic_attachment( 'webcomic42' ) ) {
+ * // this is a webcomic-recognized attachment in collection 42
+ * }
+ * </code>
+ *
+ * @param mixed $collection Collection ID or an array of these to check.
+ * @return boolean
+ * @uses WebcomicTag::is_webcomic_attachment()
+ */
+ function is_webcomic_attachment( $collection = '' ) {
+ return WebcomicTag::is_webcomic_attachment();
+ }
+}
+
if ( !function_exists( 'is_webcomic_page' ) ) {
/** Is the query for a webcomic-related page?
*
@@ -2823,6 +2874,33 @@ function is_a_webcomic( $the_post = false ) {
}
}
+if ( !function_exists( 'is_a_webcomic_attachment' ) ) {
+ /** Is the current post a Webcomic-recognized attachment?
+ *
+ * <code>
+ * if ( is_a_webcomic_attachment() ) {
+ * // the current post is a webcomic-recognized attachment
+ * }
+ *
+ * if ( is_a_webcomic_attachment( 42 ) ) {
+ * // the post with an ID of 42 is a webcomic-recognized attachment
+ * }
+ *
+ * if ( is_a_webcomic_attachment( 0, 'webcomic42' ) ) {
+ * // the current post is a webcomic-recognized attachment in collection 42
+ * }
+ * </code>
+ *
+ * @param mixed $the_post Post object or ID to check.
+ * @param mixed $collection Collection ID or an array of these to check.
+ * @return boolean
+ * @uses WebcomicTag::is_a_webcomic_attachment()
+ */
+ function is_a_webcomic_attachment( $the_post = false, $collection = '' ) {
+ return WebcomicTag::is_a_webcomic_attachment( $the_post, $collection );
+ }
+}
+
if ( !function_exists( 'has_webcomic_storyline' ) ) {
/** Does the current post belong to a specific storyline?
*
View
4 -/php/taxonomy.php
@@ -304,7 +304,7 @@ public function add_form_fields( $taxonomy ) {
<?php $storyline ? _e( 'Cover', 'webcomic' ) : _e( 'Avatar', 'webcomic' ); ?>
<input type="file" name="webcomic_image" id="webcomic_image">
</label>
- <p><?php $storyline ? printf( __( 'The cover is a representative image that can be displayed on your site. Covers are uploaded to the Media Library. Maximum upload file size: %s%s', 'webcomic' ), $upload_size, $sizes[ $u ] ) : printf( __( 'The avatar is a representative image that can be displayed on your site. Avatars are uploaded to the Media Library. Maximum upload file size: %s%s', 'webcomic' ), $upload_size, $sizes[ $u ] ); ?></p>
+ <p><?php $storyline ? printf( __( 'The cover is a representative image that can be displayed on your site. Covers are uploaded to the Media Library. Maximum upload file size: %1$s%2$s', 'webcomic' ), $upload_size, $sizes[ $u ] ) : printf( __( 'The avatar is a representative image that can be displayed on your site. Avatars are uploaded to the Media Library. Maximum upload file size: %1$s%2$s', 'webcomic' ), $upload_size, $sizes[ $u ] ); ?></p>
</div>
<?php }
}
@@ -355,7 +355,7 @@ public function edit_form_fields( $term, $taxonomy ) {
printf( '<label><input type="checkbox" name="webcomic_detach" style="width:auto"> %s</label><br>', __( 'Detach', 'webcomic' ) );
}
?>
- <p class="description"><?php $storyline ? printf( __( 'The cover is a representative image that can be displayed on your site. Covers are uploaded to the Media Library. Maximum upload file size: %s%s', 'webcomic' ), $upload_size, $sizes[ $u ] ) : printf( __( 'The avatar is a representative image that can be displayed on your site. Avatars are uploaded to the Media Library. Maximum upload file size: %s%s', 'webcomic' ), $upload_size, $sizes[ $u ] ); ?></p>
+ <p class="description"><?php $storyline ? printf( __( 'The cover is a representative image that can be displayed on your site. Covers are uploaded to the Media Library. Maximum upload file size: %1$s%2$s', 'webcomic' ), $upload_size, $sizes[ $u ] ) : printf( __( 'The avatar is a representative image that can be displayed on your site. Avatars are uploaded to the Media Library. Maximum upload file size: %1$s%2$s', 'webcomic' ), $upload_size, $sizes[ $u ] ); ?></p>
</td>
</tr>
<?php
View
51 webcomic.php
@@ -150,6 +150,7 @@ public function __construct() {
if ( self::$config[ 'integrate' ] ) {
add_action( 'loop_end', array( $this, 'loop_end' ), 10, 1 );
add_action( 'loop_start', array( $this, 'loop_start' ), 10, 1 );
+ add_action( 'the_excerpt', array( $this, 'the_excerpt' ), 10, 1 );
add_action( 'the_content', array( $this, 'the_content' ), 10, 1 );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10, 1 );
}
@@ -413,8 +414,6 @@ public function post_type_link( $link, $post, $name, $sample ) {
return $link;
}
- $time = explode( ' ', date( 'Y m d H i s', strtotime( $post->post_date ) ) );
-
if ( false !== strpos( $link, "%{$post->post_type}_storyline%" ) and $storylines = get_the_terms( $post->ID, "{$post->post_type}_storyline" ) and !is_wp_error( $storylines ) ) {
$storylines = array_reverse( $storylines );
$storyline = $storylines[ 0 ]->slug;
@@ -435,6 +434,7 @@ public function post_type_link( $link, $post, $name, $sample ) {
$storyline = '';
}
+ $time = explode( ' ', date( 'Y m d H i s', strtotime( $post->post_date ) ) );
$tokens = array(
'%year%' => $time[ 0 ],
'%monthnum%' => $time[ 1 ],
@@ -595,7 +595,9 @@ public function the_post( $post ) {
*
* We have to do this as early as possible to ensure that the
* correct template can be set if the collection is using a custom
- * theme.
+ * theme. It'd be better to use `wp_get_theme` for the integration
+ * check, but custom headers can't be retrieved this way since
+ * WordPress 3.4.
*
* @uses Webcomic::$config
* @uses Webcomic::$integrate
@@ -629,8 +631,9 @@ public function setup_theme() {
self::$collection = empty( self::$config[ 'collections' ][ $match[ 0 ] ] ) ? preg_replace( '/_(archive|webcomic|storyline|character)$/', '', array_search( $match[ 1 ], $permalinks ) ) : $match[ 0 ];
}
- $current_theme = wp_get_theme( get_stylesheet_directory() . '/style.css' );
- self::$integrate = empty( $current_theme[ 'Webcomic' ] );
+ $integrate = get_file_data( get_stylesheet_directory() . '/style.css', array( 'webcomic' => 'Webcomic' ) );
+
+ self::$integrate = empty( $integrate[ 'webcomic' ] );
}
/** Register and enqueue javascript.
@@ -910,6 +913,31 @@ public function loop_end( $query ) {
/** Automagically integrate basic webcomic functionality.
*
+ * @param string $excerpt The post excerpt.
+ * @return string
+ * @uses Webcomic::$integrate
+ * @hook the_content
+ * @filter string webcomic_the_excerpt $prepend, $append
+ * @template the_excerpt-{$collection}.php, the_excerpt.php
+ */
+ public function the_excerpt( $excerpt ) {
+ global $wp_query, $post;
+
+ if ( self::$integrate and in_the_loop() and $wp_query->is_main_query() and !is_feed() and $collection = get_post_type( $post ) and isset( self::$config[ 'collections' ][ $collection ] ) ) {
+ $prepend = $append = '';
+
+ if ( !locate_template( array( "webcomic/the_excerpt-{$collection}.php", 'webcomic/the_excerpt.php' ), true, false ) ) {
+ require self::$dir . '-/php/integrate/the_excerpt.php';
+ }
+
+ $excerpt = apply_filters( 'webcomic_the_excerpt', $prepend . $excerpt . $append, $excerpt, $prepend, $append );
+ }
+
+ return $excerpt;
+ }
+
+ /** Automagically integrate basic webcomic functionality.
+ *
* @param string $content The post content.
* @return string
* @uses Webcomic::$integrate
@@ -1106,9 +1134,9 @@ public function twitter_oauth() {
$admin_url = add_query_arg( array( 'post_type' => $_GET[ 'webcomic_collection' ], 'page' => "{$_GET[ 'webcomic_collection' ]}-options" ), admin_url( 'edit.php' ) );
if ( isset( $_GET[ 'denied' ] ) ) {
- wp_die( sprintf( __( 'Authorization was denied. <a href="%s">Return to %s Settings</a>', 'webcomic' ), $admin_url, self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'name' ] ), __( 'Twitter Authorization Denied | Webcomic', 'webcomic' ), array( 'response' => 200 ) );
+ wp_die( sprintf( __( 'Authorization was denied. <a href="%1$s">Return to %2$s Settings</a>', 'webcomic' ), $admin_url, self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'name' ] ), __( 'Twitter Authorization Denied | Webcomic', 'webcomic' ), array( 'response' => 200 ) );
} else {
- $oauth = new TwitterOAuth( self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'consumer_key' ], self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'consumer_secret' ], $_GET[ 'oauth_token' ], self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'request_token' ], self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'consumer_secret' ], $_GET[ 'request_secret' ] );
+ $oauth = new TwitterOAuth( self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'consumer_key' ], self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'consumer_secret' ], $_GET[ 'oauth_token' ], self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'twitter' ][ 'request_token' ] );
$token = $oauth->getAccessToken( $_GET[ 'oauth_verifier' ] );
if ( isset( $token[ 'oauth_token' ], $token[ 'oauth_token_secret' ] ) ) {
@@ -1118,12 +1146,11 @@ public function twitter_oauth() {
update_option( 'webcomic_options', self::$config );
- wp_die( sprintf( __( 'Newly published %s webcomics will be tweeted to <a href="%s">%s</a>. <a href="%s">Return to %s Settings</a>', 'webcomic' ),
+ wp_die( sprintf( __( 'Newly published %1$s webcomics will be tweeted to <a href="%2$s">%3$s</a>. <a href="%4$s">Return to %1s Settings</a>', 'webcomic' ),
self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'name' ],
"http://twitter.com/{$token[ 'screen_name' ]}",
$token[ 'screen_name' ],
- $admin_url,
- self::$config[ 'collections' ][ $_GET[ 'webcomic_collection' ] ][ 'name' ]
+ $admin_url
), __( 'Twitter Authorization Complete | Webcomic', 'webcomic' ), array( 'response' => 200 ) );
} else {
wp_die( sprintf( __( 'Your credentials could not be verified. Please ensure that your <b>consumer key</b> and <b>consumer secret</b> were entered correctly and <a href="%s">try again.</a>', 'webcomic' ), $admin_url ), __( 'Twitter Authorization Failed | Webcomic', 'webcomic' ), array( 'response' => 200 ) );
@@ -1207,8 +1234,8 @@ private function save_transcript() {
if ( self::$config[ 'collections' ][ $the_post->post_type ][ 'transcripts' ][ 'notify' ][ 'hook' ] ) {
wp_mail(
self::$config[ 'collections' ][ $the_post->post_type ][ 'transcripts' ][ 'notify' ][ 'email' ],
- sprintf( __( '[%s] %s Transcript Submitted', 'webcomic' ), get_bloginfo( 'name' ), $the_post->post_title ),
- sprintf( __( 'This is an automated notification that %s%s has <a href="%s">%s</a> for %s.', 'webcomic' ),
+ sprintf( __( '[%1$s] %2$s Transcript Submitted', 'webcomic' ), get_bloginfo( 'name' ), $the_post->post_title ),
+ sprintf( __( 'This is an automated notification that %1$s%2$s has <a href="%3$s">%4$s</a> for %5$s.', 'webcomic' ),
$_POST[ 'webcomic_transcript_author' ],
$_POST[ 'webcomic_transcript_email' ] ? " &lt;{$_POST[ 'webcomic_transcript_email' ]}&gt;" : '',
esc_url( admin_url( "post.php?post={$new_post}&action=edit" ) ),

0 comments on commit 9bcdd0a

Please sign in to comment.