Skip to content
Browse files

Final thrust!

Significant cleanup for final release, plus a couple of last-minute
feature additions and alterations.
  • Loading branch information...
1 parent 9bcdd0a commit 7c902bde6cc554b16a621b2918b8f8bae4030059 Michael Sisk committed Aug 12, 2012
Showing with 609 additions and 246 deletions.
  1. +3 −2 -/php/admin.php
  2. +115 −0 -/php/commerce.php
  3. +10 −10 -/php/config.php
  4. +65 −3 -/php/help.php
  5. +2 −2 -/php/posts.php
  6. +2 −2 -/php/shortcodes.php
  7. +104 −74 -/php/tags.php
  8. +2 −2 -/php/taxonomy.php
  9. +173 −45 -/php/widgets.php
  10. +2 −2 readme.md
  11. +3 −3 readme.txt
  12. +128 −101 webcomic.php
View
5 -/php/admin.php
@@ -50,6 +50,7 @@ public function __construct() {
require_once self::$dir . '-/php/users.php'; new WebcomicUsers;
require_once self::$dir . '-/php/media.php'; new WebcomicMedia;
require_once self::$dir . '-/php/config.php'; new WebcomicConfig;
+ require_once self::$dir . '-/php/commerce.php'; new WebcomicCommerce;
require_once self::$dir . '-/php/taxonomy.php'; new WebcomicTaxonomy;
require_once self::$dir . '-/php/transcripts.php'; new WebcomicTranscripts;
@@ -412,7 +413,7 @@ public function admin_init() {
public function admin_head() {
$screen = get_current_screen();
- if ( preg_match( '/^(page|options-media|media_page_webcomic-generator|settings_page_webcomic-options|(edit-)?webcomic_(transcript|language)|(webcomic\d+_page_|edit-)?webcomic\d+(-options|_storyline|_character)?)$/', $screen->id ) ) {
+ if ( preg_match( '/^(page|options-media|tools_page_webcomic-commerce|tools_page_webcomic-upgrader|media_page_webcomic-generator|settings_page_webcomic-options|(edit-)?webcomic_(transcript|language)|(webcomic\d+_page_|edit-)?webcomic\d+(-options|_storyline|_character)?)$/', $screen->id ) ) {
require_once self::$dir . '-/php/help.php';
new WebcomicHelp( $screen );
@@ -479,7 +480,7 @@ public function admin_enqueue_scripts() {
*/
public function plugin_row_meta( $meta, $file, $data ) {
if ( 'Webcomic' === $data[ 'Name' ] ) {
- $meta[] = sprintf( '<a href="%s" target="_blank">%s</a>', add_query_arg( array( 'hosted_button_id' => 'UD3J2DJPSN9UC' ), 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick' ), __( 'Donate', 'webcomic' ) );
+ $meta[] = sprintf( '<a href="%s" target="_blank">%s</a>', add_query_arg( array( 'hosted_button_id' => 'UD3J2DJPSN9UC' ), '//paypal.com/cgi-bin/webscr?cmd=_s-xclick' ), __( 'Donate', 'webcomic' ) );
if ( self::$config[ 'uninstall' ] ) {
$meta[] = sprintf( '<strong style="color:#bc0b0b">%s</strong>', self::$config[ 'convert' ] ? __( 'Webcomic data will be converted to posts, categories, and tags if the plugin is deactivated.', 'webcomic' ) : __( 'Webcomic data will be deleted if the plugin is deactivated.', 'webcomic' ) );
View
115 -/php/commerce.php
@@ -0,0 +1,115 @@
+<?php
+/** Contains the WebcomicCommerce class.
+ *
+ * @package Webcomic
+ */
+
+/** Handle the IPN log tool.
+ *
+ * @package Webcomic
+ */
+class WebcomicCommerce extends Webcomic {
+ /** Register hooks.
+ *
+ * @uses WebcomicCommerce::admin_init()
+ * @uses WebcomicCommerce::admin_menu()
+ */
+ public function __construct() {
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
+ }
+
+ /** Empty the current ipn log file.
+ *
+ * @uses Webcomic::$dir
+ * @uses Webcomic::$error
+ * @hook admin_init
+ */
+ public function admin_init() {
+ global $blog_id;
+
+ if ( isset( $_POST[ 'webcomic_commerce' ], $_POST[ 'empty_log' ] ) and wp_verify_nonce( $_POST[ 'webcomic_commerce' ], 'webcomic_commerce' ) ) {
+ $logfile = self::$dir . sprintf( '-/log/ipn-%s.php', $blog_id ? $blog_id : 1 );
+
+ if ( is_writable( $logfile ) ) {
+ file_put_contents( $logfile, "<?php die; ?>\n" );
+ } else {
+ self::$error[] = __( 'Webcomic could not empty the log file. Please try again.', 'webcomic' );
+ }
+
+ }
+ }
+
+ /** Register submenu page for ipn log viewer.
+ *
+ * @uses WebcomicCommerce::page()
+ * @hook admin_menu
+ */
+ public function admin_menu() {
+ add_submenu_page( 'tools.php', __( 'Webcomic Commerce', 'webcomic' ), __( 'Webcomic Commerce', 'webcomic' ), 'manage_options', 'webcomic-commerce', array( $this, 'page' ) );
+ }
+
+ /** Render the commerce tool page. */
+ public function page() {
+ global $blog_id;
+
+ $logfile = self::$dir . sprintf( '-/log/ipn-%s.php', $blog_id ? $blog_id : 1 );
+ $log = is_readable( $logfile ) ? str_replace( "<?php die; ?>\n", '', file_get_contents( $logfile ) ) : '';
+ ?>
+ <div class="wrap">
+ <div id="icon-tools" class="icon32"></div>
+ <h2><?php _e( 'Webcomic Commerce', 'webcomic' ); ?></h2>
+ <br>
+ <table class="wp-list-table widefat fixed">
+ <thead>
+ <tr>
+ <th><?php _e( 'Transaction', 'webcomic' ); ?></th>
+ <th><?php _e( 'Item', 'webcomic' ); ?></th>
+ <th><?php _e( 'Message', 'webcomic' ); ?></th>
+ <th class="column-date"><?php _e( 'Date', 'webcomic' ); ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ if ( $log ) {
+ $i = 0;
+ $log = explode( "\n", $log );
+
+ foreach ( $log as $l ) {
+ if ( empty( $l ) ) {
+ continue;
+ } else {
+ $l = explode( "\t", $l );
+ $l[ 1 ] = empty( $l[ 1 ] ) ? '' : strtotime( $l[ 1 ] );
+ $error = empty( $l[ 4 ] ) ? '' : ' style="color:#bc0b0b;font-weight:bold"';
+
+ if ( empty( $l[ 2 ] ) ) {
+ $l[ 2 ] = __( '- Shopping Cart -', 'webcomic' );
+ }
+ }
+ ?>
+ <tr<?php echo $i % 2 ? '' : ' class="alternate"'; ?>>
+ <td<?php echo $error; ?>><?php echo $l[ 0 ]; ?></td>
+ <td<?php echo $error; ?>><?php echo $l[ 2 ]; ?></td>
+ <td<?php echo $error; ?>><?php echo $l[ 3 ]; ?></td>
+ <td<?php echo $error; ?>><?php echo empty( $l[ 1 ] ) ? '' : sprintf( '<abbr title="%s">%s</abbr>', date( __( 'Y/m/d g:i:s A', 'webcomic' ), $l[ 1 ] ), date( __( 'Y/m/d', 'webcomic' ), $l[ 1 ] ) ); ?></td>
+ </tr>
+ <?php $i++; } } else { ?>
+ <tr>
+ <td colspan="4" class="alternate"><p><?php _e( "Webcomic hasn't logged any commerce activity.", 'webcomic' ); ?></p></td>
+ </tr>
+ <?php } ?>
+ </tbody>
+ </table>
+ <?php if ( $log ) { ?>
+ <form method="post" style="float:right">
+ <?php
+ wp_nonce_field( 'webcomic_commerce', 'webcomic_commerce' );
+ submit_button( __( 'Empty Log', 'webcomic' ), 'primary', 'empty_log' );
+ ?>
+ </form>
+ <?php } ?>
+ </div>
+ <?php
+ }
+}
View
20 -/php/config.php
@@ -402,7 +402,7 @@ public function collection_description() {
/** Render the Cover setting.
*
- * @filter integer webcomic_upload_size_limit
+ * @filter integer webcomic_upload_size_limit Filters the maximum allowed upload size for poster uploads. Defaults to the value returned by `wp_max_upload_size`.
* @uses Webcomic::$config
*/
public function collection_image() {
@@ -452,7 +452,7 @@ public function collection_theme() {
printf(
'<option value="%s"%s>%s</option>',
$theme[ 'Template' ],
- selected( self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'theme' ], $theme[ 'Template' ], false ),
+ selected( $theme[ 'Template' ], self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'theme' ], false ),
esc_html( $theme[ 'Name' ] )
);
}
@@ -556,7 +556,7 @@ public function collection_transcripts_languages() {
?>
<select name="webcomic_transcripts_languages[]" id="webcomic_transcripts_languages" style="min-height:8em;vertical-align:top" multiple>
<optgroup label="<?php esc_attr_e( 'Transcript Languages', 'webcomic' ); ?>">
- <option value="!"<?php selected( '!' === self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'transcripts' ][ 'languages' ][ 0 ] ); ?>><?php _e( '- Any -', 'webcomic' ); ?></option>
+ <option value="!"<?php selected( '!', self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'transcripts' ][ 'languages' ][ 0 ] ); ?>><?php _e( '- Any -', 'webcomic' ); ?></option>
<?php
if ( $terms = get_terms( 'webcomic_language', array( 'get' => 'all' ) ) and !is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
@@ -582,7 +582,7 @@ public function collection_transcripts_languages() {
public function collection_commerce_business() {
?>
<input type="email" name="webcomic_commerce_business" id="webcomic_commerce_business" value="<?php echo esc_attr( self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'commerce' ][ 'business' ] ); ?>" class="regular-text">
- <span class="description"><a href="http://paypal.com" target="_blank"><?php _e( 'Get a PayPal Account', 'webcomic' ); ?></a></span>
+ <span class="description"><a href="//paypal.com" target="_blank"><?php _e( 'Get a PayPal Account', 'webcomic' ); ?></a></span>
<?php
}
@@ -842,7 +842,7 @@ public function collection_slugs_archive() {
?>
<label>
<input type="text" name="webcomic_slugs[archive]" id="webcomic_slugs_archive" value="<?php echo self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'archive' ]; ?>" class="regular-text">
- <?php printf( '<span class="description">%s/<b>%s</b>/</span>', get_home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'archive' ] ); ?>
+ <?php printf( '<span class="description">%s/<b>%s</b>/</span>', home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'archive' ] ); ?>
</label>
<?php
}
@@ -855,7 +855,7 @@ public function collection_slugs_webcomic() {
?>
<label>
<input type="text" name="webcomic_slugs[webcomic]" id="webcomic_slugs_webcomic" value="<?php echo self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'webcomic' ]; ?>" class="regular-text">
- <?php printf( '<span class="description">%s/<b>%s</b>/single-webcomic-slug</span>', get_home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'webcomic' ] ); ?>
+ <?php printf( '<span class="description">%s/<b>%s</b>/single-webcomic-slug</span>', home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'webcomic' ] ); ?>
</label>
<?php
}
@@ -868,7 +868,7 @@ public function collection_slugs_storyline() {
?>
<label>
<input type="text" name="webcomic_slugs[storyline]" id="webcomic_slugs_storyline" value="<?php echo self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'storyline' ]; ?>" class="regular-text">
- <?php printf( '<span class="description">%s/<b>%s</b>/single-storyline-slug</span>', get_home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'storyline' ] ); ?>
+ <?php printf( '<span class="description">%s/<b>%s</b>/single-storyline-slug</span>', home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'storyline' ] ); ?>
</label>
<?php
}
@@ -881,7 +881,7 @@ public function collection_slugs_character() {
?>
<label>
<input type="text" name="webcomic_slugs[character]" id="webcomic_slugs_character" value="<?php echo self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'character' ]; ?>" class="regular-text">
- <?php printf( '<span class="description">%s/<b>%s</b>/single-character-slug</span>', get_home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'character' ] ); ?>
+ <?php printf( '<span class="description">%s/<b>%s</b>/single-character-slug</span>', home_url(), self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'slugs' ][ 'character' ] ); ?>
</label>
<?php
}
@@ -1122,7 +1122,7 @@ public function save( $options ) {
if ( $collection[ 'twitter' ][ 'consumer_key' ] !== self::$config[ 'collections' ][ $id ][ 'twitter' ][ 'consumer_key' ] or $collection[ 'twitter' ][ 'consumer_secret' ] !== self::$config[ 'collections' ][ $id ][ 'twitter' ][ 'consumer_secret' ] ) {
$collection[ 'twitter' ][ 'oauth_token' ] = $collection[ 'twitter' ][ 'oauth_secret' ] = '';
- } else if ( $twitter[ 'oauth_token' ] and $twitter[ 'oauth_secret' ] ) {
+ } else if ( $collection[ 'twitter' ][ 'oauth_token' ] and $collection[ 'twitter' ][ 'oauth_secret' ] ) {
$collection[ 'twitter' ][ 'request_token' ] = $collection[ 'twitter' ][ 'request_secret' ] = '';
}
@@ -1132,7 +1132,7 @@ public function save( $options ) {
$collection[ 'commerce' ][ 'total' ][ 'international' ] = round( $collection[ 'commerce' ][ 'price' ][ 'international' ] + $collection[ 'commerce' ][ 'shipping' ][ 'international' ], 2 );
$collection[ 'commerce' ][ 'total' ][ 'original' ] = round( $collection[ 'commerce' ][ 'price' ][ 'original' ] + $collection[ 'commerce' ][ 'shipping' ][ 'original' ], 2 );
- if ( $_POST[ 'webcomic_transcripts_languages' ] and !in_array( '!', $_POST[ 'webcomic_transcripts_languages' ] ) ) {
+ if ( !empty( $_POST[ 'webcomic_transcripts_languages' ] ) and !in_array( '!', $_POST[ 'webcomic_transcripts_languages' ] ) ) {
$collection[ 'transcripts' ][ 'languages' ] = array();
foreach ( $_POST[ 'webcomic_transcripts_languages' ] as $language ) {
View
68 -/php/help.php
@@ -14,6 +14,8 @@ class WebcomicHelp extends Webcomic {
* @param object $screen Current screen object.
* @uses WebcomicHelp::sidebar()
* @uses WebcomicHelp::media_sizes()
+ * @uses WebcomicHelp::commerce_overview()
+ * @uses WebcomicHelp::legacy_overview()
* @uses WebcomicHelp::generator_overview()
* @uses WebcomicHelp::settings_general()
* @uses WebcomicHelp::settings_collections()
@@ -68,6 +70,18 @@ public function __construct( $screen ) {
'title' => __( 'Additional Image Sizes', 'webcomic' ),
'content' => $this->media_sizes()
) );
+ } else if ( 'tools_page_webcomic-commerce' === $screen->id ) {
+ $screen->add_help_tab( array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview', 'webcomic' ),
+ 'content' => $this->commerce_overview()
+ ) );
+ } else if ( 'tools_page_webcomic-upgrader' === $screen->id ) {
+ $screen->add_help_tab( array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview', 'webcomic' ),
+ 'content' => $this->legacy_overview()
+ ) );
} else if ( 'media_page_webcomic-generator' === $screen->id ) {
$screen->add_help_tab( array(
'id' => 'overview',
@@ -537,7 +551,7 @@ private function edit_webcomic_customize() {
private function edit_webcomic_media() {
return sprintf( '
<p>%s</p>',
- __( "To attach a file to your webcomic, click <em>Add Attachments</em> in the Webcomic Media box or the <em>Upload/Insert</em> icon above the webcomic editor and follow the instructions. Webcomic will automatically recognize any images attached to your webcomic, so as long as you've enabled the <em>Integrate</em> option, are using an official Webcomic theme, or have added Webcomic's template tags to your theme you do not need to insert the images into your post. The Webcomic Media box will show previews of all the images attached to your webcomic after the media popup has been dismissed.", 'webcomic' )
+ __( "To attach a file to your webcomic, click <em>Add Attachments</em> in the Webcomic Media box or the <em>Upload/Insert</em> icon above the webcomic editor and follow the instructions. Webcomic will automatically recognize any images attached to your webcomic, so as long as you've enabled the <em>Integrate</em> option, are using a Webcomic-ready theme, or have added Webcomic's template tags to your theme you do not need to insert the images into your post. The Webcomic Media box will show previews of all the images attached to your webcomic after the media popup has been dismissed.", 'webcomic' )
);
}
@@ -714,7 +728,7 @@ private function languages_adding() {
<p>%s</p>',
__( "When adding a new language on this screen, you'll fill in the following fields:", 'webcomic' ),
__( '<strong>Name</strong> - The name is how it appears on your site.', 'webcomic' ),
- sprintf( __( '<strong>Slug</strong> - The "slug" is the URL-friendly version of the name. It should be an appropriate <a href="%s" target="_blank">language subtag</a>.', 'webcomic' ), 'http://www.iana.org/assignments/language-subtag-registry' ),
+ sprintf( __( '<strong>Slug</strong> - The "slug" is the URL-friendly version of the name. It should be an appropriate <a href="%s" target="_blank">language subtag</a>.', 'webcomic' ), '//iana.org/assignments/language-subtag-registry' ),
__( '<strong>Description</strong> - The description is not prominent by default; it may be used in various ways, however.', 'webcomic' ),
__( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.', 'webcomic' )
);
@@ -953,7 +967,55 @@ private function media_sizes() {
);
}
- /** Return additional sizes help.
+ /** Return commerce overview help.
+ *
+ * @return string
+ */
+ private function commerce_overview() {
+ global $blog_id;
+
+ return sprintf( '
+ <p>%s</p>
+ <ul>
+ <li>%s</li>
+ <li>%s</li>
+ <li>%s</li>
+ <li>%s</li>
+ </ul>
+ <p>%s</p>',
+ __( "The Webcomic Commerce tool displays the PayPal Instant Payment Notification (IPN) data that Webcomic has recorded, including:", 'webcomic' ),
+ __( '<strong>Transaction</strong> - The transaction ID provided by PayPal.', 'webcomic' ),
+ __( "<strong>Item</strong> - The item ID generated by Webcomic and sent to PayPal. Item ID's may appear as a collection ID for donations (like <em>webcomic42</em>) or as a post ID, collection ID, and type string for print sales (like <em>101-webcomic42-domestic</em>).", 'webcomic' ),
+ __( '<strong>Message</strong> - A transaction message generated by Webcomic.', 'webcomic' ),
+ __( '<strong>Date</strong> - The date the transaction took place. Hover over the date to see the full timestamp provided by PayPal.', 'webcomic' ),
+ __( 'Webcomic records this data for informational purposes only, such as noting transaction errors (which will appear as bold red entries in the list). Similar information should be available through your PayPal account. You may remove all of the IPN data Webcomic has recorded by clicking <strong>Empty Log</strong> at the bottom of the list.', 'webcomic' )
+ );
+ }
+
+ /** Return upgrade webcomic help.
+ *
+ * @return string
+ */
+ private function legacy_overview() {
+ return sprintf( '
+ <p>%s</p>
+ <ol>
+ <li>%s</li>
+ <li>%s</li>
+ <li>%s</li>
+ <li>%s</li>
+ <li>%s</li>
+ </ol>',
+ sprintf( __( "The Upgrade Webcomic tool attempts 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. If you're upgrading to Webcomic 4 from Webcomic 1, 2, or 3 please read the following carefully:", 'webcomic' ), self::$config[ 'legacy' ], self::$version ),
+ sprintf( __( 'Upgrades are not reversible and, once begun, should not be stopped. You should <a href="%1$s">backup your site</a> before starting the <em>irreversible</em>, <em>unstoppable</em> upgrade, or click <strong>Not Interested</strong> to uninstall Webcomic %2$s.', 'webcomic' ), esc_url( admin_url( 'export.php' ) ), self::$version ),
+ sprintf( __( 'Webcomic %s uses <a href="%1$s" target="_blank">the WordPress Media Library</a> for file management. All of your existing webcomic files must be imported into the media library during the upgrade. Existing files will not be moved or deleted; they will be <strong>copied</strong> into the media library.', 'webcomic' ), 'http://codex.wordpress.org/Media_Library_Screen' ),
+ sprintf( __( "The permalink URL's to your webcomics may change after upgrading. Permalinks <a href='%s' target=''>may be customized</a> for each of your collections once the upgrade is complete.", 'webcomic' ), '//github.com/mgsisk/webcomic/wiki/Permalink-Settings' ),
+ sprintf( __( 'Webcomic 1, 2, and 3 themes are <em>not</not> compatible with Webcomic 4, but a selection of <a href="%1$s" target="_blank">new Webcomic-ready themes</a>. are available for Webcomic %2$s.', 'webcomic' ), 'http://webcomic.nu/themes', self::$version ),
+ sprintf( __( "Webcomic %s includes an array of new <a href='//github.com/mgsisk/webcomic/wiki/Template-Tags-and-Shortcodes' target='_blank'>template tags, shortcodes</a>, and <a href='//github.com/mgsisk/webcomic/wiki/Widgets' target='_blank'>widgets</a> that function differently from previous versions. If you have customized an existing WordPress theme or built your own using Webcomic's template tags, shortcodes, and/or widgets your theme may need to be updated.", 'webcomic' ), self::$version )
+ );
+ }
+
+ /** Return additional page collection help.
*
* @return string
*/
View
4 -/php/posts.php
@@ -237,7 +237,7 @@ public function save_webcomic_commerce( $id, $post ) {
* @param string $post Post object to update.
* @uses Webcomic::$config
* @hook transition_post_status
- * @filter string webcomic_tweet $post
+ * @filter string webcomic_tweet Filters the tweet text pushed to Twitter whenever a webcomic is published. Defaults to the collection-specific tweet format.
*/
public function tweet_webcomic( $new, $old, $post ) {
if ( 'publish' === $new and 'publish' !== $old and !empty( self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'format' ] ) and !empty( self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'oauth_token' ] ) and !empty( self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'oauth_secret' ] ) ) {
@@ -550,7 +550,7 @@ public function commerce( $post ) {
wp_nonce_field( 'webcomic_meta_commerce', 'webcomic_meta_commerce' );
?>
- <p><label><input type="checkbox" name="webcomic_commerce_prints"<?php disabled( !self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] ); checked( ( 'auto-draft' === $post->post_status and self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'prints' ] ) or ( self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] and get_post_meta( $post->ID, 'webcomic_prints', true ) ) ); ?>> <?php _e( 'Sell prints', 'webcomic' ); ?></label></p>
+ <p><label><input type="checkbox" name="webcomic_commerce_prints"<?php checked( ( 'auto-draft' === $post->post_status and self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'prints' ] ) or ( self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] and get_post_meta( $post->ID, 'webcomic_prints', true ) ) ); disabled( !self::$config[ 'collections' ][ $post->post_type ][ 'commerce' ][ 'business' ] ); ?>> <?php _e( 'Sell prints', 'webcomic' ); ?></label></p>
<div style="margin:0 -11px">
<table class="widefat fixed">
<thead>
View
4 -/php/shortcodes.php
@@ -117,7 +117,7 @@ public function init() {
* @return string
* @uses WebcomicTag::verify_webcomic_age()
* @uses WebcomicTag::get_webcomic_collection()
- * @filter string webcomic_verify_age_inline $clear, $collection, $age, $content
+ * @filter string webcomic_verify_age_inline Filters the output of the `verify_webcomic_age` shortcode. Defaults to a generic age verification message.
*/
public function verify_webcomic_age( $atts, $content ) {
extract( shortcode_atts( array(
@@ -152,7 +152,7 @@ public function verify_webcomic_age( $atts, $content ) {
* @param string $content Shortcode content.
* @return string
* @uses WebcomicTag::verify_webcomic_role()
- * @filter string webcomic_verify_role_inline $loggedin, $collection, $roles, $content
+ * @filter string webcomic_verify_role_inline Filters the output of the `verify_webcomic_role` shortcode. Defaults to a generic role verification message.
*/
public function verify_webcomic_role( $atts, $content ) {
extract( shortcode_atts( array(
View
178 -/php/tags.php
@@ -1,8 +1,6 @@
<?php
/** Contains the WebcomicTag class and template tag functions.
*
- * @todo is_webcomic_attachment
- * @todo is_a_webcomic_attachment
* @package Webcomic
*/
@@ -253,6 +251,16 @@ public static function is_a_webcomic_attachment( $the_post = false, $collection
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 Webcomic-recognized attachments?
+ *
+ * @param mixed $the_post Post object or ID to check.
+ * @return boolean
+ * @uses Webcomic::get_attachments
+ */
+ public static function has_webcomic_attachments( $the_post = false ) {
+ return ( boolean ) self::get_attachments( $the_post );
+ }
+
/** Does the current webcomic have any transcripts?
*
* @param boolean $pending Does the current webcomic have any transcripts pending review?
@@ -383,7 +391,7 @@ public static function verify_webcomic_role( $collection = '', $user = false, $r
* @uses Webcomic::$config
* @uses Webcomic::get_attachments()
* @uses WebcomicTag::relative_webcomic_link()
- * @filter string the_webcomic $the_post, $attachments
+ * @filter string the_webcomic Filters the output of `the_webcomic`.
*/
public static function the_webcomic( $size = 'full', $relative = '', $in_same_term = false, $excluded_terms = false, $taxonomy = 'storyline', $the_post = false ) {
if ( $the_post = get_post( $the_post ) and isset( self::$config[ 'collections' ][ $the_post->post_type ] ) and $attachments = self::get_attachments( $the_post->ID ) ) {
@@ -407,11 +415,11 @@ public static function the_webcomic( $size = 'full', $relative = '', $in_same_te
/** Return an array of webomics related to the current webcomic.
*
- * @filter array get_related_webcomics $storylines, $characters, $the_post
* @param boolean $storylines Match based on storylines.
* @param boolean $characters Match based on characters.
* @param mixed $the_post The post object or ID to match.
* @return array
+ * @filter array get_related_webcomics Filters the webcomics returned by `get_related_webcomics` and used by `the_related_webcomics`.
*/
public static function get_related_webcomics( $storylines = true, $characters = true, $the_post = false ) {
if ( $the_post = get_post( $the_post ) and isset( self::$config[ 'collections' ][ $the_post->post_type ] ) ) {
@@ -491,9 +499,9 @@ public static function the_related_webcomics( $before = '', $sep = ', ', $after
* @return object
* @uses Webcomic::$config
* @uses Webcomic::$collection
- * @filter string get_{$relative}_webcomic_join $in_same_term, $excluded_terms
- * @filter string get_{$relative}_webcomic_where $in_same_term, $excluded_terms
- * @filter string get_{$relative}_webcomic_sort $or
+ * @filter string get_{$relative}_webcomic_join Filters the JOIN portion of the MySQL query used to retrieve relative webcomics, one of `next`, `previous`, `first`, `last`, or `random`.
+ * @filter string get_{$relative}_webcomic_where Filters the WHERE portion of the MySQL query used to retrieve relative webcomics, one of `next`, `previous`, `first`, `last`, or `random`.
+ * @filter string get_{$relative}_webcomic_sort Filters the SORT portion of the MySQL query used to retrieve relative webcomics, one of `next`, `previous`, `first`, `last`, or `random`.
*/
public static function get_relative_webcomic( $relative = 'random', $in_same_term = false, $excluded_terms = false, $taxonomy = 'storyline', $collection = '' ) {
global $wpdb, $post;
@@ -582,7 +590,7 @@ public static function get_relative_webcomic( $relative = 'random', $in_same_ter
* @param string $collection The collection to retrieve from. Used when retrieving first, last, or random webcomics outside of the loop.
* @return string
* @uses WebcomicTag::get_relative_webcomic()
- * @filter string get_{$relative}_webcomic_link $the_post, $in_same_term, $excluded_terms, $taxonomy, $collection
+ * @filter string get_{$relative}_webcomic_link Filters the relative webcomic URL returned by `get_relative_webcomic_link` and used by `previous_webcomic_link`, `next_webcomic_link`, `first_webcomic_link`, `last_webcomic_link`, and `random_webcomic_link`.
*/
public static function get_relative_webcomic_link( $relative = 'random', $in_same_term = false, $excluded_terms = false, $taxonomy = 'storyline', $collection = '' ) {
if ( $the_post = self::get_relative_webcomic( $relative, $in_same_term, $excluded_terms, $taxonomy, $collection ) ) {
@@ -598,10 +606,10 @@ public static function get_relative_webcomic_link( $relative = 'random', $in_sam
* @param string $taxonomy The taxonomy of the terms specified with $in_same_term and $excluded_terms arguments. The shorthand 'storyline' or 'character' may be used.
* @return string
* @uses Webcomic::$config
- * @filter string get_random-nocache_webcomic_link $collection, $in_same_term, $excluded_terms, $taxonomy
+ * @filter string get_random-nocache_webcomic_link Filters the cache proof URL returned by `get_random_webcomic_link` and used by `relative_webcomic_link`.
*/
public static function get_random_webcomic_link( $collection, $in_same_term = false, $excluded_terms = false, $taxonomy = 'storyline' ) {
- return empty( self::$config[ 'collections' ][ $collection ] ) ? '' : apply_filters( 'get_random-nocache_webcomic_link', add_query_arg( array( 'random_webcomic' => $collection, 'in_same_story' => $in_same_term ? urlencode( maybe_serialize( $in_same_term ) ) : false, 'excluded_storylines' => $excluded_terms ? urlencode( maybe_serialize( $excluded_terms ) ) : false, 'taxonomy' => $taxonomy ? $taxonomy : false ), get_home_url() ), $collection, $in_same_term, $excluded_terms, $taxonomy );
+ return empty( self::$config[ 'collections' ][ $collection ] ) ? '' : apply_filters( 'get_random-nocache_webcomic_link', add_query_arg( array( 'random_webcomic' => $collection, 'in_same_story' => $in_same_term ? urlencode( maybe_serialize( $in_same_term ) ) : false, 'excluded_storylines' => $excluded_terms ? urlencode( maybe_serialize( $excluded_terms ) ) : false, 'taxonomy' => $taxonomy ? $taxonomy : false ), home_url() ), $collection, $in_same_term, $excluded_terms, $taxonomy );
}
/** Return a relative webcomic link.
@@ -617,7 +625,7 @@ public static function get_random_webcomic_link( $collection, $in_same_term = fa
* @uses Webcomic::get_attachments()
* @uses WebcomicTag::get_relative_webcomic()
* @uses WebcomicTag::get_random_webcomic_link()
- * @filter string {$relative}_webcomic_link $link, $in_same_term, $excluded_terms, $taxonomy, $collection
+ * @filter string {$relative}_webcomic_link Filters the output of the relative webcomic link template tags: `previous_webcomic_link`, `next_webcomic_link`, `first_webcomic_link`, `last_webcomic_link`, and `random_webcomic_link`.
*/
public static function relative_webcomic_link( $format, $link, $relative = 'random', $in_same_term = false, $excluded_terms = false, $taxonomy = 'storyline', $collection = '' ) {
global $post;
@@ -697,7 +705,7 @@ public static function relative_webcomic_link( $format, $link, $relative = 'rand
* @param mixed $the_post Post object or ID to retrive the purchase link for.
* @return string
* @uses WebcomicTag::webcomic_prints_available()
- * @filter string get_purchase_webcomic_link $permalink $the_post
+ * @filter string get_purchase_webcomic_link Filters the URL returned by `get_purchase_webcomic_link` and used by `purchase_webcomic_link`.
*/
public static function get_purchase_webcomic_link( $the_post = false ) {
global $wp_rewrite;
@@ -717,7 +725,7 @@ public static function get_purchase_webcomic_link( $the_post = false ) {
* @return string
* @uses Webcomic::get_attachments()
* @uses WebcomicTag::get_purchase_webcomic_link()
- * @filter string purchase_webcomic_link $link, $the_post
+ * @filter string purchase_webcomic_link Filters the output of `purchase_webcomic_link`.
*/
public static function purchase_webcomic_link( $format, $link, $the_post = false ) {
if ( $the_post = get_post( $the_post ) and $href = self::get_purchase_webcomic_link( $the_post ) ) {
@@ -766,7 +774,7 @@ public static function purchase_webcomic_link( $format, $link, $the_post = false
* @return string
* @uses Webcomic::$config
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_collection_link $link, $target, $collection
+ * @filter string webcomic_collection_link Filters the output of `the_webcomic_collection`.
*/
public static function webcomic_collection_link( $format, $link, $target = 'archive', $collection = '' ) {
global $post;
@@ -813,8 +821,8 @@ public static function webcomic_collection_link( $format, $link, $target = 'arch
* @param string $image Image size to use when displaying term images for links.
* @return string
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_term_links-webcomic\d+_{$taxonomy} $terms, $before, $sep, $after, $target, $image
- * @filter string the_webcomic_term_list $id, $before, $sep, $after, $target, $image, $taxonomy
+ * @filter string webcomic_term_links-webcomic\d+_{$taxonomy} Filters the array of term links generated by `get_the_webcomic_term_list` and used by `the_webcomic_storylines` and `the_webcomic_characters`.
+ * @filter string the_webcomic_term_list Filters the output of `get_the_webcomic_term_list` used by `the_webcomic_storylines` and `the_webcomic_characters`.
*/
public static function get_the_webcomic_term_list( $id = 0, $taxonomy, $before = '', $sep = ', ', $after = '', $target = 'archive', $image = '' ) {
global $post;
@@ -929,7 +937,7 @@ public static function get_relative_webcomic_term( $relative = 'random', $taxono
* @param array $args An array of arguments to pass to get_terms().
* @return string
* @uses WebcomicTag::get_relative_webcomic_term()
- * @filter string get_{$relative}_webcomic_term_link $target, $term, $args
+ * @filter string get_{$relative}_webcomic_term_link Filters the URL returned by `get_relative_webcomic_term_link` and used by the
*/
public static function get_relative_webcomic_term_link( $target = 'archive', $relative = 'random', $taxonomy = '', $args = array() ) {
global $wpdb;
@@ -960,10 +968,10 @@ public static function get_relative_webcomic_term_link( $target = 'archive', $re
* @param string $target The target url, one of 'archive', 'first', 'last', or 'random'.
* @param array $args An array of arguments to pass to get_terms().
* @return string
- * @filter string get_random-nocache_webcomic_term_link $taxonomy, $target, $args
+ * @filter string get_random-nocache_webcomic_term_link Filters the cache-proof URL returned by `get_random_webcomic_term_link` and used by `random_webcomic_link`.
*/
public static function get_random_webcomic_term_link( $taxonomy, $target = 'archive', $args = array() ) {
- return apply_filters( 'get_random-nocache_webcomic_term_link', add_query_arg( array( 'random_webcomic_term' => $taxonomy, 'target' => $target, 'args' => $args ? urlencode( maybe_serialize( $args ) ) : false ), get_home_url() ), $taxonomy, $target, $args );
+ return apply_filters( 'get_random-nocache_webcomic_term_link', add_query_arg( array( 'random_webcomic_term' => $taxonomy, 'target' => $target, 'args' => $args ? urlencode( maybe_serialize( $args ) ) : false ), home_url() ), $taxonomy, $target, $args );
}
/** Return a relative term link.
@@ -978,7 +986,7 @@ public static function get_random_webcomic_term_link( $taxonomy, $target = 'arch
* @uses WebcomicTag::get_relative_webcomic_term()
* @uses WebcomicTag::get_relative_webcomic_term_link()
* @uses WebcomicTag::get_random_webcomic_term_link()
- * @filter string {$relative}_webcomic_term_link $link, $target, $term, $args
+ * @filter string {$relative}_webcomic_term_link Filters the output of the relative webcomic term link template tags: `previous_webcomic_storyline_link`, `next_webcomic_storyline_link`, `first_webcomic_storyline_link`, `last_webcomic_storyline_link`, `random_webcomic_storyline_link`, `previous_webcomic_character_link`, `next_webcomic_character_link`, `first_webcomic_character_link`, `last_webcomic_character_link`, `random_webcomic_character_link`.
*/
public static function relative_webcomic_term_link( $format, $link, $target = 'archive', $relative = 'random', $taxonomy = '', $args = array() ) {
global $wpdb;
@@ -1043,7 +1051,7 @@ public static function relative_webcomic_term_link( $format, $link, $target = 'a
* @param mixed $term Term ID or object to return a title for.
* @param string $taxonomy The taxonomy $term belongs to.
* @return string
- * @filter string webcomic_term_title $prefix, $term
+ * @filter string webcomic_term_title Filters the term title returned by `webcomic_term_title` and used by `webcomic_storyline_title` and `webcomic_character_title`.
*/
public static function webcomic_term_title( $prefix = '', $term = 0, $taxonomy = '' ) {
$term = $taxonomy ? get_term( $term, $taxonomy ) : get_queried_object();
@@ -1060,7 +1068,7 @@ public static function webcomic_term_title( $prefix = '', $term = 0, $taxonomy =
* @param integer $term Term ID to return a description for. Will use global term ID by default.
* @param string $taxonomy Taxonomy the term belongs to.
* @return string
- * @filter string webcomic_term_description $term
+ * @filter string webcomic_term_description Filters the term description returned by `webcomic_term_description` and used by `webcomic_storyline_description` and `webcomic_character_description`.
*/
public static function webcomic_term_description( $term = 0, $taxonomy = '' ) {
$term = $taxonomy ? get_term( $term, $taxonomy ) : get_queried_object();
@@ -1076,7 +1084,7 @@ public static function webcomic_term_description( $term = 0, $taxonomy = '' ) {
* @param integer $term Term ID. Will use global term ID by default.
* @param string $taxonomy The taxonomy $term must belongs to.
* @return string
- * @filter string webcomic_term_image $size, $term
+ * @filter string webcomic_term_image Filters the term image returned by `webcomic_term_image` and used by `webcomic_storyline_cover` and `webcomic_character_avatar`.
*/
public static function webcomic_term_image( $size = 'full', $term = 0, $taxonomy = '' ) {
$term = $taxonomy ? get_term( $term, $taxonomy ) : get_queried_object();
@@ -1115,7 +1123,7 @@ public static function webcomic_collection_title( $prefix = '', $collection = ''
* @return string
* @uses Webcomic::$config
* @uses Webcomic::$collection
- * @filter string webcomic_collection_description $collection
+ * @filter string webcomic_collection_description Filters the output of `webcomic_collection_description`.
*/
public static function webcomic_collection_description( $collection = '' ) {
$collection = $collection ? $collection : self::$collection;
@@ -1132,7 +1140,7 @@ public static function webcomic_collection_description( $collection = '' ) {
* @return string
* @uses Webcomic::$config
* @uses Webcomic::$collection
- * @filter string webcomic_collection_image $size, $collection
+ * @filter string webcomic_collection_image Filters the the image returned by `webcomic_collection_image` and used by `webcomic_collection_poster`.
*/
public static function webcomic_collection_image( $size = 'full', $collection = '' ) {
$colleciton = $collection ? $collection : self::$collection;
@@ -1149,7 +1157,7 @@ public static function webcomic_collection_image( $size = 'full', $collection =
* @return string
* @uses Webcomic::$config
* @uses Webcomic::$collection
- * @filter string webcomic_collection_print_amount $dec, $sep, $collection
+ * @filter string webcomic_collection_print_amount Filters the output of `webcomic_collection_print_amount`.
*/
public static function webcomic_collection_print_amount( $type, $dec = '.', $sep = ',', $collection = '' ) {
$collection = $collection ? $collection : self::$collection;
@@ -1181,7 +1189,7 @@ public static function webcomic_collection_print_amount( $type, $dec = '.', $sep
* @return string
* @uses Webcomic::$config
* @uses Webcomic::$collection
- * @filter string webcomic_donation_amount $dec, $sep, $collection
+ * @filter string webcomic_donation_amount Filters the output of `webcomic_donation_amount`.
*/
public static function webcomic_donation_amount( $dec = '.', $sep = ',', $collection = '' ) {
$collection = $collection ? $collection : self::$collection;
@@ -1203,7 +1211,7 @@ public static function webcomic_donation_amount( $dec = '.', $sep = ',', $collec
* @param string $collection The collection to render donation fields for.
* @return string
* @uses Webcomic::$config
- * @filter string webcomic_donation_fields $collection
+ * @filter string webcomic_donation_fields Filters the output of `webcomic_donation_fields`.
*/
public static function webcomic_donation_fields( $collection = '' ) {
$collection = $collection ? $collection : self::$collection;
@@ -1220,10 +1228,10 @@ public static function webcomic_donation_fields( $collection = '' ) {
<input type="hidden" name="item_number" value="%s">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="currency_code" value="%s">%s',
- get_home_url(),
+ home_url(),
self::$config[ 'collections' ][ $collection ][ 'commerce' ][ 'business' ],
esc_attr( substr( self::$config[ 'collections' ][ $collection ][ 'name' ], 0, 127 ) ),
- add_query_arg( array( 'webcomic_commerce_ipn' => 'donation' ), get_home_url() ),
+ add_query_arg( array( 'webcomic_commerce_ipn' => 'donation' ), home_url( '/' ) ),
$collection,
self::$config[ 'collections' ][ $collection ][ 'commerce' ][ 'currency' ],
self::$config[ 'collections' ][ $collection ][ 'commerce' ][ 'donation' ] ? sprintf( '<input type="hidden" name="amount" value="%s">', self::$config[ 'collections' ][ $collection ][ 'commerce' ][ 'donation' ] ) : ''
@@ -1244,7 +1252,7 @@ public static function webcomic_donation_fields( $collection = '' ) {
* @uses Webcomic::$config
* @uses Webcomic::$collection
* @uses WebcomicTag::webcomic_donation_fields()
- * @filter string webcomic_donation_form $label, $collection
+ * @filter string webcomic_donation_form Filters the output of `webcomic_donation_form`.
*/
public static function webcomic_donation_form( $label = '', $collection = '' ) {
$collection = $collection ? $collection : self::$collection;
@@ -1274,7 +1282,7 @@ public static function webcomic_donation_form( $label = '', $collection = '' ) {
* @param mixed $the_post The post object or ID to get print amounts for.
* @return string
* @uses Webcomic::$config
- * @filter string webcomic_print_amount $type, $dec, $sep, $the_post
+ * @filter string webcomic_print_amount Filters the output of `webcomic_print_amount`.
*/
public static function webcomic_print_amount( $type, $dec = '.', $sep = ',', $the_post = '' ) {
$type = explode( '-', $type );
@@ -1299,7 +1307,7 @@ public static function webcomic_print_amount( $type, $dec = '.', $sep = ',', $th
* @param mixed $the_post The post object or ID to get print adjustments for.
* @return string
* @uses Webcomic::$config
- * @filter string webcomic_print_adjustment $type, $the_post
+ * @filter string webcomic_print_adjustment Filters the output of `webcomic_print_adjustment`.
*/
public static function webcomic_print_adjustment( $type, $the_post = '' ) {
$type = explode( '-', $type );
@@ -1320,7 +1328,7 @@ public static function webcomic_print_adjustment( $type, $the_post = '' ) {
* @param mixed $the_post The post object or ID to get print adjustments for.
* @return string
* @uses Webcomic::$config
- * @filter string webcomic_print_fields $type, $the_post, $commerce
+ * @filter string webcomic_print_fields Filters the output of `webcomic_print_fields`.
*/
public static function webcomic_print_fields( $type, $the_post = false ) {
if ( !$type or !$the_post = get_post( $the_post ) or empty( self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'business' ] ) or ( 'cart' === $type and '_cart' !== self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'method' ] ) or !get_post_meta( $the_post->ID, 'webcomic_prints', true ) or ( 'original' === $type and !get_post_meta( $the_post->ID, 'webcomic_original', true ) ) ) {
@@ -1350,7 +1358,7 @@ public static function webcomic_print_fields( $type, $the_post = false ) {
$commerce[ 'total' ][ $type ],
self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'business' ],
substr( $the_post->post_title, 0, 127 ),
- add_query_arg( array( 'webcomic_commerce_ipn' => 'print' ), get_home_url() ),
+ add_query_arg( array( 'webcomic_commerce_ipn' => 'print' ), home_url( '/' ) ),
substr( "{$the_post->ID}-{$the_post->post_type}-{$type}", 0, 127 ),
self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'currency' ],
'_cart' === self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'method' ] ? 'add' : $quantity,
@@ -1373,7 +1381,7 @@ public static function webcomic_print_fields( $type, $the_post = false ) {
* @uses Webcomic::$config
* @uses WebcomicTag::webcomic_print_amount()
* @uses WebcomicTag::webcomic_print_fields()
- * @filter string webcomic_print_form $type, $label, $the_post
+ * @filter string webcomic_print_form Filters the output of `webcomic_print_form`.
*/
public static function webcomic_print_form( $type, $label = '', $the_post = false ) {
if ( !$the_post = get_post( $the_post ) or !$fields = self::webcomic_print_fields( $type, $the_post ) ) {
@@ -1447,7 +1455,7 @@ public static function webcomic_transcripts_template( $template = '' ) {
* @param mixed $the_post The post object or ID to get a transcript link to.
* @return string
* @uses WebcomicTag::webcomic_transcripts_open()
- * @filter string get_webcomic_transcripts_link $the_post, $anchor
+ * @filter string get_webcomic_transcripts_link Filters the URL returned by `get_webcomic_transcripts_link` and used by `webcomic_transcripts_link`.
*/
public static function get_webcomic_transcripts_link( $language = false, $the_post = false ) {
global $wp_rewrite;
@@ -1470,7 +1478,7 @@ public static function get_webcomic_transcripts_link( $language = false, $the_po
* @param mixed $language The language object or ID that transcripts should be limited to.
* @param mixed $the_post The post object or ID to get a transcript link to.
* @return string
- * @filter string webcomic_transcripts_link $link, $the_post
+ * @filter string webcomic_transcripts_link Filters the output of `webcomic_transcripts_link`.
*/
public static function webcomic_transcripts_link( $format, $none, $some, $off, $language = false, $the_post = false ) {
if ( $the_post = get_post( $the_post ) and $href = self::get_webcomic_transcripts_link( $language, $the_post ) ) {
@@ -1523,7 +1531,7 @@ public static function webcomic_transcripts_link( $format, $none, $some, $off, $
* @param array $args An array of arguments that will be passed to get_children().
* @param mixed $the_post The post object or ID to retrieve transcripts for.
* @return array
- * @filter array get_webcomic_transcripts $pending, $args, $the_post
+ * @filter array get_webcomic_transcripts Filters the array of transcripts returned by `get_webcomic_transcripts`.
*/
public static function get_webcomic_transcripts( $pending = false, $args = array(), $the_post = false ) {
if ( $the_post = get_post( $the_post ) ) {
@@ -1548,7 +1556,7 @@ public static function get_webcomic_transcripts( $pending = false, $args = array
* @param string $sep Separate items using this.
* @param string $after After list.
* @return string
- * @filter string the_webcomic_transcript_authors
+ * @filter string the_webcomic_transcript_authors Filters the author list returned by `get_webcomic_transcript_authors` and used by `the_webcomic_transcript_authors`.
*/
public static function get_webcomic_transcript_authors( $id = 0, $post_author = true, $before = '', $sep = ', ', $after = '' ) {
global $post;
@@ -1578,7 +1586,7 @@ public static function get_webcomic_transcript_authors( $id = 0, $post_author =
* @param string $sep Separate items using this.
* @param string $after After list.
* @return string
- * @filter string the_webcomic_transcript_term_list $id, $before, $sep, $after
+ * @filter string the_webcomic_transcript_term_list Filters the output of `get_the_webcomic_transcript_term_list` used by `the_webcomic_transcript_languages`.
*/
public static function get_the_webcomic_transcript_term_list( $id = 0, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
global $post;
@@ -1602,7 +1610,7 @@ public static function get_the_webcomic_transcript_term_list( $id = 0, $taxonomy
* @param mixed $the_post The post object or ID to submit a transcript for.
* @return string
* @uses Webcomic::$config
- * @filter string webcomic_transcript_fields $transcript, $the_post
+ * @filter string webcomic_transcript_fields Filters the output of `webcomic_transcript_fields`.
*/
public static function webcomic_transcript_fields( $transcript = false, $the_post = false ) {
if ( $the_post = get_post( $the_post ) and isset( self::$config[ 'collections' ][ $the_post->post_type ] ) and get_post_meta( $the_post->ID, 'webcomic_transcripts', true ) ) {
@@ -1645,22 +1653,22 @@ public static function webcomic_transcript_fields( $transcript = false, $the_pos
* @uses Webcomic::$config
* @uses WebcomicTag::webcomic_transcripts_open()
* @uses WebcomicTag::webcomic_transcript_fields()
- * @action webcomic_transcript_form_before
- * @action webcomic_transcript_form_must_log_in_after
- * @action webcomic_transcript_form_top
- * @action webcomic_transcript_form_logged_in_after
- * @action webcomic_transcript_form_before_fields
- * @action webcomic_transcript_form_after_fields
- * @action webcomic_transcript_form
- * @action webcomic_transcript_form_after
- * @action webcomic_transcript_form_closed
- * @filter array webcomic_transcript_form_defaults
- * @filter array webcomic_transcript_form_default_fields
- * @filter string webcomic_transcript_form_logged_in
- * @filter string webcomic_transcript_form_field_{$field}
- * @filter string webcomic_transcript_form_field_language
- * @filter string webcomic_transcript_form_field_transcript
- * @filter string webcomic_transcript_form_field_submit
+ * @action webcomic_transcript_form_before Triggered before webcomic transcript form output begins.
+ * @action webcomic_transcript_form_must_log_in_after Triggered if users must be registered and logged in to transcribe and the current user is not logged in.
+ * @action webcomic_transcript_form_top Triggered just after the opening `<form>` tag.
+ * @action webcomic_transcript_form_logged_in_after Triggered if the current user is registered and logged in.
+ * @action webcomic_transcript_form_before_fields Triggered just before form field output begins.
+ * @action webcomic_transcript_form_after_fields Triggered just after form field output ends.
+ * @action webcomic_transcript_form Triggered just before the closing `<form>` tag.
+ * @action webcomic_transcript_form_after Triggered after webcomic transcript form output has ended.
+ * @action webcomic_transcript_form_closed Triggered if transcription is closed.
+ * @filter array webcomic_transcript_form_defaults Filters the array of default arguments used by `webcomic_transcript_form`.
+ * @filter array webcomic_transcript_form_default_fields Filters the array of default fields used by `webcomic_transcript_form`.
+ * @filter string webcomic_transcript_form_logged_in Filters the message displayed by `webcomic_transcript_form` for logged in users.
+ * @filter string webcomic_transcript_form_field_{$field} Filters the individual fields from the `$fields` argument used by `webcomic_transcript_form`.
+ * @filter string webcomic_transcript_form_field_language Filters the webcomic transcript language field used by `webcomic_transcript_form`.
+ * @filter string webcomic_transcript_form_field_transcript Filters the non-wysiwyg `<textarea>` field used by `webcomic_transcript_form`.
+ * @filter string webcomic_transcript_form_field_submit Filters the submit button used by `webcomic_transcript_form`.
*/
public static function webcomic_transcript_form( $args = array(), $transcript = false, $the_post = false ) {
if ( !$the_post = get_post( $the_post ) or empty( self::$config[ 'collections' ][ $the_post->post_type ] ) or ( $transcript and !$update_post = get_post( $transcript ) ) ) {
@@ -1825,7 +1833,7 @@ public static function webcomic_transcript_form( $args = array(), $transcript =
* @return string
* @uses WebcomicTag::webcomic_transcripts_open()
* @uses Walker_WebcomicTranscriptTerm_Dropdown
- * @filter string webcomic_dropdown_transcript_terms $r
+ * @filter string webcomic_dropdown_transcript_terms Filters the HTML returned by `webcomic_dropdown_transcript_terms` and used by `webcomic_dropdown_transcript_languages`.
*/
public static function webcomic_dropdown_transcript_terms( $args = array(), $the_post = false ) {
if ( $the_post = get_post( $the_post ) and isset( self::$config[ 'collections' ][ $the_post->post_type ] ) ) {
@@ -1905,7 +1913,7 @@ public static function webcomic_dropdown_transcript_terms( $args = array(), $the
* @return string
* @uses WebcomicTag::webcomic_transcripts_open()
* @uses Walker_WebcomicTranscriptTerm_List
- * @filter string webcomic_list_transcript_terms $r
+ * @filter string webcomic_list_transcript_terms Filters the HTML returned by `webcomic_list_transcript_terms` and used by `webcomic_list_transcript_languages`.
*/
public static function webcomic_list_transcript_terms( $args = array(), $the_post = false ) {
if ( $the_post = get_post( $the_post ) and isset( self::$config[ 'collections' ][ $the_post->post_type ] ) ) {
@@ -1990,7 +1998,7 @@ public static function webcomic_list_transcript_terms( $args = array(), $the_pos
* @param array $args Array of arguments. See function description for detailed information.
* @return string
* @uses Walker_WebcomicTerm_Dropdown
- * @filter string webcomic_dropdown_terms $r
+ * @filter string webcomic_dropdown_terms Filters the HTML returned by `webcomic_list_transcript_terms` and used by `webcomic_dropdown_storylines` and `webcomic_dropdown_characters`.
*/
public static function webcomic_dropdown_terms( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2072,8 +2080,8 @@ public static function webcomic_dropdown_terms( $args = array() ) {
* @uses WebcomicTag::sort_webcomic_collections_count()
* @uses WebcomicTag::sort_webcomic_collections_updated()
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_collection_dropdown_title $v
- * @filter string webcomic_dropdown_collections $r
+ * @filter string webcomic_collection_dropdown_title Filters the collection titles used by `webcomic_dropdown_collections`.
+ * @filter string webcomic_dropdown_collections Filters the output of `webcomic_dropdown_collections`.
*/
public static function webcomic_dropdown_collections( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2212,7 +2220,7 @@ public static function webcomic_dropdown_collections( $args = array() ) {
* @param array $args Array of arguments. See function description for detailed information.
* @return string
* @uses Walker_WebcomicTerm_List
- * @filter string webcomic_list_terms $r
+ * @filter string webcomic_list_terms Filters the HTML returned by `webcomic_list_terms` and used by `webcomic_list_storylines` and `webcomic_list_characters`.
*/
public static function webcomic_list_terms( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2297,8 +2305,8 @@ public static function webcomic_list_terms( $args = array() ) {
* @uses WebcomicTag::sort_webcomic_collections_count()
* @uses WebcomicTag::sort_webcomic_collections_updated()
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_collection_list_title $v
- * @filter string webcomic_list_collections $r
+ * @filter string webcomic_collection_list_title Filters the collection titles used by `webcomic_list_collections`.
+ * @filter string webcomic_list_collections Filters the output of `webcomic_list_collections`.
*/
public static function webcomic_list_collections( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2443,7 +2451,7 @@ public static function webcomic_list_collections( $args = array() ) {
*
* @param array $args Array of arguments. See function description for detailed information.
* @return string
- * @filter string webcomic_term_cloud $r
+ * @filter string webcomic_term_cloud Filters the HTML returned by `webcomic_term_cloud` and used by `webcomic_storyline_cloud` and `webcomic_character_cloud`.
*/
public static function webcomic_term_cloud( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2547,7 +2555,7 @@ public static function webcomic_term_cloud( $args = array() ) {
*
* @param array $args Array of arguments. See function description for detailed information.
* @return string
- * @filter string webcomic_collection_cloud $r
+ * @filter string webcomic_collection_cloud Filters the output of `webcomic_collection_cloud`.
*/
public static function webcomic_collection_cloud( $args = array() ) {
$r = wp_parse_args( $args, array(
@@ -2901,6 +2909,28 @@ function is_a_webcomic_attachment( $the_post = false, $collection = '' ) {
}
}
+if ( !function_exists( 'has_webcomic_attachments' ) ) {
+ /** Does the current webcomic have any Webcomic-recognized attachments?
+ *
+ * <code>
+ * if ( has_webcomic_attachments() ) {
+ * // the current post has webcomic-recognized attachments
+ * }
+ *
+ * if ( has_webcomic_attachments( 42 ) ) {
+ * // the post with an ID of 42 has webcomic-recognized attachments
+ * }
+ * </code>
+ *
+ * @param mixed $the_post Post object or ID to check.
+ * @return boolean
+ * @uses WebcomicTag::has_webcomic_attachments()
+ */
+ function has_webcomic_attachments( $the_post = false ) {
+ return WebcomicTag::has_webcomic_attachments( $the_post );
+ }
+}
+
if ( !function_exists( 'has_webcomic_storyline' ) ) {
/** Does the current post belong to a specific storyline?
*
@@ -5120,7 +5150,7 @@ class Walker_WebcomicTerm_Dropdown extends Walker {
* @param integer $depth Depth the walker is currently at.
* @param array $args Arguments passed to the walker.
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_term_dropdown_title $term
+ * @filter string webcomic_term_dropdown_title Filters the term titles used by `webcomic_dropdown_storylines` and `webcomic_dropdown_characters`.
*/
public function start_el( &$output, $term, $depth, $args ) {
extract( $args, $args[ 'hierarchical' ] ? EXTR_SKIP : EXTR_OVERWRITE );
@@ -5233,9 +5263,9 @@ public function end_lvl( &$output, $depth, $args ) {
* @param integer $depth Depth the walker is currently at.
* @param array $args Arguments passed to the walker.
* @uses WebcomicTag::get_relative_webcomic_link()
- * @filter string webcomic_term_list_title $term
- * @filter string webcomic_term_image $size, $term
- * @filter string webcomic_term_description, $term
+ * @filter string webcomic_term_list_title Filters the term titles used by `webcomic_list_storylines` and `webcomic_list_characters`.
+ * @filter string webcomic_term_image Filters the term images used by `webcomic_list_storylines` and `webcomic_list_characters`.
+ * @filter string webcomic_term_description Filters the term titles used by `webcomic_dropdown_transcript_languages`.
*/
public function start_el( &$output, $term, $depth, $args ) {
extract( $args, $args[ 'hierarchical' ] ? EXTR_SKIP : EXTR_OVERWRITE );
@@ -5349,7 +5379,7 @@ class Walker_WebcomicTranscriptTerm_Dropdown extends Walker {
* @param integer $depth Depth the walker is currently at.
* @param array $args Arguments passed to the walker.
* @uses WebcomicTag::get_webcomic_transcripts_link()
- * @filter string webcomic_transcript_term_dropdown_title $term
+ * @filter string webcomic_transcript_term_dropdown_title Filters the term titles used by `webcomic_dropdown_transcript_languages`.
*/
public function start_el( &$output, $term, $depth, $args ) {
extract( $args, $args[ 'hierarchical' ] ? EXTR_SKIP : EXTR_OVERWRITE );
@@ -5422,7 +5452,7 @@ public function end_lvl( &$output, $depth, $args ) {
* @param integer $depth Depth the walker is currently at.
* @param array $args Arguments passed to the walker.
* @uses WebcomicTag::get_webcomic_transcripts_link()
- * @filter string webcomic_transcript_term_list_title $term
+ * @filter string webcomic_transcript_term_list_title Filters the term titles used by `webcomic_list_transcript_languages`.
*/
public function start_el( &$output, $term, $depth, $args ) {
extract( $args, $args[ 'hierarchical' ] ? EXTR_SKIP : EXTR_OVERWRITE );
View
4 -/php/taxonomy.php
@@ -274,7 +274,7 @@ public function get_terms_args( $args, $taxonomies ) {
* We have to use a small amount of Javascript to disable the AJAX
* submission and ensure any files are actually uploaded.
*
- * @filter integer webcomic_upload_size_limit
+ * @filter integer webcomic_upload_size_limit Filters the maximum allowed upload size for cover and avatar uploads. Defaults to the value returned by `wp_max_upload_size`.
* @param string $taxonomy The add term form taxonomy.
* @hook (webcomic\d+)_storyline_add_form_fields, (webcomic\d+)_character_add_form_fields
*/
@@ -314,7 +314,7 @@ public function add_form_fields( $taxonomy ) {
* We have to use a small amount of Javascript to disable the AJAX
* submission and ensure any files are actually uploaded.
*
- * @filter integer webcomic_upload_size_limit
+ * @filter integer webcomic_upload_size_limit Filters the maximum allowed upload size for cover and avatar uploads. Defaults to the value returned by `wp_max_upload_size`.
* @param object $term The current term object.
* @param string $taxonomy The taxonomy of the current term.
* @hook (webcomic\d+)_storyline_edit_form_fields, (webcomic\d+)_character_edit_form_fields
View
218 -/php/widgets.php
@@ -28,6 +28,7 @@ public function __construct() {
*/
public function widgets_init() {
register_widget( 'Widget_WebcomicLink' );
+ register_widget( 'Widget_DynamicWebcomic' );
register_widget( 'Widget_RecentWebcomics' );
register_widget( 'Widget_WebcomicDonation' );
register_widget( 'Widget_WebcomicStorylines' );
@@ -101,9 +102,9 @@ public function form( $instance ) {
<label>
<?php _e( 'Target:', 'webcomic' ); ?><br>
<select name="<?php echo $this->get_field_name( 'relative' ); ?>">
- <option value="first"<?php selected( $relative, 'first' ); ?>><?php _e( 'First', 'webcomic' ); ?></option>
- <option value="last"<?php selected( $relative, 'last' ); ?>><?php _e( 'Last', 'webcomic' ); ?></option>
- <option value="random-nocache"<?php selected( $relative, 'random-nocache' ); ?>><?php _e( 'Random', 'webcomic' ); ?></option>
+ <option value="first"<?php echo empty( $relative ) ? '' : selected( 'first', $relative, false ); ?>><?php _e( 'First', 'webcomic' ); ?></option>
+ <option value="last"<?php echo empty( $relative ) ? '' : selected( 'last', $relative, false ); ?>><?php _e( 'Last', 'webcomic' ); ?></option>
+ <option value="random-nocache"<?php echo empty( $relative ) ? '' : selected( 'random-nocache', $relative, false ); ?>><?php _e( 'Random', 'webcomic' ); ?></option>
</select>
</label>
</p>
@@ -115,7 +116,7 @@ public function form( $instance ) {
foreach ( $config[ 'collections' ] as $k => $v ) {
printf( '<option value="%s"%s>%s</option>',
$k,
- empty( $collection ) ? '' : selected( $collection === $k, true, false ),
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
esc_html( $v[ 'name' ] )
);
}
@@ -144,8 +145,8 @@ public function form( $instance ) {
<td><?php _e( 'Publish Date', 'webcomic' ); ?></td>
</tr>
<?php
- $count = 0;
- $sizes = '';
+ $count = 1;
+ $sizes = '<tr><td>%full</td></tr>';
foreach ( get_intermediate_image_sizes() as $size ) {
$count++;
@@ -162,6 +163,123 @@ public function form( $instance ) {
}
}
+/** Dynamic Webcomic widget.
+ *
+ * @package Webcomic
+ */
+class Widget_DynamicWebcomic extends WP_Widget {
+ /** Initialize the plugin.
+ */
+ public function __construct() {
+ parent::__construct( false, __( 'Dynamic Webcomic', 'webcomic' ), array( 'description' => __( 'A dynamic browser for your webcomics.', 'webcomic' ) ) );
+ }
+
+ /** Render the widget.
+ *
+ * @param array $args General widget arguments.
+ * @param array $instance Specific instance arguments.
+ * @uses Webcomic::dir()
+ * @uses WebcomicTag::get_webcomic_collection()
+ * @uses WebcomicTag::get_webcomic_collections()
+ */
+ public function widget( $args, $instance ) {
+ $config = Webcomic::config();
+
+ if ( $config[ 'dynamic' ] ) {
+ extract( $args );
+ extract( $instance );
+
+ if ( !$collection ) {
+ $collection = WebcomicTag::get_webcomic_collection();
+ } else if ( -1 === ( int ) $collection ) {
+ $collection = WebcomicTag::get_webcomic_collections();
+ }
+
+ if ( $collection ) {
+ $webcomic = new WP_Query( array( 'post_type' => $collection, 'posts_per_page' => 1, 'order' => $reverse ? 'ASC' : 'DESC' ) );
+
+ if ( $webcomic->have_posts() ) {
+ echo $before_widget, empty( $title ) ? '' : $before_title . $title . $after_title, sprintf( '<div data-webcomic-container="%s">', $widget_id );
+
+ while ( $webcomic->have_posts() ) { $webcomic->the_post();
+ if ( !locate_template( array( "webcomic/dynamic-{$widget_id}-{$collection}.php", "webcomic/dynamic-{$widget_id}.php", "webcomic/dynamic-{$collection}.php", 'webcomic/dynamic.php' ), true, false ) ) {
+ require Webcomic::dir() . '-/php/integrate/dynamic.php';
+ }
+ }
+
+ echo '</div>', $after_widget;
+ }
+
+ wp_reset_postdata();
+ }
+ }
+ }
+
+ /** Update an instance of the widget.
+ *
+ * @param array $new New instance settings.
+ * @param array $old Old instance settings.
+ * @return array
+ */
+ public function update( $new, $old ) {
+ $old[ 'title' ] = strip_tags( $new[ 'title' ] );
+ $old[ 'reverse' ] = $new[ 'reverse' ];
+ $old[ 'collection' ] = $new[ 'collection' ];
+
+ return $old;
+ }
+
+ /** Render widget settings.
+ *
+ * The Dynamic Webcomic widget requires that the dynamic navigation
+ * option be enabled. If dynamic navigation is not enabled an error
+ * message will be displayed in place of the widget settings.
+ *
+ * @param array $instance Specific instance settings.
+ * @uses Webcomic::config()
+ */
+ public function form( $instance ) {
+ extract( $instance );
+
+ $config = Webcomic::config();
+
+ if ( $config[ 'dynamic' ] ) { ?>
+ <p>
+ <label>
+ <?php _e( 'Title', 'webcomic' ); ?>
+ <input type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo empty( $title ) ? '' : esc_attr( $title ); ?>" class="widefat">
+ </label>
+ </p>
+ <p>
+ <label><?php _e( 'Collection:', 'webcomic' ); ?><br>
+ <select name="<?php echo $this->get_field_name( 'collection' ); ?>">
+ <option value=""><?php _e( '- Any Collection -', 'webcomic' ); ?></option>
+ <option value="-1"<?php echo empty( $collection ) ? '' : selected( -1, $collection, false ); ?>><?php _e( '- All Collections -', 'webcomic' ); ?></option>
+ <?php
+ foreach ( $config[ 'collections' ] as $k => $v ) {
+ printf( '<option value="%s"%s>%s</option>',
+ $k,
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
+ esc_html( $v[ 'name' ] )
+ );
+ }
+ ?>
+ </select>
+ </label>
+ </p>
+ <p>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'reverse' ); ?>" value="1"<?php echo empty( $reverse ) ? '' : checked( $reverse, true, false ); ?>> <?php _e( 'Start with first webcomic', 'webcomic' ); ?></label><br>
+ </p>
+ <?php } else { ?>
+ <p style="color:#bc0b0b"><strong><?php _e( 'Please enable the dynamic navigation option on the Settings > Webcomic administrative page to use this widget.', 'webcomic' ); ?></strong></p>
+ <input type="hidden" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo empty( $title ) ? '' : esc_attr( $title ); ?>">
+ <input type="hidden" name="<?php echo $this->get_field_name( 'collection' ); ?>" value="<?php echo empty( $collection ) ? '' : $collection; ?>">
+ <input type="hidden" name="<?php echo $this->get_field_name( 'reverse' ); ?>" value="<?php echo empty( $reverse ) ? '' : $reverse; ?>">
+ <?php
+ }
+ }
+}
+
/** Recent Webcomics widget.
*
* @package Webcomic
@@ -191,19 +309,21 @@ public function widget( $args, $instance ) {
$collection = WebcomicTag::get_webcomic_collections();
}
- $the_posts = new WP_Query( array( 'post_type' => $collection, 'numberposts' => $numberposts ) );
-
- if ( $the_posts->have_posts() ) {
- echo $before_widget, empty( $title ) ? '' : $before_title . $title . $after_title, '<ul class="recent-webcomics">';
+ if ( $collection ) {
+ $the_posts = new WP_Query( array( 'post_type' => $collection, 'posts_per_page' => $numberposts ) );
- while ( $the_posts->have_posts() ) { $the_posts->the_post();
- echo '<li>', $image ? WebcomicTag::the_webcomic( $image, 'self' ) : sprintf( '<a href="%s">%s</a>', get_permalink(), get_the_title( '', '', false ) ), '</li>';
+ if ( $the_posts->have_posts() ) {
+ echo $before_widget, empty( $title ) ? '' : $before_title . $title . $after_title, '<ul class="recent-webcomics">';
+
+ while ( $the_posts->have_posts() ) { $the_posts->the_post();
+ echo '<li>', $image ? WebcomicTag::the_webcomic( $image, 'self' ) : sprintf( '<a href="%s">%s</a>', get_permalink(), get_the_title( '', '', false ) ), '</li>';
+ }
+
+ echo $after_widget;
}
- echo $after_widget;
+ wp_reset_postdata();
}
-
- wp_reset_postdata();
}
/** Update an instance of the widget.
@@ -241,12 +361,12 @@ public function form( $instance ) {
<label><?php _e( 'Collection:', 'webcomic' ); ?><br>
<select name="<?php echo $this->get_field_name( 'collection' ); ?>">
<option value=""><?php _e( '- Any Collection -', 'webcomic' ); ?></option>
- <option value="-1"<?php selected( $collection, -1 ) ?>><?php _e( '- All Collections -', 'webcomic' ); ?></option>
+ <option value="-1"<?php echo empty( $collection ) ? '' : selected( -1, $collection, false ); ?>><?php _e( '- All Collections -', 'webcomic' ); ?></option>
<?php
foreach ( $config[ 'collections' ] as $k => $v ) {
printf( '<option value="%s"%s>%s</option>',
$k,
- empty( $collection ) ? '' : selected( $collection === $k, true, false ),
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
esc_html( $v[ 'name' ] )
);
}
@@ -261,7 +381,7 @@ public function form( $instance ) {
</label>
</p>
<p>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'image' ); ?>" value="%thumbnail"<?php checked( $image, '%thumbnail' ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'image' ); ?>" value="%thumbnail"<?php echo empty( $image ) ? '' : checked( '%thumbnail' === $image, true, false ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label>
</p>
<?php
}
@@ -349,7 +469,7 @@ public function form( $instance ) {
foreach ( $commerce as $k => $v ) {
printf( '<option value="%s"%s>%s</option>',
$k,
- empty( $collection ) ? '' : selected( $collection === $k, true, false ),
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
esc_html( $v )
);
}
@@ -455,9 +575,9 @@ public function form( $instance ) {
<label>
<?php _e( 'Format:', 'webcomic' ); ?><br>
<select name="<?php echo $this->get_field_name( 'format' ); ?>">
- <option value="list"<?php selected( $format, 'list' ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
- <option value="dropdown"<?php selected( $format, 'dropdown' ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
- <option value="cloud"<?php selected( $format, 'cloud' ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
+ <option value="list"<?php echo empty( $format ) ? '' : selected( 'list', $format, false ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
+ <option value="dropdown"<?php echo empty( $format ) ? '' : selected( 'dropdown', $format, false ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
+ <option value="cloud"<?php echo empty( $format ) ? '' : selected( 'cloud', $format, false ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
</select>
</label>
</p>
@@ -469,7 +589,7 @@ public function form( $instance ) {
foreach ( $config[ 'collections' ] as $k => $v ) {
printf( '<option value="%s"%s>%s</option>',
$k,
- empty( $collection ) ? '' : selected( $collection === $k, true, false ),
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
esc_html( $v[ 'name' ] )
);
}
@@ -478,11 +598,11 @@ public function form( $instance ) {
</label>
</p>
<p>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php checked( $webcomics, true ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php checked( $show_image, 'thumbnail' ); ?>> <?php _e( 'Show storyline covers', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php checked( $show_count, true ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php checked( $webcomic_image, 'thumbnail' ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php checked( $target, 'first' ); ?>> <?php _e( 'Link to the beginning of storylines', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php echo empty( $webcomics ) ? '' : checked( $webcomics, true, false ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php echo empty( $show_image ) ? '' : checked( 'thumbnail' === $show_image, true, false ); ?>> <?php _e( 'Show storyline covers', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php echo empty( $show_count ) ? '' : checked( $show_count, true, false ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php echo empty( $webcomic_image ) ? '' : checked( 'thumbnail' === $webcomic_image, true, false ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php echo empty( $target ) ? '' : checked( 'first' === $target, true, false ); ?>> <?php _e( 'Link to the beginning of storylines', 'webcomic' ); ?></label>
</p>
<?php
}
@@ -576,9 +696,9 @@ public function form( $instance ) {
<label>
<?php _e( 'Format:', 'webcomic' ); ?><br>
<select name="<?php echo $this->get_field_name( 'format' ); ?>">
- <option value="list"<?php selected( $format, 'list' ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
- <option value="dropdown"<?php selected( $format, 'dropdown' ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
- <option value="cloud"<?php selected( $format, 'cloud' ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
+ <option value="list"<?php echo empty( $format ) ? '' : selected( 'list', $format, false ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
+ <option value="dropdown"<?php echo empty( $format ) ? '' : selected( 'dropdown', $format, false ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
+ <option value="cloud"<?php echo empty( $format ) ? '' : selected( 'cloud', $format, false ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
</select>
</label>
</p>
@@ -590,7 +710,7 @@ public function form( $instance ) {
foreach ( $config[ 'collections' ] as $k => $v ) {
printf( '<option value="%s"%s>%s</option>',
$k,
- empty( $collection ) ? '' : selected( $collection === $k, true, false ),
+ empty( $collection ) ? '' : selected( $k, $collection, false ),
esc_html( $v[ 'name' ] )
);
}
@@ -599,11 +719,11 @@ public function form( $instance ) {
</label>
</p>
<p>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php checked( $webcomics, true ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php checked( $show_image, 'thumbnail' ); ?>> <?php _e( 'Show character avatars', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php checked( $show_count, true ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php checked( $webcomic_image, 'thumbnail' ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php checked( $target, 'first' ); ?>> <?php _e( 'Link to the first appearance of characters', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php echo empty( $webcomics ) ? '' : checked( $webcomics, true, false ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php echo empty( $show_image ) ? '' : checked( 'thumbnail' === $show_image, true, false ); ?>> <?php _e( 'Show character avatars', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php echo empty( $show_count ) ? '' : checked( $show_count, true, false ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php echo empty( $webcomic_image ) ? '' : checked( 'thumbnail' === $webcomic_image, true, false ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php echo empty( $target ) ? '' : checked( 'first' === $target, true, false ); ?>> <?php _e( 'Link to the first appareance of characters', 'webcomic' ); ?></label>
</p>
<?php
}
@@ -680,6 +800,14 @@ public function update( $new, $old ) {
*/
public function form( $instance ) {
extract( $instance );
+
+ $title = empty( $title ) ? '' : $title;
+ $format = empty( $format ) ? '' : $format;
+ $target = empty( $target ) ? '' : $target;
+ $webcomics = empty( $webcomics ) ? '' : $webcomics;
+ $show_count = empty( $show_count ) ? '' : $show_count;
+ $show_image = empty( $show_image ) ? '' : $show_image;
+ $webcomic_image = empty( $webcomic_image ) ? '' : $webcomic_image;
?>
<p>
<label>
@@ -691,18 +819,18 @@ public function form( $instance ) {
<label>
<?php _e( 'Format:', 'webcomic' ); ?><br>
<select name="<?php echo $this->get_field_name( 'format' ); ?>">
- <option value="list"<?php selected( $format, 'list' ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
- <option value="dropdown"<?php selected( $format, 'dropdown' ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
- <option value="cloud"<?php selected( $format, 'cloud' ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
+ <option value="list"<?php echo empty( $format ) ? '' : selected( 'list', $format, false ); ?>><?php _e( 'List', 'webcomic' ); ?></option>
+ <option value="dropdown"<?php echo empty( $format ) ? '' : selected( 'dropdown', $format, false ); ?>><?php _e( 'Dropdown', 'webcomic' ); ?></option>
+ <option value="cloud"<?php echo empty( $format ) ? '' : selected( 'cloud', $format, false ); ?>><?php _e( 'Cloud', 'webcomic' ); ?></option>
</select>
</label>
</p>
<p>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php checked( $webcomics, true ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php checked( $show_image, 'thumbnail' ); ?>> <?php _e( 'Show collection posters', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php checked( $show_count, true ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php checked( $webcomic_image, 'thumbnail' ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php checked( $target, 'first' ); ?>> <?php _e( 'Link to the beginning of collections', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomics' ); ?>" value="1"<?php echo empty( $webcomics ) ? '' : checked( $webcomics, true, false ); ?>> <?php _e( 'Show webcomics', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="thumbnail"<?php echo empty( $show_image ) ? '' : checked( 'thumbnail' === $show_image, true, false ); ?>> <?php _e( 'Show collection posters', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'show_count' ); ?>" value="1"<?php echo empty( $show_count ) ? '' : checked( $show_count, true, false ); ?>> <?php _e( 'Show webcomic counts', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'webcomic_image' ); ?>" value="thumbnail"<?php echo empty( $webcomic_image ) ? '' : checked( 'thumbnail' === $webcomic_image, true, false ); ?>> <?php _e( 'Show webcomic previews', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'target' ); ?>" value="first"<?php echo empty( $target ) ? '' : checked( 'first' === $target, true, false ); ?>> <?php _e( 'Link to the beginning of collections', 'webcomic' ); ?></label>
</p>
<?php
}
View
4 readme.md
@@ -23,7 +23,7 @@ You can install Webcomic from the **Plugins > Add New** page in the administrati
### Manual Installation
-1. Download and extract Webcomic from the WordPress plugin directory.
+1. Download and extract Webcomic from the [WordPress plugin directory](//wordpress.org/extend/plugins/webcomic).
2. Upload the `webcomic` directory to your `wp-content/plugins` directory.
3. Activate Webcomic through the **Plugins > Installed Plugins** page in the administrative dashboard.
@@ -34,7 +34,7 @@ You can install Webcomic from the **Plugins > Add New** page in the administrati
Once installed and activated you can use Webcomic in one of three ways:
1. Turn on the [**Integrate** option](//github.com/mgsisk/webcomic/Wiki/Configuring#Integrate) found on the **Settings > Webcomic** page in the administrative dashboard.
-2. Use an [official Webcomic theme](http://webcomic.nu/download) to get the most out of Webcomic's features with minimal hassle.
+2. Use a [Webcomic-ready theme](http://webcomic.nu/download) to get the most out of Webcomic's features with minimal hassle.
3. Leverage Webcomic's new [template tags, shortcodes]((//github.com/mgsisk/webcomic/Wiki/Template-Tags-and-Shortcodes), and [widgets](//github.com/mgsisk/webcomic/Wiki/Widgets) to [modify an existing theme](//wordpress.org/extend/themes) or [build your own](//codex.wordpress.org/Theme_Development).
### Where can I get help with Webcomic?
View
6 readme.txt
@@ -6,7 +6,7 @@ Requires at least: 3.3
Tested up to: 3.4.1
Stable tag: 4
License: GPL2
-License URI: //www.gnu.org/licenses/gpl-2.0.html
+License URI: //gnu.org/licenses/gpl-2.0.html
Comic publishing power for the web.
@@ -37,7 +37,7 @@ You can install Webcomic from the **Plugins > Add New** page in the administrati
= Manual Installation =
-1. Download and extract Webcomic from the WordPress plugin directory.
+1. Download and extract Webcomic from the [WordPress plugin directory](//wordpress.org/extend/plugins/webcomic).
2. Upload the `webcomic` directory to your `wp-content/plugins` directory.
3. Activate Webcomic through the **Plugins > Installed Plugins** page in the administrative dashboard.
@@ -48,7 +48,7 @@ You can install Webcomic from the **Plugins > Add New** page in the administrati
Once installed and activated you can use Webcomic in one of three ways:
1. Turn on the [**Integrate** option](//github.com/mgsisk/webcomic/Wiki/Configuring#Integrate) found on the **Settings > Webcomic** page in the administrative dashboard.
-2. Use an [official Webcomic theme](http://webcomic.nu/download) to get the most out of Webcomic's features with minimal hassle.
+2. Use a [Webcomic-ready theme](http://webcomic.nu/download) to get the most out of Webcomic's features with minimal hassle.
3. Leverage Webcomic's new [template tags, shortcodes]((//github.com/mgsisk/webcomic/Wiki/Template-Tags-and-Shortcodes), and [widgets](//github.com/mgsisk/webcomic/Wiki/Widgets) to [modify an existing theme](//wordpress.org/extend/themes) or [build your own](//codex.wordpress.org/Theme_Development).
= Where can I get help with Webcomic? =
View
229 webcomic.php
@@ -29,15 +29,13 @@
/** Comic Publishing Power for the Web
*
- * @todo Future: Bulk media actions; see core.trac.wordpress.org/ticket/16031
- * @todo Future: Screen Options; see core.trac.wordpress.org/ticket/18323
- * @todo Future: Post-specific access settings?
- * @todo Future: Dynamic navigation widget?
- * @todo Future: PayPal IPN log viewer?
+ * @todo Future Bulk media actions; see core.trac.wordpress.org/ticket/16031
+ * @todo Future Screen Options; see core.trac.wordpress.org/ticket/18323
+ * @todo 4 Add short descriptions for actions and filters.
*
* @package Webcomic
* @copyright 2008 - 2012 Michael Sisk
- * @license http://www.gnu.org/licenses/gpl-2.0.html GPL2
+ * @license //gnu.org/licenses/gpl-2.0.html GPL2
* @version 4
* @link http://webcomic.nu
*/
@@ -497,7 +495,7 @@ public function get_attachment_image_attributes( $attributes, $attachment ) {
* @uses Webcomic::$collection
* @uses Webcomic::get_attachments()
* @hook wp_head
- * @filter array webcomic_opengraph $object, self::$collection
+ * @filter array webcomic_opengraph Filters the Open Graph data Webcomic adds to all Webcomic-related pages.
*/
public function head() {
global $wp_the_query, $wp_query, $post;
@@ -816,7 +814,6 @@ public function body_class( $classes, $class ) {
* @uses Webcomic::$config
* @uses Webcomic:get_attachments()
* @hook the_content_feed
- * @filter string the_webcomic_feed $feeds, $content, $prepend, $append
* @template feed-{$collectionID}.php, feed.php
*/
public function the_content_feed( $content ) {
@@ -831,7 +828,7 @@ public function the_content_feed( $content ) {
require self::$dir . '-/php/integrate/feed.php';
}
- $content = apply_filters( 'the_webcomic_feed', $prepend . $content . $append, $feeds, $content, $prepend, $append );
+ $content = $prepend . $content . $append;
}
return $content;
@@ -863,7 +860,7 @@ public function extra_theme_headers( $extra ) {
* @uses Webcomic::$config
* @uses Webcomic::$integrate
* @hook loop_start
- * @action webcomic_loop_start $collection
+ * @action webcomic_loop_start Triggered during integration just before Webcomic content is prepended to the start of a WordPress loop.
* @template loop_start-{$collection}.php, loop_start.php
*/
public function loop_start( $query ) {
@@ -896,7 +893,7 @@ public function loop_start( $query ) {
* @uses Webcomic::$config
* @uses Webcomic::$integrate
* @hook loop_start
- * @action webcomic_loop_end $collection
+ * @action webcomic_loop_end Triggered during integration just before Webcomic content is appended to the end of a WordPress loop.
* @template loop_end-{$collection}.php, loop_end.php
*/
public function loop_end( $query ) {
@@ -917,7 +914,6 @@ public function loop_end( $query ) {
* @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 ) {
@@ -929,8 +925,6 @@ public function the_excerpt( $excerpt ) {
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;
@@ -942,7 +936,6 @@ public function the_excerpt( $excerpt ) {
* @return string
* @uses Webcomic::$integrate
* @hook the_content
- * @filter string webcomic_the_content $prepend, $append
* @template the_content-{$collection}.php, the_content.php
*/
public function the_content( $content ) {
@@ -955,7 +948,7 @@ public function the_content( $content ) {
require self::$dir . '-/php/integrate/the_content.php';
}
- $content = apply_filters( 'webcomic_the_content', $prepend . $content . $append, $content, $prepend, $append );
+ $content = $prepend . $content . $append;
}
return $content;
@@ -995,13 +988,12 @@ protected function get_attachments( $id = 0 ) {
*
* Logs instant payment notifications and updates the original print
* availability of webcomics as necessary. Logs are saved to
- * /webcomic/-/logs/ipn-{$blog_id}.log
+ * /webcomic/-/logs/ipn-{$blog_id}.php
*
- * ssl://www.paypal.com | ssl://www.sandbox.paypal.com
+ * https://www.paypal.com/cgi-bin/webscr | https://www.sandbox.paypal.com/cgi-bin/webscr
*
* @uses Webcomic::$config
- * @action webcomic_ipn
- * @filter array webcomic_ipn_log
+ * @action webcomic_ipn Triggered prior to processing a Paypal IPN request.
*/
private function log_ipn() {
global $blog_id;
@@ -1010,116 +1002,133 @@ private function log_ipn() {
do_action( 'webcomic_ipn' );
$output = array();
- $header = $message = '';
- $logfile = self::$dir . sprintf( '-/log/ipn-%s.log', $blog_id ? $blog_id : 1 );
- $request = 'cmd=_notify-validate';
+ $header = $message = $error = '';
+ $logfile = self::$dir . sprintf( '-/log/ipn-%s.php', $blog_id ? $blog_id : 1 );
+ $request = 'cmd=' . urlencode( '_notify-validate' );
foreach ( $_POST as $k => $v ) {
$value = urlencode( stripslashes( $v ) );
$request .= "&{$k}={$value}";
}
- $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
- $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $header .= "Content-Length: " . strlen( $request ) . "\r\n\r\n";
- $socket = fsockopen ( 'ssl://www.paypal.com', 443, $error_number, $error_message, 30 );
-
- if ( !$socket ) {
- $message = __( 'HTTP Error', 'webcomic' );
- } else {
- fputs( $socket, $header . $request );
+ if ( $curl = curl_init() ) {
+ curl_setopt( $curl, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr' );
+ curl_setopt( $curl, CURLOPT_HEADER, 0 );
+ curl_setopt( $curl, CURLOPT_POST, 1 );
+ curl_setopt( $curl, CURLOPT_RETURNTRANSFER,1);