Permalink
Browse files

General code cleanup.

This commit includes no functional changes, just source cleanup. This
includes renanming functions for better consistency, reorganizing class
methods for better readability, and correcting inline documentation
(among other things).
  • Loading branch information...
1 parent 1440ff1 commit 3465fb2cb21b141628866f1909218f5c4d1ab7d2 Michael Sisk committed Jan 29, 2013
Showing with 123 additions and 112 deletions.
  1. +2 −0 -/php/admin.php
  2. +10 −6 -/php/media.php
  3. +37 −39 -/php/pages.php
  4. +16 −16 -/php/posts.php
  5. +8 −4 -/php/taxonomy.php
  6. +35 −33 -/php/transcripts.php
  7. +1 −1 -/php/upgrade.php
  8. +2 −1 -/php/users.php
  9. +12 −12 webcomic.php
View
@@ -23,9 +23,11 @@ class WebcomicAdmin extends Webcomic {
* @uses WebcomicAdmin::plugin_row_meta()
* @uses WebcomicAdmin::plugin_action_links()
* @uses WebcomicPosts
+ * @uses WebcomicPages
* @uses WebcomicUsers
* @uses WebcomicMedia
* @uses WebcomicConfig
+ * @uses WebcomicCommerce
* @uses WebcomicTaxonomy
* @uses WebcomicTranscripts
* @uses WebcomicLegacy
View
@@ -18,16 +18,20 @@ class WebcomicMedia extends Webcomic {
* @uses WebcomicMedia::admin_footer()
* @uses WebcomicMedia::delete_attachment()
* @uses WebcomicMedia::admin_enqueue_scripts()
+ * @uses WebcomicMedia::media_upload_webcomic_media()
+ * @uses WebcomicMedia::attachment_submitbox_misc_actions()
+ * @uses WebcomicMedia::media_upload_tabs()
* @uses WebcomicMedia::media_row_actions()
* @uses WebcomicMedia::display_media_states()
+ * @uses WebcomicMedia::image_size_names_choose()
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
- add_action( 'media_upload_webcomic_media', array( $this, 'media' ) );
add_action( 'delete_attachment', array( $this, 'delete_attachment' ), 10, 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
+ add_action( 'media_upload_webcomic_media', array( $this, 'media_upload_webcomic_media' ) );
add_action( 'attachment_submitbox_misc_actions', array( $this, 'attachment_submitbox_misc_actions' ), 20 );
add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ), 10, 1 );
@@ -175,8 +179,8 @@ public function admin_init() {
* @hook admin_menu
*/
public function admin_menu() {
- add_submenu_page( 'upload.php', __( 'Webcomic Attacher', 'webcomic' ), __( 'Webcomic Attacher', 'webcomic' ), 'upload_files', 'webcomic-attacher', array( $this, 'attacher' ) );
- add_submenu_page( 'upload.php', __( 'Webcomic Generator', 'webcomic' ), __( 'Webcomic Generator', 'webcomic' ), 'upload_files', 'webcomic-generator', array( $this, 'generator' ) );
+ add_submenu_page( 'upload.php', __( 'Webcomic Attacher', 'webcomic' ), __( 'Webcomic Attacher', 'webcomic' ), 'upload_files', 'webcomic-attacher', array( $this, 'page_attacher' ) );
+ add_submenu_page( 'upload.php', __( 'Webcomic Generator', 'webcomic' ), __( 'Webcomic Generator', 'webcomic' ), 'upload_files', 'webcomic-generator', array( $this, 'page_generator' ) );
}
/** Render javascript for the webcomic generator.
@@ -195,7 +199,7 @@ public function admin_footer() {
*
* @hook media_upload_webcomic_media
*/
- public function media( $output = false ) {
+ public function media_upload_webcomic_media( $output = false ) {
if ( $output ) {
if ( $attachments = self::get_attachments( $_GET[ 'post_id' ] ) ) {
printf( '<div><p>%s</p><hr></div><ul class="webcomic-media">', __( 'Drag and drop the media attachments to change the order Webcomic will display them.', 'webcomic' ) );
@@ -407,7 +411,7 @@ public function image_size_names_choose( $sizes ) {
*
* @uses Webcomic::$config
*/
- public function attacher() {
+ public function page_attacher() {
global $wpdb, $post;
?>
<div class="wrap">
@@ -591,7 +595,7 @@ public function attacher() {
* @uses Webcomic::$config
* @uses Webcomic::get_attachments()
*/
- public function generator() {
+ public function page_generator() {
global $post;
$attachments = self::get_attachments();
View
@@ -11,32 +11,31 @@
class WebcomicPages extends Webcomic {
/** Register hooks.
*
- * @uses Webcomic::$config
* @uses WebcomicPages::admin_footer()
* @uses WebcomicPages::add_meta_boxes()
- * @uses WebcomicPages::save_page()
+ * @uses WebcomicPages::wp_insert_post()
* @uses WebcomicPages::pre_post_update()
* @uses WebcomicPages::admin_enqueue_scripts()
* @uses WebcomicPages::bulk_edit_custom_box()
* @uses WebcomicPages::quick_edit_custom_box()
- * @uses WebcomicPages::manage_custom_column()
- * @uses WebcomicPages::manage_columns()
- * @uses WebcomicPages::manage_sortable_columns()
+ * @uses WebcomicPages::manage_page_posts_custom_column()
* @uses WebcomicPages::request()
+ * @uses WebcomicPages::manage_edit_page_columns()
+ * @uses WebcomicPages::manage_edit_page_sortable_columns()
*/
public function __construct() {
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
- add_action( 'wp_insert_post', array( $this, 'save_page' ), 10, 2 );
+ add_action( 'wp_insert_post', array( $this, 'wp_insert_post' ), 10, 2 );
add_action( 'pre_post_update', array( $this, 'pre_post_update' ), 10, 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_custom_box' ), 10, 2 );
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
- add_action( "manage_page_posts_custom_column", array( $this, 'manage_custom_column' ), 10, 2 );
+ add_action( 'manage_page_posts_custom_column', array( $this, 'manage_page_posts_custom_column' ), 10, 2 );
add_filter( 'request', array( $this, 'request' ), 10, 1 );
- add_filter( 'manage_edit-page_columns', array( $this, 'manage_columns' ), 10, 1 );
- add_filter( 'manage_edit-page_sortable_columns', array( $this, 'manage_sortable_columns' ), 10, 1 );
+ add_filter( 'manage_edit-page_columns', array( $this, 'manage_edit_page_columns' ), 10, 1 );
+ add_filter( 'manage_edit-page_sortable_columns', array( $this, 'manage_edit_page_sortable_columns' ), 10, 1 );
}
/** Render javascript for page meta boxes.
@@ -54,12 +53,11 @@ public function admin_footer() {
/** Add page meta boxes.
*
- * @uses Webcomic::$config
- * @uses WebcomicPages::page_collection()
+ * @uses WebcomicPages::box_webcomic_collection()
* @hook add_meta_boxes
*/
public function add_meta_boxes() {
- add_meta_box( 'webcomic-collection', __( 'Webcomic Collection', 'webcomic' ), array( $this, 'page_collection' ), 'page', 'side' );
+ add_meta_box( 'webcomic-collection', __( 'Webcomic Collection', 'webcomic' ), array( $this, 'box_webcomic_collection' ), 'page', 'side' );
}
/** Save metadata with pages.
@@ -68,7 +66,7 @@ public function add_meta_boxes() {
* @param object $post Post object to update.
* @hook wp_insert_post
*/
- public function save_page( $id, $post ) {
+ public function wp_insert_post( $id, $post ) {
if (
isset( $_POST[ 'webcomic_meta_collection' ], $_POST[ 'webcomic_page_collection' ] )
and 'page' === $post->post_type
@@ -185,36 +183,12 @@ public function quick_edit_custom_box( $column, $type ) {
* @param integer $id Current post ID.
* @hook manage_page_posts_custom_column
*/
- public function manage_custom_column( $column, $id ) {
+ public function manage_page_posts_custom_column( $column, $id ) {
if ( 'webcomic_collection' === $column ) {
echo ( $collection = get_post_meta( $id, 'webcomic_collection', true ) and isset( self::$config[ 'collections' ][ $collection ] ) ) ? sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( array( 'post_type' => 'page', 'meta_key' => 'webcomic_collection', 'meta_value' => $collection ), admin_url( 'edit.php' ) ) ), self::$config[ 'collections' ][ $collection ][ 'name' ] ) : __( 'No Collection', 'webcomic' );
}
}
- /** Add custom webcomic collection to management pages.
- *
- * @param array $columns Array of of post columns.
- * @return array
- * @hook manage_edit-page_columns
- */
- public function manage_columns( $columns ) {
- $pre = array_slice( $columns, 0, 3 );
-
- $pre[ 'webcomic_collection' ] = __( 'Webcomic Collection', 'webcomic' );
-
- return array_merge( $pre, $columns );
- }
-
- /** Add sortable webcomic collection column.
- *
- * @param array $columns An array of sortable columns.
- * @return array
- * @hook manage_edit-page_sortable_columns
- */
- public function manage_sortable_columns( $columns ) {
- return array_merge( array( 'webcomic_collection' => 'webcomic_collection' ), $columns );
- }
-
/** Handle sorting and filtering pages by webcomic collection.
*
* Because of how WordPress handles custom field queries, sorting
@@ -241,12 +215,36 @@ public function request( $request ) {
return $request;
}
+ /** Add custom webcomic collection to management pages.
+ *
+ * @param array $columns Array of of post columns.
+ * @return array
+ * @hook manage_edit-page_columns
+ */
+ public function manage_edit_page_columns( $columns ) {
+ $pre = array_slice( $columns, 0, 3 );
+
+ $pre[ 'webcomic_collection' ] = __( 'Webcomic Collection', 'webcomic' );
+
+ return array_merge( $pre, $columns );
+ }
+
+ /** Add sortable webcomic collection column.
+ *
+ * @param array $columns An array of sortable columns.
+ * @return array
+ * @hook manage_edit-page_sortable_columns
+ */
+ public function manage_edit_page_sortable_columns( $columns ) {
+ return array_merge( array( 'webcomic_collection' => 'webcomic_collection' ), $columns );
+ }
+
/** Render the page collection meta box.
*
* @param object $page Current page object.
* @uses Webcomic::$config
*/
- public function page_collection( $page ) {
+ public function box_webcomic_collection( $page ) {
$page_collection = get_post_meta( $page->ID, 'webcomic_collection', true );
wp_nonce_field( 'webcomic_meta_collection', 'webcomic_meta_collection' );
View
@@ -24,9 +24,9 @@ class WebcomicPosts extends Webcomic {
* @uses WebcomicPosts::bulk_edit_custom_box()
* @uses WebcomicPosts::quick_edit_custom_box()
* @uses WebcomicPosts::posts_where()
- * @uses WebcomicPosts::manage_custom_column()
- * @uses WebcomicPosts::view_orphans()
- * @uses WebcomicPosts::manage_columns()
+ * @uses WebcomicPosts::manage_webcomic_posts_custom_column()
+ * @uses WebcomicPosts::view_edit_webcomics()
+ * @uses WebcomicPosts::manage_edit_webcomic_columns()
*/
public function __construct() {
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
@@ -37,17 +37,17 @@ public function __construct() {
add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ) );
add_action( 'wp_insert_post', array( $this, 'save_webcomic_commerce' ), 10, 2 );
add_action( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );
- add_action( 'wp_insert_post', array( $this, 'save_webcomic_transcripts' ), 10, 2 );
+ add_action( 'wp_insert_post,', array( $this, 'save_webcomic_transcripts' ), 10, 2 );
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_custom_box' ), 10, 2 );
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 1 );
foreach ( array_keys( self::$config[ 'collections' ] ) as $k ) {
- add_action( "manage_{$k}_posts_custom_column", array( $this, 'manage_custom_column' ), 10, 2 );
+ add_action( "manage_{$k}_posts_custom_column", array( $this, 'manage_webcomic_posts_custom_column' ), 10, 2 );
- add_filter( "views_edit-{$k}", array( $this, 'view_orphans' ), 10, 1 );
- add_filter( "manage_edit-{$k}_columns", array( $this, 'manage_columns' ), 10, 1 );
+ add_filter( "views_edit-{$k}", array( $this, 'view_edit_webcomic' ), 10, 1 );
+ add_filter( "manage_edit-{$k}_columns", array( $this, 'manage_edit_webcomic_columns' ), 10, 1 );
}
}
@@ -76,9 +76,9 @@ public function admin_footer() {
*/
public function add_meta_boxes() {
foreach ( array_keys( self::$config[ 'collections' ] ) as $k ) {
- add_meta_box( 'webcomic-media', __( 'Webcomic Media', 'webcomic' ), array( $this, 'media' ), $k, 'side', 'high' );
- add_meta_box( 'webcomic-commerce', __( 'Webcomic Commerce', 'webcomic' ), array( $this, 'commerce' ), $k, 'normal', 'high' );
- add_meta_box( 'webcomic-transcripts', __( 'Webcomic Transcripts', 'webcomic' ), array( $this, 'transcripts' ), $k, 'normal', 'high' );
+ add_meta_box( 'webcomic-media', __( 'Webcomic Media', 'webcomic' ), array( $this, 'box_media' ), $k, 'side', 'high' );
+ add_meta_box( 'webcomic-commerce', __( 'Webcomic Commerce', 'webcomic' ), array( $this, 'box_commerce' ), $k, 'normal', 'high' );
+ add_meta_box( 'webcomic-transcripts', __( 'Webcomic Transcripts', 'webcomic' ), array( $this, 'box_transcripts' ), $k, 'normal', 'high' );
}
}
@@ -371,7 +371,7 @@ public function posts_where( $where ) {
* @uses Webcomic::get_attachments()
* @hook manage_(webcomic\d+)_posts_custom_column
*/
- public function manage_custom_column( $column, $id ) {
+ public function manage_webcomic_posts_custom_column( $column, $id ) {
global $post;
if ( 'webcomic_attachments' === $column ) {
@@ -424,7 +424,7 @@ public function manage_custom_column( $column, $id ) {
* @return array
* @hook views_edit-(webcomic\d+)
*/
- public function view_orphans( $views ) {
+ public function view_edit_webcomic( $views ) {
global $wpdb;
if ( $orphans = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s AND ID NOT IN ( SELECT post_parent FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%%' )", $_GET[ 'post_type' ] ) ) ) {
@@ -453,7 +453,7 @@ public function view_orphans( $views ) {
* @return array
* @hook manage_edit-(webcomic\d+)_columns
*/
- public function manage_columns( $columns ) {
+ public function manage_edit_webcomic_columns( $columns ) {
$pre = array_slice( $columns, 0, 1 );
$mid = array_slice( $columns, 1, 2 );
@@ -469,7 +469,7 @@ public function manage_columns( $columns ) {
* @param object $post Current post object.
* @uses WebcomicPosts::ajax_media_preview()
*/
- public function media( $post ) {
+ public function box_media( $post ) {
?>
<div id="webcomic_media_preview"><?php self::ajax_media_preview( $post->ID ); ?></div>
<?php
@@ -480,7 +480,7 @@ public function media( $post ) {
* @param object $post Current post object.
* @uses Webcomic::$config
*/
- public function commerce( $post ) {
+ public function box_commerce( $post ) {
$commerce = get_post_meta( $post->ID, 'webcomic_commerce', true );
$commerce = $commerce ? $commerce : array();
@@ -583,7 +583,7 @@ public function commerce( $post ) {
* @param object $post Current post object.
* @uses Webcomic::$config
*/
- public function transcripts( $post ) {
+ public function box_transcripts( $post ) {
wp_nonce_field( 'webcomic_meta_transcripts', 'webcomic_meta_transcripts' );
?>
<p><label><input type="checkbox" name="webcomic_transcripts"<?php checked( ( 'auto-draft' === $post->post_status and self::$config[ 'collections' ][ $post->post_type ][ 'transcripts' ][ 'open' ] ) or get_post_meta( $post->ID, 'webcomic_transcripts', true ) ); ?>> <?php _e( 'Allow transcribing', 'webcomic' ); ?></label></p>
View
@@ -278,7 +278,8 @@ public function get_terms_args( $args, $taxonomies ) {
*
* @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
+ * @hook (webcomic\d+)_storyline_add_form_fields
+ * @hook (webcomic\d+)_character_add_form_fields
*/
public function add_form_fields( $taxonomy ) {
$sizes = array( 'KB', 'MB', 'GB' );
@@ -319,7 +320,8 @@ public function add_form_fields( $taxonomy ) {
* @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
+ * @hook (webcomic\d+)_storyline_edit_form_fields
+ * @hook (webcomic\d+)_character_edit_form_fields
*/
public function edit_form_fields( $term, $taxonomy ) {
$sizes = array( 'KB', 'MB', 'GB' );
@@ -384,7 +386,8 @@ public function storyline_row_actions( $actions, $term ) {
* @param string $value
* @param string $column Name of the current column.
* @param integer $id Current term ID.
- * @hook manage_(webcomic\d+)_storyline_custom_column, manage_(webcomic\d+)_character_custom_column
+ * @hook manage_(webcomic\d+)_storyline_custom_column
+ * @hook manage_(webcomic\d+)_character_custom_column
*/
public function manage_custom_column( $value, $column, $id ) {
if ( 'webcomic_image' === $column and isset( self::$config[ 'terms' ][ $id ][ 'image' ] ) and $image = wp_get_attachment_image( self::$config[ 'terms' ][ $id ][ 'image' ] ) ) {
@@ -399,7 +402,8 @@ public function manage_custom_column( $value, $column, $id ) {
*
* @param array $columns Array of of term columns.
* @return array
- * @hook manage_edit-(webcomic\d+)_storyline_columns, manage_edit-(webcomic\d+)_character_columns
+ * @hook manage_edit-(webcomic\d+)_storyline_columns
+ * @hook manage_edit-(webcomic\d+)_character_columns
*/
public function manage_edit_columns( $columns ) {
$screen = get_current_screen();
Oops, something went wrong.

0 comments on commit 3465fb2

Please sign in to comment.