Guest User

Untitled

a guest
Mar 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.53 KB | None | 0 0
  1. <?php
  2. /**Theme Name : Appointment
  3. * Theme Core Functions and Codes
  4. */
  5. /**Includes reqired resources here**/
  6. define('WEBRITI_TEMPLATE_DIR_URI', get_template_directory_uri());
  7. define('WEBRITI_TEMPLATE_DIR' , get_template_directory());
  8. define('WEBRITI_THEME_FUNCTIONS_PATH' , WEBRITI_TEMPLATE_DIR.'/functions');
  9. define('WEBRITI_THEME_OPTIONS_PATH' , WEBRITI_TEMPLATE_DIR_URI.'/functions/theme_options');
  10. require( WEBRITI_THEME_FUNCTIONS_PATH.'/scripts/script.php');
  11. require( WEBRITI_THEME_FUNCTIONS_PATH.'/menu/default_menu_walker.php');
  12. require( WEBRITI_THEME_FUNCTIONS_PATH.'/menu/appoinment_nav_walker.php');
  13. require( WEBRITI_THEME_FUNCTIONS_PATH.'/widgets/sidebars.php');
  14. require( WEBRITI_THEME_FUNCTIONS_PATH . '/template-tags.php');
  15. require( WEBRITI_THEME_FUNCTIONS_PATH . '/breadcrumbs/breadcrumbs.php');
  16. require( WEBRITI_THEME_FUNCTIONS_PATH .'/widgets/appointment_info_widget.php');
  17. require( WEBRITI_THEME_FUNCTIONS_PATH .'/widgets/header-widget.php');
  18. require( WEBRITI_THEME_FUNCTIONS_PATH . '/font/font.php');
  19. require( WEBRITI_THEME_FUNCTIONS_PATH . '/post-type/custom-post-type.php');
  20. require( WEBRITI_THEME_FUNCTIONS_PATH . '/meta-box/post-meta.php');
  21. require( WEBRITI_THEME_FUNCTIONS_PATH . '/taxonomies/taxonomies.php');
  22. require( WEBRITI_THEME_FUNCTIONS_PATH . '/pagination/webriti_pagination.php');
  23. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-callout.php');
  24. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-client.php');
  25. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-service.php');
  26. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-slider.php');
  27. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-copyright.php');
  28. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-header.php');
  29. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-news.php');
  30. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-project.php');
  31. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-testimonial.php');
  32. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-template.php');
  33. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-layout.php');
  34. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer-footer-callout.php');
  35. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer_theme_style.php');
  36. require( WEBRITI_THEME_FUNCTIONS_PATH . '/customizer/customizer_banner.php');
  37. require( WEBRITI_TEMPLATE_DIR . '/css/custom-light.php');
  38. require_once('theme_setup_data.php');
  39.  
  40.  
  41. // Custom Category control
  42. require( WEBRITI_THEME_FUNCTIONS_PATH . '/custom-controls/select/category-dropdown-custom-control.php');
  43. require( WEBRITI_THEME_FUNCTIONS_PATH . '/custom-controls/select/taxonomy-dropdown-custom-control.php');
  44.  
  45. /* Theme Setup Function */
  46. add_action( 'after_setup_theme', 'appointment_setup' );
  47.  
  48.  
  49. function appointment_setup()
  50. {
  51. // Load text domain for translation-ready
  52. load_theme_textdomain( 'appointment', WEBRITI_THEME_FUNCTIONS_PATH . '/lang' );
  53. // Custom-header
  54. $header_args = array(
  55. 'flex-height' => true,
  56. 'height' => 200,
  57. 'flex-width' => true,
  58. 'width' => 1600,
  59. 'admin-head-callback' => 'mytheme_admin_header_style',
  60. );
  61.  
  62. add_theme_support( 'custom-header', $header_args );
  63.  
  64. add_theme_support( 'post-thumbnails' ); //supports featured image
  65. // Register primary menu
  66. register_nav_menu( 'primary', __( 'Primary Menu', 'appointment' ) );
  67. // Add default posts and comments RSS feed links to head.
  68. add_theme_support( 'automatic-feed-links' );
  69. // Set the content_width with 900
  70.  
  71.  
  72. }
  73. // set appoinment page title
  74. function appointment_title( $title, $sep )
  75. {
  76. global $paged, $page;
  77.  
  78. if( is_home() ){
  79. return $title;
  80. }
  81.  
  82. if ( is_feed() )
  83. return $title;
  84. // Add the site name.
  85. $title .= get_bloginfo( 'name' );
  86. // Add the site description for the home/front page.
  87. $site_description = get_bloginfo( 'description' );
  88. if ( $site_description && ( is_home() || is_front_page() ) )
  89. $title = "$title $sep $site_description";
  90. // Add a page number if necessary.
  91. if ( $paged >= 2 || $page >= 2 )
  92. $title = "$title $sep " . sprintf( _e( 'Page', 'appointment' ), max( $paged, $page ) );
  93.  
  94. return $title;
  95. }
  96. add_filter( 'wp_title', 'appointment_title', 10,2 );
  97.  
  98.  
  99. add_filter('get_avatar','appointment_add_gravatar_class');
  100.  
  101. function appointment_add_gravatar_class($class) {
  102. $class = str_replace("class='avatar", "class='img-circle", $class);
  103. return $class;
  104. }
  105. function appointment_add_to_author_profile( $contactmethods ) {
  106. $contactmethods['facebook_profile'] = __('Facebook Profile URL','appointment');
  107. $contactmethods['twitter_profile'] = __('Twitter Profile URL','appointment');
  108. $contactmethods['linkedin_profile'] = __('Linkedin Profile URL','appointment');
  109. $contactmethods['google_profile'] = __('Google Profile URL','appointment');
  110. return $contactmethods;
  111. }
  112. add_filter( 'user_contactmethods', 'appointment_add_to_author_profile', 10, 1);
  113.  
  114. /********** Image Resize *************/
  115. add_filter('get_the_excerpt','appointment_post_slider_excerpt');
  116. function appointment_post_slider_excerpt($output){
  117. $output = strip_tags(preg_replace(" (\[.*?\])",'',$output));
  118. $output = strip_shortcodes($output);
  119. $original_len = strlen($output);
  120. $output = substr($output, 0, 155);
  121. $len=strlen($output);
  122. if($original_len>155) {
  123. $output = $output;
  124. $format = get_post_format();
  125. if($format =='video') {
  126. return '<p>' .$output.'</p><a href="' . get_permalink() . '" class="format-video-btn-sm">Read More</a>';
  127. }
  128. else
  129. {
  130. return '<div class="slide-text-bg2">' .'<span>'.$output.'</span>'.'</div>'.
  131. '<div class="slide-btn-area-sm"><a href="' . get_permalink() . '" class="slide-btn-sm">'.__("
  132. Read more","appointment").'</a></div>';
  133. }
  134. }
  135. else {
  136. $format = get_post_format();
  137. if($format =='video') {
  138. return '<p>' .$output.'</p>';
  139. }
  140. else
  141. {
  142. return '<div class="slide-text-bg2"><span>'.$output.'</span></div>';
  143. }
  144. }
  145.  
  146. }
  147.  
  148. //this will by default select the all category
  149. function appointment_mfields_set_default_object_terms( $post_id, $post ) {
  150. if ( 'publish' == $post->post_status && $post->post_type == 'appoint_portfolio' ) {
  151. $taxonomies = get_object_taxonomies( $post->post_type,'object' );
  152. foreach ( $taxonomies as $taxonomy ) {
  153. $terms = wp_get_post_terms( $post_id, $taxonomy->name );
  154. $myid = get_option('appointment_webriti_default_term_id');
  155. $a=get_term_by('id',$myid,'portfolio_categories');
  156. if ( empty( $terms )) {
  157. wp_set_object_terms( $post_id,$a->slug , $taxonomy->name );
  158. }
  159. }
  160. }
  161. }
  162. add_action( 'save_post', 'appointment_mfields_set_default_object_terms', 100, 2 );
  163.  
  164. function appointment_get_portfolio_terms()
  165. {
  166. $post_type = 'appoint_portfolio';
  167. $tax = 'portfolio_categories';
  168. $term_args=array( 'hide_empty' => true,'orderby' => 'id');
  169. $tax_terms = get_terms($tax, $term_args);
  170. return $tax_terms;
  171. }
  172. function appointment_get_custom_link($url,$target,$title)
  173. {
  174. if($title)
  175. {?>
  176. <a href="<?php echo $url; ?>" <?php if($target=='on' || $target==true){ echo 'target="_blank"'; } ?> >
  177. <?php echo $title; ?>
  178. </a>
  179. <?php } }
  180.  
  181. function get_home_blog_excerpt()
  182. {
  183. global $post;
  184. $excerpt = get_the_content();
  185. $excerpt = strip_tags(preg_replace(" (\[.*?\])",'',$excerpt));
  186. $excerpt = strip_shortcodes($excerpt);
  187. $original_len = strlen($excerpt);
  188. $excerpt = substr($excerpt, 0, 145);
  189. $len=strlen($excerpt);
  190. if($original_len>275) {
  191. $excerpt = $excerpt;
  192. return $excerpt . '<div class="blog-btn-area-sm"><a href="' . get_permalink() . '" class="blog-btn-sm">Read More</a></div>';
  193. }
  194. else
  195. { return $excerpt; }
  196. }
  197. add_theme_support( 'post-formats', array(
  198. 'aside', 'quote', 'status', 'video'
  199. ) );
  200.  
  201. function appointment_blog_exclude_category( $query ) {
  202.  
  203. $appointment_options = theme_setup_data();
  204.  
  205. $current_options = wp_parse_args( get_option( 'appointment_options', array() ), $appointment_options );
  206.  
  207.  
  208. if( is_admin() || is_front_page() ) {
  209. return;
  210. }
  211. else
  212. {
  213.  
  214. if( $current_options['blog_page_slider_enable'] != 1 ) {
  215.  
  216. $query->set( 'category__not_in',$current_options['slider_select_category'] );
  217.  
  218. }
  219.  
  220. }
  221.  
  222. }
  223. add_action( 'pre_get_posts', 'appointment_blog_exclude_category' );
  224.  
  225. function appointment_exclude_widget_categories($args){
  226. $appointment_options=theme_setup_data();
  227. $current_options = wp_parse_args( get_option( 'appointment_options', array() ), $appointment_options );
  228. $exclude = $current_options['slider_select_category']; // The IDs of the excluding categories
  229. if( $current_options['blog_page_slider_enable'] == false ) {
  230. $args["exclude"] = $exclude;
  231. }
  232. return $args;
  233. }
  234. add_filter("widget_categories_args","appointment_exclude_widget_categories");
  235.  
  236. add_filter('pre_post_title', 'appoinment_allow_empty_title_post');
  237. add_filter('pre_post_content', 'appoinment_allow_empty_title_post');
  238.  
  239. function appoinment_allow_empty_title_post($value)
  240. {
  241. if ( empty($value) ) {
  242. return ' ';
  243. }
  244. return $value;
  245. }
  246.  
  247. add_filter('wp_insert_post_data', 'appointment_empty_post_insert');
  248. function appointment_empty_post_insert($data)
  249. {
  250. if ( ' ' == $data['post_title'] ) {
  251. $data['post_title'] = '';
  252. }
  253. if ( ' ' == $data['post_content'] ) {
  254. $data['post_content'] = '';
  255. }
  256. return $data;
  257. }
Add Comment
Please, Sign In to add comment