Skip to content
Browse files

Changed:

Function names are now sane, so instead of having intermingled fk_add_cast() and fk_cast_edit(), it's all fk_cast_BLAH() or fk_episode_BLAH()
  • Loading branch information...
1 parent 7cc3269 commit 08a37ee75ce2ed4f9e8c35196ca96e111a7d4209 @gabebw committed
Showing with 35 additions and 35 deletions.
  1. +2 −2 fk-box-cast.php
  2. +5 −5 fk-box-character.php
  3. +2 −2 fk-box-episode.php
  4. +1 −1 fk-boxes.php
  5. +4 −4 fk-lib-cast.php
  6. +9 −9 fk-lib-character.php
  7. +11 −11 fk-lib-episode.php
  8. +1 −1 fk-lib.php
View
4 fk-box-cast.php
@@ -33,7 +33,7 @@ function fk_box_link_cast_to_character(){
*/
function fk_box_cb_link_cast_to_character(){
global $fk_settings, $post;
- $all_character_pages = fk_get_all_characters();
+ $all_character_pages = fk_character_get_all();
// Use nonce for verification
wp_nonce_field('fk_set_character_name', 'fk_set_character_name_nonce');
@@ -70,6 +70,6 @@ function fk_save_page_cast($page_id){
}
check_admin_referer('fk_set_character_name', 'fk_set_character_name_nonce');
$characters = $_POST['fk_characters']; // array(32, 9, 10)
- fk_add_cast($page_id, $characters);
+ fk_cast_add($page_id, $characters);
}
?>
View
10 fk-box-character.php
@@ -55,7 +55,7 @@ function fk_box_cb_character_appearances(){
global $fk_settings, $post;
wp_nonce_field('fk_character_appearance', 'fk_character_appearance_nonce');
- $all_episodes = fk_get_all_episodes();
+ $all_episodes = fk_episode_get_all();
echo '<p>';
if( empty($all_episodes) ){
printf(__('No episodes have been added. Maybe you want to <a href="%s">add one</a>?'),
@@ -65,7 +65,7 @@ function fk_box_cb_character_appearances(){
} else {
// $already_appeared_in tracks episodes that the character has already been marked as having been in, so we can check them.
// Empty array if no appearances.
- $already_appeared_in = fk_get_appearances_for($post->ID);
+ $already_appeared_in = fk_episode_get_characters($post->ID);
// TODO: select all eps in a season - even w/o JS
// - place the following in a div with class hide-if-js (handled by WP):
@@ -102,7 +102,7 @@ function fk_box_add_actor_for_character(){
function fk_box_cb_add_actor_for_character(){
global $post, $fk_settings;
- $all_cast = fk_get_all_cast();
+ $all_cast = fk_cast_get_all();
if( 0 === $post->ID ){
$played_by = false;
} else {
@@ -140,10 +140,10 @@ function fk_save_page_character($post_id){
$cast = $_POST['fk_cast'];
$appearances = $_POST['fk_appearances']; // array
if( fk_character_exists($post_id) ){
- fk_edit_character($post_id, array('cast_member' => $cast, 'appearances' => $appearances));
+ fk_character_edit($post_id, array('cast_member' => $cast, 'appearances' => $appearances));
} else {
// new character
- fk_add_character($post_id, $cast, $appearances);
+ fk_character_add($post_id, $cast, $appearances);
}
return true;
}
View
4 fk-box-episode.php
@@ -125,9 +125,9 @@ function fk_save_page_episode($post_id){
$new = array('season' => $season,
'ep_num' => $ep_num,
'appearances' => $appearances);
- fk_edit_episode($post_id, $new);
+ fk_episode_edit($post_id, $new);
} else {
- fk_add_episode($post_id, $season, $ep_num, $appearances);
+ fk_episode_add($post_id, $season, $ep_num, $appearances);
}
}
?>
View
2 fk-boxes.php
@@ -52,7 +52,7 @@ function fk_none_notices(){
function fk_box_type(){
if( function_exists( 'add_meta_box' )){
- add_meta_box('fk_change_type_id', __("Set Page Type"), 'fk_box_cb_type', 'page', 'normal');
+ add_meta_box('fk_change_type_id', __("TV Fan Kit - Set Page Type"), 'fk_box_cb_type', 'page', 'normal');
}
}
View
8 fk-lib-cast.php
@@ -9,7 +9,7 @@
* @param int $cast_id the page id corresponding to the wordpress page that holds the character.
* @param array $characters (Optional) An array of characters played by this actor.
*/
-function fk_add_cast($cast_id, $characters=array()){
+function fk_cast_add($cast_id, $characters=array()){
// TODO: pseudonym?
global $wpdb, $fk_settings;
$name = get_post_field('post_title', $cast_id);
@@ -38,7 +38,7 @@ function fk_add_cast($cast_id, $characters=array()){
* @param array $new Specify only the parameters you wish to change. You can use query-string syntax like in get_pages.
* @see get_pages()
*/
-function fk_edit_cast($cast_id, $new){
+function fk_cast_edit($cast_id, $new){
global $wpdb, $fk_settings;
$defaults = array('cast_id' => $cast_id,
'characters' => fk_cast_get_characters_for($cast_id)
@@ -85,7 +85,7 @@ function fk_edit_cast($cast_id, $new){
* @param bool $delete_characters (default false) If set to true, deletes characters played by this actor.
* TODO
*/
-function fk_delete_page_cast($cast_id, $delete_characters = false){
+function fk_cast_delete($cast_id, $delete_characters = false){
global $wpdb, $fk_settings;
// todo: have option for deleting characters
if( $delete_characters === true ){
@@ -100,7 +100,7 @@ function fk_delete_page_cast($cast_id, $delete_characters = false){
/**
* Returns array of objects with cast_id and name properties set, ordered alphabetically by first name.
*/
-function fk_get_all_cast(){
+function fk_cast_get_all(){
global $wpdb, $fk_settings;
$all_cast = $wpdb->get_results($wpdb->prepare("SELECT cast_id, name FROM $fk_settings->cast_table"));
return $all_cast;
View
18 fk-lib-character.php
@@ -11,7 +11,7 @@
* @param int $cast_id (optional) The id of the actor/actress who plays this character.
* @param array $appearances (optional) An array of episode_id's that the character appeared in.
*/
-function fk_add_character($character_id, $cast_id = null, $appearances=array()){
+function fk_character_add($character_id, $cast_id = null, $appearances=array()){
global $wpdb, $fk_settings;
if( fk_character_exists($character_id) ){
@@ -35,7 +35,7 @@ function fk_add_character($character_id, $cast_id = null, $appearances=array())
}
// todo: is there a way to add all appearances in just one mysql query?
// maybe have $episode_id optionally be an array
- fk_add_appearance_for($character_id, $episode_id);
+ fk_character_add_appearance_for($character_id, $episode_id);
}
}
@@ -43,7 +43,7 @@ function fk_add_character($character_id, $cast_id = null, $appearances=array())
* Delete a character. Deletes appearances, relationships to cast members as well. DOES NOT delete actor who played the character.
* @param int $character_id The id of the character to delete.
*/
-function fk_delete_page_character($character_id){
+function fk_character_delete($character_id){
global $wpdb, $fk_settings;
$wpdb->query($wpdb->prepare("DELETE FROM $fk_settings->character_table AS ch, $fk_settings->cast2character_table AS cc,
$fk_settings->appearance_table AS app WHERE ch.character_id = %d AND cc.character_id = %d AND app.character_id = %d ",
@@ -59,7 +59,7 @@ function fk_delete_page_character($character_id){
* @param int $character_id
* @param array|string $new The query-string or array of options to update.
*/
-function fk_edit_character($character_id, $new){
+function fk_character_edit($character_id, $new){
global $wpdb, $fk_settings;
$defaults = array('appearances' => fk_character_get_appearances($character_id),
'cast_member' => fk_get_actor_who_plays($character_id));
@@ -76,11 +76,11 @@ function fk_edit_character($character_id, $new){
$to_add = array_diff($value, $defaults['appearances']);
// add
foreach( $to_add as $episode_id ){
- fk_add_appearance_for($character_id, $episode_id);
+ fk_character_add_appearance($character_id, $episode_id);
}
// delete
foreach( $to_delete as $episode_id ){
- fk_remove_appearance_for($character_id, $episode_id);
+ fk_character_remove_appearance($character_id, $episode_id);
}
} elseif( $field === 'cast_member' ){
$cast_id = $value;
@@ -161,7 +161,7 @@ function fk_character_exists($character_id){
* @param int $episode_id
* @return bool False if character already added to episode or episode or character does not exist, true otherwise.
*/
-function fk_add_appearance_for($character_id, $episode_id){
+function fk_character_add_appearance($character_id, $episode_id){
global $wpdb, $fk_settings;
if( ! ( fk_character_exists($character_id) && fk_episode_exists($episode_id) ) ){
return false;
@@ -181,7 +181,7 @@ function fk_add_appearance_for($character_id, $episode_id){
* Remove a character from an episode.
* @return bool False if character did not appear in episode, true otherwise. (I think.)
*/
-function fk_remove_appearance_for($character_id, $episode_id){
+function fk_character_remove_appearance($character_id, $episode_id){
global $wpdb, $fk_settings;
$return = $wpdb->query($wpdb->prepare("DELETE FROM $fk_settings->appearance_table
WHERE character_id = %d AND episode_id = %d",
@@ -193,7 +193,7 @@ function fk_remove_appearance_for($character_id, $episode_id){
* Get all characters.
* @return array Returns an array of objects with character_id and name variables. Returns empty array if no character pages exist.
*/
-function fk_get_all_characters(){
+function fk_character_get_all(){
global $wpdb, $fk_settings;
$characters = $wpdb->get_results($wpdb->prepare("SELECT character_id, name FROM $fk_settings->character_table ORDER BY name ASC"));
return $characters;
View
22 fk-lib-episode.php
@@ -7,7 +7,7 @@
/**
* Add an episode.
*/
-function fk_add_episode($episode_id, $season, $ep_num){
+function fk_episode_add($episode_id, $season, $ep_num){
global $wpdb, $fk_settings;
// Check for nulls because when passed from POST data we don't actually check for sanity before passing in here.
$query = $wpdb->prepare("INSERT INTO $fk_settings->episode_table
@@ -28,21 +28,21 @@ function fk_add_episode($episode_id, $season, $ep_num){
* @param array|string $new The new values.
* @return bool True if episode updated or created successfully, false otherwise.
*/
-function fk_edit_episode($episode_id, $new){
+function fk_episode_edit($episode_id, $new){
global $wpdb, $fk_settings;
if( ! fk_episode_exists($episode_id) ){
// Episode does not exist, try to create it.
if( isset($new['season'], $new['ep_num']) ){
wp_die("Oh no, episode doesn't exist!");
- fk_add_episode($episode_id, $new['season'], $new['ep_num']);
+ fk_episode_add($episode_id, $new['season'], $new['ep_num']);
return true;
} else {
return false;
}
}
// Page does exist; check values and update as necessary.
- list($old_season, $old_ep_num) = fk_get_season_ep_num($post_id);
- $old_appearances = fk_episode_get_appearances($post_id);
+ list($old_season, $old_ep_num) = fk_episode_get_season_ep_num($post_id);
+ $old_appearances = fk_episode_get_characters($post_id);
$defaults = array('season' => $old_season,
'ep_num' => $old_ep_num,
'appearances' => $old_appearances);
@@ -73,10 +73,10 @@ function fk_edit_episode($episode_id, $new){
$delete_appearances = array_diff($old_appearances, $new_appearances);
foreach( (array) $delete_appearances as $del ){
// $del?
- fk_character_delete_appearance_for($character_id, $post_id);
+ fk_character_delete_appearance($character_id, $post_id);
}
foreach( (array) $appearances as $character_id ){
- fk_character_add_appearance_for($character_id, $post_id);
+ fk_character_add_appearance($character_id, $post_id);
}
break;
}
@@ -96,7 +96,7 @@ function fk_episode_get_id($season, $ep_num){
return $id;
}
-function fk_delete_page_episode($episode_id){
+function fk_episode_delete($episode_id){
global $wpdb, $fk_settings;
// Delete episode - also deletes appearances by characters.
$wpdb->query($wpdb->prepare("DELETE FROM $fk_settings->episode_table WHERE episode_id = %d",
@@ -111,7 +111,7 @@ function fk_delete_page_episode($episode_id){
* @param int $episode_id the id of the page.
* @return array 2-element array($season, $ep_num). Usually we use list() on the return value of this function.
*/
-function fk_get_season_ep_num($episode_id){
+function fk_episode_get_season_ep_num($episode_id){
global $wpdb, $fk_settings;
$bad = array(false, false);
if( fk_get_page_type($episode_id) !== 'episode' ){
@@ -124,7 +124,7 @@ function fk_get_season_ep_num($episode_id){
return $season_ep_num_array;
}
-function fk_episode_get_appearances($episode_id){
+function fk_episode_get_characters($episode_id){
global $wpdb, $fk_settings;
$appearances = $wpdb->get_col(
$wpdb->prepare("SELECT character_id FROM $fk_settings->appearance_table WHERE episode_id = %d", $episode_id)
@@ -136,7 +136,7 @@ function fk_episode_get_appearances($episode_id){
* Get all episodes, arranged by season and episode number.
* @return array Returns an array of objects with episode_id, season, and ep_num variables. Returns empty array if no episode pages exist.
*/
-function fk_get_all_episodes(){
+function fk_episode_get_all(){
global $wpdb, $fk_settings;
$all_episodes = $wpdb->get_results($wpdb->prepare("SELECT season, ep_num, episode_id FROM $fk_settings->episode_table ORDER BY season,ep_num ASC"));
return $all_episodes;
View
2 fk-lib.php
@@ -148,7 +148,7 @@ function fk_write_episode_quote_page($episode_id){
if( ! fk_episode_exists($episode_id) ){
return false;
}
- list($season, $ep_num) = fk_get_season_ep_num($episode_id);
+ list($season, $ep_num) = fk_episode_get_season_ep_num($episode_id);
$page_title = __("Quotes for Episode") . sprintf("%02dx%02d: %s", $season, $ep_num, $title);
// TODO: post_parent - depends on season or episode
// TODO: page_template - depends on whether season or episode

0 comments on commit 08a37ee

Please sign in to comment.
Something went wrong with that request. Please try again.