JezK
Edit File: configuration.php
<?php /* Please do not edit this file as it may cause errors. Melakukan modifikasi/edit pada file ini dapat menyebabkan error atau kerusakan fungsi dari theme. */ // Force Change Default Options WordPress add_action('after_switch_theme', 'config_wp_options'); function config_wp_options() { global $wpdb; $dboptions = $wpdb->prefix . 'options'; // change default homepage as latest post $wpdb->update($dboptions, array('option_value'=> 'posts'),array ('option_name'=> 'show_on_front')); // change post per page to 9 item $wpdb->update($dboptions, array('option_value'=> '9'),array ('option_name'=> 'posts_per_page')); // change order comment to desc $wpdb->update($dboptions, array('option_value'=> 'desc'),array ('option_name'=> 'comment_order')); // change timezone $wpdb->update($dboptions, array('option_value'=> 'Asia/Bangkok'),array ('option_name'=> 'timezone_string')); // change permalink to postname if not set if (get_option( 'permalink_structure' ) == '') { $wpdb->update($dboptions, array('option_value'=> '/%postname%.html'),array ('option_name'=> 'permalink_structure')); } update_option( 'thumbnail_size_w', 140 ); update_option( 'thumbnail_size_h', 90 ); } // Add JS variable add_action( 'wp_footer', 'jsvar' ); function jsvar() { global $oketheme;?> <script type="text/javascript"> var ajaxurl = "<?php echo admin_url('admin-ajax.php');?>"; mata_uang = "<?php echo $oketheme['currency'];?>"; nilai_tukar = "<?php echo str_replace(".","",$oketheme['kurs']);?>"; </script> <?php } // Auto Featured Image add_action('save_post', 'oketheme_featured'); function oketheme_featured() { global $post; $imgnew = rwmb_meta('gambar', array('limit' => 1)); $imgnew2= rwmb_meta('rent_gambar', array('limit' => 1)); if (!has_post_thumbnail() && isset($post->ID)) { if (!empty( $imgnew )) { $attachment = reset($imgnew); $attachment_id = $attachment['ID']; set_post_thumbnail($post->ID, $attachment_id); } else if (!empty( $imgnew2 )) { $attachment = reset($imgnew2); $attachment_id = $attachment['ID']; set_post_thumbnail($post->ID, $attachment_id); } else { $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); if ($attached_image){ foreach ($attached_image as $attachment_id => $attachment){ set_post_thumbnail($post->ID, $attachment_id); } } } } } // Setup 100% Quality of Image add_filter( 'jpeg_quality', 'set_image_quality'); function set_image_quality() { return 100; } // Gravatar add_filter('avatar_defaults', 'okegravatar'); function okegravatar ($avatar_defaults) { $myavatar = get_bloginfo('stylesheet_directory') . '/images/gravatar.jpg'; $avatar_defaults[$myavatar] = wp_get_theme()->get( 'Name' )." Avatar"; return $avatar_defaults; } // Shorten Text function okeshorten($text, $limit) { $chars_limit = $limit; $chars_text = strlen($text); $text = substr($text,0,$chars_limit); if ($chars_text > $chars_limit) { $text = $text."..."; } return $text; } // Replaces the excerpt "Read More" text by a link add_filter('excerpt_more', 'read_more'); function read_more($more) { return '...'; } // Post Views Oketheme function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return '0'; } else { $count = number_format($count,0,',','.'); } return $count.''; } function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } add_filter('manage_posts_columns', 'posts_column_views'); function posts_column_views($defaults){ $defaults['post_views'] = __('Views'); return $defaults; } add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2); function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); } } // Change Login WP Logo add_action( 'login_enqueue_scripts', 'oke_login_logo' ); function oke_login_logo() { global $oketheme; if ($oketheme['logo']['url'] != "") {?> <style type="text/css"> body.login div#login h1 a { background-image: url(<?php echo $oketheme['logo']['url'];?>); padding-bottom: 10px; background-size:100%; width: 300px; } </style> <?php } else { ?> <style type="text/css"> body.login div#login h1 a { background-image: none; padding-bottom: 0; background-size:0; width:0; height:0; } </style> <?php } } // Add favicon to admin page add_action('login_head', 'add_favicon'); add_action('admin_head', 'add_favicon'); function add_favicon() { echo '<link rel="shortcut icon" href="' . get_stylesheet_directory_uri() . '/images/wpicon.png" type="image/x-icon">'; } // Notice at customizer page about theme options add_filter('customize_preview_init', 'customizer_note', 10, 2); function customizer_note(){ $theme = wp_get_theme(); $button = webdev() ? 'Theme Options' : $theme->get( 'Name' ).' Options';?> <style> .cuznote { width: calc(100% - 10px); background: #fcf9e8d9; border: 1px solid #dba617; border-left-width: 5px; padding: 10px; font-size: 13px; position: fixed; z-index: 9999; top: 5px; left: 5px; } .cuznote a{ font-weight: 500; cursor: pointer; } </style> <script> function open_options() { window.open("<?php echo admin_url('admin.php?page='.oketheme_id().'-options&tab=0');?>"); } </script> <div class="cuznote"> <b>Attention:</b> Some features cannot be set from this Customizer page. Please set the theme options provided. <a onclick="open_options()"><?=$button;?></a> </div> <?php } // SEO Custom Title add_filter( 'wp_title', 'seo_wp_title', 10, 2 ); function seo_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; $title .= get_bloginfo( 'name', 'display' ); $site_desc = get_bloginfo( 'description', 'display' ); if ( $site_desc && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_desc"; if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', '' ), max( $paged, $page ) ); return $title; } // Register Menus function oketheme_register_menu() { register_nav_menus( array( 'menuatas' => __( 'Menu Wizata') ) ); } add_action( 'init', 'oketheme_register_menu' ); // Register Sidebar if (function_exists('register_sidebar')) { register_sidebar(array( 'name' => __('Sidebar - Widget Area Sidebar', 'oketheme'), 'description' => __('Drag widget here to display in the Sidebar Area', 'oketheme'), 'id' => 'sidebar-area', 'before_widget' => '<div class="sidebar">', 'after_widget' => '</div>', 'before_title' => '<h4><i class="el-icon-ok-circle" style="font-size:90%;margin-right:5px"></i> ', 'after_title' => '</h4>' )); register_sidebar(array( 'name' => __('Footer - Widget Area Left', 'oketheme'), 'description' => __('Drag widget here to display in the Footer Area (Left)', 'oketheme'), 'id' => 'footer-area-1', 'before_widget' => '<div class="footbar">', 'after_widget' => '</div>', 'before_title' => '<h4><i class="el-icon-ok-circle" style="font-size:90%;margin-right:5px"></i> ', 'after_title' => '</h4>' )); register_sidebar(array( 'name' => __('Footer - Widget Area Middle', 'oketheme'), 'description' => __('Drag widget here to display in the Footer Area (Middle) ', 'oketheme'), 'id' => 'footer-area-2', 'before_widget' => '<div class="footbar">', 'after_widget' => '</div>', 'before_title' => '<h4><i class="el-icon-ok-circle" style="font-size:90%;margin-right:5px"></i> ', 'after_title' => '</h4>' )); register_sidebar(array( 'name' => __('Footer - Widget Area Right', 'oketheme'), 'description' => __('Drag widget here to display in the Footer Area (Right) ', 'oketheme'), 'id' => 'footer-area-3', 'before_widget' => '<div class="footbar">', 'after_widget' => '</div>', 'before_title' => '<h4><i class="el-icon-ok-circle" style="font-size:90%;margin-right:5px"></i> ', 'after_title' => '</h4>' )); } // Convert +62 Whatsapp function indowa($nowa) { $splitwa = str_split($nowa); if ($splitwa[0] == '0') { return preg_replace('/^0/', '62', $nowa); } else { return $nowa; } } // Notis Don't Delete Page Testimonial add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 ); function ecs_add_post_state( $post_states, $post ) { if($post->ID == get_page_by_path('testimonial')->ID){ $post_states[] = '*jangan dihapus'; } return $post_states; } // Create Custom Page function is_custom_page() { if (get_query_var('is_konfirmasi_page') || get_query_var('is_artikel_page') || get_query_var('paged') || get_query_var('is_tour_result_page') || get_query_var('is_invoice_page') || get_query_var('is_payment_page')) { return true; } } add_action('init', 'cp_add_rewrite_rule', 10, 0); function cp_add_rewrite_rule(){ add_rewrite_rule('^artikel/page/([0-9]+)/?', 'index.php?is_artikel_page=1&paged=$matches[1]', 'top'); add_rewrite_rule('^artikel/?','index.php?is_artikel_page=1','top'); add_rewrite_rule('^konfirmasi?','index.php?is_konfirmasi_page=1','top'); add_rewrite_rule('^tour-search-result?','index.php?is_tour_result_page=1','top'); add_rewrite_rule('^invoice?','index.php?is_invoice_page=1','top'); add_rewrite_rule('^payment?','index.php?is_payment_page=1','top'); } add_action('query_vars','cp_set_query_var'); function cp_set_query_var($vars) { $cp_vars = array( 'is_artikel_page', 'is_konfirmasi_page', 'is_tour_result_page', 'is_invoice_page', 'is_payment_page' ); $vars = array_merge($vars, $cp_vars); return $vars; } add_filter('template_include', 'cp_include_template', 1000, 1); function cp_include_template($template){ if(get_query_var('is_artikel_page')){ $new_template = get_template_directory() . '/temp-artikel.php'; if(file_exists($new_template)) $template = $new_template; } if(get_query_var('is_konfirmasi_page')){ $new_template = get_template_directory() . '/temp-konfirmasi.php'; if(file_exists($new_template)) $template = $new_template; } if(get_query_var('is_tour_result_page')){ $new_template = get_template_directory() . '/temp-tour-result.php'; if(file_exists($new_template)) $template = $new_template; } if(get_query_var('is_invoice_page')){ $new_template = get_template_directory() . '/temp-invoice.php'; if(file_exists($new_template)) $template = $new_template; } if(get_query_var('is_payment_page')){ $new_template = get_template_directory() . '/temp-payment.php'; if(file_exists($new_template)) $template = $new_template; } return $template; } // Delete Post Not Need add_action('after_switch_theme', 'del_pagepost'); function del_pagepost() { wp_delete_post(1); wp_delete_post(2); // Delete Post $del_page = array(); $del_page[] = get_page_by_path('tour-search-result'); $del_page[] = get_page_by_path('konfirmasi'); $del_page[] = get_page_by_path('ppthanks'); $del_page[] = get_page_by_path('cancel'); $del_page[] = get_page_by_path('artikel'); foreach ($del_page as $page) { if(isset($page->ID)){ wp_delete_post($page->ID, true); } } } // Add New Testimoni add_action('after_switch_theme', 'add_testimoni'); function add_testimoni() { $new_page_title = 'Testimonial'; $new_page_content = ''; $new_page_template = 'temp-testimonial.php'; $new_page_slug = 'testimonial'; $page_check = get_page_by_path($new_page_slug); $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_name' => $new_page_slug, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, 'comment_status' => 'open', ); if(!isset($page_check->ID)){ $new_page_id = wp_insert_post($new_page); if(!empty($new_page_template)){ update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } $time = current_time('mysql'); $moni = get_page_by_path('testimonial'); $cmoni = get_comments_number( $moni->ID ); $data1 = array( 'comment_post_ID' => $moni->ID, 'comment_author' => 'Naruto Uzumaki', 'comment_author_email' => 'narutoozuma@oketheme.com', 'comment_author_url' => 'https://www.oketheme.com', 'comment_content' => 'Senang sekali bisa menggunakan layanan tour website ini. Harganya murah namun pelayanan yang diberikan TOP banget. Sukses selalu dan akan saya rekomendasikan kepada teman dan kerabat saya. Trims! *Ini adalah contoh testimoni, dapat Anda hapus pada wp-admin > menu Comments.', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0, 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => $time, 'comment_approved' => 1, ); $data2 = array( 'comment_post_ID' => $moni->ID, 'comment_author' => 'Tsubasa Ozora', 'comment_author_email' => 'tsuba@oketheme.com', 'comment_author_url' => 'https://www.oketheme.com', 'comment_content' => 'Sungguh pengalaman yang menyenangkan liburan menggunakan layanan tour pada website ini. Tidak salah pilih dan service yang diberikan mantab sekali. Terus tingkatkan dan sukses selalu! *Ini adalah contoh testimoni, dapat Anda hapus pada wp-admin > menu Comments.', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0, 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => $time, 'comment_approved' => 1, ); if ($cmoni == '0') { wp_insert_comment($data1); wp_insert_comment($data2); } } // Change Label function oke_label() { global $menu; global $submenu; $menu[5][0] = 'Artikel'; $submenu['edit.php'][5][0] = 'Semua Artikel'; $submenu['edit.php'][10][0] = 'Tambah Artikel'; $submenu['edit.php'][15][0] = 'Kategori'; $submenu['edit.php'][16][0] = 'Tags'; $menu[20][0] = 'Halaman'; $submenu['edit.php?post_type=page'][5][0] = 'Semua Halaman'; $submenu['edit.php?post_type=page'][10][0] = 'Tambah Halaman'; } add_action( 'admin_menu', 'oke_label' ); function oke_posts_label() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'Artikel'; $labels->singular_name = 'Artikel'; $labels->add_new = 'Tambah Artikel'; $labels->add_new_item = 'Tambah Artikel Baru'; $labels->edit_item = 'Edit Artikel'; $labels->new_item = 'Artikel'; $labels->view_item = 'Lihat Artikel'; $labels->search_items = 'Cari Artikel'; $labels->not_found = 'Artikel tidak ditemukan'; $labels->not_found_in_trash = 'Artikel tidak ditemukan di kotak sampah'; } add_action( 'init', 'oke_posts_label' ); // Breadcrumb function oke_crumb() { global $oketheme; if ($oketheme['crumb_act']) { $text['home'] = 'Home'; // text for the 'Home' link $text['category'] = 'Archive of "%s"'; // text for a category page $text['search'] = 'Result of "%s"'; // text for a search results page $text['tag'] = 'Tags "%s"'; // text for a tag page $text['author'] = 'Posted by %s'; // text for an author page $text['404'] = '404 Error'; // text for the 404 page $text['page'] = 'Page %s'; // text 'Page N' $text['cpage'] = 'Comment Page %s'; // text 'Comment Page N' $wrap_before = '<div class="crumbs" itemscope itemtype="http://schema.org/BreadcrumbList">'; // the opening wrapper tag $wrap_after = '</div><!-- .breadcrumbs -->'; // the closing wrapper tag $sep = ' » '; // separator between crumbs $before = '<span class="crumbs__current">'; // tag before the current crumb $after = '</span>'; // tag after the current crumb $show_on_home = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $show_home_link = 1; // 1 - show the 'Home' link, 0 - don't show $show_current = 1; // 1 - show current page title, 0 - don't show $show_last_sep = 1; // 1 - show last separator, when current page title is not displayed, 0 - don't show global $post; $home_url = home_url('/'); $link = '<span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">'; $link .= '<a class="crumbs__link" href="%1$s" itemprop="item"><span itemprop="name">%2$s</span></a>'; $link .= '<meta itemprop="position" content="%3$s" />'; $link .= '</span>'; $parent_id = ( $post ) ? $post->post_parent : ''; $home_link = sprintf( $link, $home_url, $text['home'], 1 ); if ( is_home() || is_front_page() ) { if ( $show_on_home ) echo $wrap_before . $home_link . $wrap_after; } else { $position = 0; echo $wrap_before; if ( $show_home_link ) { $position += 1; echo $home_link; } if ( is_category() ) { $parents = get_ancestors( get_query_var('cat'), 'category' ); foreach ( array_reverse( $parents ) as $cat ) { $position += 1; if ( $position > 1 ) echo $sep; echo sprintf( $link, get_category_link( $cat ), get_cat_name( $cat ), $position ); } if ( get_query_var( 'paged' ) ) { $position += 1; $cat = get_query_var('cat'); echo $sep . sprintf( $link, get_category_link( $cat ), get_cat_name( $cat ), $position ); echo $sep . $before . sprintf( $text['page'], get_query_var( 'paged' ) ) . $after; } else { if ( $show_current ) { if ( $position >= 1 ) echo $sep; echo $before . sprintf( $text['category'], single_cat_title( '', false ) ) . $after; } elseif ( $show_last_sep ) echo $sep; } } elseif ( is_search() ) { if ( get_query_var( 'paged' ) ) { $position += 1; if ( $show_home_link ) echo $sep; echo sprintf( $link, $home_url . '?s=' . get_search_query(), sprintf( $text['search'], get_search_query() ), $position ); echo $sep . $before . sprintf( $text['page'], get_query_var( 'paged' ) ) . $after; } else { if ( $show_current ) { if ( $position >= 1 ) echo $sep; echo $before . sprintf( $text['search'], get_search_query() ) . $after; } elseif ( $show_last_sep ) echo $sep; } } elseif ( is_year() ) { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . get_the_time('Y') . $after; elseif ( $show_home_link && $show_last_sep ) echo $sep; } elseif ( is_month() ) { if ( $show_home_link ) echo $sep; $position += 1; echo sprintf( $link, get_year_link( get_the_time('Y') ), get_the_time('Y'), $position ); if ( $show_current ) echo $sep . $before . get_the_time('F') . $after; elseif ( $show_last_sep ) echo $sep; } elseif ( is_day() ) { if ( $show_home_link ) echo $sep; $position += 1; echo sprintf( $link, get_year_link( get_the_time('Y') ), get_the_time('Y'), $position ) . $sep; $position += 1; echo sprintf( $link, get_month_link( get_the_time('Y'), get_the_time('m') ), get_the_time('F'), $position ); if ( $show_current ) echo $sep . $before . get_the_time('d') . $after; elseif ( $show_last_sep ) echo $sep; } elseif ( is_single() && ! is_attachment() ) { if ( get_post_type() != 'post' ) { $position += 1; $post_type = get_post_type_object( get_post_type() ); if ( $position > 1 ) echo $sep; echo sprintf( $link, get_post_type_archive_link( $post_type->name ), $post_type->labels->name, $position ); if ( $show_current ) echo $sep . $before . get_the_title() . $after; elseif ( $show_last_sep ) echo $sep; } else { $cat = get_the_category(); $catID = $cat[0]->cat_ID; $parents = get_ancestors( $catID, 'category' ); $parents = array_reverse( $parents ); $parents[] = $catID; foreach ( $parents as $cat ) { $position += 1; if ( $position > 1 ) echo $sep; echo sprintf( $link, get_category_link( $cat ), get_cat_name( $cat ), $position ); } if ( get_query_var( 'cpage' ) ) { $position += 1; echo $sep . sprintf( $link, get_permalink(), get_the_title(), $position ); echo $sep . $before . sprintf( $text['cpage'], get_query_var( 'cpage' ) ) . $after; } else { if ( $show_current ) echo $sep . $before . get_the_title() . $after; elseif ( $show_last_sep ) echo $sep; } } } elseif ( is_post_type_archive() ) { $post_type = get_post_type_object( get_post_type() ); if ( get_query_var( 'paged' ) ) { $position += 1; if ( $position > 1 ) echo $sep; echo sprintf( $link, get_post_type_archive_link( $post_type->name ), $post_type->label, $position ); echo $sep . $before . sprintf( $text['page'], get_query_var( 'paged' ) ) . $after; } else { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . $post_type->label . $after; elseif ( $show_home_link && $show_last_sep ) echo $sep; } } elseif ( is_attachment() ) { $parent = get_post( $parent_id ); $cat = get_the_category( $parent->ID ); $catID = $cat[0]->cat_ID; $parents = get_ancestors( $catID, 'category' ); $parents = array_reverse( $parents ); $parents[] = $catID; foreach ( $parents as $cat ) { $position += 1; if ( $position > 1 ) echo $sep; echo sprintf( $link, get_category_link( $cat ), get_cat_name( $cat ), $position ); } $position += 1; echo $sep . sprintf( $link, get_permalink( $parent ), $parent->post_title, $position ); if ( $show_current ) echo $sep . $before . get_the_title() . $after; elseif ( $show_last_sep ) echo $sep; } elseif ( is_page() && ! $parent_id ) { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . get_the_title() . $after; elseif ( $show_home_link && $show_last_sep ) echo $sep; } elseif ( is_page() && $parent_id ) { $parents = get_post_ancestors( get_the_ID() ); foreach ( array_reverse( $parents ) as $pageID ) { $position += 1; if ( $position > 1 ) echo $sep; echo sprintf( $link, get_page_link( $pageID ), get_the_title( $pageID ), $position ); } if ( $show_current ) echo $sep . $before . get_the_title() . $after; elseif ( $show_last_sep ) echo $sep; } elseif ( is_tag() ) { if ( get_query_var( 'paged' ) ) { $position += 1; $tagID = get_query_var( 'tag_id' ); echo $sep . sprintf( $link, get_tag_link( $tagID ), single_tag_title( '', false ), $position ); echo $sep . $before . sprintf( $text['page'], get_query_var( 'paged' ) ) . $after; } else { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . sprintf( $text['tag'], single_tag_title( '', false ) ) . $after; elseif ( $show_home_link && $show_last_sep ) echo $sep; } } elseif ( is_author() ) { $author = get_userdata( get_query_var( 'author' ) ); if ( get_query_var( 'paged' ) ) { $position += 1; echo $sep . sprintf( $link, get_author_posts_url( $author->ID ), sprintf( $text['author'], $author->display_name ), $position ); echo $sep . $before . sprintf( $text['page'], get_query_var( 'paged' ) ) . $after; } else { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . sprintf( $text['author'], $author->display_name ) . $after; elseif ( $show_home_link && $show_last_sep ) echo $sep; } } elseif ( is_404() ) { if ( $show_home_link && $show_current ) echo $sep; if ( $show_current ) echo $before . $text['404'] . $after; elseif ( $show_last_sep ) echo $sep; } elseif ( has_post_format() && ! is_singular() ) { if ( $show_home_link && $show_current ) echo $sep; echo get_post_format_string( get_post_format() ); } echo $wrap_after; } } } // Pagination function okepagination() { global $wp_query; $big = 999999999; echo '<div class="pagination">'; echo paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'prev_text' => 'Previous', 'next_text' => 'Next' )); echo '</div>'; } // Generated Random ID function random_id($length) { $randomString = substr(str_shuffle("ABCDEFGHJKLMNPQRSTUVWXYZ123456789"), 0, $length); return $randomString; } // Custom Column Post function register_okecolums( $columns, $post_type ) { switch ( $post_type ) { case 'tour': $new_columns = array(); foreach( $columns as $key => $value ) { $new_columns[ $key ] = $value; if ( $key == 'title' ) $new_columns[ 'thumb' ] = 'Preview'; } return $new_columns; case 'rental': $new_columns = array(); foreach( $columns as $key => $value ) { $new_columns[ $key ] = $value; if ( $key == 'title' ) $new_columns[ 'thumb' ] = 'Preview'; } return $new_columns; } return $columns; } add_filter( 'manage_posts_columns', 'register_okecolums', 10, 2 ); function show_okecolumns( $column_name, $post_id ) { switch( $column_name ) { case 'thumb': if ( has_post_thumbnail()) { the_post_thumbnail('thumbnail'); } else { echo '<img width="140" height="90" src="'.get_template_directory_uri().'/images/thumbnail.jpg"';} break; } } add_action( 'manage_posts_custom_column', 'show_okecolumns', 10, 2 ); // Custom Title Editor function model_title_text( $title ){ $screen = get_current_screen(); if ( 'tour' == $screen->post_type ) { $title = 'Tulis nama tour'; } if ( 'rental' == $screen->post_type ) { $title = 'Tulis nama armada'; } if ( 'post' == $screen->post_type ) { $title = 'Tulis judul artikel'; } return $title; } add_filter( 'enter_title_here', 'model_title_text' ); // Badge function badge_single(){ if (rwmb_meta( 'badge') != '') { echo '<div class="badge">'; if (rwmb_meta( 'badge') == 'best') { echo '<img width="120" height="117" src="'.get_template_directory_uri().'/images/badge1.png">'; } else if (rwmb_meta( 'badge') == 'sale') { echo '<img width="120" height="117" src="'.get_template_directory_uri().'/images/badge2.png">'; } echo '</div>'; } } function badge(){ global $oketheme; badge_single(); echo '<div class="badbot">'; if (rwmb_meta( 'flight_act')) { echo '<a title="'.($oketheme["translate"]=='id'?'Termasuk penerbangan':'Flight included').'"><i class="glyphicon glyphicon-plane"></i> '.($oketheme["translate"]=='id'?'Penerbangan':'Flight').'</a>'; } if (rwmb_meta( 'hotel_act')) { echo '<a title="'.($oketheme["translate"]=='id'?'Termasuk hotel':'Hotel included').'"><i class="glyphicon glyphicon-bed"></i> Hotel</a>'; } if (rwmb_meta( 'disc_act')) { echo '<a title="'.($oketheme["translate"]=='id'?'Tersedia diskon':'Discount available').'"><i class="glyphicon glyphicon-scissors"></i> '.($oketheme["translate"]=='id'?'Diskon':'Discount').'</a>'; } echo '</div>'; } // Custom Testimonial function custom_testi( $comment, $args, $depth ) { global $oketheme; $GLOBALS['comment'] = $comment; switch( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?> <li <?php comment_class(); ?> id="comment<?php comment_ID(); ?>"> <div class="back-link">< ?php comment_author_link(); ?></div> <?php break; default : ?> <li id="comment-<?php comment_ID(); ?>"> <div class="isitesti"> <div class="avatesti"> <?php echo get_avatar($comment->comment_author_email ,150 );?> </div> <h3><?php echo $comment->comment_author; ?></h3> <?php if (get_comment_meta( $comment->comment_ID, 'city', true ) != ''){ echo '<strong>'.get_comment_meta( $comment->comment_ID, 'city', true ).'</strong><br/>'; }?> <?php if (get_comment_meta( $comment->comment_ID, 'rating', true ) != ''){ echo '<img src="'; echo get_template_directory_uri(); echo '/images/'; echo get_comment_meta( $comment->comment_ID, 'rating', true ); echo 'star.gif"> <span class="small">RATING '; echo get_comment_meta( $comment->comment_ID, 'rating', true ); echo '/5</span><br/>'; }?> <p> <?php echo $comment->comment_content;?><br/> <?php if ($oketheme['translate'] == 'id') { ?> <span class="small t2">Disubmit pada: <?php comment_date(); ?></span> <?php if ( $comment->comment_approved == '0' ) : ?> <br/>*Testimoni Anda dalam proses moderasi untuk dapat ditampilkan. <?php endif; ?> <?php } else { ?> <span class="small t2">Submited at <?php comment_date(); ?></span> <?php if ( $comment->comment_approved == '0' ) : ?> <br/>*Your testimonial will be displayed after moderated. <?php endif; ?> <?php } ?> </p> </div> </li> <?php break; endswitch; } // City Comment add_filter('comment_form_default_fields','custom_fields'); function custom_fields($fields) { global $oketheme; if (is_page('testimonial')){ if ($oketheme['translate'] == 'id') { $fields[ 'city' ] = '<label for="city"><strong>Kota Anda</strong></label><input id="city" name="city" type="text" placeholder="Tulis kota Anda" tabindex="3" />'; } else { $fields[ 'city' ] = '<label for="city"><strong>Your City</strong></label><input id="city" name="city" type="text" placeholder="Enter your city" tabindex="3" />'; } } return $fields; } add_action( 'comment_form_logged_in_after', 'additional_fields' ); add_action( 'comment_form_after_fields', 'additional_fields' ); function additional_fields () { if (current_user_can('moderate_comments') ) { } else if (is_page('testimonial')){ echo '<label for="rating"><strong>Rating</strong></label> <p>'; for( $i=1; $i <= 5; $i++ ) { echo '<div class="rating"><input style="cursor:pointer;" type="radio" name="rating" value="'. $i .'"/><img style="margin-top:-10px" src="';echo get_template_directory_uri();echo '/images/'. $i .'star.gif"></div>'; } echo'</span></p>'; } } add_action( 'comment_post', 'save_comment_meta_data' ); function save_comment_meta_data( $comment_id ) { if ( ( isset( $_POST['city'] ) ) && ( $_POST['city'] != '') ) $city = wp_filter_nohtml_kses($_POST['city']); add_comment_meta( $comment_id, 'city', $city ); if ( ( isset( $_POST['rating'] ) ) && ( $_POST['rating'] != '') ) $rating = wp_filter_nohtml_kses($_POST['rating']); add_comment_meta( $comment_id, 'rating', $rating ); } add_action( 'add_meta_boxes_comment', 'extend_comment_add_meta_box' ); function extend_comment_add_meta_box() { add_meta_box( 'title', __( 'Kota & Rating' ), 'extend_comment_meta_box', 'comment', 'normal', 'high' ); } function extend_comment_meta_box ( $comment ) { $city = get_comment_meta( $comment->comment_ID, 'city', true ); $rating = get_comment_meta( $comment->comment_ID, 'rating', true ); wp_nonce_field( 'extend_comment_update', 'extend_comment_update', false ); ?> <p> <label for="city">Kota</label> <input type="text" name="city" value="<?php echo esc_attr( $city ); ?>" class="widefat" /> </p> <p> <label for="rating">Rating</label><br/> <span class="commentratingbox"> <?php for( $i=1; $i <= 5; $i++ ) { echo '<span style="padding:5px 0;"><input style="margin-top:-5px;cursor:pointer;" type="radio" name="rating" id="rating" value="'. $i .'"'; if ( $rating == $i ) echo ' checked="checked"'; echo ' /><img src="';echo get_template_directory_uri();echo '/images/'. $i .'star.gif"></span><br/>'; } ?> </span> </p> <?php } add_action( 'edit_comment', 'extend_comment_edit_metafields' ); function extend_comment_edit_metafields( $comment_id ) { if( ! isset( $_POST['extend_comment_update'] ) || ! wp_verify_nonce( $_POST['extend_comment_update'], 'extend_comment_update' ) ) return; if ( ( isset( $_POST['city'] ) ) && ( $_POST['city'] != '') ) : $city = wp_filter_nohtml_kses($_POST['city']); update_comment_meta( $comment_id, 'city', $city ); else : delete_comment_meta( $comment_id, 'city'); endif; if ( ( isset( $_POST['rating'] ) ) && ( $_POST['rating'] != '') ): $rating = wp_filter_nohtml_kses($_POST['rating']); update_comment_meta( $comment_id, 'rating', $rating ); else : delete_comment_meta( $comment_id, 'rating'); endif; } add_filter( 'comment_text', 'modify_comment'); function modify_comment( $text ){ $plugin_url_path = get_bloginfo('stylesheet_directory') . '/'; if( $commentrating = get_comment_meta( get_comment_ID(), 'rating', true ) ) { $commentrating = '<p class="small">Rating: <strong>'. $commentrating .' / 5</strong> <img style="margin-top:-4px" src="'. $plugin_url_path . 'images/'. $commentrating . 'star.gif"/></p>'; $text = $text . $commentrating; return $text; } else { return $text; } } // Nama Tour function nama_tour() { global $post; $judul = $post->post_title; $getlength = strlen($judul); if ($getlength > 32) { echo substr($judul, 0, 32).'...'; } else { echo $judul; } } // Harga View Display function harga_view() { global $oketheme; $act = rwmb_meta( 'harpil_act'); $a = rwmb_meta( 'harga'); $kurs = str_replace(".","",$oketheme['kurs']); echo '<p>'; if ($act == '1') { $a2 = rwmb_meta( 'harpil'); $a2s = $a2[0][1]; } if (($act != '1')&&($a != '')) { $c = str_replace(".","",$a); $harga = number_format($c,0,',','.'); $price = number_format($c/$kurs,2); echo '<strong class="harga">'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).'</strong> <span class="small">/ '.$oketheme['t_pax'].'</span>'; } else if (($act == '1')&&($a2s != '')){ $c = str_replace(".","",$a2s); $harga = number_format($c,0,',','.'); $price = number_format($c/$kurs,2); if ($oketheme['translate'] == 'id') { echo '<span class="vsmall t1">*Mulai</span> ';} else {echo '<span class="vsmall t1">*Start</span> '; } echo '<strong class="harga">'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).'</strong> <span class="small">/ '.$oketheme['t_pax'].'</span>'; } else { echo '<strong>'.$oketheme['t_hargahubungi'].'</strong>'; } echo '</p>'; } // Harga View Single function harga_view_single(){ global $oketheme; $act = rwmb_meta( 'harpil_act'); $a = rwmb_meta( 'harga'); $kurs = str_replace(".","",$oketheme['kurs']); if ($act == '1') { $a2 = rwmb_meta( 'harpil'); $a2s = $a2[0][1]; } if (($act != '1')&&($a != '')) { $c = str_replace(".","",$a); $harga = number_format($c,0,',','.'); $price = number_format($c/$kurs,2); echo ' <div class="b4div"><strong class="price">'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).'</strong> <strong class="small">/ '.$oketheme['t_pax'].'</strong></div> <div class="afterdiv"><strong class="price">'.$oketheme['currency'].' <span id="afterharga"></span></strong> <strong class="small">/ '.$oketheme['t_pax'].'</strong></div> <div class="small">'.rwmb_meta( 'afterharga').'</div> '; } else if (($act == '1')&&($a2s != '')){ echo ' <div class="picked"> <div class="pilihpick"></div> <div class="b4div"><strong class="price">'.$oketheme['currency'].' <span class="hargapick"></span></strong> <strong class="small">/ '.$oketheme['t_pax'].'</strong></div> <div class="afterdiv"><strong class="price">'.$oketheme['currency'].' <span id="afterharga"></span></strong> <strong class="small">/ '.$oketheme['t_pax'].'</strong></div> <div class="small">'.rwmb_meta( 'afterharga').'</div> </div> '; echo '<table class="harpil">'; foreach ( $a2 as $price ) { if ($price[1] != ''){ $pilihan = $price[0]; $x = str_replace(".","",$price[1]); $harga = number_format($x,0,',','.'); $price = number_format($x/$kurs,2); echo ' <tr> <td valign="top"> <label class="redio redio--radio"><input type="radio" class="redio" onclick="pilihharga()" name="harpil" value="'.$pilihan.'|'.$x.'"/><div class="redio__indicator"></div>'.$pilihan.'</label> </td> <td class="pilhar" valign="top"> '.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).' / '.$oketheme['t_pax'].' </td> </tr>'; } } echo '</table>'; } else { echo '<p class="price">'.$oketheme['t_hargahubungi'].'</p>'; } } // Harga Tour Input function harga_input() { $act = rwmb_meta( 'harpil_act'); $a = rwmb_meta( 'harga'); if (($act != '1')&&($a != '')) { $harga = str_replace(".","",$a); echo $harga; } } // Harga Discount Input function discount_input() { $act = rwmb_meta( 'disc_act'); $a = rwmb_meta( 'discount1'); $b = rwmb_meta( 'discount2'); $c = rwmb_meta( 'discount3'); if (($act == '1')&&($a[0] != '')&&($a[1] != '')) { $disc = str_replace(".","",$a[0]); $pax = str_replace(".","",$a[1]); echo '<input type="hidden" id="discount1" value="'.$disc.'|'.$pax.'">'; } else { echo '<input type="hidden" id="discount1" value="0|9999">'; } if (($act == '1')&&($b[0] != '')&&($b[1] != '')) { $disc = str_replace(".","",$b[0]); $pax = str_replace(".","",$b[1]); echo '<input type="hidden" id="discount2" value="'.$disc.'|'.$pax.'">'; } else { echo '<input type="hidden" id="discount2" value="0|9999">'; } if (($act == '1')&&($c[0] != '')&&($c[1] != '')) { $disc = str_replace(".","",$c[0]); $pax = str_replace(".","",$c[1]); echo '<input type="hidden" id="discount3" value="'.$disc.'|'.$pax.'">'; } else { echo '<input type="hidden" id="discount3" value="0|9999">'; } } // Discount List function disclist() { global $oketheme; $act = rwmb_meta( 'disc_act'); $a = rwmb_meta( 'discount1'); $b = rwmb_meta( 'discount2'); $c = rwmb_meta( 'discount3'); $kurs = str_replace(".","",$oketheme['kurs']); $x = array($a,$b,$c); if ($act) { echo '<span class="disc"><i class="glyphicon glyphicon-scissors"></i> '.($oketheme["translate"]=='id'?'Tersedia diskon':'Discount available').'</span><div class="disclist"><ul>'; foreach ( $x as $y ) { $pax = $y[1]; $z = str_replace(".","",$y[0]); @$disk = number_format($z,0,',','.'); @$disc = number_format($z/$kurs,2); if (($pax != '') && ($disc != '')) { echo '<li>'.($oketheme["translate"]=='id'?'diskon':'Discount').' <u class="t2">'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$disk:$disc).'</u> / '.$oketheme['t_pax'].' <span class="small t1">'.($oketheme["translate"]=='id'?'*Minimal order':'*Minimum order').' '.$pax.' '.$oketheme['t_pax'].'</span></li>'; } } echo '</ul></div>'; } } // Harga View Rental function harga_rental(){ global $oketheme; $act = rwmb_meta( 'rent_harpil_act'); $a = rwmb_meta( 'rent_harga'); $a2 = rwmb_meta( 'rent_harpil'); $durasi = rwmb_meta( 'rent_durasi')?rwmb_meta( 'rent_durasi'):$oketheme['rental_durasi']; $kurs = str_replace(".","",$oketheme['kurs']); $a2s = $a2[0][1]??''; echo '<ul style="margin-bottom:15px">'; if (($act != '1')&&($a != '')) { $c = str_replace(".","",$a); $harga = number_format($c,0,',','.'); $price = number_format($c/$kurs,2); echo '<li><strong>'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).'</strong> <span class="small">'.$durasi.'</span></li>'; } else if (($act == '1')&&($a2s != '')){ foreach ( $a2 as $xx ) { if ($xx[1] != ''){ $pilihan = $xx[0]; $x = str_replace(".","",$xx[1]); $harga = number_format($x,0,',','.'); $price = number_format($x/$kurs,2); echo ' <li><b>'.$oketheme['currency'].' '.($oketheme['currency']=='Rp'?$harga:$price).'</b> <span class="small">'.$durasi.'</span><br/><span class="vsmall t2">'.$pilihan.'</span></li>'; } } } else { echo '<li><strong>'.$oketheme['t_hargahubungi'].'</strong></li>'; } echo '</ul>'; } // Custom Post Type Tour add_action('init', 'tour_post_type'); function tour_post_type() { register_post_type('tour', array( 'labels' => array( 'name' => 'Tour', 'singular_name' => 'Tour', 'add_new' => 'Tambah Tour Baru', 'add_new_item' => 'Tambah Tour Baru', 'edit_item' => 'Edit Tour', 'view_item' => 'Lihat Detail', 'search_items' => 'Mencari Tour', 'not_found' => 'Tour tidak ditemukan', 'not_found_in_trash' => 'Tidak ditemukan di kotak sampah' ), 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-palmtree', 'supports' => array('title','editor','thumbnail'), )); } add_action( 'edit_form_after_title',function() { global $oketheme; if (!$oketheme['tour_editor_act']) { remove_post_type_support( 'tour', 'editor' ); } if (!$oketheme['rental_editor_act']) { remove_post_type_support( 'rental', 'editor' ); } }); // Taxonomies Wizata add_action( 'init', 'wizata_taxonomies', 0 ); function wizata_taxonomies() { // Kategori $labels = array( 'name' => _x( 'Kategori', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'Kategori', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Cari Kategori', 'textdomain' ), 'all_items' => __( 'Semua Kategori', 'textdomain' ), 'parent_item' => __( 'Parent Kategori', 'textdomain' ), 'parent_item_colon' => __( 'Parent Kategori:', 'textdomain' ), 'edit_item' => __( 'Edit Kategori', 'textdomain' ), 'update_item' => __( 'Update Kategori', 'textdomain' ), 'add_new_item' => __( 'Tambahkan Kategori Baru', 'textdomain' ), 'new_item_name' => __( 'Nama Kategori Baru', 'textdomain' ), 'menu_name' => __( 'Kategori', 'textdomain' ), 'translate' => __( 'Categories', 'textdomain' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'kategori' ), ); register_taxonomy( 'kategori', array( 'tour' ), $args ); // Destinasi $labels = array( 'name' => _x( 'Destinasi', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'Destinasi', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Cari Destinasi', 'textdomain' ), 'all_items' => __( 'Semua Destinasi', 'textdomain' ), 'parent_item' => __( 'Parent Destinasi', 'textdomain' ), 'parent_item_colon' => __( 'Parent Destinasi:', 'textdomain' ), 'edit_item' => __( 'Edit Destinasi', 'textdomain' ), 'update_item' => __( 'Update Destinasi', 'textdomain' ), 'add_new_item' => __( 'Tambahkan Destinasi Baru', 'textdomain' ), 'new_item_name' => __( 'Nama Destinasi Baru', 'textdomain' ), 'menu_name' => __( 'Destinasi', 'textdomain' ), 'translate' => __( 'Destination', 'textdomain' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'destinasi' ), ); register_taxonomy( 'destinasi', array( 'tour' ), $args ); // Durasi $labels = array( 'name' => _x( 'Durasi', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'Durasi', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Cari Durasi', 'textdomain' ), 'all_items' => __( 'Semua Durasi', 'textdomain' ), 'parent_item' => __( 'Parent Durasi', 'textdomain' ), 'parent_item_colon' => __( 'Parent Durasi:', 'textdomain' ), 'edit_item' => __( 'Edit Durasi', 'textdomain' ), 'update_item' => __( 'Update Durasi', 'textdomain' ), 'add_new_item' => __( 'Tambahkan Durasi Baru', 'textdomain' ), 'new_item_name' => __( 'Nama Durasi Baru', 'textdomain' ), 'menu_name' => __( 'Durasi', 'textdomain' ), 'translate' => __( 'Duration', 'textdomain' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'durasi' ), ); register_taxonomy( 'durasi', array( 'tour' ), $args ); // Kategori Rental $labels = array( 'name' => _x( 'Kategori', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'Kategori', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Cari Kategori', 'textdomain' ), 'all_items' => __( 'Semua Kategori', 'textdomain' ), 'parent_item' => __( 'Parent Kategori', 'textdomain' ), 'parent_item_colon' => __( 'Parent Kategori:', 'textdomain' ), 'edit_item' => __( 'Edit Kategori', 'textdomain' ), 'update_item' => __( 'Update Kategori', 'textdomain' ), 'add_new_item' => __( 'Tambahkan Kategori Baru', 'textdomain' ), 'new_item_name' => __( 'Nama Kategori Baru', 'textdomain' ), 'menu_name' => __( 'Kategori', 'textdomain' ), 'translate' => __( 'Categories', 'textdomain' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'rentcat' ), ); register_taxonomy( 'rentcat', array( 'rental' ), $args ); $custom_tax_mb = new Taxonomy_Single_Term( 'kategori', array( 'tour' ), 'select' ); $custom_tax_mb = new Taxonomy_Single_Term( 'destinasi', array( 'tour' ), 'select' ); $custom_tax_mb = new Taxonomy_Single_Term( 'durasi', array( 'tour' ), 'select' ); $custom_tax_mb = new Taxonomy_Single_Term( 'rentcat', array( 'rental' ), 'select' ); } // Select Taxonomies function buildSelect($tax){ global $oketheme; $terms = get_terms($tax); $taxo = get_taxonomy( $tax ); $x = '<select name="'. $tax .'">'; if ($oketheme['translate'] == 'id') { $x .= '<option value="">Semua '. ucfirst($tax) .'</option>'; } else { $x .= '<option value="">All '. ucfirst($taxo->labels->translate) .'</option>'; } foreach ($terms as $term) { $x .= '<option value="' . $term->slug . '">' . $term->name . '</option>'; } $x .= '</select>'; return $x; } // Meta Box function oke_meta( $meta_boxes ) { global $oketheme; if (isset($oketheme['t_pax'])) { $t_pax = $oketheme['t_pax']; } else { $t_pax = 'pax'; } $durasi = isset($oketheme['rental_durasi'])?$oketheme['rental_durasi']:'/ x jam'; $meta_boxes[] = array( 'id' => 'tour_info', 'title' => 'Informasi Tour', 'post_types' => array( 'tour'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array( array( 'id' => 'harga', 'hidden' => ['harpil_act', '=', '1'], 'type' => 'text', 'name' => __( 'Harga Tour', 'oketheme' ), 'desc' => __( 'Apabila "harga tour" dikosongkan, maka akan ditampilkan teks "Harga Hubungi Kami".<br>*Gunakan harga dalam rupiah. Harga tersebut otomatis akan diconvert sesuai mata uang yang Anda pilih pada setingan theme.', 'oketheme' ), 'placeholder' => __( 'Contoh: 5.000.000', 'oketheme' ), 'size' => 30, ), array( 'id' => 'harpil_act', 'name' => __( 'Multi Harga', 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk mengaktifkan multi harga (harga pilihan).', 'oketheme' ), ), array( 'id' => 'harpil', 'visible' => ['harpil_act', '=', '1'], 'type' => 'text_list', 'name' => __( '<span style="color:#FFF">.</span>', 'oketheme' ), 'desc' => __( 'Tentukan nama dan harga pada masing-masing pilihan. Urutkan dari harga yang paling murah terlebih dahulu.<br>*Gunakan harga dalam rupiah. Harga tersebut otomatis akan diconvert sesuai mata uang yang Anda pilih pada setingan theme.', 'oketheme' ), 'options' => array( 'Pilihan' => '', 'Harga' => '', ), 'clone' => true, 'max_clone' => 10, 'add_button' => __( '+ Tambah', 'oketheme' ), ), array( 'id' => 'afterharga', 'type' => 'textarea', 'name' => __( 'Info Harga', 'oketheme' ), 'placeholder' => __( '*Harga diatas dapat berubah sewaktu-waktu tanpa pemberitahuan terlebih dahulu.', 'oketheme' ), 'rows' => 2, 'desc' => __( '*HTML is allowed. Gunakan kode <br/> untuk enter (ganti baris)', 'oketheme' ), ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'id' => 'disc_act', 'name' => __( 'Diskon /'.$t_pax, 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk mengaktifkan diskon /'.$t_pax.'.', 'oketheme' ), ), array( 'id' => 'discount1', 'visible' => ['disc_act', '=', '1'], 'type' => 'text_list', 'name' => __( '<span style="color:#FFF">.</span>', 'oketheme' ), 'options' => array( '[Diskon] ex: 100.000' => '', '[Minimal '.$t_pax.'] ex: 3' => '', ), ), array( 'id' => 'discount2', 'visible' => ['disc_act', '=', '1'], 'type' => 'text_list', 'name' => __( '<span style="color:#FFF">.</span>', 'oketheme' ), 'options' => array( '[Diskon] ex: 150.000' => '', '[Minimal '.$t_pax.'] ex: 6' => '', ), ), array( 'id' => 'discount3', 'visible' => ['disc_act', '=', '1'], 'type' => 'text_list', 'name' => __( '<span style="color:#FFF">.</span>', 'oketheme' ), 'options' => array( '[Diskon] ex: 200.000' => '', '[Minimal '.$t_pax.'] ex: 9' => '', ), 'desc' => __( 'Diskon sebesar <span style="color:red">[Diskon]</span>, apabila minimal pesanan <span style="color:red">[Minimal '.$t_pax.']</span> tercapai. *Urutkan dari harga yang paling murah terlebih dahulu.<br/><b>Note:</b> Diskon ini tidak mengurangi keseluruhan total pesanan, melainkan mengurangi harga per '.$t_pax.'.', 'oketheme' ), ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'id' => 'datetour', 'type' => 'date', 'name' => __( 'Tanggal Tour', 'oketheme' ), 'desc' => __( 'Apabila "tanggal tour" dikosongkan, maka tour ini selalu tersedia kapan saja.', 'oketheme' ), 'js_options' => array( 'dateFormat' => __( 'd MM yy', 'oketheme' ), 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true, ), 'clone' => true, 'add_button' => __( '+ Tambah', 'oketheme' ), ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'id' => 'gambar', 'type' => 'image_advanced', 'name' => __( 'Gambar/ Foto', 'oketheme' ), 'max_file_uploads' => 15, 'desc' => __( 'Upload gambar/foto display tour. Ukuran rekomendasi: 700x400 pixel', 'oketheme' ), ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'id' => 'itinerary', 'name' => __( 'Tabs: Itinerary', 'oketheme' ), 'type' => 'wysiwyg', 'desc' => __( 'Silahkan tulis itinerary atau jadwal acara pada tour ini.', 'oketheme' ), 'options' => array( 'textarea_rows' => 8, 'teeny' => false, 'media_buttons' => false, ), ), array( 'id' => 'term', 'name' => __( 'Tabs: Syarat Ketentuan', 'oketheme' ), 'type' => 'wysiwyg', 'desc' => __( 'Silahkan tulis syarat & ketentuan yang berlaku pada tour ini.', 'oketheme' ), 'options' => array( 'textarea_rows' => 8, 'teeny' => false, 'media_buttons' => false, ), ), array( 'id' => 'ctabs_act', 'name' => __( 'Tabs: Tambahan (Custom)', 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk mengaktifkan tabs tambahan.', 'oketheme' ), ), array( 'id' => 'ctabs_title', 'visible' => ['ctabs_act', '=', '1'], 'type' => 'text', 'name' => __( '-- Judul Tabs', 'oketheme' ), 'desc' => __( 'Tulis judul untuk tabs tambahan.', 'oketheme' ), 'placeholder' => __( 'Judul tabs tambahan', 'oketheme' ), 'size' => 30, ), array( 'id' => 'ctabs', 'visible' => ['ctabs_act', '=', '1'], 'name' => __( '-- Deskripsi Tabs', 'oketheme' ), 'type' => 'wysiwyg', 'desc' => __( 'Silahkan tulis sesuatu untuk ditampilkan pada tabs tambahan.', 'oketheme' ), 'options' => array( 'textarea_rows' => 8, 'teeny' => false, ), ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'name' => __( 'Badge', 'oketheme' ), 'id' => 'badge', 'type' => 'select', 'options' => array( '' => __( 'Tanpa Badge', 'oketheme' ), 'best' => __( 'Best Seller', 'oketheme' ), 'sale' => __( 'Hot Sale', 'oketheme' ), ), ), array( 'id' => 'flight_act', 'name' => __( 'Flight Mark', 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk menandai tour ini include biaya pesawat (penerbangan).', 'oketheme' ), ), array( 'id' => 'hotel_act', 'name' => __( 'Hotel Mark', 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk menandai tour ini include biaya hotel (penginapan).', 'oketheme' ), ), array( 'id' => 'copyright', 'type' => 'heading', 'desc' => __( editor_copyright(), 'oketheme' ), 'name' => null, ), ), ); $meta_boxes[] = array( 'id' => 'rental_info', 'title' => esc_html__( 'Informasi Armada', 'oketheme' ), 'post_types' => array( 'rental'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array( array( 'id' => 'rent_harga', 'hidden' => ['harpil_act', '=', '1'], 'type' => 'text', 'name' => __( 'Harga Sewa', 'oketheme' ), 'desc' => __( 'Apabila "harga sewa" dikosongkan, maka akan ditampilkan teks "Harga Hubungi Kami".<br>*Gunakan harga dalam rupiah. Harga tersebut otomatis akan diconvert sesuai mata uang yang Anda pilih pada setingan theme.', 'oketheme' ), 'placeholder' => __( 'Contoh: 5.000.000', 'oketheme' ), 'size' => 30, ), array( 'id' => 'rent_harpil_act', 'name' => __( 'Multi Harga', 'oketheme' ), 'type' => 'checkbox', 'desc' => __( 'Centang, untuk mengaktifkan multi harga (harga pilihan).', 'oketheme' ), ), array( 'id' => 'rent_harpil', 'visible' => ['harpil_act', '=', '1'], 'type' => 'text_list', 'name' => __( '<span style="color:#FFF">.</span>', 'oketheme' ), 'desc' => __( 'Tentukan nama dan harga pada masing-masing pilihan. Urutkan dari harga yang paling murah terlebih dahulu.<br>*Gunakan harga dalam rupiah. Harga tersebut otomatis akan diconvert sesuai mata uang yang Anda pilih pada setingan theme.', 'oketheme' ), 'options' => array( 'Pilihan' => '', 'Harga' => '', ), 'clone' => true, 'max_clone' => 10, 'add_button' => __( '+ Tambah', 'oketheme' ), ), array( 'id' => 'rent_durasi', 'type' => 'text', 'name' => __( 'Durasi Sewa', 'oketheme' ), 'desc' => __( 'Tentukan durasi sewa kendaraan.<br>*Jika tidak diisi, maka akan menggunakan durasi default yaitu <b>'.$durasi.'</b> sesuai pada setingan theme.', 'oketheme' ), 'placeholder' => __( 'Contoh: / 12 jam', 'oketheme' ), 'std' => '', 'size' => 30, ), array( 'id' => 'divider', 'type' => 'divider', ), array( 'id' => 'rent_fasilitas', 'type' => 'text_list', 'name' => __( 'Fasilitas', 'oketheme' ), 'desc' => __( 'Fasilitas yang didapatkan customer ketika menyewa armada ini.', 'oketheme' ), 'options' => array( 'Contoh: Air Mineral' => '', ), 'clone' => true, 'max_clone' => 20, 'add_button' => __( '+ Tambah', 'oketheme' ), ), array( 'id' => 'rent_gambar', 'type' => 'image_advanced', 'name' => __( 'Gambar/ Foto', 'oketheme' ), 'max_file_uploads' => 1, 'desc' => __( 'Upload gambar/foto display tour. Ukuran rekomendasi: 700x400 pixel', 'oketheme' ), ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'oke_meta' ); // Paypal Mode function pp_link() { global $oketheme; if ($oketheme['paypal_mode'] == 'live') { $link = 'https://www.paypal.com/cgi-bin/webscr'; }else { $link = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } return $link; } // Request Transaksi Tripay add_action( 'wp_ajax_nopriv_reqPayment', 'reqPayment_callback' ); //ajax logout user add_action( 'wp_ajax_reqPayment', 'reqPayment_callback' ); // ajax login user function reqPayment_callback(){ global $wpdb; global $oketheme; // Data submitted $merchant_ref = $_POST["invoice"]; $method = $_POST["channel"]; // Get invoice detail from databse $tb_booking = $wpdb->prefix . 'bookingan'; $x = $wpdb->get_row("SELECT * FROM $tb_booking WHERE invoice = '$merchant_ref'"); // Parameter if ($oketheme['tripay_act'] == 'live') { $apiKey = $oketheme['tripay_pro_apikey']; $privateKey = $oketheme['tripay_pro_privatekey']; $endpoint = 'https://tripay.co.id/api/transaction/create'; } else { $apiKey = $oketheme['tripay_sand_apikey']; $privateKey = $oketheme['tripay_sand_privatekey']; $endpoint = 'https://tripay.co.id/api-sandbox/transaction/create'; } $merchantCode = $oketheme['tripay_merchant_code']; $hargatotal = str_replace(".","",$x->hargatotal); $depe = str_replace(".","",$x->depe); $sdepe = str_replace(".","",$x->sdepe); if ($x->dp != '100' && $x->status == 'unpaid') { $amount = $depe; $price = $depe; $name = 'INV/Booking ID:'.$merchant_ref.' (DP '.$x->dp.'%)'; } else if ($x->status == 'dp') { $amount = $sdepe; $price = $sdepe; $name = 'INV/Booking ID:'.$merchant_ref.' (Full Payment)'; } else { $amount = $hargatotal; $price = $hargatotal; $name = 'INV/Booking ID:'.$merchant_ref.' (Full Payment)'; } $data = [ 'method' => $method, 'merchant_ref' => $merchant_ref, 'amount' => $amount, 'customer_name' => $x->nama1_cust.' '.$x->nama2_cust, 'customer_email' => $x->email_cust, 'customer_phone' => $x->hp_cust, 'order_items' => [ [ 'sku' => null, 'name' => $name, 'price' => $price, 'quantity' => '1', 'product_url' => $x->urltour, 'image_url' => $x->imgtour, ], ], 'return_url' => site_url().'/invoice/?id='.$merchant_ref.'&email='.$x->email_cust, 'expired_time' => (time() + (24 * 60 * 60)), // 24 jam 'signature' => hash_hmac('sha256', $merchantCode.$merchant_ref.$amount, $privateKey) ]; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_FRESH_CONNECT => true, CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => ['Authorization: Bearer '.$apiKey], CURLOPT_FAILONERROR => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($data), CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4 ]); $response = curl_exec($curl); curl_close($curl); $result = json_decode($response, true); $trx_id = $result['data']['reference']; $instruksi = $result['data']['instructions']; if ($result['success']) { // update data at booking table $sql = $wpdb->query(" UPDATE $tb_booking SET payment = 'tripay|$trx_id' WHERE invoice = '$merchant_ref' "); // create instruction $howto = '<h2>'.$result['data']['payment_name'].'</h2>'; if ($result['data']['qr_url']) { $howto .= '<img src="'.$result['data']['qr_url'].'">'; } else if ($result['data']['pay_code']){ $howto .= 'Kode Bayar <code>'.$result['data']['pay_code'].'</code>'; } else { $howto .= 'Link Pembayaran: <b><a href="'.$result['data']['checkout_url'].'" target="blank">'.$result['data']['checkout_url'].'</a></b>'; } if($instruksi) { $howto .= '<p>Berikut ini cara pembayaran yang dapat Anda lakukan:</p>'; foreach ($instruksi as $y) { $howto .= '<h4>'.$y['title'].'</h4><ul>'; foreach ($y['steps'] as $z) { $howto .= '<li>'.$z.'</li>'; } $howto .= '</ul>'; } } // encode json to show echo json_encode(array('success'=>$result['success'], 'message'=> $result['message'],'instructions'=> $howto)); } else { echo json_encode(array('success'=>$result['success'], 'message'=> $result['message'])); } wp_die(); } // Required & include files require_once( get_template_directory() . '/functions/dashboard.php'); include_once( get_template_directory() . '/functions/inc/class.taxonomy-single-term.php'); include_once( get_template_directory() . '/functions/inc/metabox/mb/meta-box.php'); include_once( get_template_directory() . '/functions/inc/metabox/mb-logic/meta-box-logic.php'); include_once( get_template_directory() . '/functions/inc/tgm/oketgm.php');