Advertisement
Guest User

Untitled

a guest
Oct 14th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.72 KB | None | 0 0
  1. <?php
  2. /**
  3. * Moesia functions and definitions
  4. *
  5. * @package Moesia
  6. */
  7.  
  8.  
  9. if ( ! function_exists( 'moesia_setup' ) ) :
  10. /**
  11. * Sets up theme defaults and registers support for various WordPress features.
  12. *
  13. * Note that this function is hooked into the after_setup_theme hook, which
  14. * runs before the init hook. The init hook is too late for some features, such
  15. * as indicating support for post thumbnails.
  16. */
  17. function moesia_setup() {
  18.  
  19. /*
  20. * Make theme available for translation.
  21. * Translations can be filed in the /languages/ directory.
  22. * If you're building a theme based on Moesia, use a find and replace
  23. * to change 'moesia' to the name of your theme in all the template files
  24. */
  25. load_theme_textdomain( 'moesia', get_template_directory() . '/languages' );
  26.  
  27. // Add default posts and comments RSS feed links to head.
  28. add_theme_support( 'automatic-feed-links' );
  29.  
  30. // Set the content width based on the theme's design and stylesheet.
  31. global $content_width;
  32. if ( ! isset( $content_width ) ) {
  33. $content_width = 640; /* pixels */
  34. }
  35.  
  36. /*
  37. * Enable support for Post Thumbnails on posts and pages.
  38. *
  39. * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  40. */
  41. add_theme_support( 'post-thumbnails' );
  42. add_image_size('project-image', 350, 250, true);
  43.  
  44. // This theme uses wp_nav_menu() in one location.
  45. register_nav_menus( array(
  46. 'primary' => __( 'Primary Menu', 'moesia' ),
  47. ) );
  48.  
  49. /*
  50. * Switch default core markup for search form, comment form, and comments
  51. * to output valid HTML5.
  52. */
  53. add_theme_support( 'html5', array(
  54. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
  55. ) );
  56.  
  57. /*
  58. * Enable support for Post Formats.
  59. * See http://codex.wordpress.org/Post_Formats
  60. */
  61. add_theme_support( 'post-formats', array(
  62. 'aside', 'image', 'video', 'quote', 'link'
  63. ) );
  64.  
  65. // Setup the WordPress core custom background feature.
  66. add_theme_support( 'custom-background', apply_filters( 'moesia_custom_background_args', array(
  67. 'default-color' => 'f5f5f5',
  68. 'default-image' => '',
  69. ) ) );
  70. }
  71. endif; // moesia_setup
  72. add_action( 'after_setup_theme', 'moesia_setup' );
  73.  
  74. /**
  75. * Register widget area.
  76. *
  77. * @link http://codex.wordpress.org/Function_Reference/register_sidebar
  78. */
  79. function moesia_widgets_init() {
  80. register_sidebar( array(
  81. 'name' => __( 'Sidebar', 'moesia' ),
  82. 'id' => 'sidebar-1',
  83. 'description' => '',
  84. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  85. 'after_widget' => '</aside>',
  86. 'before_title' => '<h2 class="widget-title">',
  87. 'after_title' => '</h2>',
  88. ) );
  89. register_sidebar( array(
  90. 'name' => __( 'Footer A', 'moesia' ),
  91. 'id' => 'sidebar-3',
  92. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  93. 'after_widget' => '</aside>',
  94. 'before_title' => '<h3 class="widget-title">',
  95. 'after_title' => '</h3>',
  96. ) );
  97. register_sidebar( array(
  98. 'name' => __( 'Footer B', 'moesia' ),
  99. 'id' => 'sidebar-4',
  100. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  101. 'after_widget' => '</aside>',
  102. 'before_title' => '<h3 class="widget-title">',
  103. 'after_title' => '</h3>',
  104. ) );
  105. register_sidebar( array(
  106. 'name' => __( 'Footer C', 'moesia' ),
  107. 'id' => 'sidebar-5',
  108. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  109. 'after_widget' => '</aside>',
  110. 'before_title' => '<h3 class="widget-title">',
  111. 'after_title' => '</h3>',
  112. ) );
  113.  
  114. //Register the front page widgets
  115. if ( function_exists('siteorigin_panels_activate') ) {
  116. register_widget( 'Moesia_Services' );
  117. register_widget( 'Moesia_Employees' );
  118. register_widget( 'Moesia_Fp_Social_Profile' );
  119. register_widget( 'Moesia_Blockquote' );
  120. register_widget( 'Moesia_Skills' );
  121. register_widget( 'Moesia_Facts' );
  122. register_widget( 'Moesia_Testimonials' );
  123. register_widget( 'Moesia_Clients' );
  124. register_widget( 'Moesia_Projects' );
  125. register_widget( 'Moesia_Action' );
  126. register_widget( 'Moesia_Latest_News' );
  127. }
  128.  
  129. //Register the sidebar widgets
  130. register_widget( 'Moesia_Recent_Comments' );
  131. register_widget( 'Moesia_Recent_Posts' );
  132. register_widget( 'Moesia_Social_Profile' );
  133. register_widget( 'Moesia_Video_Widget' );
  134. register_widget( 'Moesia_Contact_Info' );
  135. }
  136. add_action( 'widgets_init', 'moesia_widgets_init' );
  137.  
  138. /**
  139. * Load the front page widgets.
  140. */
  141. if ( function_exists('siteorigin_panels_activate') ) {
  142. require get_template_directory() . "/widgets/fp-services.php";
  143. require get_template_directory() . "/widgets/fp-employees.php";
  144. require get_template_directory() . "/widgets/fp-social.php";
  145. require get_template_directory() . "/widgets/fp-blockquote.php";
  146. require get_template_directory() . "/widgets/fp-skills.php";
  147. require get_template_directory() . "/widgets/fp-facts.php";
  148. require get_template_directory() . "/widgets/fp-testimonials.php";
  149. require get_template_directory() . "/widgets/fp-clients.php";
  150. require get_template_directory() . "/widgets/fp-projects.php";
  151. require get_template_directory() . "/widgets/fp-call-to-action.php";
  152. require get_template_directory() . "/widgets/fp-latest-news.php";
  153. }
  154.  
  155. /**
  156. * Load the sidebar widgets.
  157. */
  158. require get_template_directory() . "/widgets/recent-comments.php";
  159. require get_template_directory() . "/widgets/recent-posts.php";
  160. require get_template_directory() . "/widgets/social-profile.php";
  161. require get_template_directory() . "/widgets/video-widget.php";
  162. require get_template_directory() . "/widgets/contact-info.php";
  163.  
  164. /**
  165. * Enqueue scripts and styles.
  166. */
  167. function moesia_scripts() {
  168.  
  169. wp_enqueue_style( 'moesia-bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap/bootstrap.min.css', array(), true );
  170.  
  171. wp_enqueue_style( 'moesia-style', get_stylesheet_uri() );
  172.  
  173. //Load the fonts
  174. $headings_font = esc_html(get_theme_mod('headings_fonts'));
  175. $body_font = esc_html(get_theme_mod('body_fonts'));
  176. if( $headings_font ) {
  177. wp_enqueue_style( 'moesia-headings-fonts', '//fonts.googleapis.com/css?family='. $headings_font );
  178. } else {
  179. wp_enqueue_style( 'moesia-roboto-condensed', '//fonts.googleapis.com/css?family=Roboto+Condensed:700');
  180. }
  181. if( $body_font ) {
  182. wp_enqueue_style( 'moesia-body-fonts', '//fonts.googleapis.com/css?family='. $body_font );
  183. } else {
  184. wp_enqueue_style( 'moesia-roboto', '//fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic');
  185. }
  186.  
  187. wp_enqueue_style( 'moesia-font-awesome', get_stylesheet_directory_uri() . '/fonts/font-awesome.min.css' );
  188.  
  189. wp_enqueue_script( 'moesia-navigation', get_stylesheet_directory_uri() . '/js/navigation.js', array(), '20120206', true );
  190.  
  191. wp_enqueue_script( 'moesia-waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array('jquery'), true );
  192.  
  193. wp_enqueue_script( 'moesia-waypoints-sticky', get_stylesheet_directory_uri() . '/js/waypoints-sticky.min.js', array('jquery'), true );
  194.  
  195. if ( get_theme_mod('moesia_scroller') != 1 ) {
  196.  
  197. wp_enqueue_script( 'moesia-nicescroll', get_stylesheet_directory_uri() . '/js/jquery.nicescroll.min.js', array('jquery'), true );
  198.  
  199. wp_enqueue_script( 'moesia-nicescroll-init', get_stylesheet_directory_uri() . '/js/nicescroll-init.js', array('jquery'), true );
  200.  
  201. }
  202.  
  203. if ( is_page_template('page_front-page.php') ) {
  204.  
  205. wp_enqueue_script( 'moesia-carousel', get_stylesheet_directory_uri() . '/js/slick.min.js', array( 'jquery' ), true );
  206.  
  207. wp_enqueue_script( 'moesia-carousel-init', get_stylesheet_directory_uri() . '/js/carousel-init.js', array(), true );
  208.  
  209. wp_enqueue_style( 'moesia-pretty-photo', get_stylesheet_directory_uri() . '/inc/prettyphoto/css/prettyPhoto.min.css' );
  210.  
  211. wp_enqueue_script( 'moesia-pretty-photo-js', get_stylesheet_directory_uri() . '/inc/prettyphoto/js/jquery.prettyPhoto.min.js', array(), true );
  212.  
  213. wp_enqueue_script( 'moesia-pretty-photo-init', get_stylesheet_directory_uri() . '/inc/prettyphoto/js/prettyphoto-init.js', array(), true );
  214.  
  215. }
  216.  
  217. if ( get_theme_mod('moesia_animate') != 1 ) {
  218.  
  219. wp_enqueue_script( 'moesia-wow', get_stylesheet_directory_uri() . '/js/wow.min.js', array( 'jquery' ), true );
  220.  
  221. wp_enqueue_style( 'moesia-animations', get_stylesheet_directory_uri() . '/css/animate/animate.min.css' );
  222.  
  223. wp_enqueue_script( 'moesia-wow-init', get_stylesheet_directory_uri() . '/js/wow-init.js', array( 'jquery' ), true );
  224.  
  225. }
  226.  
  227. wp_enqueue_script( 'moesia-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array('jquery'), true );
  228.  
  229. wp_enqueue_script( 'moesia-fitvids', get_stylesheet_directory_uri() . '/js/jquery.fitvids.js', array('jquery'), true );
  230.  
  231. wp_enqueue_script( 'moesia-skip-link-focus-fix', get_stylesheet_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
  232.  
  233. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  234. wp_enqueue_script( 'comment-reply' );
  235. }
  236. }
  237. add_action( 'wp_enqueue_scripts', 'moesia_scripts' );
  238.  
  239. /**
  240. * Enqueues the necessary script for image uploading in widgets
  241. */
  242. add_action('admin_enqueue_scripts', 'moesia_image_upload');
  243. function moesia_image_upload($post) {
  244. if( 'post.php' != $post )
  245. return;
  246. wp_enqueue_script('moesia-image-upload', get_template_directory_uri() . '/js/image-uploader.js', array('jquery'), true );
  247. if ( did_action( 'wp_enqueue_media' ) )
  248. return;
  249. wp_enqueue_media();
  250. }
  251.  
  252. /**
  253. * Load html5shiv
  254. */
  255. function moesia_html5shiv() {
  256. echo '<!--[if lt IE 9]>' . "\n";
  257. echo '<script src="' . esc_url( get_template_directory_uri() . '/js/html5shiv.js' ) . '"></script>' . "\n";
  258. echo '<![endif]-->' . "\n";
  259. }
  260. add_action( 'wp_head', 'moesia_html5shiv' );
  261.  
  262. /**
  263. * Adds more contact methods in the User profile screen (links used for the author bio).
  264. */
  265. function moesia_contactmethods( $contactmethods ) {
  266.  
  267. $contactmethods['moesia_facebook'] = __( 'Author Bio: Facebook', 'moesia' );
  268. $contactmethods['moesia_twitter'] = __( 'Author Bio: Twitter', 'moesia' );
  269. $contactmethods['moesia_googleplus'] = __( 'Author Bio: Google Plus', 'moesia' );
  270. $contactmethods['moesia_linkedin'] = __( 'Author Bio: Linkedin', 'moesia' );
  271.  
  272. return $contactmethods;
  273. }
  274. add_filter( 'user_contactmethods', 'moesia_contactmethods', 10, 1);
  275.  
  276.  
  277. /**
  278. * Change the excerpt length
  279. */
  280. function moesia_excerpt_length( $length ) {
  281.  
  282. $excerpt = get_theme_mod('exc_lenght', '30');
  283. return $excerpt;
  284.  
  285. }
  286. add_filter( 'excerpt_length', 'moesia_excerpt_length', 999 );
  287. /**
  288. * Implement the Custom Header feature.
  289. */
  290. require get_template_directory() . '/inc/custom-header.php';
  291.  
  292. /**
  293. * Custom template tags for this theme.
  294. */
  295. require get_template_directory() . '/inc/template-tags.php';
  296.  
  297. /**
  298. * Custom functions that act independently of the theme templates.
  299. */
  300. require get_template_directory() . '/inc/extras.php';
  301.  
  302. /**
  303. * Customizer additions.
  304. */
  305. require get_template_directory() . '/inc/customizer.php';
  306.  
  307. /**
  308. * Load Jetpack compatibility file.
  309. */
  310. require get_template_directory() . '/inc/jetpack.php';
  311. /**
  312. * Dynamic styles
  313. */
  314. require get_template_directory() . '/styles.php';
  315.  
  316. /**
  317. *TGM Plugin activation.
  318. */
  319. require_once dirname( __FILE__ ) . '/plugins/class-tgm-plugin-activation.php';
  320.  
  321. add_action( 'tgmpa_register', 'moesia_recommend_plugin' );
  322. function moesia_recommend_plugin() {
  323.  
  324. $plugins = array(
  325. array(
  326. 'name' => 'Page Builder by SiteOrigin',
  327. 'slug' => 'siteorigin-panels',
  328. 'required' => false,
  329. ),
  330. array(
  331. 'name' => 'Types - Custom Fields and Custom Post Types Management',
  332. 'slug' => 'types',
  333. 'required' => false,
  334. ),
  335. );
  336.  
  337. tgmpa( $plugins);
  338.  
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement