templates = array();
// Add a filter to the attributes metabox to inject template into the cache.
add_filter(
'page_attributes_dropdown_pages_args',
array( $this, 'register_project_templates' )
);
// Add a filter to the save post to inject out template into the page cache
add_filter(
'wp_insert_post_data',
array( $this, 'register_project_templates' )
);
// Add a filter to the template include to determine if the page has our
// template assigned and return it's path
add_filter(
'template_include',
array( $this, 'view_project_template' )
);
// Add your templates to this array.
$this->templates = array(
'../jwplayer.php' => 'JW Player',
);
}
/**
* Adds our template to the pages cache in order to trick WordPress
* into thinking the template file exists where it doens't really exist.
*
*/
public function register_project_templates( $atts ) {
// Create the key used for the themes cache
$cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
// Retrieve the cache list.
// If it doesn't exist, or it's empty prepare an array
$templates = wp_get_theme()->get_page_templates();
if ( empty( $templates ) ) {
$templates = array();
}
// New cache, therefore remove the old one
wp_cache_delete( $cache_key, 'themes' );
// Now add our template to the list of templates by merging our templates
// with the existing templates array from the cache.
$templates = array_merge( $templates, $this->templates );
// Add the modified cache to allow WordPress to pick it up for listing
// available templates
wp_cache_add( $cache_key, $templates, 'themes', 1800 );
return $atts;
}
/**
* Checks if the template is assigned to the page
*/
public function view_project_template( $template ) {
global $post;
if ( ! isset( $this->templates[ get_post_meta(
$post->ID, '_wp_page_template', true
) ] )
) {
return $template;
}
$file = plugin_dir_path( __FILE__ ) . get_post_meta(
$post->ID, '_wp_page_template', true
);
// Just to be safe, we check if the file exist first
if ( file_exists( $file ) ) {
return $file;
} else {
echo $file;
}
return $template;
}
}
add_action( 'plugins_loaded', array( 'FANSUB_HRS_PageTemplater', 'get_instance' ) );
function fansub_kntl_get_post_type() {
$value = fansub_option_get_value( 'fansub_kntl', 'post_type_name' );
if ( empty( $value ) ) {
$data = fansub_kntl_get_option();
$value = fansub_get_value_by_key( $data, 'post_type_name' );
}
if ( empty( $value ) ) {
$value = 'post';
}
return $value;
}
function fansub_kntl_get_post_type_label_singular_name() {
$data = fansub_kntl_get_option();
$singular_name = fansub_get_value_by_key( $data, 'post_type_label_singular_name' );
if ( empty( $singular_name ) ) {
$singular_name = fansub_get_value_by_key( $data, 'post_type_label_name' );
}
return $singular_name;
}
function fansub_kntl_convert_post_title_to_parts( $title ) {
$post_title = str_replace( ' ', '-', $title );
$title_parts = explode( '-', $post_title );
return $title_parts;
}
function fansub_kntl_get_post_types() {
return array( fansub_kntl_get_post_type(), 'episode', 'batch' );
}
function fansub_kntl_get_current_animation_single() {
$animation = get_query_var( 'animation' );
if ( ! fansub_id_number_valid( $animation ) ) {
$animation = fansub_get_post_by_column( 'post_name', $animation, 'id', array( 'post_type' => fansub_kntl_get_post_type() ) );
}
return $animation;
}
function fansub_kntl_query_new_release( $args = array() ) {
$transient_name = 'fansub_kntl_query_new_release';
if ( false === ( $query = get_transient( $transient_name ) ) || true ) {
$data_defaults = fansub_kntl_get_option();
$defaults = array(
'post_type' => fansub_kntl_get_post_types(),
'post_status' => 'publish'
);
$defaults = shortcode_atts( $defaults, $data_defaults );
$args = wp_parse_args( $args, $defaults );
$query = fansub_query( $args );
$batch_ids = array();
$episode_ids = array();
$animation_ids = array();
$exclude_ids = array();
$parents_has_new_child = array();
$animations_has_new_child = array();
$animation_type = fansub_kntl_get_post_type();
$episode_type = 'episode';
$episode_child_key = 'episodes';
$batch_type = 'batch';
$batch_child_key = 'batches';
foreach ( $query->posts as $post ) {
if ( 'batch' == $post->post_type ) {
$batch_ids[] = $post->ID;
} elseif ( 'episode' == $post->post_type ) {
//$episode_ids[] = $post->ID;
} else {
$animation_ids[] = $post->ID;
}
}
foreach ( $batch_ids as $id ) {
$parent_id = get_post_meta( $id, $episode_type, true );
$has_new_child = false;
if ( fansub_id_number_valid( $parent_id ) ) {
$childs = get_post_meta( $parent_id, $batch_child_key, true );
if ( fansub_array_has_value( $childs ) ) {
$has_new_child = true;
$exclude_ids = array_merge( $exclude_ids, $childs );
$exclude_ids = array_unique( $exclude_ids );
$tmp_args = array(
'post_type' => $batch_type,
'posts_per_page' => 1,
'fields' => 'ids'
);
$tmp_query = fansub_query_post_by_meta( $episode_type, $parent_id, $tmp_args, 'numeric' );
if ( $tmp_query->have_posts() ) {
$exclude_ids[] = $id;
$exclude_ids = array_unique( $exclude_ids );
$parents_has_new_child[] = $parent_id;
$latest_id = current( $tmp_query->posts );
$exclude_ids = fansub_sanitize_array( $exclude_ids );
$exclude_ids = array_unique( $exclude_ids );
$exclude_ids = fansub_remove_array_item_by_value( $latest_id, $exclude_ids );
}
}
$parent_id = get_post_meta( $parent_id, $animation_type, true );
if ( fansub_id_number_valid( $parent_id ) ) {
$childs = get_post_meta( $parent_id, $episode_child_key, true );
if ( fansub_array_has_value( $childs ) ) {
$exclude_ids = array_merge( $exclude_ids, $childs );
$exclude_ids = array_unique( $exclude_ids );
}
}
} else {
$parent_id = get_post_meta( $id, $animation_type, true );
if ( fansub_id_number_valid( $parent_id ) ) {
$childs = get_post_meta( $parent_id, $batch_child_key, true );
if ( fansub_array_has_value( $childs ) ) {
$has_new_child = true;
$exclude_ids = array_merge( $exclude_ids, $childs );
$exclude_ids = array_unique( $exclude_ids );
$tmp_args = array(
'post_type' => $batch_type,
'posts_per_page' => 1,
'fields' => 'ids'
);
$tmp_query = fansub_query_post_by_meta( $animation_type, $parent_id, $tmp_args, 'numeric' );
if ( $tmp_query->have_posts() ) {
$exclude_ids[] = $id;
$exclude_ids = array_unique( $exclude_ids );
$parents_has_new_child[] = $parent_id;
$latest_id = current( $tmp_query->posts );
$exclude_ids = fansub_sanitize_array( $exclude_ids );
$exclude_ids = fansub_remove_array_item_by_value( $latest_id, $exclude_ids );
}
}
}
}
}
foreach ( $episode_ids as $id ) {
$parent_id = get_post_meta( $id, $animation_type, true );
$has_new_child = false;
if ( fansub_id_number_valid( $parent_id ) ) {
$childs = get_post_meta( $parent_id, $episode_child_key, true );
if ( fansub_array_has_value( $childs ) ) {
$has_new_child = true;
$exclude_ids = array_merge( $exclude_ids, $childs );
$exclude_ids = array_unique( $exclude_ids );
$tmp_args = array(
'post_type' => $episode_type,
'posts_per_page' => 1,
'fields' => 'ids'
);
$tmp_query = fansub_query_post_by_meta( $animation_type, $parent_id, $tmp_args, 'numeric' );
if ( $tmp_query->have_posts() ) {
$exclude_ids[] = $id;
$exclude_ids = array_unique( $exclude_ids );
$parents_has_new_child[] = $parent_id;
$latest_id = current( $tmp_query->posts );
$exclude_ids = fansub_sanitize_array( $exclude_ids );
$exclude_ids = fansub_remove_array_item_by_value( $latest_id, $exclude_ids );
}
}
}
}
$exclude_ids = array_merge( $exclude_ids, $parents_has_new_child );
$exclude_ids = fansub_sanitize_array( $exclude_ids );
$args['post__not_in'] = $exclude_ids;
$query = fansub_query( $args );
set_transient( $transient_name, $query, 3 * DAY_IN_SECONDS );
}
return $query;
}
function fansub_horrilbesubs_get_single_page() {
return fansub_option_get_value( 'fansub_kntl', 'single_page' );
}
function fansub_kntl_build_single_url( $page_id, $animation_id ) {
$url = get_permalink( $animation_id );
if ( fansub_id_number_valid( $page_id ) ) {
$animation = get_post( $animation_id );
$post_type = fansub_kntl_get_post_type();
if ( is_a( $animation, 'WP_Post' ) && $post_type == $animation->post_type ) {
$url = get_permalink( $page_id );
$permalink_struct = get_option( 'permalink_structure' );
if ( ! empty( $permalink_struct ) ) {
$url = trailingslashit( $url );
$url .= trailingslashit( $animation->post_name );
} else {
$url = add_query_arg( array( 'animation' => $animation_id ), $url );
}
}
}
return $url;
}
function fansub_kntl_new_release_shortcode( $atts, $content = null ) {
$defaults = fansub_kntl_get_option_defaults();
$option_data = fansub_kntl_get_option();
$option_data = shortcode_atts( $defaults, $option_data );
$option_data = shortcode_atts( $option_data, $atts );
$release_title = fansub_get_value_by_key( $option_data, 'release_box_title' );
$post_number = fansub_get_value_by_key( $option_data, 'posts_per_page' );
$date_format = fansub_get_value_by_key( $option_data, 'date_format' );
$single_page = fansub_get_value_by_key( $option_data, 'single_page' );
$release_box_search_placeholder = fansub_get_value_by_key( $option_data, 'release_box_search_placeholder' );
$data = $option_data;
$result = '';
$title = isset( $data['release_box_title'] ) ? $data['release_box_title'] : $release_title;
$number = isset( $data['posts_per_page'] ) ? $data['posts_per_page'] : $post_number;
$query = fansub_kntl_query_new_release( array( 'posts_per_page' => $number ) );
$date_format = isset( $data['date_format'] ) ? $data['date_format'] : $date_format;
$post_type = fansub_kntl_get_post_type();
$option_data = fansub_kntl_get_option();
$qualities = fansub_get_value_by_key( $option_data, 'qualities' );
$qualities = fansub_string_to_array( ',', $qualities );
$qualities = array_map( 'trim', $qualities );
$servers = fansub_get_value_by_key( $option_data, 'servers' );
$servers = fansub_string_to_array( ',', $servers );
$servers = array_map( 'trim', $servers );
$query_vars = $query->query_vars;
$post_not_in = isset( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
$refresh_text = fansub_get_value_by_key( $option_data, 'refresh_text' );
$clear_text = fansub_get_value_by_key( $option_data, 'clear_text' );
ob_start();
?>
have_posts() ) {
$query->the_post();
$post = get_post( get_the_ID() );
$post_not_in[] = $post->ID;
$post_title = $post->post_title;
$post_link = '#';
$suffix = '';
$parts = array();
if ( 'episode' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$suffix = '' . ' - ' . $part . '';
}
}
} elseif ( 'batch' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$episode_id = get_post_meta( $post->ID, 'episode', true );
if ( is_numeric( $episode_id ) && $episode_id > 0 ) {
$animation_id = get_post_meta( $episode_id, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
} else {
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
//$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
}
$post_title = $post->post_title;
} else {
$post_title = $post->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $post->ID );
}
$link_html = new FANSUB_HTML( 'a' );
$link_html->set_href( $post_link );
$link_html->set_text( $post_title );
$link_html->set_class( 'post-title-link' );
$saved_suffix = get_post_meta( $post->ID, 'suffix', true );
if ( 'batch' == $post->post_type ) {
$suffix = '';
}
if ( ! empty( $saved_suffix ) ) {
$suffix = '' . ' - ' . $saved_suffix . '';
}
?>
- post_type ) ); ?>>
- ()
- output(); ?>
-
ID, $file_name_key, true );
if ( empty( $file_name ) ) {
if ( 'episode' == $post->post_type ) {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} elseif ( 'batch' == $post->post_type ) {
$bt_ep_id = get_post_meta( $post->ID, 'episode', true );
if ( fansub_id_number_valid( $bt_ep_id ) ) {
$ep_am_id = get_post_meta( $bt_ep_id, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} else {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
}
}
} else {
if ( ! fansub_string_contain( $file_name, $quality ) ) {
$file_name .= ' [' . $quality . ']';
}
}
$quality_item_class = 'quality quality-' . $quality;
$server_items_html = '- ' . $file_name . '
';
foreach ( $servers as $server ) : ?>
ID, $meta_name, true );
if ( ! empty( $meta_value ) ) {
fansub_add_string_with_space_before( $quality_item_class, 'has-link' );
}
ob_start();
?>
-
-
post_type ) {
$defaults = fansub_kntl_get_option_defaults();
$option_data = fansub_kntl_get_option();
$option_data = shortcode_atts( $defaults, $option_data );
$option_data = shortcode_atts( $option_data, $atts );
$single_batch_title = fansub_get_value_by_key( $option_data, 'single_batch_title' );
$single_episode_title = fansub_get_value_by_key( $option_data, 'single_episode_title' );
$post_number = fansub_get_value_by_key( $option_data, 'posts_per_page' );
$date_format = fansub_get_value_by_key( $option_data, 'date_format' );
$single_page = fansub_get_value_by_key( $option_data, 'single_page' );
$release_box_search_placeholder = fansub_get_value_by_key( $option_data, 'release_box_search_placeholder' );
$single_search_placeholder = fansub_get_value_by_key( $option_data, 'single_search_placeholder' );
$data = $option_data;
$qualities = fansub_get_value_by_key( $option_data, 'qualities' );
$qualities = fansub_string_to_array( ',', $qualities );
$qualities = array_map( 'trim', $qualities );
$servers = fansub_get_value_by_key( $option_data, 'servers' );
$servers = fansub_string_to_array( ',', $servers );
$servers = array_map( 'trim', $servers );
$post_not_in = isset( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
$refresh_text = fansub_get_value_by_key( $option_data, 'refresh_text' );
$clear_text = fansub_get_value_by_key( $option_data, 'clear_text' );
$episode = fansub_query_post_by_meta( 'animation', $animation->ID, array(
'post_type' => 'episode',
'posts_per_page' => $post_number
), 'numeric' );
$batch = new WP_Query( array( 'post_type' => 'batch', 'posts_per_page' => $post_number ) );
$batches = array();
if ( $episode->have_posts() ) {
foreach ( $episode->posts as $apost ) {
$saved = get_post_meta( $apost->ID, 'batches', true );
if ( fansub_array_has_value( $saved ) ) {
$batches = array_merge( $batches, $saved );
}
}
}
$am_batches = get_post_meta( $animation->ID, 'batches', true );
if ( is_array( $batches ) && is_array( $am_batches ) ) {
$batches = array_merge( $batches, $am_batches );
}
$batches = fansub_sanitize_array( $batches );
if ( fansub_array_has_value( $batches ) ) {
$batch_args = array(
'post_type' => 'batch',
'post__in' => $batches,
'posts_per_page' => - 1
);
$batch = fansub_query( $batch_args );
}
if ( ! $batch->have_posts() || ! $episode->have_posts() ) {
$batches = get_post_meta( $animation->ID, 'batches', true );
$batches = fansub_sanitize_array( $batches );
$batch_args = array(
'post_type' => 'batch',
'post__in' => $batches,
'posts_per_page' => - 1
);
$batch = fansub_query( $batch_args );
}
$post_content = apply_filters( 'the_content', $animation->post_content );
ob_start();
?>
false,
'bfi_thumb' => false,
'post_id' => $animation->ID
) ); ?>
have_posts() && 1 == 2 ) : ?>
have_posts() ) : ?>
have_posts() ) {
$query_vars = $query->query_vars;
while ( $query->have_posts() ) {
$query->the_post();
$post = get_post( get_the_ID() );
$post_not_in[] = $post->ID;
$post_title = $post->post_title;
$post_link = '#';
$suffix = '';
if ( ! $have_batch ) {
$saved_ep = get_post_meta( $post->ID, 'episode', true );
$saved_am = get_post_meta( $saved_ep, 'animation', true );
if ( $saved_am == $animation->ID ) {
$have_batch = true;
} else {
$saved_am = get_post_meta( $post->ID, 'animation', true );
if ( $saved_am == $animation->ID ) {
$have_batch = true;
} else {
continue;
}
}
}
$parts = array();
if ( 'episode' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$suffix = '' . ' - ' . $part . '';
}
}
} elseif ( 'batch' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$episode_id = get_post_meta( $post->ID, 'episode', true );
if ( is_numeric( $episode_id ) && $episode_id > 0 ) {
$animation_id = get_post_meta( $episode_id, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
} else {
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
}
} else {
$post_title = $post->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $post->ID );
}
if ( fansub_array_has_value( $parts ) ) {
}
$link_html = new FANSUB_HTML( 'span' );
$link_html->set_text( $post_title );
$link_html->set_class( 'post-title-link' );
$saved_suffix = get_post_meta( $post->ID, 'suffix', true );
if ( ! empty( $saved_suffix ) ) {
$suffix = '' . ' - ' . $saved_suffix . '';
}
?>
- post_type ) ); ?>>
- (
)
- output(); ?>
-
ID, $file_name_key, true );
if ( empty( $file_name ) ) {
if ( 'episode' == $post->post_type ) {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} elseif ( 'batch' == $post->post_type ) {
$bt_ep_id = get_post_meta( $post->ID, 'episode', true );
if ( fansub_id_number_valid( $bt_ep_id ) ) {
$ep_am_id = get_post_meta( $bt_ep_id, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} else {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
}
}
} else {
if ( ! fansub_string_contain( $file_name, $quality ) ) {
$file_name .= ' [' . $quality . ']';
}
}
$quality_item_class = 'quality quality-' . $quality;
$server_items_html = '- ' . $file_name . '
';
foreach ( $servers as $server ) : ?>
ID, $meta_name, true );
if ( ! empty( $meta_value ) ) {
fansub_add_string_with_space_before( $quality_item_class, 'has-link' );
}
ob_start();
?>
-
-
' . fansub_get_value_by_key( $option_data, 'single_batch_none' ) . '';
}
} else {
echo '- ' . fansub_get_value_by_key( $option_data, 'single_batch_none' ) . '
';
}
?>
have_posts() && $have_batch && 1 == 2 ) : ?>
have_posts() ) : ?>
have_posts() ) {
$query_vars = $episode->query_vars;
while ( $episode->have_posts() ) {
$episode->the_post();
$post = get_post( get_the_ID() );
$post_not_in[] = $post->ID;
$post_title = $post->post_title;
$post_link = '#';
$suffix = '';
$parts = array();
if ( 'episode' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$suffix = '' . ' - ' . $part . '';
}
}
} elseif ( 'batch' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$episode_id = get_post_meta( $post->ID, 'episode', true );
if ( is_numeric( $episode_id ) && $episode_id > 0 ) {
$animation_id = get_post_meta( $episode_id, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
} else {
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
}
} else {
$post_title = $post->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $post->ID );
}
$link_html = new FANSUB_HTML( 'span' );
$link_html->set_text( $post_title );
$link_html->set_class( 'post-title-link' );
$saved_suffix = get_post_meta( $post->ID, 'suffix', true );
if ( ! empty( $saved_suffix ) ) {
$suffix = '' . ' - ' . $saved_suffix . '';
}
?>
- post_type ) ); ?>>
- (
)
- output(); ?>
-
ID, $file_name_key, true );
if ( empty( $file_name ) ) {
if ( 'episode' == $post->post_type ) {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} elseif ( 'batch' == $post->post_type ) {
$bt_ep_id = get_post_meta( $post->ID, 'episode', true );
if ( fansub_id_number_valid( $bt_ep_id ) ) {
$ep_am_id = get_post_meta( $bt_ep_id, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} else {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
}
}
} else {
if ( ! fansub_string_contain( $file_name, $quality ) ) {
$file_name .= ' [' . $quality . ']';
}
}
$quality_item_class = 'quality quality-' . $quality;
$server_items_html = '- ' . $file_name . '
';
foreach ( $servers as $server ) : ?>
ID, $meta_name, true );
if ( ! empty( $meta_value ) ) {
fansub_add_string_with_space_before( $quality_item_class, 'has-link' );
}
ob_start();
?>
-
-
' . fansub_get_value_by_key( $option_data, 'single_episode_none' ) . '';
}
?>
have_posts() ) : ?>
ID, array(
'post_type' => 'video',
'posts_per_page' => - 1
), 'numeric' );
$video_box_title = fansub_get_value_by_key( $option_data, 'video_box_title', 'Promotional Videos' );
if ( $video->have_posts() ) {
?>
ID ) ) : ?>
$number,
'post_type' => 'episode'
);
$query = fansub_query( $query_args );
$date_format = isset( $data['date_format'] ) ? $data['date_format'] : $date_format;
$post_type = fansub_kntl_get_post_type();
$option_data = fansub_kntl_get_option();
$qualities = fansub_get_value_by_key( $option_data, 'qualities' );
$qualities = fansub_string_to_array( ',', $qualities );
$qualities = array_map( 'trim', $qualities );
$servers = fansub_get_value_by_key( $option_data, 'servers' );
$servers = fansub_string_to_array( ',', $servers );
$servers = array_map( 'trim', $servers );
$query_vars = $query->query_vars;
$post_not_in = isset( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
$refresh_text = fansub_get_value_by_key( $option_data, 'refresh_text' );
$clear_text = fansub_get_value_by_key( $option_data, 'clear_text' );
ob_start();
?>
have_posts() ) {
$query->the_post();
$post = get_post( get_the_ID() );
$post_not_in[] = $post->ID;
$post_title = '';
$post_link = '#';
$suffix = '';
$parts = array();
if ( 'episode' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$suffix = '' . ' - ' . $part . '';
}
}
} elseif ( 'batch' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$episode_id = get_post_meta( $post->ID, 'episode', true );
if ( is_numeric( $episode_id ) && $episode_id > 0 ) {
$animation_id = get_post_meta( $episode_id, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
} else {
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
}
} else {
$post_title = $post->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $post->ID );
}
$link_html = new FANSUB_HTML( 'a' );
$link_html->set_href( $post_link );
$link_html->set_text( $post_title );
$link_html->set_class( 'post-title-link' );
$saved_suffix = get_post_meta( $post->ID, 'suffix', true );
if ( ! empty( $saved_suffix ) ) {
$suffix = '' . ' - ' . $saved_suffix . '';
}
?>
- post_type ) ); ?>>
- ()
- output(); ?>
-
ID, $file_name_key, true );
if ( empty( $file_name ) ) {
if ( 'episode' == $post->post_type ) {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} elseif ( 'batch' == $post->post_type ) {
$bt_ep_id = get_post_meta( $post->ID, 'episode', true );
if ( fansub_id_number_valid( $bt_ep_id ) ) {
$ep_am_id = get_post_meta( $bt_ep_id, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} else {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
}
}
} else {
if ( ! fansub_string_contain( $file_name, $quality ) ) {
$file_name .= ' [' . $quality . ']';
}
}
$quality_item_class = 'quality quality-' . $quality;
$server_items_html = '- ' . $file_name . '
';
foreach ( $servers as $server ) : ?>
ID, $meta_name, true );
if ( ! empty( $meta_value ) ) {
fansub_add_string_with_space_before( $quality_item_class, 'has-link' );
}
ob_start();
?>
-
-
$number,
'post_type' => 'batch'
);
$query = fansub_query( $query_args );
$date_format = isset( $data['date_format'] ) ? $data['date_format'] : $date_format;
$post_type = fansub_kntl_get_post_type();
$option_data = fansub_kntl_get_option();
$qualities = fansub_get_value_by_key( $option_data, 'qualities' );
$qualities = fansub_string_to_array( ',', $qualities );
$qualities = array_map( 'trim', $qualities );
$servers = fansub_get_value_by_key( $option_data, 'servers' );
$servers = fansub_string_to_array( ',', $servers );
$servers = array_map( 'trim', $servers );
$query_vars = $query->query_vars;
$post_not_in = isset( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
$refresh_text = fansub_get_value_by_key( $option_data, 'refresh_text' );
$clear_text = fansub_get_value_by_key( $option_data, 'clear_text' );
ob_start();
?>
have_posts() ) {
$query->the_post();
$post = get_post( get_the_ID() );
$post_not_in[] = $post->ID;
$post_title = $post->post_title;
$post_link = '#';
$suffix = '';
$parts = array();
if ( 'episode' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
//$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$suffix = '' . ' - ' . $part . '';
}
}
} elseif ( 'batch' == $post->post_type ) {
$parts = fansub_kntl_convert_post_title_to_parts( $post->post_title );
array_shift( $parts );
$parts = array_map( 'trim', $parts );
$episode_id = get_post_meta( $post->ID, 'episode', true );
if ( is_numeric( $episode_id ) && $episode_id > 0 ) {
$animation_id = get_post_meta( $episode_id, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
//$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
} else {
$animation_id = get_post_meta( $post->ID, 'animation', true );
$animation = get_post( $animation_id );
if ( is_a( $animation, 'WP_Post' ) ) {
//$post_title = $animation->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $animation->ID );
if ( ! fansub_array_has_value( $parts ) ) {
}
$part = array_pop( $parts );
if ( ! empty( $part ) ) {
$tmp_part = array_pop( $parts );
if ( ! empty( $tmp_part ) ) {
//$part = $tmp_part . '-' . $part;
}
$suffix = '' . ' - ' . $part . '';
}
}
}
} else {
$post_title = $post->post_title;
$post_link = fansub_kntl_build_single_url( $single_page, $post->ID );
}
$link_html = new FANSUB_HTML( 'a' );
$link_html->set_href( $post_link );
$link_html->set_text( $post_title );
$link_html->set_class( 'post-title-link' );
$saved_suffix = get_post_meta( $post->ID, 'suffix', true );
$suffix = '';
if ( ! empty( $saved_suffix ) ) {
$suffix = '' . ' - ' . $saved_suffix . '';
}
?>
- post_type ) ); ?>>
- ()
- output(); ?>
-
ID, $file_name_key, true );
if ( empty( $file_name ) ) {
if ( 'episode' == $post->post_type ) {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} elseif ( 'batch' == $post->post_type ) {
$bt_ep_id = get_post_meta( $post->ID, 'episode', true );
if ( fansub_id_number_valid( $bt_ep_id ) ) {
$ep_am_id = get_post_meta( $bt_ep_id, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
} else {
$ep_am_id = get_post_meta( $post->ID, 'animation', true );
if ( fansub_id_number_valid( $ep_am_id ) ) {
$ep_am = get_post( $ep_am_id );
$file_name = $ep_am->post_title . ' [' . $quality . ']';
}
}
}
} else {
if ( ! fansub_string_contain( $file_name, $quality ) ) {
$file_name .= ' [' . $quality . ']';
}
}
$quality_item_class = 'quality quality-' . $quality;
$server_items_html = '- ' . $file_name . '
';
foreach ( $servers as $server ) : ?>
ID, $meta_name, true );
if ( ! empty( $meta_value ) ) {
fansub_add_string_with_space_before( $quality_item_class, 'has-link' );
}
ob_start();
?>
-
-
'Anime Titles' );
$option_data = wp_parse_args( $option_data, $defaults );
$atts = shortcode_atts( $default_atts, $atts );
$option_data = wp_parse_args( $atts, $option_data );
$box_title = fansub_get_value_by_key( $option_data, 'title' );
$single_page = fansub_get_value_by_key( $option_data, 'single_page' );
$posts_per_page = fansub_get_value_by_key( $option_data, 'anime_number', 20 );
$posts_per_page = 12;
$post_type = fansub_kntl_get_post_type();
$args = array(
'posts_per_page' => $posts_per_page,
'post_type' => $post_type,
'orderby' => 'title',
'order' => 'ASC',
'paged' => fansub_get_paged()
);
$query = fansub_query( $args );
if ( ! empty( $box_title ) ) {
$box_title = fansub_wrap_tag( $box_title, 'h2' );
}
$result = '' . $box_title;
if ( $query->have_posts() ) {
$pagination_args = array(
'query' => $query,
'show_first_item' => true,
'label' => '',
'first' => '««',
'last' => '»»',
'ajax' => true,
'current_item_link' => true
);
ob_start();
fansub_pagination( $pagination_args );
$pagination = ob_get_clean();
$result .= $pagination;
$result .= '
';
$loop_html = '';
while ( $query->have_posts() ) {
$query->the_post();
$permalink = fansub_kntl_build_single_url( $single_page, get_the_ID() );
ob_start();
?>
- >
false,
'lazyload' => true,
'before' => '
',
'after' => '
',
'permalink' => $permalink
) );
fansub_post_title_link( array( 'permalink' => $permalink ) );
fansub_entry_summary();
?>
';
$result .= $pagination;
}
$result .= '
';
return $result;
}
add_shortcode( 'fansub_list', 'fansub_kntl_anime_list' );
function fansub_kntl_advanced_search( $atts, $content = null ) {
$defaults = fansub_kntl_get_option_defaults();
$option_data = fansub_kntl_get_option();
$default_atts = array( 'title' => '' );
$option_data = wp_parse_args( $option_data, $defaults );
$atts = shortcode_atts( $default_atts, $atts );
$option_data = wp_parse_args( $atts, $option_data );
$box_title = fansub_get_value_by_key( $option_data, 'title' );
$placeholder = fansub_get_value_by_key( $option_data, 'placehoder', 'Search Anime...' );
$single_page = fansub_get_value_by_key( $option_data, 'single_page' );
$post_type = fansub_kntl_get_post_type();
$q = isset( $_REQUEST['q'] ) ? $_REQUEST['q'] : '';
$args = array(
'posts_per_page' => - 1,
'post_type' => $post_type,
's' => $q
);
$query = fansub_query( $args );
if ( ! empty( $box_title ) ) {
$box_title = fansub_wrap_tag( $box_title, 'h2' );
}
$result = '' . $box_title . '
';
$form = fansub_search_form( array(
'placeholder' => $placeholder,
'action' => get_permalink(),
'echo' => false,
'class' => 'advanced-search-form',
'name' => 'q'
) );
$result .= $form;
if ( $query->have_posts() && ! empty( $q ) ) {
$result .= '
';
$result .= '
Search Results
';
$result .= '
';
$loop_html = '';
while ( $query->have_posts() ) {
$query->the_post();
$permalink = fansub_kntl_build_single_url( $single_page, get_the_ID() );
ob_start();
?>
- >
false,
'lazyload' => true,
'before' => '
',
'after' => '
',
'permalink' => $permalink
) );
fansub_post_title_link( array( 'permalink' => $permalink ) );
fansub_entry_summary();
?>
';
}
$result .= '
';
return $result;
}
add_shortcode( 'fansub_advanced_search', 'fansub_kntl_advanced_search' );
function fansub_kntl_jwplayer_shortcode_embed( $atts, $content = null ) {
$defaults = fansub_kntl_get_option_defaults();
$option_data = fansub_kntl_get_option();
$default_atts = array( 'title' => '' );
$option_data = wp_parse_args( $option_data, $defaults );
$atts = shortcode_atts( $default_atts, $atts );
$option_data = wp_parse_args( $atts, $option_data );
$post_id = fansub_get_value_by_key( $option_data, 'post_id' );
$result = '';
if ( ! fansub_id_number_valid( $post_id ) ) {
$post_id = isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : 0;
}
if ( fansub_id_number_valid( $post_id ) ) {
global $post;
$tmp = $post;
$post = get_post( $post_id );
setup_postdata( $post );
ob_start();
the_content();
$html_data = ob_get_clean();
wp_reset_postdata();
$post = $tmp;
$result = $html_data;
}
return $result;
}
add_shortcode( 'fansub_jwplayer', 'fansub_kntl_jwplayer_shortcode_embed' );
$animation->ID ) ) ); ?>
ID ); ?>